NetSurf
Data Structures | Macros | Functions | Variables
preferences.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "utils/file.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "netsurf/browser_window.h"
#include "desktop/searchweb.h"
#include "gtk/compat.h"
#include "gtk/toolbar_items.h"
#include "gtk/window.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
#include "gtk/resources.h"
#include "gtk/preferences.h"
Include dependency graph for preferences.c:

Go to the source code of this file.

Data Structures

struct  ppref
 

Macros

#define TOGGLEBUTTON_SIGNALS(WIDGET, OPTION)
 
#define SPINBUTTON_SIGNALS(WIDGET, OPTION, MULTIPLIER)
 
#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER)
 
#define ENTRY_SIGNALS(WIDGET, OPTION)
 
#define GB(TYPE, NAME)   GTK_##TYPE(gtk_builder_get_object(preferences_builder, #NAME))
 

Functions

G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_changed (GtkComboBox *combo, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_changed (GtkComboBox *combo, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboDefault_changed (GtkComboBox *combo, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboDefault_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_fontPreview_clicked (GtkButton *button, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_changed (GtkComboBox *combo, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_realize (GtkWidget *widget, struct ppref *priv)
 Fill content language list store. More...
 
G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_toggled (GtkToggleButton *togglebutton, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_changed (GtkComboBox *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_changed (GtkComboBox *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_changed (GtkComboBox *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_setCurrentPage_clicked (GtkButton *button, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_setDefaultPage_clicked (GtkButton *button, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboSearch_changed (GtkComboBox *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_comboSearch_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_selectionchanged (GtkFileChooser *chooser, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_realize (GtkWidget *widget, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_response (GtkDialog *dlg, gint resid)
 
G_MODULE_EXPORT gboolean nsgtk_preferences_dialogPreferences_deleteevent (GtkDialog *dlg, struct ppref *priv)
 
G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_destroy (GtkDialog *dlg, struct ppref *priv)
 
static void set_proxy_widgets_sensitivity (int proxyval, struct ppref *priv)
 
static nserror comboboxLanguage_add_from_data (GtkListStore *liststore, GtkComboBox *combobox, const char *accept_language, const uint8_t *data, size_t data_size)
 populate language combo from data More...
 
static nserror comboboxLanguage_add_from_file (GtkListStore *liststore, GtkComboBox *combobox, const char *accept_language, const char *file_location)
 populate language combo from file More...
 
GtkWidget * nsgtk_preferences (struct browser_window *bw, GtkWindow *parent)
 Initialise prefernces window. More...
 

Variables

static struct ppref ppref
 

Macro Definition Documentation

◆ ENTRY_SIGNALS

#define ENTRY_SIGNALS (   WIDGET,
  OPTION 
)
Value:
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv)\
{ \
nsoption_set_charp(OPTION, \
strdup(gtk_entry_get_text(GTK_ENTRY(editable)))); \
} \
\
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
{ \
const char *OPTION; \
OPTION = nsoption_charp(OPTION); \
if (OPTION != NULL) { \
gtk_entry_set_text(GTK_ENTRY(widget), OPTION); \
} \
}
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:297

Definition at line 133 of file preferences.c.

◆ GB

#define GB (   TYPE,
  NAME 
)    GTK_##TYPE(gtk_builder_get_object(preferences_builder, #NAME))

◆ SPINBUTTON_SIGNALS

#define SPINBUTTON_SIGNALS (   WIDGET,
  OPTION,
  MULTIPLIER 
)
Value:
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
struct ppref *priv) \
{ \
nsoption_set_int(OPTION, \
round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
} \
\
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
{ \
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
}
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279

Definition at line 91 of file preferences.c.

◆ SPINBUTTON_UINT_SIGNALS

#define SPINBUTTON_UINT_SIGNALS (   WIDGET,
  OPTION,
  MULTIPLIER 
)
Value:
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
struct ppref *priv) \
{ \
nsoption_set_uint(OPTION, \
round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
} \
\
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
{ \
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
}
#define nsoption_uint(OPTION)
Get the value of an unsigned integer option.
Definition: nsoption.h:288

Definition at line 112 of file preferences.c.

◆ TOGGLEBUTTON_SIGNALS

#define TOGGLEBUTTON_SIGNALS (   WIDGET,
  OPTION 
)
Value:
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
struct ppref *priv) \
{ \
nsoption_set_bool(OPTION, \
gtk_toggle_button_get_active(togglebutton)); \
} \
\
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
struct ppref *priv); \
G_MODULE_EXPORT void \
nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
struct ppref *priv) \
{ \
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), \
nsoption_bool(OPTION)); \
}
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:270

Definition at line 68 of file preferences.c.

Function Documentation

◆ comboboxLanguage_add_from_data()

static nserror comboboxLanguage_add_from_data ( GtkListStore *  liststore,
GtkComboBox *  combobox,
const char *  accept_language,
const uint8_t *  data,
size_t  data_size 
)
static

populate language combo from data

Definition at line 542 of file preferences.c.

References NSERROR_OK.

Referenced by nsgtk_preferences_comboboxLanguage_realize().

Here is the caller graph for this function:

◆ comboboxLanguage_add_from_file()

static nserror comboboxLanguage_add_from_file ( GtkListStore *  liststore,
GtkComboBox *  combobox,
const char *  accept_language,
const char *  file_location 
)
static

populate language combo from file

Definition at line 598 of file preferences.c.

References NSERROR_NOT_FOUND, NSERROR_OK, and NSLOG.

Referenced by nsgtk_preferences_comboboxLanguage_realize().

Here is the caller graph for this function:

◆ nsgtk_preferences()

GtkWidget * nsgtk_preferences ( struct browser_window bw,
GtkWindow *  parent 
)

Initialise prefernces window.

Definition at line 951 of file preferences.c.

References ppref::bw, ppref::content_language, ppref::dialog, ppref::entryHomePageURL, ppref::entryProxyHost, ppref::entryProxyNoproxy, ppref::entryProxyPassword, ppref::entryProxyUser, GB, NSERROR_OK, nsgtk_builder_new_from_resname(), NSLOG, parent, ppref, ppref::search_providers, and ppref::spinProxyPort.

Referenced by preferences_button_clicked_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_preferences_checkShowSingleTab_realize()

G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 712 of file preferences.c.

References nsoption_bool.

◆ nsgtk_preferences_checkShowSingleTab_toggled()

G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_toggled ( GtkToggleButton *  togglebutton,
struct ppref priv 
)

Definition at line 703 of file preferences.c.

References nsgtk_window_update_all(), and nsoption_set_bool.

Here is the call graph for this function:

◆ nsgtk_preferences_comboboxLanguage_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_changed ( GtkComboBox *  combo,
struct ppref priv 
)

Definition at line 514 of file preferences.c.

References nsoption_set_charp.

◆ nsgtk_preferences_comboboxLanguage_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_realize ( GtkWidget *  widget,
struct ppref priv 
)

Fill content language list store.

Definition at line 653 of file preferences.c.

References comboboxLanguage_add_from_data(), comboboxLanguage_add_from_file(), ppref::content_language, NSERROR_OK, nsgtk_data_from_resname(), nsgtk_path_from_resname(), NSLOG, and nsoption_charp.

Here is the call graph for this function:

◆ nsgtk_preferences_comboboxLoadImages_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_changed ( GtkComboBox *  combo,
struct ppref priv 
)

Definition at line 417 of file preferences.c.

References nsoption_set_bool.

◆ nsgtk_preferences_comboboxLoadImages_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 451 of file preferences.c.

References nsoption_bool.

◆ nsgtk_preferences_comboButtonType_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_changed ( GtkComboBox *  widget,
struct ppref priv 
)

Definition at line 774 of file preferences.c.

References nsgtk_window_update_all(), and nsoption_set_int.

Here is the call graph for this function:

◆ nsgtk_preferences_comboButtonType_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 784 of file preferences.c.

References nsoption_int.

◆ nsgtk_preferences_comboDefault_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboDefault_changed ( GtkComboBox *  combo,
struct ppref priv 
)

Definition at line 482 of file preferences.c.

References nsoption_set_int.

◆ nsgtk_preferences_comboDefault_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboDefault_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 493 of file preferences.c.

References nsoption_int.

◆ nsgtk_preferences_comboDeveloperView_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_changed ( GtkComboBox *  widget,
struct ppref priv 
)

Definition at line 749 of file preferences.c.

References nsoption_set_int.

◆ nsgtk_preferences_comboDeveloperView_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 757 of file preferences.c.

References nsoption_int.

◆ nsgtk_preferences_comboProxyType_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_changed ( GtkComboBox *  combo,
struct ppref priv 
)

Definition at line 282 of file preferences.c.

References nsoption_set_bool, nsoption_set_int, OPTION_HTTP_PROXY_AUTH_BASIC, OPTION_HTTP_PROXY_AUTH_NONE, OPTION_HTTP_PROXY_AUTH_NTLM, and set_proxy_widgets_sensitivity().

Here is the call graph for this function:

◆ nsgtk_preferences_comboProxyType_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 317 of file preferences.c.

References nsoption_bool, nsoption_charp, nsoption_int, and set_proxy_widgets_sensitivity().

Here is the call graph for this function:

◆ nsgtk_preferences_comboSearch_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboSearch_changed ( GtkComboBox *  widget,
struct ppref priv 
)

Definition at line 831 of file preferences.c.

References nsoption_set_int, and search_web_select_provider().

Here is the call graph for this function:

◆ nsgtk_preferences_comboSearch_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboSearch_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 845 of file preferences.c.

References nsoption_int, ppref::search_providers, and search_web_iterate_providers().

Here is the call graph for this function:

◆ nsgtk_preferences_comboTabPosition_changed()

G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_changed ( GtkComboBox *  widget,
struct ppref priv 
)

Definition at line 727 of file preferences.c.

References nsgtk_window_update_all(), and nsoption_set_int.

Here is the call graph for this function:

◆ nsgtk_preferences_comboTabPosition_realize()

G_MODULE_EXPORT void nsgtk_preferences_comboTabPosition_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 738 of file preferences.c.

References nsoption_int.

◆ nsgtk_preferences_dialogPreferences_deleteevent()

G_MODULE_EXPORT gboolean nsgtk_preferences_dialogPreferences_deleteevent ( GtkDialog *  dlg,
struct ppref priv 
)

Definition at line 918 of file preferences.c.

References netsurf_mkpath(), nsgtk_config_home, and nsoption_write().

Here is the call graph for this function:

◆ nsgtk_preferences_dialogPreferences_destroy()

G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_destroy ( GtkDialog *  dlg,
struct ppref priv 
)

Definition at line 938 of file preferences.c.

References netsurf_mkpath(), nsgtk_config_home, and nsoption_write().

Here is the call graph for this function:

◆ nsgtk_preferences_dialogPreferences_response()

G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_response ( GtkDialog *  dlg,
gint  resid 
)

Definition at line 903 of file preferences.c.

References netsurf_mkpath(), nsgtk_config_home, and nsoption_write().

Here is the call graph for this function:

◆ nsgtk_preferences_fileChooserDownloads_realize()

G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_realize ( GtkWidget *  widget,
struct ppref priv 
)

Definition at line 891 of file preferences.c.

References nsoption_charp.

◆ nsgtk_preferences_fileChooserDownloads_selectionchanged()

G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_selectionchanged ( GtkFileChooser *  chooser,
struct ppref priv 
)

Definition at line 881 of file preferences.c.

References nsoption_set_charp.

◆ nsgtk_preferences_fontPreview_clicked()

G_MODULE_EXPORT void nsgtk_preferences_fontPreview_clicked ( GtkButton *  button,
struct ppref priv 
)

Definition at line 504 of file preferences.c.

References nsgtk_window_update_all().

Here is the call graph for this function:

◆ nsgtk_preferences_setCurrentPage_clicked()

G_MODULE_EXPORT void nsgtk_preferences_setCurrentPage_clicked ( GtkButton *  button,
struct ppref priv 
)

Definition at line 802 of file preferences.c.

References browser_window_access_url(), ppref::bw, ppref::entryHomePageURL, nsoption_set_charp, and nsurl_access().

Here is the call graph for this function:

◆ nsgtk_preferences_setDefaultPage_clicked()

G_MODULE_EXPORT void nsgtk_preferences_setDefaultPage_clicked ( GtkButton *  button,
struct ppref priv 
)

Definition at line 814 of file preferences.c.

References ppref::entryHomePageURL, and nsoption_set_charp.

◆ set_proxy_widgets_sensitivity()

static void set_proxy_widgets_sensitivity ( int  proxyval,
struct ppref priv 
)
static

Definition at line 220 of file preferences.c.

Referenced by nsgtk_preferences_comboProxyType_changed(), and nsgtk_preferences_comboProxyType_realize().

Here is the caller graph for this function:

Variable Documentation

◆ ppref

struct ppref ppref
static

Definition at line 60 of file preferences.c.

Referenced by nsgtk_preferences().