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_gui.c | 18 ++- gtk/gtk_gui.h | 5 +- gtk/gtk_options.c | 147 ++++++++++++++++++++ gtk/gtk_options.h | 19 +++ gtk/gtk_window.c | 1 + gtk/netsurf.glade | 407 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- makefile | 2 +- 7 files changed, 583 insertions(+), 16 deletions(-) create mode 100644 gtk/gtk_options.c create mode 100644 gtk/gtk_options.h diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index 6b7408c33..164e83dc5 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -27,6 +27,7 @@ #include "netsurf/desktop/netsurf.h" #include "netsurf/desktop/options.h" #include "netsurf/gtk/gtk_gui.h" +#include "netsurf/gtk/gtk_options.h" #include "netsurf/render/box.h" #include "netsurf/render/form.h" #include "netsurf/render/html.h" @@ -43,11 +44,12 @@ bool gui_in_multitask = false; char *default_stylesheet_url; char *adblock_stylesheet_url; +char *options_file_location; +char *glade_file_location; struct gui_window *search_current_window = 0; GladeXML *gladeWindows; -GtkWindow *wndChoices; /** * Locate a shared resource file by searching known places in order. @@ -98,16 +100,24 @@ void gui_init(int argc, char** argv) char buf[PATH_MAX]; gtk_init(&argc, &argv); - - gladeWindows = glade_xml_new("./gtk/netsurf.glade", NULL, NULL); - wndChoices = glade_xml_get_widget(gladeWindows, "wndChoices"); + + /* TODO: make this search for the file using the resource finding + * function above + */ + glade_file_location = strdup("./gtk/netsurf.glade"); + + glade_init(); + gladeWindows = glade_xml_new(glade_file_location, NULL, NULL); glade_xml_signal_autoconnect(gladeWindows); find_resource(buf, "Choices", "Choices"); LOG(("Using '%s' as Choices file", buf)); + options_file_location = strdup(buf); options_read(buf); + nsgtk_options_init(); + if (!option_cookie_file) { find_resource(buf, "Cookies", "Cookies"); LOG(("Using '%s' as Cookies file", buf)); diff --git a/gtk/gtk_gui.h b/gtk/gtk_gui.h index 0742d7e54..91c2bb3eb 100644 --- a/gtk/gtk_gui.h +++ b/gtk/gtk_gui.h @@ -7,6 +7,9 @@ #include #include +#include extern bool gui_in_multitask; -extern GtkWindow *wndChoices; +extern GladeXML *gladeWindows; +extern char *options_file_location; + 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); +} + diff --git a/gtk/gtk_options.h b/gtk/gtk_options.h new file mode 100644 index 000000000..379b32c4b --- /dev/null +++ b/gtk/gtk_options.h @@ -0,0 +1,19 @@ +/* + * 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 + */ + +#ifndef NETSURF_GTK_OPTIONS_H +#define NETSURF_GTK_OPTIONS_H + +#include + +extern GtkWindow *wndChoices; + +void nsgtk_options_init(void); /** Init options and load window */ +void nsgtk_options_load(void); /** Load current options into window */ +void nsgtk_options_save(void); /** Save options from window */ + +#endif diff --git a/gtk/gtk_window.c b/gtk/gtk_window.c index e42df1c1f..0a263f949 100644 --- a/gtk/gtk_window.c +++ b/gtk/gtk_window.c @@ -23,6 +23,7 @@ #include "netsurf/gtk/gtk_gui.h" #include "netsurf/gtk/gtk_plotters.h" #include "netsurf/gtk/gtk_window.h" +#include "netsurf/gtk/gtk_options.h" #include "netsurf/render/box.h" #include "netsurf/render/font.h" #include "netsurf/render/form.h" diff --git a/gtk/netsurf.glade b/gtk/netsurf.glade index 64af50db1..9507c50ec 100644 --- a/gtk/netsurf.glade +++ b/gtk/netsurf.glade @@ -42,6 +42,7 @@ True -6 + @@ -56,7 +57,7 @@ GTK_RELIEF_NORMAL True -10 - + @@ -241,6 +242,7 @@ True + False Stop pop-up windows normally containing adverts appearing. True Disable pop-up windows @@ -261,13 +263,14 @@ True + False Do not allow the embedded of applets and plugins. True Disable plug-ins True GTK_RELIEF_NORMAL True - True + False False True @@ -374,6 +377,7 @@ True + False Visited pages are forgotten after this many days True 1 @@ -382,7 +386,7 @@ GTK_UPDATE_ALWAYS False False - 1 0 100 1 10 10 + 14 0 100 1 10 10 0 @@ -426,13 +430,14 @@ True + False Show a tooltip showing the URL of a page in the local history tree. True Hover URLs by pointer in local history True GTK_RELIEF_NORMAL True - True + False False True @@ -506,13 +511,14 @@ True + False Ask before overwriting files when downloading. True Request confirmation before overwriting files True GTK_RELIEF_NORMAL True - True + False False True @@ -526,13 +532,14 @@ True + False Show a drop-down list of recent addresses when typing into the address bar. True Display recently visited URLs as you type True GTK_RELIEF_NORMAL True - True + False False True @@ -544,7 +551,7 @@ - + True When requesting items or pages, tell the server what linked to them. True @@ -686,6 +693,7 @@ True + False None Simple proxy Basic authentication @@ -897,7 +905,7 @@ NTML authentication - + True If your proxy server requires authentication, enter your password here. True @@ -1227,13 +1235,14 @@ NTML authentication True + False Enable the use of Cairo, which provides better looking results at the cost of speed. True Use Cairo for anti-aliased drawing True GTK_RELIEF_NORMAL True - False + True False True @@ -1247,13 +1256,14 @@ NTML authentication True + False Smoothly resize images when zooming in and out. True Resample images when not at natural size True GTK_RELIEF_NORMAL True - False + True False True @@ -1697,6 +1707,7 @@ NTML authentication True + False True False False @@ -1717,6 +1728,7 @@ NTML authentication True + False True False False @@ -1737,6 +1749,7 @@ NTML authentication True + False True False False @@ -1757,6 +1770,7 @@ NTML authentication True + False True False False @@ -1777,6 +1791,7 @@ NTML authentication True + False Sans-serif Sans Monospace @@ -1798,6 +1813,7 @@ Fantasy True + False True False False @@ -2398,6 +2414,7 @@ Fantasy True + False Perform maintainance True False @@ -3237,4 +3254,374 @@ Fantasy + + NetSurf + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ALWAYS + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 0 + + + + True + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + True + True + + + + True + gtk-go-back + True + True + False + + + False + True + + + + + + True + gtk-go-forward + True + True + False + + + False + True + + + + + + True + gtk-stop + True + True + False + + + False + True + + + + + + True + + True + gtk-refresh + True + True + False + + + False + True + + + + + + True + + True + gtk-zoom-in + True + True + False + + + False + True + + + + + + True + + True + gtk-zoom-100 + True + True + False + + + False + True + + + + + + True + + True + gtk-zoom-out + True + True + False + + + False + True + + + + + + True + + True + gtk-open + True + True + False + + + False + True + + + + + + True + + True + gtk-preferences + True + True + False + + + False + True + + + + + + True + True + True + False + + + + True + True + True + True + 0 + + True + + False + + + + + True + False + + + + + + True + True + True + False + + + + True + 2 + stock_smiley-1 + 0.5 + 0.5 + 3 + 0 + + + + + False + False + + + + + + + + + 0 + False + True + + + + + + True + 2 + 2 + False + 0 + 0 + + + + True + GTK_UPDATE_CONTINUOUS + False + 0 0 100 1 10 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + True + True + + + + True + False + 0 + + + + True + Status bar text goes here + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_MIDDLE + -1 + False + 0 + + + 0 + True + True + + + + + True + False + + + + + + True + GTK_UPDATE_CONTINUOUS + False + 0 0 100 1 10 0 + + + True + True + + + + + 0 + 1 + 1 + 2 + fill + + + + + + True + 1 + gtk-close + 0.5 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + GTK_SHADOW_NONE + + + + True + + + + + 0 + 1 + 0 + 1 + fill + fill + + + + + 0 + True + True + + + + + + diff --git a/makefile b/makefile index a738608d0..08a8524b0 100644 --- a/makefile +++ b/makefile @@ -67,7 +67,7 @@ OBJECTS_GTK += filetyped.o # debug/ OBJECTS_GTK += browser.o history_core.o netsurf.o selection.o textinput.o \ version.o gesture_core.o # desktop/ OBJECTS_GTK += font_pango.o gtk_bitmap.o gtk_gui.o \ - gtk_schedule.o gtk_thumbnail.o \ + gtk_schedule.o gtk_thumbnail.o gtk_options.o \ gtk_plotters.o gtk_treeview.o gtk_window.o # gtk/ -- cgit v1.2.3