diff options
-rw-r--r-- | ChangeLog | 33 | ||||
-rw-r--r-- | data/epiphany.schemas.in | 198 | ||||
-rw-r--r-- | embed/downloader-view.c | 2 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.h | 35 | ||||
-rwxr-xr-x | embed/find-dialog.c | 6 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 37 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 189 | ||||
-rwxr-xr-x | embed/print-dialog.c | 31 | ||||
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/ephy-dialog.c | 403 | ||||
-rw-r--r-- | lib/ephy-dialog.h | 9 | ||||
-rw-r--r-- | lib/ephy-prefs-utils.c | 285 | ||||
-rw-r--r-- | lib/ephy-prefs-utils.h | 61 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 21 | ||||
-rw-r--r-- | src/prefs-dialog.c | 28 |
15 files changed, 661 insertions, 679 deletions
@@ -1,3 +1,36 @@ +2003-06-13 Marco Pesenti Gritti <marco@it.gnome.org> + + * lib/ephy-dialog.c: (set_config_from_editable), + (set_config_from_optionmenu), (set_config_from_radiobuttongroup), + (set_config_from_spin_button), (set_config_from_togglebutton), + (set_config_from_color), (set_editable_from_config), + (set_optionmenu_from_config), (set_radiobuttongroup_from_config), + (set_spin_button_from_config), (set_togglebutton_from_config), + (set_color_from_config), (prefs_togglebutton_clicked_cb), + (prefs_radiobutton_clicked_cb), (prefs_spinbutton_timeout_cb), + (prefs_color_changed_cb), (prefs_entry_changed_cb), + (prefs_optionmenu_selected_cb), (ephy_dialog_init), (load_props), + (save_props), (free_props), (ephy_dialog_finalize), + (ephy_dialog_add_enum), (init_props), (impl_construct), + (impl_show): + + Add support for string enums. + + * lib/ephy-dialog.h: + * lib/ephy-prefs.h: + * src/prefs-dialog.c: (prefs_dialog_init): + * data/epiphany.schemas.in: + * embed/downloader-view.c: + * embed/ephy-embed-prefs.h: + * embed/find-dialog.c: + * embed/mozilla/mozilla-embed-single.cpp: + * embed/mozilla/mozilla-notifiers.cpp: + * embed/print-dialog.c: + * lib/Makefile.am: + + Cleanup gconf prefs. This breaks compatibility + but better now that later. + 2003-06-13 Christian Persch <chpe@cvs.gnome.org> The Friday the 13th Mega Patch. Beware! diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in index bd59ac934..e4c14c8b2 100644 --- a/data/epiphany.schemas.in +++ b/data/epiphany.schemas.in @@ -1,20 +1,19 @@ <gconfschemafile> <schemalist> <schema> - <key>/schemas/apps/epiphany/general/start_page</key> - <applyto>/apps/epiphany/general/start_page</applyto> + <key>/schemas/apps/epiphany/general/homepage</key> + <applyto>/apps/epiphany/general/homepage</applyto> <owner>epiphany</owner> <type>string</type> <default>http://www.google.com</default> <locale name="C"> <short>Home page</short> - <long>Address of the user's home page that is displayed when - opening a new window or tab</long> + <long>Address of the user's home page</long> </locale> </schema> <schema> - <key>/schemas/apps/epiphany/find/match_case</key> - <applyto>/apps/epiphany/find/match_case</applyto> + <key>/schemas/apps/epiphany/dialogs/find_match_case</key> + <applyto>/apps/epiphany/dialogs/find_atch_case</applyto> <owner>epiphany</owner> <type>bool</type> <default>0</default> @@ -24,8 +23,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/find/autowrap</key> - <applyto>/apps/epiphany/find/autowrap</applyto> + <key>/schemas/apps/epiphany/dialogs/find_autowrap</key> + <applyto>/apps/epiphany/dialogs/find_autowrap</applyto> <owner>epiphany</owner> <type>bool</type> <default>1</default> @@ -36,8 +35,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/use_own_colors</key> - <applyto>/apps/epiphany/rendering/use_own_colors</applyto> + <key>/schemas/apps/epiphany/web/use_own_colors</key> + <applyto>/apps/epiphany/web/use_own_colors</applyto> <owner>epiphany</owner> <type>bool</type> <default>false</default> @@ -48,8 +47,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/use_own_fonts</key> - <applyto>/apps/epiphany/rendering/use_own_fonts</applyto> + <key>/schemas/apps/epiphany/web/use_own_fonts</key> + <applyto>/apps/epiphany/web/use_own_fonts</applyto> <owner>epiphany</owner> <type>bool</type> <default>false</default> @@ -60,19 +59,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/underline_links</key> - <applyto>/apps/epiphany/rendering/underline_links</applyto> - <owner>epiphany</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Underline links</short> - <long>Underline links.</long> - </locale> - </schema> - <schema> - <key>/schemas/apps/epiphany/interface/ask_download_dest</key> - <applyto>/apps/epiphany/interface/ask_download_dest</applyto> + <key>/schemas/apps/epiphany/general/ask_download_dest</key> + <applyto>/apps/epiphany/general/ask_download_dest</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -82,8 +70,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/interface/open_in_tab</key> - <applyto>/apps/epiphany/interface/open_in_tab</applyto> + <key>/schemas/apps/epiphany/general/open_in_tab</key> + <applyto>/apps/epiphany/general/open_in_tab</applyto> <owner>epiphany</owner> <type>bool</type> <default>false</default> @@ -93,8 +81,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/interface/middle_click_open_url</key> - <applyto>/apps/epiphany/interface/middle_click_open_url</applyto> + <key>/schemas/apps/epiphany/general/middle_click_open_url</key> + <applyto>/apps/epiphany/general/middle_click_open_url</applyto> <owner>epiphany</owner> <type>bool</type> <default>0</default> @@ -104,8 +92,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/interface/show_toolbars</key> - <applyto>/apps/epiphany/interface/show_toolbars</applyto> + <key>/schemas/apps/epiphany/general/show_toolbars</key> + <applyto>/apps/epiphany/general/show_toolbars</applyto> <owner>epiphany</owner> <type>bool</type> <default>1</default> @@ -115,8 +103,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/interface/show_bookmarks_bar</key> - <applyto>/apps/epiphany/interface/show_bookmarks_bar</applyto> + <key>/schemas/apps/epiphany/general/show_bookmarks_bar</key> + <applyto>/apps/epiphany/general/show_bookmarks_bar</applyto> <owner>epiphany</owner> <type>bool</type> <default>0</default> @@ -126,8 +114,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/interface/show_statusbar</key> - <applyto>/apps/epiphany/interface/show_statusbar</applyto> + <key>/schemas/apps/epiphany/general/show_statusbar</key> + <applyto>/apps/epiphany/general/show_statusbar</applyto> <owner>epiphany</owner> <type>bool</type> <default>1</default> @@ -137,8 +125,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/default_encoding</key> - <applyto>/apps/epiphany/rendering/default_encoding</applyto> + <key>/schemas/apps/epiphany/web/default_encoding</key> + <applyto>/apps/epiphany/web/default_encoding</applyto> <owner>epiphany</owner> <type>string</type> <default>ISO-8859-1</default> @@ -164,20 +152,19 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/default_font</key> - <applyto>/apps/epiphany/rendering/default_font</applyto> + <key>/schemas/apps/epiphany/web/default_font_type</key> + <applyto>/apps/epiphany/web/default_font_type</applyto> <owner>epiphany</owner> - <type>int</type> - <default>0</default> + <type>string</type> + <default>serif</default> <locale name="C"> <short>Default font type</short> - <long>Default font type. Possible values are 0 (serif), 1 - (sans-serif)</long> + <long>Default font type. Possible values are serif and sans-serif</long> </locale> </schema> <schema> - <key>/schemas/apps/epiphany/downloader/show_details</key> - <applyto>/apps/epiphany/downloader/show_details</applyto> + <key>/schemas/apps/epiphany/dialogs/downloader_show_details</key> + <applyto>/apps/epiphany/dialogs/downloader_show_details</applyto> <owner>epiphany</owner> <type>bool</type> <default>false</default> @@ -187,20 +174,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/network/no_proxies_for</key> - <applyto>/apps/epiphany/network/no_proxies_for</applyto> - <owner>epiphany</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>No proxy for</short> - <long>List of domains for wherefore not to use the proxy, comma - delimited</long> - </locale> - </schema> - <schema> - <key>/schemas/apps/epiphany/network/cache_size</key> - <applyto>/apps/epiphany/network/cache_size</applyto> + <key>/schemas/apps/epiphany/web/cache_size</key> + <applyto>/apps/epiphany/web/cache_size</applyto> <owner>epiphany</owner> <type>int</type> <default>50</default> @@ -210,20 +185,20 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/network/cache_compare</key> - <applyto>/apps/epiphany/network/cache_compare</applyto> + <key>/schemas/apps/epiphany/web/cache_compare</key> + <applyto>/apps/epiphany/web/cache_compare</applyto> <owner>epiphany</owner> - <type>int</type> - <default>3</default> + <type>string</type> + <default>automatic</default> <locale name="C"> <short>When to compare cached copy</short> - <long>When to compare cached copy to web copy. Possible values are 0 - (once per session), 1 (every time), 2 (never), 3 (automatic).</long> + <long>When to compare cached copy to web copy. Possible values are + once per session, every time, never, automatic.</long> </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/lang</key> - <applyto>/apps/epiphany/rendering/lang</applyto> + <key>/schemas/apps/epiphany/web/language</key> + <applyto>/apps/epiphany/web/language</applyto> <owner>epiphany</owner> <type>list</type> <list_type>string</list_type> @@ -234,8 +209,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/top_margin</key> - <applyto>/apps/epiphany/print/top_margin</applyto> + <key>/schemas/apps/epiphany/dialogs/print_top_margin</key> + <applyto>/apps/epiphany/dialogs/print_top_margin</applyto> <owner>epiphany</owner> <type>float</type> <default>0.5</default> @@ -245,8 +220,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/bottom_margin</key> - <applyto>/apps/epiphany/print/bottom_margin</applyto> + <key>/schemas/apps/epiphany/dialogs/print_bottom_margin</key> + <applyto>/apps/epiphany/dialogs/print_bottom_margin</applyto> <owner>epiphany</owner> <type>float</type> <default>0.5</default> @@ -256,8 +231,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/left_margin</key> - <applyto>/apps/epiphany/print/left_margin</applyto> + <key>/schemas/apps/epiphany/dialogs/print_left_margin</key> + <applyto>/apps/epiphany/dialogs/print_left_margin</applyto> <owner>epiphany</owner> <type>float</type> <default>0.5</default> @@ -267,8 +242,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/right_margin</key> - <applyto>/apps/epiphany/print/right_margin</applyto> + <key>/schemas/apps/epiphany/dialogs/print_right_margin</key> + <applyto>/apps/epiphany/dialogs/print_right_margin</applyto> <owner>epiphany</owner> <type>float</type> <default>0.5</default> @@ -278,8 +253,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/page_title_toggle</key> - <applyto>/apps/epiphany/print/page_title_toggle</applyto> + <key>/schemas/apps/epiphany/dialogs/print_page_title</key> + <applyto>/apps/epiphany/dialogs/print_page_title</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -289,8 +264,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/page_url_toggle</key> - <applyto>/apps/epiphany/print/page_url_toggle</applyto> + <key>/schemas/apps/epiphany/dialogs/print_page_url</key> + <applyto>/apps/epiphany/dialogs/print_page_url</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -300,8 +275,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/date_toggle</key> - <applyto>/apps/epiphany/print/date_toggle</applyto> + <key>/schemas/apps/epiphany/dialogs/print_date</key> + <applyto>/apps/epiphany/dialogs/print_date</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -311,8 +286,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/page_numbers_toggle</key> - <applyto>/apps/epiphany/print/page_numbers_toggle</applyto> + <key>/schemas/apps/epiphany/dialogs/print_page_numbers</key> + <applyto>/apps/epiphany/dialogs/print_page_numbers</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -322,8 +297,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/printer</key> - <applyto>/apps/epiphany/print/printer</applyto> + <key>/schemas/apps/epiphany/dialogs/print_printer</key> + <applyto>/apps/epiphany/dialogs/print_printer</applyto> <owner>epiphany</owner> <type>string</type> <default>lpr</default> @@ -333,8 +308,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/file</key> - <applyto>/apps/epiphany/print/file</applyto> + <key>/schemas/apps/epiphany/dialogs/print_file</key> + <applyto>/apps/epiphany/dialogs/print_file</applyto> <owner>epiphany</owner> <type>string</type> <locale name="C"> @@ -343,25 +318,14 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/print/printon</key> - <applyto>/apps/epiphany/print/printon</applyto> - <owner>epiphany</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>Print range</short> - <long>Print range: 0 (all pages), 1 (specific range).</long> - </locale> - </schema> - <schema> - <key>/schemas/apps/epiphany/print/paper</key> - <applyto>/apps/epiphany/print/paper</applyto> + <key>/schemas/apps/epiphany/dialogs/print_paper</key> + <applyto>/apps/epiphany/dialogs/print_paper</applyto> <owner>epiphany</owner> <type>int</type> <default>0</default> <locale name="C"> <short>Paper type</short> - <long>Paper type: 0 (Letter), 1 (Legal), 2 (Executive), 3 (A4).</long> + <long>Paper type: letter, legal, executive, A4.</long> </locale> </schema> <schema> @@ -392,8 +356,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/directories/downloading</key> - <applyto>/apps/epiphany/directories/downloading</applyto> + <key>/schemas/apps/epiphany/directories/download</key> + <applyto>/apps/epiphany/directories/download</applyto> <owner>epiphany</owner> <type>string</type> <default>~</default> @@ -401,8 +365,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/rendering/autodetect_encoding</key> - <applyto>/apps/epiphany/rendering/autodetect_encoding</applyto> + <key>/schemas/apps/epiphany/web/autodetect_encoding</key> + <applyto>/apps/epiphany/web/autodetect_encoding</applyto> <owner>epiphany</owner> <type>string</type> <default></default> @@ -421,20 +385,20 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/security/cookie_accept</key> - <applyto>/apps/epiphany/security/cookie_accept</applyto> + <key>/schemas/apps/epiphany/web/cookie_accept</key> + <applyto>/apps/epiphany/web/cookie_accept</applyto> <owner>epiphany</owner> - <type>int</type> - <default>0</default> + <type>string</type> + <default>anywhere</default> <locale name="C"> <short>Cookie accept</short> - <long>Where to accept cookies from. Possible values are 0 (anywhere), - 1 (from current server only), 2 (nowhere)</long> + <long>Where to accept cookies from. Possible values are anywhere, + current site, nowhere</long> </locale> </schema> <schema> - <key>/schemas/apps/epiphany/security/allow_popups</key> - <applyto>/apps/epiphany/security/allow_popups</applyto> + <key>/schemas/apps/epiphany/web/allow_popups</key> + <applyto>/apps/epiphany/web/allow_popups</applyto> <owner>epiphany</owner> <type>bool</type> <default>true</default> @@ -445,8 +409,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/security/java_enabled</key> - <applyto>/apps/epiphany/security/java_enabled</applyto> + <key>/schemas/apps/epiphany/web/java_enabled</key> + <applyto>/apps/epiphany/web/java_enabled</applyto> <owner>epiphany</owner> <type>bool</type> <default>1</default> @@ -456,8 +420,8 @@ </locale> </schema> <schema> - <key>/schemas/apps/epiphany/security/javascript_enabled</key> - <applyto>/apps/epiphany/security/javascript_enabled</applyto> + <key>/schemas/apps/epiphany/web/javascript_enabled</key> + <applyto>/apps/epiphany/web/javascript_enabled</applyto> <owner>epiphany</owner> <type>bool</type> <default>1</default> diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 004b707c9..390fd98d5 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -40,6 +40,8 @@ #include <gtk/gtkprogressbar.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> +#define CONF_DOWNLOADING_SHOW_DETAILS "/apps/epiphany/dialogs/downloader_show_details" + enum { DOWNLOAD_REMOVE, diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 8a2089e8a..2bc82ad5d 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -1,22 +1,19 @@ -#define CONF_NETWORK_CACHE_SIZE "/apps/epiphany/network/cache_size" -#define CONF_NETWORK_CACHE_COMPARE "/apps/epiphany/network/cache_compare" -#define CONF_NETWORK_USER_AGENT "/apps/epiphany/network/user_agent" -#define CONF_RENDERING_FONT "/apps/epiphany/rendering/font" -#define CONF_RENDERING_FONT_VAR_SIZE "/apps/epiphany/rendering/font_var_size" -#define CONF_RENDERING_FONT_FIXED_SIZE "/apps/epiphany/rendering/font_fixed_size" -#define CONF_RENDERING_FONT_MIN_SIZE "/apps/epiphany/rendering/font_min_size" -#define CONF_RENDERING_LANGUAGE "/apps/epiphany/rendering/lang" -#define CONF_RENDERING_USE_OWN_COLORS "/apps/epiphany/rendering/use_own_colors" -#define CONF_RENDERING_USE_OWN_FONTS "/apps/epiphany/rendering/use_own_fonts" -#define CONF_RENDERING_UNDERLINE_LINKS "/apps/epiphany/rendering/underline_links" -#define CONF_SECURITY_ALLOW_POPUPS "/apps/epiphany/security/allow_popups" -#define CONF_SECURITY_JAVA_ENABLED "/apps/epiphany/security/java_enabled" -#define CONF_SECURITY_JAVASCRIPT_ENABLED "/apps/epiphany/security/javascript_enabled" -#define CONF_SECURITY_COOKIES_ACCEPT "/apps/epiphany/security/cookie_accept" -#define CONF_LANGUAGE_AUTODETECT_ENCODING "/apps/epiphany/rendering/autodetect_encoding" -#define CONF_LANGUAGE_DEFAULT_ENCODING "/apps/epiphany/rendering/default_encoding" -#define CONF_RENDERING_DEFAULT_FONT "/apps/epiphany/rendering/default_font" -#define CONF_FILTERING_DEFAULT_STATUSBAR "/apps/epiphany/filtering/default_allow_statusbar" +#define CONF_NETWORK_CACHE_SIZE "/apps/epiphany/web/cache_size" +#define CONF_NETWORK_CACHE_COMPARE "/apps/epiphany/web/cache_compare" +#define CONF_RENDERING_FONT "/apps/epiphany/web/font" +#define CONF_RENDERING_FONT_VAR_SIZE "/apps/epiphany/web/font_var_size" +#define CONF_RENDERING_FONT_FIXED_SIZE "/apps/epiphany/web/font_fixed_size" +#define CONF_RENDERING_FONT_MIN_SIZE "/apps/epiphanyweb/font_min_size" +#define CONF_RENDERING_LANGUAGE "/apps/epiphany/web/language" +#define CONF_RENDERING_USE_OWN_COLORS "/apps/epiphany/web/use_own_colors" +#define CONF_RENDERING_USE_OWN_FONTS "/apps/epiphany/web/use_own_fonts" +#define CONF_SECURITY_ALLOW_POPUPS "/apps/epiphany/web/allow_popups" +#define CONF_SECURITY_JAVA_ENABLED "/apps/epiphany/web/java_enabled" +#define CONF_SECURITY_JAVASCRIPT_ENABLED "/apps/epiphany/web/javascript_enabled" +#define CONF_SECURITY_COOKIES_ACCEPT "/apps/epiphany/web/cookie_accept" +#define CONF_LANGUAGE_AUTODETECT_ENCODING "/apps/epiphany/web/autodetect_encoding" +#define CONF_LANGUAGE_DEFAULT_ENCODING "/apps/epiphany/web/default_encoding" +#define CONF_RENDERING_DEFAULT_FONT "/apps/epiphany/web/default_font_type" /* These are defined gnome wide now */ #define CONF_NETWORK_PROXY_MODE "/system/proxy/mode" diff --git a/embed/find-dialog.c b/embed/find-dialog.c index a81de1618..9cb2f8138 100755 --- a/embed/find-dialog.c +++ b/embed/find-dialog.c @@ -23,9 +23,9 @@ #include "ephy-embed.h" #include <gtk/gtk.h> -#define CONF_FIND_MATCH_CASE "/apps/epiphany/find/match_case" -#define CONF_FIND_AUTOWRAP "/apps/epiphany/find/autowrap" -#define CONF_FIND_WORD "/apps/epiphany/find/word" +#define CONF_FIND_MATCH_CASE "/apps/epiphany/dialogs/find_match_case" +#define CONF_FIND_AUTOWRAP "/apps/epiphany/dialogs/find_autowrap" +#define CONF_FIND_WORD "/apps/epiphany/dialogs/find_word" static void find_dialog_class_init (FindDialogClass *klass); static void find_dialog_init (FindDialog *dialog); diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 808d61f24..fa67a9ea3 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -37,6 +37,8 @@ #include <time.h> #include <libgnome/gnome-i18n.h> #include <string.h> +#include <sys/utsname.h> +#include "nsBuildID.h" #include <nsICacheService.h> #include <nsCOMPtr.h> #include <nsIPrefService.h> @@ -322,6 +324,34 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass) shell_class->show_file_picker = impl_show_file_picker; } +static char * +build_user_agent () +{ + static char *user_agent; + struct utsname name; + char *system; + + if (uname (&name) == 0) + { + system = g_strdup_printf ("%s %s", + name.sysname, + name.machine); + } + else + { + system = g_strdup ("Unknown"); + } + + user_agent = g_strdup_printf + ("Mozilla/5.0 (X11; U; %s) Gecko/%d Epiphany/" VERSION, + system, + NS_BUILD_ID/100); + + g_free (system); + + return user_agent; +} + static void mozilla_set_default_prefs (MozillaEmbedSingle *mes) { @@ -392,6 +422,13 @@ mozilla_set_default_prefs (MozillaEmbedSingle *mes) /* Enable Image Auto-Resizing */ pref->SetBoolPref ("browser.enable_automatic_image_resizing", PR_TRUE); + + /* User agent */ + char *user_agent; + + user_agent = build_user_agent (); + pref->SetCharPref ("general.useragent.override", user_agent); + g_free (user_agent); } static char * diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp index f17e36213..f67bf6492 100644 --- a/embed/mozilla/mozilla-notifiers.cpp +++ b/embed/mozilla/mozilla-notifiers.cpp @@ -35,8 +35,6 @@ #include <locale.h> #include <libgnome/gnome-i18n.h> #include <stdlib.h> -#include <sys/utsname.h> -#include "nsBuildID.h" #include "nsCOMPtr.h" #include "nsIPrefService.h" #include "nsIServiceManager.h" @@ -85,12 +83,6 @@ mozilla_language_notifier(GConfClient *client, EphyEmbedSingle *single); static void -mozilla_default_font_notifier(GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single); - -static void mozilla_proxy_mode_notifier (GConfClient *client, guint cnxn_id, GConfEntry *entry, @@ -100,12 +92,21 @@ mozilla_proxy_autoconfig_notifier (GConfClient *client, guint cnxn_id, GConfEntry *entry, EphyEmbedSingle *single); - static void -mozilla_user_agent_notifier(GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single); +mozilla_proxy_mode_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyEmbedSingle *single); +static void +mozilla_cookies_accept_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + char *pref); +static void +mozilla_cache_compare_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + char *pref); /* Keeps the list of the notifiers we installed for mozilla prefs */ /* to be able to remove them when exiting */ @@ -129,7 +130,6 @@ conversion_table [] = { { CONF_SECURITY_JAVA_ENABLED, BOOL_PREF, "security.enable_java"}, { CONF_SECURITY_JAVASCRIPT_ENABLED, BOOL_PREF, "javascript.enabled"}, - { CONF_RENDERING_UNDERLINE_LINKS, BOOL_PREF, "browser.underline_anchors"}, { CONF_NETWORK_PROXY_AUTO_URL, STRING_PREF, "network.proxy.autoconfig_url"}, { CONF_NETWORK_HTTP_PROXY, STRING_PREF, "network.proxy.http"}, { CONF_NETWORK_FTP_PROXY, STRING_PREF, "network.proxy.ftp"}, @@ -137,10 +137,10 @@ conversion_table [] = { CONF_NETWORK_HTTP_PROXY_PORT, INT_PREF, "network.proxy.http_port"}, { CONF_NETWORK_FTP_PROXY_PORT, INT_PREF, "network.proxy.ftp_port"}, { CONF_NETWORK_SSL_PROXY_PORT, INT_PREF, "network.proxy.ssl_port"}, - { CONF_NETWORK_CACHE_COMPARE, INT_PREF, "browser.cache.check_doc_frequency"}, - { CONF_SECURITY_COOKIES_ACCEPT, BOOL_PREF, "network.cookie.warnAboutCookies"}, { CONF_LANGUAGE_DEFAULT_ENCODING, STRING_PREF, "intl.charset.default" }, { CONF_LANGUAGE_AUTODETECT_ENCODING, STRING_PREF, "intl.charset.detector" }, + { CONF_RENDERING_DEFAULT_FONT, STRING_PREF, "font.default" }, + { NULL, 0, NULL } }; @@ -151,8 +151,6 @@ static const struct } custom_notifiers [] = { - { CONF_NETWORK_USER_AGENT, - (GConfClientNotifyFunc) mozilla_user_agent_notifier }, { CONF_RENDERING_USE_OWN_COLORS, (GConfClientNotifyFunc) mozilla_own_colors_notifier }, { CONF_RENDERING_USE_OWN_FONTS, @@ -161,15 +159,18 @@ custom_notifiers [] = (GConfClientNotifyFunc) mozilla_allow_popups_notifier }, { CONF_RENDERING_LANGUAGE, (GConfClientNotifyFunc) mozilla_language_notifier }, - { CONF_RENDERING_DEFAULT_FONT, - (GConfClientNotifyFunc) mozilla_default_font_notifier }, { CONF_NETWORK_PROXY_MODE, (GConfClientNotifyFunc) mozilla_proxy_mode_notifier }, { CONF_NETWORK_PROXY_AUTO_URL, (GConfClientNotifyFunc) mozilla_proxy_autoconfig_notifier }, { CONF_NETWORK_CACHE_SIZE, (GConfClientNotifyFunc) mozilla_cache_size_notifier }, - {NULL, NULL} + { CONF_NETWORK_CACHE_COMPARE, + (GConfClientNotifyFunc) mozilla_cache_compare_notifier }, + { CONF_SECURITY_COOKIES_ACCEPT, + (GConfClientNotifyFunc) mozilla_cookies_accept_notifier }, + + { NULL, NULL } }; static gboolean @@ -280,6 +281,64 @@ mozilla_proxy_mode_notifier (GConfClient *client, } static void +mozilla_cookies_accept_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + char *pref) +{ + const char *mode; + int mozilla_mode = 0; + + mode = gconf_value_get_string(entry->value); + + if (strcmp (mode, "anywhere") == 0) + { + mozilla_mode = 0; + } + else if (strcmp (mode, "current site") == 0) + { + mozilla_mode = 1; + } + else if (strcmp (mode, "nowhere") == 0) + { + mozilla_mode = 2; + } + + mozilla_prefs_set_int ("network.cookie.cookieBehavior", mozilla_mode); +} + +static void +mozilla_cache_compare_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + char *pref) +{ + const char *mode; + int mozilla_mode = 0; + + mode = gconf_value_get_string(entry->value); + + if (strcmp (mode, "once per session") == 0) + { + mozilla_mode = 0; + } + else if (strcmp (mode, "every time") == 0) + { + mozilla_mode = 1; + } + else if (strcmp (mode, "never") == 0) + { + mozilla_mode = 2; + } + else if (strcmp (mode, "automatic") == 0) + { + mozilla_mode = 3; + } + + mozilla_prefs_set_int ("browser.cache.check_doc_frequency", mozilla_mode); +} + +static void mozilla_font_notifier (GConfClient *client, guint cnxn_id, GConfEntry *entry, @@ -620,91 +679,3 @@ mozilla_language_notifier(GConfClient *client, g_slist_foreach (languages, (GFunc) g_free, NULL); g_slist_free (languages); } - -static void -mozilla_default_font_notifier(GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single) -{ - const gchar *font_types [] = {"serif","sans-serif"}; - int default_font; - - default_font = eel_gconf_get_integer (CONF_RENDERING_DEFAULT_FONT); - if (default_font < 0 || - default_font >= (int)(sizeof(font_types) / sizeof(font_types[0]))) - { - g_warning ("mozilla_default_font_notifier: " - "unsupported value: %d", default_font); - return; - } - mozilla_prefs_set_string ("font.default", font_types[default_font]); -} - -static void -mozilla_prefs_set_user_agent () -{ - static gchar *default_user_agent = NULL; - gchar *value; - gchar *user_agent = NULL; - struct utsname name; - gchar *system; - - if (!default_user_agent) - { - if (uname (&name) == 0) - { - system = g_strdup_printf ("%s %s", - name.sysname, - name.machine); - } - else - { - system = g_strdup ("Unknown"); - } - - default_user_agent = g_strdup_printf - ("Mozilla/5.0 (X11; U; %s) Gecko/%d Epiphany/" VERSION, - system, - NS_BUILD_ID/100); - - g_free (system); - } - - value = eel_gconf_get_string (CONF_NETWORK_USER_AGENT); - - /* now, build a valid user agent string */ - if (!value || !strcmp ("", value) - || !strcmp ("default", value) - || !strcmp ("Ephy", value) - || !strcmp (_("Default (recommended)"), value) - || !strcmp ("Default (recommended)", value)) - { - user_agent = g_strdup (default_user_agent); - } - else - { - user_agent = g_strdup (value); - } - - mozilla_prefs_set_string ("general.useragent.override", user_agent); - g_free (user_agent); -} - -static void -mozilla_user_agent_notifier (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EphyEmbedSingle *single) -{ - switch (entry->value->type) - { - case GCONF_VALUE_STRING: - mozilla_prefs_set_user_agent (); - break; - - default: - g_warning ("Unsupported variable type"); - break; - } -} diff --git a/embed/print-dialog.c b/embed/print-dialog.c index 4a19c7571..2ba9ca348 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -21,22 +21,21 @@ #include <gtk/gtkdialog.h> #include <gtk/gtkstock.h> -#define CONF_PRINT_BOTTOM_MARGIN "/apps/epiphany/print/bottom_margin" -#define CONF_PRINT_TOP_MARGIN "/apps/epiphany/print/top_margin" -#define CONF_PRINT_LEFT_MARGIN "/apps/epiphany/print/left_margin" -#define CONF_PRINT_RIGHT_MARGIN "/apps/epiphany/print/right_margin" -#define CONF_PRINT_PAGE_TITLE "/apps/epiphany/print/page_title_toggle" -#define CONF_PRINT_PAGE_URL "/apps/epiphany/print/page_url_toggle" -#define CONF_PRINT_DATE "/apps/epiphany/print/date_toggle" -#define CONF_PRINT_PAGE_NUMBERS "/apps/epiphany/print/page_numbers_toggle" -#define CONF_PRINT_PRINTER "/apps/epiphany/print/printer" -#define CONF_PRINT_FILE "/apps/epiphany/print/file" -#define CONF_PRINT_PRINTON "/apps/epiphany/print/printon" -#define CONF_PRINT_PAPER "/apps/epiphany/print/paper" -#define CONF_PRINT_ALL_PAGES "/apps/epiphany/print/all_pages" -#define CONF_PRINT_START_FROM_LAST "/apps/epiphany/print/start_from_last" -#define CONF_PRINT_COLOR "/apps/epiphany/print/color" -#define CONF_PRINT_ORIENTATION "/apps/epiphany/print/orientation" +#define CONF_PRINT_BOTTOM_MARGIN "/apps/epiphany/dialogs/print_bottom_margin" +#define CONF_PRINT_TOP_MARGIN "/apps/epiphany/dialogs/print_top_margin" +#define CONF_PRINT_LEFT_MARGIN "/apps/epiphany/dialogs/print_left_margin" +#define CONF_PRINT_RIGHT_MARGIN "/apps/epiphany/dialogs/print_right_margin" +#define CONF_PRINT_PAGE_TITLE "/apps/epiphany/dialogs/print_page_title" +#define CONF_PRINT_PAGE_URL "/apps/epiphany/dialogs/print_page_url" +#define CONF_PRINT_DATE "/apps/epiphany/dialogs/print_date" +#define CONF_PRINT_PAGE_NUMBERS "/apps/epiphany/dialogs/print_page_numbers" +#define CONF_PRINT_PRINTER "/apps/epiphany/dialogs/print_printer" +#define CONF_PRINT_FILE "/apps/epiphany/dialogs/print_file" +#define CONF_PRINT_PRINTON "/apps/epiphany/dialogs/print_on" +#define CONF_PRINT_PAPER "/apps/epiphany/dialogs/print_paper" +#define CONF_PRINT_ALL_PAGES "/apps/epiphany/dialogs/print_all_pages" +#define CONF_PRINT_COLOR "/apps/epiphany/dialogs/print_color" +#define CONF_PRINT_ORIENTATION "/apps/epiphany/dialogs/print_orientation" static void print_dialog_class_init (PrintDialogClass *klass); static void print_dialog_init (PrintDialog *dialog); diff --git a/lib/Makefile.am b/lib/Makefile.am index 3aab867c7..8829123cb 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -46,8 +46,6 @@ libephy_la_SOURCES = \ ephy-node-db.c \ ephy-node-db.h \ ephy-prefs.h \ - ephy-prefs-utils.c \ - ephy-prefs-utils.h \ ephy-state.c \ ephy-state.h \ ephy-string.c \ diff --git a/lib/ephy-dialog.c b/lib/ephy-dialog.c index 9f484704c..a21e03bba 100644 --- a/lib/ephy-dialog.c +++ b/lib/ephy-dialog.c @@ -19,8 +19,8 @@ #include "ephy-dialog.h" #include "ephy-glade.h" #include "ephy-state.h" -#include "ephy-prefs-utils.h" #include "ephy-gui.h" +#include "eel-gconf-extensions.h" #include <string.h> #include <gtk/gtktogglebutton.h> @@ -95,6 +95,7 @@ typedef struct const char *pref; int *sg; PropertyType type; + GList *string_enum; } PropertyInfo; struct EphyDialogPrivate @@ -108,6 +109,7 @@ struct EphyDialogPrivate int spin_item_id; GTimer *spin_timer; + gboolean initialized; }; #define SPIN_DELAY 0.20 @@ -177,6 +179,282 @@ ephy_dialog_class_init (EphyDialogClass *klass) G_PARAM_READWRITE)); } +static void +set_config_from_editable (GtkWidget *editable, const char *config_name) +{ + GConfValue *gcvalue = eel_gconf_get_value (config_name); + GConfValueType value_type; + char *value; + gint ivalue; + gfloat fvalue; + + if (gcvalue == NULL) { + /* ugly hack around what appears to be a gconf bug + * it returns a NULL GConfValue for a valid string pref + * which is "" by default */ + value_type = GCONF_VALUE_STRING; + } else { + value_type = gcvalue->type; + gconf_value_free (gcvalue); + } + + /* get all the text into a new string */ + value = gtk_editable_get_chars (GTK_EDITABLE(editable), 0, -1); + + switch (value_type) { + case GCONF_VALUE_STRING: + eel_gconf_set_string (config_name, + value); + break; + /* FIXME : handle possible errors in the input for int and float */ + case GCONF_VALUE_INT: + ivalue = atoi (value); + eel_gconf_set_integer (config_name, ivalue); + break; + case GCONF_VALUE_FLOAT: + fvalue = strtod (value, (char**)NULL); + eel_gconf_set_float (config_name, fvalue); + break; + default: + break; + } + + /* free the allocated strings */ + g_free (value); +} + +static void +set_config_from_optionmenu (GtkWidget *optionmenu, const char *config_name, GList *senum) +{ + int index = gtk_option_menu_get_history (GTK_OPTION_MENU (optionmenu)); + + if (senum) + { + eel_gconf_set_string (config_name, g_list_nth_data (senum, index)); + } + else + { + eel_gconf_set_integer (config_name, index); + } +} + +static void +set_config_from_radiobuttongroup (GtkWidget *radiobutton, const char *config_name, GList *senum) +{ + gint index; + + /* get value from radio button group */ + index = ephy_gui_gtk_radio_button_get (GTK_RADIO_BUTTON (radiobutton)); + + if (senum) + { + eel_gconf_set_string (config_name, g_list_nth_data (senum, index)); + } + else + { + eel_gconf_set_integer (config_name, index); + } +} + +static void +set_config_from_spin_button (GtkWidget *spinbutton, const char *config_name) +{ + gdouble value; + gboolean use_int; + + /* read the value as an integer */ + value = gtk_spin_button_get_value (GTK_SPIN_BUTTON(spinbutton)); + + use_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON(spinbutton)) == 0); + + if (use_int) + { + eel_gconf_set_integer (config_name, value); + } + else + { + eel_gconf_set_float (config_name, value); + } +} + +static void +set_config_from_togglebutton (GtkWidget *togglebutton, const char *config_name) +{ + gboolean value; + + /* read the value */ + value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(togglebutton)); + + eel_gconf_set_boolean (config_name, value); +} + +static void +set_config_from_color (GtkWidget *colorpicker, const char *config_name) +{ + guint8 r, g, b, a; + gchar color_string[9]; + + /* get color values from color picker */ + gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (colorpicker), + &r, &g, &b, &a); + + /* write into string (bounded size) */ + snprintf (color_string, 9, "#%02X%02X%02X", r, g, b); + + /* set the configuration value */ + eel_gconf_set_string (config_name, color_string); +} + +static void +set_editable_from_config (GtkWidget *editable, const char *config_name) +{ + GConfValue *gcvalue = eel_gconf_get_value (config_name); + GConfValueType value_type; + gchar *value; + + if (gcvalue == NULL) + { + /* ugly hack around what appears to be a gconf bug + * it returns a NULL GConfValue for a valid string pref + * which is "" by default */ + value_type = GCONF_VALUE_STRING; + } + else + { + value_type = gcvalue->type; + gconf_value_free (gcvalue); + } + + switch (value_type) + { + case GCONF_VALUE_STRING: + value = eel_gconf_get_string (config_name); + break; + case GCONF_VALUE_INT: + value = g_strdup_printf ("%d",eel_gconf_get_integer (config_name)); + break; + case GCONF_VALUE_FLOAT: + value = g_strdup_printf ("%.2f",eel_gconf_get_float (config_name)); + break; + default: + value = NULL; + } + + /* set this string value in the widget */ + if (value) + { + gtk_entry_set_text(GTK_ENTRY(editable), value); + } + + + /* free the allocated string */ + g_free (value); +} + +static void +set_optionmenu_from_config (GtkWidget *optionmenu, const char *config_name, GList *senum) +{ + int index; + + if (senum) + { + char *val; + GList *s; + + val = eel_gconf_get_string (config_name); + + s = g_list_find_custom (senum, val, (GCompareFunc)strcmp); + + index = g_list_position (senum, s); + } + else + { + index = eel_gconf_get_integer (config_name); + } + + gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), index); +} + +static void +set_radiobuttongroup_from_config (GtkWidget *radiobutton, const char *config_name, GList *senum) +{ + int index; + + if (senum) + { + char *val; + GList *s; + + val = eel_gconf_get_string (config_name); + + s = g_list_find_custom (senum, val, (GCompareFunc)strcmp); + + index = g_list_position (senum, s); + } + else + { + index = eel_gconf_get_integer (config_name); + } + + /* set it (finds the group for us) */ + ephy_gui_gtk_radio_button_set (GTK_RADIO_BUTTON (radiobutton), index); +} + +static void +set_spin_button_from_config (GtkWidget *spinbutton, const char *config_name) +{ + gdouble value; + gint use_int; + + use_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON(spinbutton)) == 0); + + if (use_int) + { + /* get the current value from the configuration space */ + value = eel_gconf_get_integer (config_name); + } + else + { + /* get the current value from the configuration space */ + value = eel_gconf_get_float (config_name); + } + + /* set this option value in the widget */ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), value); +} + +static void +set_togglebutton_from_config (GtkWidget *togglebutton, const char *config_name) +{ + gboolean value; + + /* get the current value from the configuration space */ + value = eel_gconf_get_boolean (config_name); + + /* set this option value in the widget */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton), value); +} + +static void +set_color_from_config (GtkWidget *colorpicker, const char *config_name) +{ + gchar *color_string; + guint r, g, b; + + /* get the string from config */ + color_string = eel_gconf_get_string (config_name); + + if (color_string) + { + /* parse it and setup the color picker */ + sscanf (color_string, "#%2X%2X%2X", &r, &g, &b); + gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (colorpicker), + r, g, b, 0); + /* free the string */ + g_free (color_string); + } +} + static PrefType get_pref_type_from_widget (GtkWidget *widget) { @@ -279,7 +557,7 @@ prefs_togglebutton_clicked_cb (GtkWidget *widget, PropertyInfo *pi) { if (pi->type == PT_AUTOAPPLY) { - ephy_pu_set_config_from_togglebutton (widget, pi->pref); + set_config_from_togglebutton (widget, pi->pref); } prefs_set_group_sensitivity (widget, pi->type, pi->sg); @@ -295,7 +573,7 @@ prefs_radiobutton_clicked_cb (GtkWidget *widget, PropertyInfo *pi) if (pi->type == PT_AUTOAPPLY) { - ephy_pu_set_config_from_radiobuttongroup (widget, pi->pref); + set_config_from_radiobuttongroup (widget, pi->pref, pi->string_enum); } prefs_set_group_sensitivity (widget, pi->type, pi->sg); @@ -325,8 +603,7 @@ prefs_spinbutton_timeout_cb (EphyDialog *dialog) gtk_spin_button_update (GTK_SPIN_BUTTON(pi.widget)); /* set */ - ephy_pu_set_config_from_spin_button (pi.widget, - pi.pref); + set_config_from_spin_button (pi.widget, pi.pref); /* done now */ return FALSE; @@ -367,7 +644,7 @@ prefs_color_changed_cb (GtkWidget *widget, guint r, guint g, { if (pi->type == PT_AUTOAPPLY) { - ephy_pu_set_config_from_color (widget, pi->pref); + set_config_from_color (widget, pi->pref); } } @@ -376,7 +653,7 @@ prefs_entry_changed_cb (GtkWidget *widget, PropertyInfo *pi) { if (pi->type == PT_AUTOAPPLY) { - ephy_pu_set_config_from_editable (widget, pi->pref); + set_config_from_editable (widget, pi->pref); } } @@ -385,7 +662,7 @@ prefs_optionmenu_selected_cb (GtkWidget *widget, PropertyInfo *pi) { if (pi->type == PT_AUTOAPPLY) { - ephy_pu_set_config_from_optionmenu (widget, pi->pref); + set_config_from_optionmenu (widget, pi->pref, pi->string_enum); } } @@ -468,6 +745,7 @@ ephy_dialog_init (EphyDialog *dialog) dialog->priv->props = NULL; dialog->priv->spin_timer = NULL; dialog->priv->name = NULL; + dialog->priv->initialized = FALSE; } static void @@ -504,33 +782,35 @@ load_props (PropertyInfo *props) if (GTK_IS_SPIN_BUTTON(props[i].widget)) { - ephy_pu_set_spin_button_from_config (props[i].widget, - props[i].pref); + set_spin_button_from_config (props[i].widget, + props[i].pref); } else if (GTK_IS_RADIO_BUTTON(props[i].widget)) { - ephy_pu_set_radiobuttongroup_from_config (props[i].widget, - props[i].pref); + set_radiobuttongroup_from_config (props[i].widget, + props[i].pref, + props[i].string_enum); } else if (GTK_IS_TOGGLE_BUTTON(props[i].widget)) { - ephy_pu_set_togglebutton_from_config (props[i].widget, - props[i].pref); + set_togglebutton_from_config (props[i].widget, + props[i].pref); } else if (GTK_IS_EDITABLE(props[i].widget)) { - ephy_pu_set_editable_from_config (props[i].widget, - props[i].pref); + set_editable_from_config (props[i].widget, + props[i].pref); } else if (GTK_IS_OPTION_MENU(props[i].widget)) { - ephy_pu_set_optionmenu_from_config (props[i].widget, - props[i].pref); + set_optionmenu_from_config (props[i].widget, + props[i].pref, + props[i].string_enum); } else if (GNOME_IS_COLOR_PICKER(props[i].widget)) { - ephy_pu_set_color_from_config (props[i].widget, - props[i].pref); + set_color_from_config (props[i].widget, + props[i].pref); } } @@ -549,38 +829,52 @@ save_props (PropertyInfo *props) if (GTK_IS_SPIN_BUTTON(props[i].widget)) { - ephy_pu_set_config_from_spin_button (props[i].widget, - props[i].pref); + set_config_from_spin_button (props[i].widget, + props[i].pref); } else if (GTK_IS_RADIO_BUTTON(props[i].widget)) { - ephy_pu_set_config_from_radiobuttongroup (props[i].widget, - props[i].pref); + set_config_from_radiobuttongroup (props[i].widget, + props[i].pref, + props[i].string_enum); } else if (GTK_IS_TOGGLE_BUTTON(props[i].widget)) { - ephy_pu_set_config_from_togglebutton (props[i].widget, - props[i].pref); + set_config_from_togglebutton (props[i].widget, + props[i].pref); } else if (GTK_IS_EDITABLE(props[i].widget)) { - ephy_pu_set_config_from_editable (props[i].widget, - props[i].pref); + set_config_from_editable (props[i].widget, + props[i].pref); } else if (GTK_IS_OPTION_MENU(props[i].widget)) { - ephy_pu_set_config_from_optionmenu (props[i].widget, - props[i].pref); + set_config_from_optionmenu (props[i].widget, + props[i].pref, + props[i].string_enum); } else if (GNOME_IS_COLOR_PICKER(props[i].widget)) { - ephy_pu_set_config_from_color (props[i].widget, - props[i].pref); + set_config_from_color (props[i].widget, + props[i].pref); } } } static void +free_props (PropertyInfo *properties) +{ + int i; + + for (i = 0; properties[i].string_enum != NULL; i++) + { + g_list_foreach (properties[i].string_enum, (GFunc)g_free, NULL); + g_list_free (properties[i].string_enum); + } +} + +static void ephy_dialog_finalize (GObject *object) { EphyDialog *dialog; @@ -597,6 +891,8 @@ ephy_dialog_finalize (GObject *object) ephy_dialog_destruct (dialog); } + free_props (dialog->priv->props); + g_free (dialog->priv->name); g_free (dialog->priv->props); g_free (dialog->priv); @@ -669,21 +965,21 @@ ephy_dialog_new_with_parent (GtkWidget *parent_window) NULL)); } -void ephy_dialog_show_embedded (EphyDialog *dialog, - GtkWidget *container) -{ - dialog->priv->container = container; - gtk_container_add (GTK_CONTAINER(container), - dialog->priv->dialog); - gtk_widget_show (dialog->priv->dialog); -} - void -ephy_dialog_remove_embedded (EphyDialog *dialog) +ephy_dialog_add_enum (EphyDialog *dialog, + int id, + guint n_items, + const char **items) { - g_object_ref (G_OBJECT(dialog->priv->dialog)); - gtk_container_remove (GTK_CONTAINER(dialog->priv->container), - dialog->priv->dialog); + int i = 0; + GList *l = NULL; + + for (i = 0; i < n_items; i++) + { + l = g_list_append (l, g_strdup (items[i])); + } + + dialog->priv->props[id].string_enum = l; } static PropertyInfo * @@ -704,6 +1000,7 @@ init_props (const EphyDialogProperty *properties, GladeXML *gxml) props[i].pref = properties[i].state_pref; props[i].sg = properties[i].sg; props[i].type = properties[i].type; + props[i].string_enum = NULL; } props[i].id = -1; @@ -711,6 +1008,7 @@ init_props (const EphyDialogProperty *properties, GladeXML *gxml) props[i].pref = NULL; props[i].sg = NULL; props[i].type = 0; + props[i].string_enum = NULL; return props; } @@ -765,13 +1063,6 @@ impl_construct (EphyDialog *dialog, g_object_weak_ref (G_OBJECT(dialog->priv->dialog), (GWeakNotify)dialog_destruction_notify, dialog); - - if (dialog->priv->props) - { - load_props (dialog->priv->props); - prefs_connect_signals (dialog); - prefs_set_sensitivity (dialog->priv->props); - } } static void @@ -857,6 +1148,14 @@ impl_run (EphyDialog *dialog) static void impl_show (EphyDialog *dialog) { + if (dialog->priv->props && !dialog->priv->initialized) + { + load_props (dialog->priv->props); + prefs_connect_signals (dialog); + prefs_set_sensitivity (dialog->priv->props); + dialog->priv->initialized = TRUE; + } + setup_default_size (dialog); if (dialog->priv->parent) diff --git a/lib/ephy-dialog.h b/lib/ephy-dialog.h index 24cb2cf5c..0a6f16a2d 100644 --- a/lib/ephy-dialog.h +++ b/lib/ephy-dialog.h @@ -83,9 +83,9 @@ struct EphyDialogClass GType ephy_dialog_get_type (void); -EphyDialog *ephy_dialog_new (void); +EphyDialog *ephy_dialog_new (void); -EphyDialog *ephy_dialog_new_with_parent (GtkWidget *parent_window); +EphyDialog *ephy_dialog_new_with_parent (GtkWidget *parent_window); void ephy_dialog_construct (EphyDialog *dialog, const EphyDialogProperty *properties, @@ -94,6 +94,11 @@ void ephy_dialog_construct (EphyDialog *dialog, void ephy_dialog_destruct (EphyDialog *dialog); +void ephy_dialog_add_enum (EphyDialog *dialog, + int id, + guint n_items, + const char **items); + gint ephy_dialog_run (EphyDialog *dialog); void ephy_dialog_show (EphyDialog *dialog); diff --git a/lib/ephy-prefs-utils.c b/lib/ephy-prefs-utils.c deleted file mode 100644 index 0e0cf4a50..000000000 --- a/lib/ephy-prefs-utils.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (C) 2000 Marco Pesenti Gritti - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "ephy-prefs-utils.h" -#include "ephy-gui.h" -#include "eel-gconf-extensions.h" - -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenushell.h> -#include <gtk/gtkspinbutton.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtklist.h> -#include <libgnomeui/gnome-color-picker.h> - -void -ephy_pu_set_config_from_editable (GtkWidget *editable, const char *config_name) -{ - GConfValue *gcvalue = eel_gconf_get_value (config_name); - GConfValueType value_type; - char *value; - gint ivalue; - gfloat fvalue; - - if (gcvalue == NULL) { - /* ugly hack around what appears to be a gconf bug - * it returns a NULL GConfValue for a valid string pref - * which is "" by default */ - value_type = GCONF_VALUE_STRING; - } else { - value_type = gcvalue->type; - gconf_value_free (gcvalue); - } - - /* get all the text into a new string */ - value = gtk_editable_get_chars (GTK_EDITABLE(editable), 0, -1); - - switch (value_type) { - case GCONF_VALUE_STRING: - eel_gconf_set_string (config_name, - value); - break; - /* FIXME : handle possible errors in the input for int and float */ - case GCONF_VALUE_INT: - ivalue = atoi (value); - eel_gconf_set_integer (config_name, ivalue); - break; - case GCONF_VALUE_FLOAT: - fvalue = strtod (value, (char**)NULL); - eel_gconf_set_float (config_name, fvalue); - break; - default: - break; - } - - /* free the allocated strings */ - g_free (value); -} - -void -ephy_pu_set_config_from_optionmenu (GtkWidget *optionmenu, const char *config_name) -{ - int index = ephy_pu_get_int_from_optionmenu (optionmenu); - - eel_gconf_set_integer (config_name, index); -} - -void -ephy_pu_set_config_from_radiobuttongroup (GtkWidget *radiobutton, const char *config_name) -{ - gint index; - - /* get value from radio button group */ - index = ephy_gui_gtk_radio_button_get (GTK_RADIO_BUTTON (radiobutton)); - - eel_gconf_set_integer (config_name, index); -} - -void -ephy_pu_set_config_from_spin_button (GtkWidget *spinbutton, const char *config_name) -{ - gdouble value; - gboolean use_int; - - /* read the value as an integer */ - value = gtk_spin_button_get_value (GTK_SPIN_BUTTON(spinbutton)); - - use_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON(spinbutton)) == 0); - - if (use_int) - { - eel_gconf_set_integer (config_name, value); - } - else - { - eel_gconf_set_float (config_name, value); - } -} - -void -ephy_pu_set_config_from_togglebutton (GtkWidget *togglebutton, const char *config_name) -{ - gboolean value; - - /* read the value */ - value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(togglebutton)); - - eel_gconf_set_boolean (config_name, value); -} - -void -ephy_pu_set_config_from_color (GtkWidget *colorpicker, const char *config_name) -{ - guint8 r, g, b, a; - gchar color_string[9]; - - /* get color values from color picker */ - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (colorpicker), - &r, &g, &b, &a); - - /* write into string (bounded size) */ - snprintf (color_string, 9, "#%02X%02X%02X", r, g, b); - - /* set the configuration value */ - eel_gconf_set_string (config_name, color_string); -} - -void -ephy_pu_set_editable_from_config (GtkWidget *editable, const char *config_name) -{ - GConfValue *gcvalue = eel_gconf_get_value (config_name); - GConfValueType value_type; - gchar *value; - - if (gcvalue == NULL) - { - /* ugly hack around what appears to be a gconf bug - * it returns a NULL GConfValue for a valid string pref - * which is "" by default */ - value_type = GCONF_VALUE_STRING; - } - else - { - value_type = gcvalue->type; - gconf_value_free (gcvalue); - } - - switch (value_type) - { - case GCONF_VALUE_STRING: - value = eel_gconf_get_string (config_name); - break; - case GCONF_VALUE_INT: - value = g_strdup_printf ("%d",eel_gconf_get_integer (config_name)); - break; - case GCONF_VALUE_FLOAT: - value = g_strdup_printf ("%.2f",eel_gconf_get_float (config_name)); - break; - default: - value = NULL; - } - - /* set this string value in the widget */ - if (value) - { - gtk_entry_set_text(GTK_ENTRY(editable), value); - } - - /* free the allocated string */ - g_free (value); -} - -void -ephy_pu_set_optionmenu_from_config (GtkWidget *optionmenu, const char *config_name) -{ - gint index; - - /* get the current value from the configuration space */ - index = eel_gconf_get_integer (config_name); - - /* set this option value in the widget */ - gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), index); -} - -void -ephy_pu_set_radiobuttongroup_from_config (GtkWidget *radiobutton, const char *config_name) -{ - gint index; - - /* get the current value from the configuration space */ - index = eel_gconf_get_integer (config_name); - - /* set it (finds the group for us) */ - ephy_gui_gtk_radio_button_set (GTK_RADIO_BUTTON (radiobutton), index); -} - -void -ephy_pu_set_spin_button_from_config (GtkWidget *spinbutton, const char *config_name) -{ - gdouble value; - gint use_int; - - use_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON(spinbutton)) == 0); - - if (use_int) - { - /* get the current value from the configuration space */ - value = eel_gconf_get_integer (config_name); - } - else - { - /* get the current value from the configuration space */ - value = eel_gconf_get_float (config_name); - } - - /* set this option value in the widget */ - gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbutton), value); -} - -void -ephy_pu_set_togglebutton_from_config (GtkWidget *togglebutton, const char *config_name) -{ - gboolean value; - - /* get the current value from the configuration space */ - value = eel_gconf_get_boolean (config_name); - - /* set this option value in the widget */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton), value); -} - -void -ephy_pu_set_color_from_config (GtkWidget *colorpicker, const char *config_name) -{ - gchar *color_string; - guint r, g, b; - - /* get the string from config */ - color_string = eel_gconf_get_string (config_name); - - if (color_string) - { - /* parse it and setup the color picker */ - sscanf (color_string, "#%2X%2X%2X", &r, &g, &b); - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (colorpicker), - r, g, b, 0); - /* free the string */ - g_free (color_string); - } -} - -int -ephy_pu_get_int_from_optionmenu (GtkWidget *optionmenu) -{ - GtkWidget *menu; - GList *list; - gpointer item; - gint index; - - /* extract the selection */ - menu = GTK_OPTION_MENU(optionmenu)->menu; - list = GTK_MENU_SHELL(menu)->children; - item = gtk_menu_get_active (GTK_MENU(menu)); - index = g_list_index (list, item); - - return index; -} diff --git a/lib/ephy-prefs-utils.h b/lib/ephy-prefs-utils.h deleted file mode 100644 index 13ac1e4d7..000000000 --- a/lib/ephy-prefs-utils.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2000 Marco Pesenti Gritti - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <gtk/gtkwidget.h> - -G_BEGIN_DECLS - -void ephy_pu_set_config_from_editable (GtkWidget *editable, - const char *config_name); - -void ephy_pu_set_config_from_optionmenu (GtkWidget *optionmenu, - const char *config_name); - -void ephy_pu_set_config_from_radiobuttongroup (GtkWidget *radiobutton, - const char *config_name); - -void ephy_pu_set_config_from_spin_button (GtkWidget *spinbutton, - const char *config_name); - -void ephy_pu_set_config_from_togglebutton (GtkWidget *togglebutton, - const char *config_name); - -void ephy_pu_set_config_from_color (GtkWidget *colorpicker, - const char *config_name); - -void ephy_pu_set_editable_from_config (GtkWidget *editable, - const char *config_name); - -void ephy_pu_set_optionmenu_from_config (GtkWidget *optionmenu, - const char *config_name); - -void ephy_pu_set_radiobuttongroup_from_config (GtkWidget *radiobutton, - const char *config_name); - -void ephy_pu_set_togglebutton_from_config (GtkWidget *togglebutton, - const char *config_name); - -void ephy_pu_set_spin_button_from_config (GtkWidget *spinbutton, - const char *config_name); - -void ephy_pu_set_color_from_config (GtkWidget *colorpicker, - const char *config_name); - -int ephy_pu_get_int_from_optionmenu (GtkWidget *optionmenu); - -G_END_DECLS diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index 6e16f4359..3b6233f6d 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -22,24 +22,19 @@ G_BEGIN_DECLS /* General */ -#define CONF_GENERAL_HOMEPAGE "/apps/epiphany/general/start_page" - -/* Interface */ -#define CONF_TABS_TABBED "/apps/epiphany/interface/open_in_tab" -#define CONF_WINDOWS_SHOW_TOOLBARS "/apps/epiphany/interface/show_toolbars" -#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/interface/show_bookmarks_bar" -#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/interface/show_statusbar" -#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/interface/middle_click_open_url" -#define CONF_ASK_DOWNLOAD_DEST "/apps/epiphany/interface/ask_download_dest" - -/* Downloader */ -#define CONF_DOWNLOADING_SHOW_DETAILS "/apps/epiphany/downloader/show_details" +#define CONF_GENERAL_HOMEPAGE "/apps/epiphany/general/homepage" +#define CONF_ASK_DOWNLOAD_DEST "/apps/epiphany/general/ask_download_dest" +#define CONF_TABS_TABBED "/apps/epiphany/general/open_in_tab" +#define CONF_WINDOWS_SHOW_TOOLBARS "/apps/epiphany/general/show_toolbars" +#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/general/show_bookmarks_bar" +#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/general/show_statusbar" +#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/general/middle_click_open_url" /* Directories */ #define CONF_STATE_SAVE_DIR "/apps/epiphany/directories/save" #define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage" #define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open" -#define CONF_STATE_DOWNLOADING_DIR "/apps/epiphany/directories/downloading" +#define CONF_STATE_DOWNLOADING_DIR "/apps/epiphany/directories/download" /* System prefs */ #define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command" diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 3dcaa806d..87e62d64b 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -156,6 +156,27 @@ static EncodingAutodetectorInfo encoding_autodetector[] = }; static guint n_encoding_autodetectors = G_N_ELEMENTS (encoding_autodetector); +static const +char *cookies_accept_enum [] = +{ + "anywhere", "current site", "nowhere" +}; +static guint n_cookies_accept_enum = G_N_ELEMENTS (cookies_accept_enum); + +static const +char *cache_compare_enum [] = +{ + "once per session", "every time", "never", "automatic" +}; +static guint n_cache_compare_enum = G_N_ELEMENTS (cache_compare_enum); + +static const +char *proportional_enum [] = +{ + "serif", "sans-serif" +}; +static guint n_proportional_enum = G_N_ELEMENTS (proportional_enum); + enum { FONT_TYPE_SERIF, @@ -1034,6 +1055,13 @@ prefs_dialog_init (PrefsDialog *pd) "prefs-dialog.glade", "prefs_dialog"); + ephy_dialog_add_enum (EPHY_DIALOG (pd), CACHE_COMPARE_PROP, + n_cache_compare_enum, cache_compare_enum); + ephy_dialog_add_enum (EPHY_DIALOG (pd), ACCEPT_COOKIES_PROP, + n_cookies_accept_enum, cookies_accept_enum); + ephy_dialog_add_enum (EPHY_DIALOG (pd), PROPORTIONAL_PROP, + n_proportional_enum, proportional_enum); + pd->priv->window = ephy_dialog_get_control (dialog, WINDOW_PROP); pd->priv->notebook = ephy_dialog_get_control (dialog, NOTEBOOK_PROP); pd->priv->langs = NULL; |