From 754b0c0c73d42dc85ba04f8bb0a7220c0f6a2ca9 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Sun, 23 Jul 2006 18:26:11 +0000 Subject: Initial code to support usable Choices window in nsgtk. Unsupported choices are currently greyed out. Additionally, only the home page URL is current saved when Apply is clicked. svn path=/trunk/netsurf/; revision=2792 --- gtk/gtk_options.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 gtk/gtk_options.c (limited to 'gtk/gtk_options.c') diff --git a/gtk/gtk_options.c b/gtk/gtk_options.c new file mode 100644 index 000000000..86bf5ff54 --- /dev/null +++ b/gtk/gtk_options.c @@ -0,0 +1,147 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2006 Rob Kendrick + */ + +#include +#include +#include +#include +#include +#include "netsurf/utils/log.h" +#include "netsurf/desktop/options.h" +#include "netsurf/gtk/gtk_gui.h" +#include "netsurf/desktop/options.h" +#include "netsurf/gtk/gtk_options.h" + +GtkWindow *wndChoices; + +static GtkWidget *entryHomePageURL, + *checkHideAdverts, + *checkDisablePopups, + *checkDisablePlugins, + *spinHistoryAge, + *checkHoverURLs, + *checkRequestOverwrite, + *checkDisplayRecentURLs, + *checkSendReferer, + + *comboProxyType, + *entryProxyHost, + *entryProxyPort, + *entryProxyUser, + *entryProxyPassword, + *spinMaxFetchers, + *spinFetchesPerHost, + *spinCachedConnections, + + *checkUseCairo, + *checkResampleImages, + *spinAnimationSpeed, + *checkDisableAnimations, + + *fontSansSerif, + *fontSerif, + *fontMonospace, + *fontCursive, + *fontFantasy, + *comboDefault, + *spinDefaultSize, + *spinMinimumSize, + + *spinMemoryCacheSize, + *spinDiscCacheAge; + +#define FIND_WIDGET(x) (x) = glade_xml_get_widget(gladeWindows, #x); if ((x) == NULL) LOG(("Unable to find widget '%s'!", #x)) + +void nsgtk_options_init(void) { + wndChoices = GTK_WINDOW(glade_xml_get_widget(gladeWindows, + "wndChoices")); + + /* get widget objects */ + FIND_WIDGET(entryHomePageURL); + FIND_WIDGET(checkHideAdverts); + FIND_WIDGET(checkDisablePopups); + FIND_WIDGET(checkDisablePlugins); + FIND_WIDGET(spinHistoryAge); + FIND_WIDGET(checkHoverURLs); + FIND_WIDGET(checkRequestOverwrite); + FIND_WIDGET(checkDisplayRecentURLs); + FIND_WIDGET(checkSendReferer); + + FIND_WIDGET(comboProxyType); + FIND_WIDGET(entryProxyHost); + FIND_WIDGET(entryProxyPort); + FIND_WIDGET(entryProxyUser); + FIND_WIDGET(entryProxyPassword); + FIND_WIDGET(spinMaxFetchers); + FIND_WIDGET(spinFetchesPerHost); + FIND_WIDGET(spinCachedConnections); + + FIND_WIDGET(checkUseCairo); + FIND_WIDGET(checkResampleImages); + FIND_WIDGET(spinAnimationSpeed); + FIND_WIDGET(checkDisableAnimations); + + FIND_WIDGET(fontSansSerif); + FIND_WIDGET(fontSerif); + FIND_WIDGET(fontMonospace); + FIND_WIDGET(fontCursive); + FIND_WIDGET(fontFantasy); + FIND_WIDGET(comboDefault); + FIND_WIDGET(spinDefaultSize); + FIND_WIDGET(spinMinimumSize); + + FIND_WIDGET(spinMemoryCacheSize); + FIND_WIDGET(spinDiscCacheAge); + + /* set the widgets to reflect the current options */ + nsgtk_options_load(); +} + +#define SET_ENTRY(x, y) gtk_entry_set_text(GTK_ENTRY((x)), (y)) +#define SET_SPIN(x, y) gtk_spin_button_set_value((x), (y)) +#define SET_CHECK(x, y) gtk_toggle_button_set_active((x), (y)) + +void nsgtk_options_load(void) { + char *b[20]; + + SET_ENTRY(entryHomePageURL, option_homepage_url); + SET_CHECK(checkHideAdverts, option_block_ads); + /* TODO: rest of "General" tab here */ + SET_CHECK(checkSendReferer, option_send_referer); + + SET_ENTRY(entryProxyHost, option_http_proxy_host); + snprintf(b, 20, "%d", option_http_proxy_port); + SET_ENTRY(entryProxyPort, b); + SET_ENTRY(entryProxyUser, option_http_proxy_auth_user); + SET_ENTRY(entryProxyPassword, option_http_proxy_auth_pass); + SET_SPIN(spinMaxFetchers, option_max_fetchers); + SET_SPIN(spinFetchesPerHost, option_max_fetchers_per_host); + SET_SPIN(spinCachedConnections, option_max_cached_fetch_handles); + + /* TODO: set checkUseCairo and checkReampleImages here */ + SET_SPIN(spinAnimationSpeed, option_minimum_gif_delay); + SET_CHECK(checkDisableAnimations, !option_animate_images); + + /* TODO: set all font name widgets here */ + SET_SPIN(spinDefaultSize, option_font_size / 10); + SET_SPIN(spinMinimumSize, option_font_min_size / 10); + + SET_SPIN(spinMemoryCacheSize, option_memory_cache_size); + SET_SPIN(spinDiscCacheAge, option_disc_cache_age); +} + +#define GET_ENTRY(x, y) if ((y)) free((y)); \ + (y) = strdup(gtk_entry_get_text(GTK_ENTRY((x)))) + +void nsgtk_options_save(void) { + GET_ENTRY(entryHomePageURL, option_homepage_url); + + /* TODO: save the other options */ + + options_write(options_file_location); +} + -- cgit v1.2.3