68#define TOGGLEBUTTON_SIGNALS(WIDGET, OPTION) \
70nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
71 struct ppref *priv); \
73nsgtk_preferences_##WIDGET##_toggled(GtkToggleButton *togglebutton, \
76 nsoption_set_bool(OPTION, \
77 gtk_toggle_button_get_active(togglebutton)); \
81nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
82 struct ppref *priv); \
84nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, \
87 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), \
88 nsoption_bool(OPTION)); \
91#define SPINBUTTON_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
93nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
94 struct ppref *priv); \
96nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
99 nsoption_set_int(OPTION, \
100 round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
103G_MODULE_EXPORT void \
104nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
105G_MODULE_EXPORT void \
106nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
108 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
109 ((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \
112#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \
113G_MODULE_EXPORT void \
114nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
115 struct ppref *priv); \
116G_MODULE_EXPORT void \
117nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \
118 struct ppref *priv) \
120 nsoption_set_uint(OPTION, \
121 round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \
124G_MODULE_EXPORT void \
125nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
126G_MODULE_EXPORT void \
127nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
129 gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \
130 ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \
133#define ENTRY_SIGNALS(WIDGET, OPTION) \
134G_MODULE_EXPORT void \
135nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \
136G_MODULE_EXPORT void \
137nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv)\
139 nsoption_set_charp(OPTION, \
140 strdup(gtk_entry_get_text(GTK_ENTRY(editable)))); \
143G_MODULE_EXPORT void \
144nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \
145G_MODULE_EXPORT void \
146nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \
148 const char *OPTION; \
149 OPTION = nsoption_charp(OPTION); \
150 if (OPTION != NULL) { \
151 gtk_entry_set_text(GTK_ENTRY(widget), OPTION); \
273 gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyHost), host);
274 gtk_widget_set_sensitive(GTK_WIDGET(priv->spinProxyPort), port);
275 gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyUser), user);
276 gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyPassword), pass);
277 gtk_widget_set_sensitive(GTK_WIDGET(priv->entryProxyNoproxy), noproxy);
285 proxy_sel = gtk_combo_box_get_active(combo);
330 }
else if (((proxytype == 2) ||
338 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), proxytype);
422 img_sel = gtk_combo_box_get_active(combo);
457 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
460 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 1);
465 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 2);
468 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 3);
486 font_sel = gtk_combo_box_get_active(combo);
487 if ((font_sel >= 0) && (font_sel <= 4)) {
495 gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
524 if (gtk_combo_box_get_active_iter(combo, &iter)) {
526 model = gtk_combo_box_get_model(combo);
529 gtk_tree_model_get(model, &iter, 0, &lang, -1);
543 GtkComboBox *combobox,
544 const char *accept_language,
548 int active_language = -1;
550 int combo_row_count = 0;
556 gtk_list_store_clear(liststore);
559 while (s < (data + data_size)) {
561 for (nl = s; nl < data + data_size; nl++) {
562 if ((*nl ==
'\n') || (bufi == (
sizeof(buf) - 2))) {
569 gtk_list_store_append(liststore, &iter);
570 gtk_list_store_set(liststore, &iter, 0, buf, -1 );
572 if (strcmp(buf, accept_language) == 0) {
573 active_language = combo_row_count;
583 if (active_language == -1) {
584 gtk_list_store_append(liststore, &iter);
585 gtk_list_store_set(liststore, &iter, 0, accept_language, -1);
586 active_language = combo_row_count;
589 gtk_combo_box_set_active(combobox, active_language);
599 GtkComboBox *combobox,
600 const char *accept_language,
601 const char *file_location)
603 int active_language = -1;
605 int combo_row_count = 0;
609 fp = fopen(file_location,
"r");
614 gtk_list_store_clear(liststore);
616 NSLOG(netsurf, INFO,
"Used %s for languages", file_location);
617 while (fgets(buf,
sizeof(buf), fp)) {
623 buf[strlen(buf) - 1] =
'\0';
625 gtk_list_store_append(liststore, &iter);
626 gtk_list_store_set(liststore, &iter, 0, buf, -1 );
628 if (strcmp(buf, accept_language) == 0) {
629 active_language = combo_row_count;
636 if (active_language == -1) {
637 gtk_list_store_append(liststore, &iter);
638 gtk_list_store_set(liststore, &iter, 0, accept_language, -1);
639 active_language = combo_row_count;
644 gtk_combo_box_set_active(combobox, active_language);
659 const char *languages_file;
660 const char *accept_language;
663 NSLOG(netsurf, INFO,
"content language list store unavailable");
669 if (accept_language == NULL) {
670 accept_language =
"en";
677 GTK_COMBO_BOX(widget),
686 GTK_COMBO_BOX(widget),
692 NSLOG(netsurf, INFO,
"error populatiung languages combo");
707 gtk_toggle_button_get_active(togglebutton));
715 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
741 gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
760 gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
787 gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
816 const gchar *url = NETSURF_HOMEPAGE;
837 const char* defprovider;
839 set = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter);
844 model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
845 gtk_tree_model_get(model, &iter, 0, &provider, -1);
852 (strcmp(provider, defprovider) == 0)) {
867 const char *provider;
868 int provider_idx = 0;
882 if ((provider != NULL) && (strcmp(name, provider) == 0)) {
889 gtk_combo_box_set_active(GTK_COMBO_BOX(widget), provider_idx);
912 dir = gtk_file_chooser_get_filename(chooser);
921 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget),
932 char *choices = NULL;
934 if (resid == GTK_RESPONSE_CLOSE) {
936 if (choices != NULL) {
940 gtk_widget_hide(GTK_WIDGET(dlg));
944G_MODULE_EXPORT gboolean
948 char *choices = NULL;
951 if (choices != NULL) {
956 gtk_widget_hide(GTK_WIDGET(dlg));
967 char *choices = NULL;
970 if (choices != NULL) {
980 GtkBuilder *preferences_builder;
987 if (priv->
dialog != NULL) {
988 gtk_window_set_transient_for(GTK_WINDOW(priv->
dialog),
parent);
989 return GTK_WIDGET(priv->
dialog);
994 NSLOG(netsurf, INFO,
"Preferences UI builder init failed");
998 priv->
dialog = gtk_builder_get_object(preferences_builder,
999 "dialogPreferences");
1000 if (priv->
dialog == NULL) {
1001 NSLOG(netsurf, INFO,
1002 "Unable to get object for preferences dialog");
1004 g_object_unref(G_OBJECT(preferences_builder));
1011#define GB(TYPE, NAME) GTK_##TYPE(gtk_builder_get_object(preferences_builder, #NAME))
1023 gtk_builder_connect_signals(preferences_builder, priv);
1026 g_object_unref(G_OBJECT(preferences_builder));
1029 gtk_window_set_transient_for(GTK_WINDOW(priv->
dialog),
parent);
1031 return GTK_WIDGET(priv->
dialog);
Browser window creation and manipulation interface.
struct nsurl * browser_window_access_url(const struct browser_window *bw)
Access a browser window's URL.
Compatibility functions for older GTK versions (interface)
nserror search_web_select_provider(const char *selection)
Change the currently selected web search provider.
ssize_t search_web_iterate_providers(ssize_t iter, const char **name)
Iterate the search providers, returning their names.
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
char * nsgtk_config_home
Directory where all configuration files are held.
nserror nsgtk_window_update_all(void)
Every window will have its tab, toolbar and drawing area updated.
#define NSLOG(catname, level, logmsg, args...)
Localised message support (interface).
NetSurf URL handling (interface).
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
static void set_proxy_widgets_sensitivity(int proxyval, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_realize(GtkWidget *widget, struct ppref *priv)
G_MODULE_EXPORT gboolean nsgtk_preferences_dialogPreferences_deleteevent(GtkDialog *dlg, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_fontPreview_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_comboButtonType_realize(GtkWidget *widget, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_fileChooserDownloads_selectionchanged(GtkFileChooser *chooser, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_comboButtonType_changed(GtkComboBox *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)
#define SPINBUTTON_SIGNALS(WIDGET, OPTION, MULTIPLIER)
G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget, struct ppref *priv)
Fill content language list store.
G_MODULE_EXPORT void nsgtk_preferences_setDefaultPage_clicked(GtkButton *button, 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_dialogPreferences_response(GtkDialog *dlg, gint resid)
G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_changed(GtkComboBox *widget, 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
#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER)
#define TOGGLEBUTTON_SIGNALS(WIDGET, OPTION)
GtkWidget * nsgtk_preferences(struct browser_window *bw, GtkWindow *parent)
Initialise prefernces window.
G_MODULE_EXPORT void nsgtk_preferences_comboDeveloperView_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_comboboxLoadImages_realize(GtkWidget *widget, struct ppref *priv)
#define ENTRY_SIGNALS(WIDGET, OPTION)
static nserror comboboxLanguage_add_from_file(GtkListStore *liststore, GtkComboBox *combobox, const char *accept_language, const char *file_location)
populate language combo from file
G_MODULE_EXPORT void nsgtk_preferences_comboSearch_realize(GtkWidget *widget, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_realize(GtkWidget *widget, struct ppref *priv)
static struct ppref ppref
G_MODULE_EXPORT void nsgtk_preferences_checkShowSingleTab_realize(GtkWidget *widget, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_comboProxyType_changed(GtkComboBox *combo, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_comboboxLoadImages_changed(GtkComboBox *combo, struct ppref *priv)
G_MODULE_EXPORT void nsgtk_preferences_dialogPreferences_destroy(GtkDialog *dlg, struct ppref *priv)
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out)
Get direct pointer to resource data.
nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
Create gtk builder object for the named ui resource.
nserror nsgtk_path_from_resname(const char *resname, const char **path_out)
Get path to resource data.
Interface to gtk builtin resource handling.
core web search facilities interface.
Interface to utility string handling.
GtkListStore * content_language
GtkListStore * search_providers
GtkEntry * entryProxyPassword
GtkSpinButton * spinProxyPort
GtkEntry * entryProxyHost
GtkEntry * entryProxyNoproxy
GtkEntry * entryHomePageURL
GObject * dialog
dialog handle created when window first accessed
GtkEntry * entryProxyUser
struct browser_window * bw
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
Default operations table for files.
nserror nsoption_write(const char *path, struct nsoption_s *opts, struct nsoption_s *defs)
Write options that have changed from the defaults to a file.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
@ OPTION_HTTP_PROXY_AUTH_NONE
@ OPTION_HTTP_PROXY_AUTH_NTLM
@ OPTION_HTTP_PROXY_AUTH_BASIC
#define nsoption_bool(OPTION)
Get the value of a boolean option.