diff options
-rw-r--r-- | ChangeLog | 53 | ||||
-rw-r--r-- | data/chrome/epiphany.manifest.in | 2 | ||||
-rw-r--r-- | data/epiphany.schemas.in | 22 | ||||
-rw-r--r-- | data/glade/prefs-dialog.glade | 852 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.h | 7 | ||||
-rw-r--r-- | embed/mozilla/EphyAboutModule.cpp | 2 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 178 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 560 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.h | 12 | ||||
-rw-r--r-- | lib/eel-gconf-extensions.c | 24 | ||||
-rw-r--r-- | lib/eel-gconf-extensions.h | 2 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 14 | ||||
-rw-r--r-- | lib/ephy-dialog.c | 57 | ||||
-rw-r--r-- | lib/ephy-dialog.h | 5 | ||||
-rw-r--r-- | lib/ephy-file-helpers.c | 148 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 14 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-action-group.c | 1 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 6 | ||||
-rw-r--r-- | src/ephy-extensions-manager.c | 1 | ||||
-rw-r--r-- | src/ephy-window.c | 4 | ||||
-rw-r--r-- | src/popup-commands.c | 3 | ||||
-rw-r--r-- | src/prefs-dialog.c | 323 | ||||
-rw-r--r-- | src/window-commands.c | 2 |
23 files changed, 1724 insertions, 568 deletions
@@ -1,3 +1,56 @@ +2006-01-17 Christian Persch <chpe@cvs.gnome.org> + + * data/chrome/epiphany.manifest.in: + + Fix number of /'s in URI. + + * data/epiphany.schemas.in: + + Add new entries. + + * embed/mozilla/EphyAboutModule.cpp: + + Fix title. + + * data/glade/prefs-dialog.glade: + * embed/ephy-embed-prefs.h: + * embed/mozilla/mozilla-embed-single.cpp: + * embed/mozilla/mozilla-notifiers.cpp: + * embed/mozilla/mozilla-notifiers.h: + * lib/eel-gconf-extensions.c: (eel_gconf_unset_key), + (eel_gconf_notify): + * lib/eel-gconf-extensions.h: + * lib/egg/egg-editable-toolbar.c: (popup_context_menu_cb), + (button_press_event_cb), (egg_editable_toolbar_set_ui_manager), + (egg_editable_toolbar_set_selected): + * lib/ephy-dialog.c: (set_value_from_pref), (set_pref_from_value), + (set_value_from_togglebutton), (strcmp_with_null), + (get_index_from_value), (compare_values), + (set_togglebutton_from_value), (set_pref_from_info_and_emit), + (spinbutton_changed_cb), (save_info): + * lib/ephy-dialog.h: + * lib/ephy-file-helpers.c: (ephy_file_monitor_timeout_cb), + (ephy_file_monitor_cb), (ephy_file_monitor_add), + (ephy_file_monitor_cancel): + * lib/ephy-file-helpers.h: + * src/ephy-extensions-manager.c: + (ephy_extensions_manager_load_file): + * src/ephy-window.c: + * src/popup-commands.c: (popup_cmd_bookmark_link): + * src/prefs-dialog.c: (prefs_dialog_finalize), (setup_font_combo), + (fonts_language_changed_cb), (font_prefs_dialog_response_cb), + (row_is_separator), (setup_fonts_dialog), + (font_prefs_button_clicked_cb), (css_checkbox_toggled), + (css_edit_button_clicked_cb), (prefs_dialog_init): + + Rework font prefs, and add user stylesheet setting. + + * src/bookmarks/ephy-bookmark-action-group.c: (node_added_cb): + * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_local): + * src/window-commands.c: (window_cmd_file_bookmark_page): + + Some build fixes. + 2006-01-17 Peter Harvey <peter.a.harvey@gmail.com> * src/bookmarks/ephy-bookmark-action.c diff --git a/data/chrome/epiphany.manifest.in b/data/chrome/epiphany.manifest.in index 472965629..f75c35f04 100644 --- a/data/chrome/epiphany.manifest.in +++ b/data/chrome/epiphany.manifest.in @@ -1,3 +1,3 @@ override chrome://branding/locale/brand.properties file://@CHROMEDIR@/branding/brand.properties override chrome://branding/locale/brand.dtd file://@CHROMEDIR@/branding/brand.dtd -override chrome://global/content/about.xhtml file:///@CHROMEDIR@/global/about.xhtml +override chrome://global/content/about.xhtml file://@CHROMEDIR@/global/about.xhtml diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in index 8fb8764dc..05ab80ff9 100644 --- a/data/epiphany.schemas.in +++ b/data/epiphany.schemas.in @@ -96,6 +96,16 @@ </locale> </schema> <schema> + <key>/schemas/apps/epiphany/web/minimum_font_size</key> + <applyto>/apps/epiphany/web/minimum_font_size</applyto> + <owner>epiphany</owner> + <type>int</type> + <default>7</default> + <locale name="C"> + <short>Minimum font size</short> + </locale> + </schema> + <schema> <key>/schemas/apps/epiphany/web/use_own_colors</key> <applyto>/apps/epiphany/web/use_own_colors</applyto> <owner>epiphany</owner> @@ -394,6 +404,18 @@ </locale> </schema> <schema> + <key>/schemas/apps/epiphany/web/image_animation</key> + <applyto>/apps/epiphany/web/image_animation</applyto> + <owner>epiphany</owner> + <type>string</type> + <default>normal</default> + <locale name="C"> + <short>Image animation mode</short> + <long>How to present animated images. Possible values are "normal", + "once" and "disabled".</long> + </locale> + </schema> + <schema> <key>/schemas/apps/epiphany/web/allow_popups</key> <applyto>/apps/epiphany/web/allow_popups</applyto> <owner>epiphany</owner> diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade index c09fa9968..16e5d21c2 100644 --- a/data/glade/prefs-dialog.glade +++ b/data/glade/prefs-dialog.glade @@ -12,6 +12,8 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">True</property> + <property name="icon_name">gtk-preferences</property> + <property name="role">epiphany-preferences</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> @@ -125,7 +127,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -291,7 +293,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -365,7 +367,7 @@ </widget> <packing> <property name="padding">0</property> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> </packing> </child> @@ -418,332 +420,87 @@ <property name="border_width">12</property> <property name="visible">True</property> <property name="homogeneous">False</property> - <property name="spacing">18</property> + <property name="spacing">6</property> <child> - <widget class="GtkVBox" id="vbox157"> + <widget class="GtkHBox" id="hbox182"> <property name="visible">True</property> <property name="homogeneous">False</property> - <property name="spacing">6</property> + <property name="spacing">24</property> <child> - <widget class="GtkLabel" id="label1244"> + <widget class="GtkHBox" id="hbox177"> <property name="visible">True</property> - <property name="label" translatable="yes"><b>Fonts</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label1312"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Minimum size:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">min_size_spinbutton</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="min_size_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">False</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">7 1 100 1 10 10</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> <child> - <widget class="GtkAlignment" id="alignment10"> + <widget class="GtkHButtonBox" id="hbuttonbox16"> <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">18</property> - <property name="right_padding">0</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">0</property> <child> - <widget class="GtkVBox" id="vbox195"> + <widget class="GtkButton" id="font_prefs_button"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">18</property> - - <child> - <widget class="GtkTable" id="table73"> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - - <child> - <widget class="GtkLabel" id="label1134"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Variable width:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">variable_combo</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1138"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Fixed width:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">monospace_combo</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1217"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Minimum size:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">min_size_spinbutton</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkComboBox" id="monospace_combo"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkHSeparator" id="hseparator2"> - <property name="visible">True</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_padding">6</property> - <property name="x_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkComboBox" id="fonts_language_combo"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkComboBox" id="variable_combo"> - <property name="visible">True</property> - <property name="add_tearoffs">False</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1121"> - <property name="visible">True</property> - <property name="label" translatable="yes">For l_anguage:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">fonts_language_combo</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="min_size_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">True</property> - <property name="wrap">False</property> - <property name="adjustment">1 1 100 1 2 2</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">shrink|fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="fixed_size_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">True</property> - <property name="wrap">False</property> - <property name="adjustment">1 1 100 1 2 2</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">shrink|fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="variable_size_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">True</property> - <property name="wrap">False</property> - <property name="adjustment">1 1 100 1 2 2</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">shrink|fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="use_fonts_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Always use _these fonts</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Detailed Font Settings...</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> </widget> </child> </widget> @@ -757,78 +514,89 @@ <packing> <property name="padding">0</property> <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="use_fonts_checkbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Let web pages specify their own _fonts</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> <property name="fill">False</property> </packing> </child> <child> - <widget class="GtkHBox" id="hbox162"> + <widget class="GtkCheckButton" id="use_colors_checkbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Let web pages specify their own _colors</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="css_container"> <property name="visible">True</property> <property name="homogeneous">False</property> - <property name="spacing">12</property> + <property name="spacing">24</property> <child> - <widget class="GtkVBox" id="vbox158"> + <widget class="GtkCheckButton" id="css_checkbox"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use custom _stylesheet</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label1246"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Colors</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> + <child> + <widget class="GtkHButtonBox" id="css_edit_box"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="spacing">0</property> <child> - <widget class="GtkAlignment" id="alignment9"> + <widget class="GtkButton" id="css_edit_button"> <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">18</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkCheckButton" id="use_colors_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Al_ways use the desktop theme colors</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - </child> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Edit Stylesheet...</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> </child> </widget> <packing> @@ -841,7 +609,7 @@ <packing> <property name="padding">0</property> <property name="expand">False</property> - <property name="fill">False</property> + <property name="fill">True</property> </packing> </child> </widget> @@ -854,7 +622,7 @@ <child> <widget class="GtkLabel" id="label1284"> <property name="visible">True</property> - <property name="label" translatable="yes">Fonts and Colors</property> + <property name="label" translatable="yes">Fonts & Style</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -921,7 +689,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -991,7 +759,7 @@ </widget> <packing> <property name="padding">0</property> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> </packing> </child> @@ -1043,7 +811,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -1115,7 +883,7 @@ </widget> <packing> <property name="padding">0</property> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> </packing> </child> @@ -1167,7 +935,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -1294,7 +1062,7 @@ </widget> <packing> <property name="padding">0</property> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> </packing> </child> @@ -1375,7 +1143,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -1479,7 +1247,7 @@ </widget> <packing> <property name="padding">0</property> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> </packing> </child> @@ -1531,7 +1299,7 @@ <property name="yscale">1</property> <property name="top_padding">0</property> <property name="bottom_padding">0</property> - <property name="left_padding">18</property> + <property name="left_padding">12</property> <property name="right_padding">0</property> <child> @@ -1701,6 +1469,7 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">True</property> + <property name="role">epiphany-preferences-add-language</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> @@ -1828,4 +1597,329 @@ </child> </widget> +<widget class="GtkDialog" id="fonts_dialog"> + <property name="border_width">5</property> + <property name="title" translatable="yes">Fonts</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">True</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">True</property> + <property name="icon_name">gtk-preferences</property> + <property name="role">epiphany-font-preferences</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area4"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="helpbutton2"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-11</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="closebutton2"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-close</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-7</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkTable" id="table73"> + <property name="border_width">5</property> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">3</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> + + <child> + <widget class="GtkLabel" id="label1134"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Variable width:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">variable_combo</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1138"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Fixed width:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">monospace_combo</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1217"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Minimum size:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">min_size_spinbutton</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="monospace_combo"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkHSeparator" id="hseparator2"> + <property name="visible">True</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_padding">6</property> + <property name="x_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="fonts_language_combo"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="variable_combo"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1121"> + <property name="visible">True</property> + <property name="label" translatable="yes">For l_anguage:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">fonts_language_combo</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="min_size_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">True</property> + <property name="wrap">False</property> + <property name="adjustment">1 1 100 1 2 2</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">shrink|fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="fixed_size_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">True</property> + <property name="wrap">False</property> + <property name="adjustment">1 1 100 1 2 2</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">shrink|fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="variable_size_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">True</property> + <property name="wrap">False</property> + <property name="adjustment">1 1 100 1 2 2</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">shrink|fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 090770724..fe2d4ee7f 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -6,6 +6,7 @@ #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_USER_CSS_ENABLED "/apps/epiphany/web/user_css_enabled" #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" @@ -13,6 +14,8 @@ #define CONF_LANGUAGE_AUTODETECT_ENCODING "/apps/epiphany/web/autodetect_encoding" #define CONF_LANGUAGE_DEFAULT_ENCODING "/apps/epiphany/web/default_encoding" #define CONF_BROWSE_WITH_CARET "/apps/epiphany/web/browse_with_caret" +#define CONF_IMAGE_ANIMATION_MODE "/apps/epiphany/web/image_animation" +#define CONF_IMAGE_LOADING_MODE "/apps/epiphany/web/image_loading" /* These are defined gnome wide now */ #define CONF_NETWORK_PROXY_MODE "/system/proxy/mode" @@ -26,9 +29,13 @@ #define CONF_NETWORK_SOCKS_PROXY_PORT "/system/proxy/socks_port" #define CONF_NETWORK_PROXY_AUTO_URL "/system/proxy/autoconfig_url" #define CONF_NETWORK_PROXY_IGNORE_HOSTS "/system/http_proxy/ignore_hosts" +#define CONF_DESKTOP_FONT_VARIABLE "/desktop/gnome/interface/font_name" +#define CONF_DESKTOP_FONT_MONOSPACE "/desktop/gnome/interface/monospace_font_name" /* DEPRECATED, we migrate them */ #define CONF_RENDERING_FONT_VAR_SIZE_OLD "/apps/epiphany/web/font_var_size" #define CONF_RENDERING_FONT_FIXED_SIZE_OLD "/apps/epiphany/web/font_fixed_size" #define CONF_RENDERING_FONT_MIN_SIZE_OLD "/apps/epiphany/web/font_min_size" #define CONF_RENDERING_FONT_TYPE_OLD "/apps/epiphany/web/default_font_type" + +#define USER_STYLESHEET_FILENAME "user-stylesheet.css" diff --git a/embed/mozilla/EphyAboutModule.cpp b/embed/mozilla/EphyAboutModule.cpp index 6f916b848..350fa8569 100644 --- a/embed/mozilla/EphyAboutModule.cpp +++ b/embed/mozilla/EphyAboutModule.cpp @@ -580,7 +580,7 @@ EphyAboutModule::WritePage(nsIURI *aOriginalURI, "\">\n" "<div id=\"body\">" "<h1>"); - Write (stream, aTitle); + Write (stream, aPrimary); Write (stream, "</h1>\n"); if (aSecondary) diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index d542dc20c..21b9d7462 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -102,22 +102,26 @@ #include <nsIIDNService.h> #endif /* ALLOW_PRIVATE_API */ -#ifdef HAVE_GECKO_1_8 -#include <nsIStyleSheetService.h> -#include "EphyUtils.h" -#endif - #include <stdlib.h> #ifdef ENABLE_NETWORK_MANAGER #include <libnm_glib.h> #endif +#ifdef HAVE_GECKO_1_8 +#include <nsIURI.h> +#include <nsIStyleSheetService.h> +#include "EphyUtils.h" +#include "ephy-file-helpers.h" +#endif + #define MOZILLA_PROFILE_DIR "/mozilla" #define MOZILLA_PROFILE_NAME "epiphany" #define MOZILLA_PROFILE_FILE "prefs.js" #define DEFAULT_PROFILE_FILE SHARE_DIR"/default-prefs.js" +#define USER_CSS_LOAD_DELAY 500 /* ms */ + #define MOZILLA_EMBED_SINGLE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_SINGLE, MozillaEmbedSinglePrivate)) struct MozillaEmbedSinglePrivate @@ -133,6 +137,12 @@ struct MozillaEmbedSinglePrivate libnm_glib_ctx *nm_context; guint nm_callback_id; #endif +#ifdef HAVE_GECKO_1_8 + char *user_css_uri; + guint user_css_enabled_notifier_id; + EphyFileMonitor *user_css_file_monitor; + guint user_css_enabled : 1; +#endif guint online : 1; }; @@ -592,6 +602,156 @@ mozilla_init_network_manager (MozillaEmbedSingle *single) #endif /* ENABLE_NETWORK_MANAGER */ +#ifdef HAVE_GECKO_1_8 + +static void +user_css_register (MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + + nsresult rv; + nsCOMPtr<nsIURI> uri; + rv = EphyUtils::NewURI (getter_AddRefs (uri), + nsDependentCString (priv->user_css_uri)); + NS_ENSURE_SUCCESS (rv, ); + + nsCOMPtr<nsIStyleSheetService> service + (do_GetService ("@mozilla.org/content/style-sheet-service;1", &rv)); + NS_ENSURE_SUCCESS (rv, ); + + rv = service->LoadAndRegisterSheet (uri, nsIStyleSheetService::AGENT_SHEET); + if (NS_FAILED (rv)) + { + g_warning ("Registering the user stylesheet failed (rv=%x)!\n", rv); + } +} + +static void +user_css_unregister (MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + + nsresult rv; + nsCOMPtr<nsIURI> uri; + rv = EphyUtils::NewURI (getter_AddRefs (uri), + nsDependentCString (priv->user_css_uri)); + NS_ENSURE_SUCCESS (rv, ); + + nsCOMPtr<nsIStyleSheetService> service + (do_GetService ("@mozilla.org/content/style-sheet-service;1", &rv)); + NS_ENSURE_SUCCESS (rv, ); + + PRBool isRegistered = PR_FALSE; + rv = service->SheetRegistered (uri, nsIStyleSheetService::USER_SHEET, + &isRegistered); + if (NS_SUCCEEDED (rv) && isRegistered) + { + rv = service->UnregisterSheet (uri, nsIStyleSheetService::USER_SHEET); + } + if (NS_FAILED (rv)) + { + g_warning ("Unregistering the user stylesheet failed (rv=%x)!\n", rv); + } +} + +static void +user_css_file_monitor_func (EphyFileMonitor *, + const char *, + MozillaEmbedSingle *single) +{ + LOG ("Reregistering the user style sheet"); + + user_css_unregister (single); + user_css_register (single); +} + +static void +user_css_enabled_notify (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + guint enabled; + + enabled = eel_gconf_get_boolean (CONF_USER_CSS_ENABLED) != FALSE; + if (priv->user_css_enabled == enabled) return; + + LOG ("User stylesheet enabled: %s", enabled ? "t" : "f"); + + priv->user_css_enabled = enabled; + + if (enabled) + { + user_css_register (single); + + g_assert (priv->user_css_file_monitor == NULL); + priv->user_css_file_monitor = + ephy_file_monitor_add (priv->user_css_uri, + GNOME_VFS_MONITOR_FILE, + USER_CSS_LOAD_DELAY, + (EphyFileMonitorFunc) user_css_file_monitor_func, + NULL, + single); + } + else + { + if (priv->user_css_file_monitor != NULL) + { + ephy_file_monitor_cancel (priv->user_css_file_monitor); + priv->user_css_file_monitor = NULL; + } + + user_css_unregister (single); + } +} + +static void +mozilla_stylesheet_init (MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + char *user_css_file; + + user_css_file = g_build_filename (ephy_dot_dir (), + USER_STYLESHEET_FILENAME, + NULL); + priv->user_css_uri = gnome_vfs_get_uri_from_local_path (user_css_file); + g_free (user_css_file); + + user_css_enabled_notify (NULL, 0, NULL, single); + priv->user_css_enabled_notifier_id = + eel_gconf_notification_add + (CONF_USER_CSS_ENABLED, + (GConfClientNotifyFunc) user_css_enabled_notify, + single); +} + +static void +mozilla_stylesheet_shutdown (MozillaEmbedSingle *single) +{ + MozillaEmbedSinglePrivate *priv = single->priv; + + if (priv->user_css_enabled_notifier_id != 0) + { + eel_gconf_notification_remove (priv->user_css_enabled_notifier_id); + priv->user_css_enabled_notifier_id = 0; + } + + if (priv->user_css_file_monitor != NULL) + { + ephy_file_monitor_cancel (priv->user_css_file_monitor); + priv->user_css_file_monitor = NULL; + } + + if (priv->user_css_uri != NULL) + { + g_free (priv->user_css_uri); + priv->user_css_uri = NULL; + } +} + +#endif /* HAVE_GECKO_1_8 */ + static gboolean init_services (MozillaEmbedSingle *single) { @@ -641,6 +801,10 @@ init_services (MozillaEmbedSingle *single) mozilla_init_network_manager (single); #endif +#ifdef HAVE_GECKO_1_8 + mozilla_stylesheet_init (single); +#endif + return TRUE; } @@ -697,6 +861,10 @@ mozilla_embed_single_dispose (GObject *object) MozillaEmbedSingle *single = MOZILLA_EMBED_SINGLE (object); MozillaEmbedSinglePrivate *priv = single->priv; +#ifdef HAVE_GECKO_1_8 + mozilla_stylesheet_shutdown (single); +#endif + if (priv->mSingleObserver) { priv->mSingleObserver->Detach (); diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp index db227962b..711d401eb 100644 --- a/embed/mozilla/mozilla-notifiers.cpp +++ b/embed/mozilla/mozilla-notifiers.cpp @@ -45,13 +45,15 @@ #include <nsCOMPtr.h> #include <nsIServiceManager.h> #include <nsIPrefService.h> +#include <nsMemory.h> /* define to migrate epiphany 1.0 font preferences */ #define MIGRATE_PIXEL_SIZE /* Keeps the list of the notifiers we installed for mozilla prefs */ /* to be able to remove them when exiting */ -GList *notifiers = NULL; +static GList *notifiers = NULL; +static nsIPrefBranch *gPrefBranch; typedef struct { @@ -71,15 +73,18 @@ free_pref_data (PrefData *data) } static gboolean -transform_accept_languages_list (GConfValue *gcvalue, +transform_accept_languages_list (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; GArray *array; GSList *languages, *l; char **langs; - if (gcvalue->type != GCONF_VALUE_LIST || + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_LIST || gconf_value_get_list_type (gcvalue) != GCONF_VALUE_STRING) return FALSE; languages = gconf_value_get_list (gcvalue); @@ -117,11 +122,15 @@ transform_accept_languages_list (GConfValue *gcvalue, } static gboolean -transform_cache_size (GConfValue *gcvalue, +transform_cache_size (GConfEntry *gcentry, GValue *value, gpointer user_data) { - if (gcvalue->type != GCONF_VALUE_INT) return FALSE; + GConfValue *gcvalue; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_INT) return FALSE; g_value_init (value, G_TYPE_INT); g_value_set_int (value, gconf_value_get_int (gcvalue) * 1024); @@ -130,15 +139,18 @@ transform_cache_size (GConfValue *gcvalue, } static gboolean -transform_cookies_accept_mode (GConfValue *gcvalue, +transform_cookies_accept_mode (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; const char *mode; int mozilla_mode = 0; - if (gcvalue->type != GCONF_VALUE_STRING) return FALSE; + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) return FALSE; mode = gconf_value_get_string (gcvalue); if (mode == NULL) return FALSE; @@ -163,16 +175,19 @@ transform_cookies_accept_mode (GConfValue *gcvalue, } static gboolean -transform_encoding (GConfValue *gcvalue, +transform_encoding (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; EphyEncodings *encodings; EphyNode *node; const char *code; gboolean is_autodetector; - if (gcvalue->type != GCONF_VALUE_STRING) return FALSE; + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) return FALSE; code = gconf_value_get_string (gcvalue); if (code == NULL) return FALSE; @@ -191,28 +206,54 @@ transform_encoding (GConfValue *gcvalue, } static gboolean -transform_font_size (GConfValue *gcvalue, - GValue *value, - gpointer user_data) +transform_image_animation_mode (GConfEntry *gcentry, + GValue *value, + gpointer user_data) + { - if (gcvalue->type != GCONF_VALUE_INT) return FALSE; + GConfValue *gcvalue; + const char *mode; + int mozilla_mode = 0; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) return FALSE; + + mode = gconf_value_get_string (gcvalue); + if (mode == NULL) return FALSE; + + if (strcmp (mode, "normal") == 0) + { + mozilla_mode = 0; + } + else if (strcmp (mode, "once") == 0) + { + mozilla_mode = 1; + } + else if (strcmp (mode, "disabled") == 0) + { + mozilla_mode = 2; + } g_value_init (value, G_TYPE_INT); - g_value_set_int (value, MAX (1, gconf_value_get_int (gcvalue))); + g_value_set_int (value, mozilla_mode); return TRUE; } static gboolean -transform_proxy_ignore_list (GConfValue *gcvalue, +transform_proxy_ignore_list (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; GArray *array; GSList *hosts, *l; char **strings; - if (gcvalue->type != GCONF_VALUE_LIST || + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_LIST || gconf_value_get_list_type (gcvalue) != GCONF_VALUE_STRING) return FALSE; hosts = gconf_value_get_list (gcvalue); @@ -243,14 +284,17 @@ transform_proxy_ignore_list (GConfValue *gcvalue, } static gboolean -transform_proxy_mode (GConfValue *gcvalue, +transform_proxy_mode (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; const char *mode; int mozilla_mode = 0; - if (gcvalue->type != GCONF_VALUE_STRING) return FALSE; + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) return FALSE; mode = gconf_value_get_string (gcvalue); if (mode == NULL) return FALSE; @@ -271,11 +315,15 @@ transform_proxy_mode (GConfValue *gcvalue, } static gboolean -transform_use_own_fonts (GConfValue *gcvalue, +transform_use_own_fonts (GConfEntry *gcentry, GValue *value, gpointer user_data) { - if (gcvalue->type != GCONF_VALUE_BOOL) return FALSE; + GConfValue *gcvalue; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_BOOL) return FALSE; g_value_init (value, G_TYPE_INT); g_value_set_int (value, gconf_value_get_bool (gcvalue) ? 0 : 1); @@ -284,11 +332,15 @@ transform_use_own_fonts (GConfValue *gcvalue, } extern "C" gboolean -mozilla_notifier_transform_bool (GConfValue *gcvalue, +mozilla_notifier_transform_bool (GConfEntry *gcentry, GValue *value, gpointer user_data) { - if (gcvalue->type != GCONF_VALUE_BOOL) return FALSE; + GConfValue *gcvalue; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_BOOL) return FALSE; g_value_init (value, G_TYPE_BOOLEAN); g_value_set_boolean (value, gconf_value_get_bool (gcvalue)); @@ -297,11 +349,15 @@ mozilla_notifier_transform_bool (GConfValue *gcvalue, } extern "C" gboolean -mozilla_notifier_transform_bool_invert (GConfValue *gcvalue, +mozilla_notifier_transform_bool_invert (GConfEntry *gcentry, GValue *value, gpointer user_data) { - if (gcvalue->type != GCONF_VALUE_BOOL) return FALSE; + GConfValue *gcvalue; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_BOOL) return FALSE; g_value_init (value, G_TYPE_BOOLEAN); g_value_set_boolean (value, !gconf_value_get_bool (gcvalue)); @@ -310,11 +366,15 @@ mozilla_notifier_transform_bool_invert (GConfValue *gcvalue, } extern "C" gboolean -mozilla_notifier_transform_int (GConfValue *gcvalue, +mozilla_notifier_transform_int (GConfEntry *gcentry, GValue *value, gpointer user_data) { - if (gcvalue->type != GCONF_VALUE_INT) return FALSE; + GConfValue *gcvalue; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_INT) return FALSE; g_value_init (value, G_TYPE_INT); g_value_set_int (value, gconf_value_get_int (gcvalue)); @@ -323,13 +383,16 @@ mozilla_notifier_transform_int (GConfValue *gcvalue, } extern "C" gboolean -mozilla_notifier_transform_string (GConfValue *gcvalue, +mozilla_notifier_transform_string (GConfEntry *gcentry, GValue *value, gpointer user_data) { + GConfValue *gcvalue; const char *str; - if (gcvalue->type != GCONF_VALUE_STRING) return FALSE; + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) return FALSE; str = gconf_value_get_string (gcvalue); if (str == NULL) return FALSE; @@ -357,6 +420,9 @@ static const PrefData notifier_entries[] = { CONF_SECURITY_ALLOW_POPUPS, "dom.disable_open_during_load", mozilla_notifier_transform_bool_invert }, + { CONF_IMAGE_ANIMATION_MODE, + "image.animation_mode", + transform_image_animation_mode }, { CONF_RENDERING_LANGUAGE, "intl.accept_languages", transform_accept_languages_list }, @@ -416,29 +482,62 @@ gboolean mozilla_pref_set (const char *pref, const GValue *value) { + NS_ENSURE_TRUE (gPrefBranch, FALSE); + g_return_val_if_fail (pref != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); - nsCOMPtr<nsIPrefService> prefService - (do_GetService (NS_PREFSERVICE_CONTRACTID)); - NS_ENSURE_TRUE (prefService, FALSE); - - nsCOMPtr<nsIPrefBranch> prefBranch; - prefService->GetBranch ("", getter_AddRefs (prefBranch)); - NS_ENSURE_TRUE (prefBranch, FALSE); - nsresult rv; switch (G_VALUE_TYPE (value)) { case G_TYPE_INT: - rv = prefBranch->SetIntPref (pref, g_value_get_int (value)); + { + PRInt32 old_value = 0; + PRInt32 new_value = g_value_get_int (value); + rv = gPrefBranch->GetIntPref (pref, &old_value); + if (NS_FAILED (rv) || old_value != new_value) + { + rv = gPrefBranch->SetIntPref (pref, g_value_get_int (value)); + } break; + } case G_TYPE_BOOLEAN: - rv = prefBranch->SetBoolPref (pref, g_value_get_boolean (value)); + { + PRBool old_value = PR_FALSE; + PRBool new_value = g_value_get_boolean (value); + rv = gPrefBranch->GetBoolPref (pref, &old_value); + if (NS_FAILED (rv) || old_value != new_value) + { + rv = gPrefBranch->SetBoolPref (pref, new_value); + } break; + } case G_TYPE_STRING: - rv = prefBranch->SetCharPref (pref, g_value_get_string (value)); + { + const char *new_value = g_value_get_string (value); + if (new_value == NULL) + { + rv = gPrefBranch->ClearUserPref (pref); + } + else + { + char *old_value = nsnull; + + rv = gPrefBranch->GetCharPref (pref, &old_value); + if (NS_FAILED (rv) || + old_value == nsnull || + strcmp (old_value, new_value) != 0) + { + rv = gPrefBranch->SetCharPref (pref, new_value); + } + + if (old_value) + { + nsMemory::Free (old_value); + } + } break; + } default: g_return_val_if_reached (FALSE); rv = NS_ERROR_FAILURE; @@ -451,31 +550,28 @@ mozilla_pref_set (const char *pref, static void notify_cb (GConfClient *client, guint cnxn_id, - GConfEntry *entry, + GConfEntry *gcentry, PrefData *data) { - GConfValue *gcvalue; GValue value = { 0, }; - g_return_if_fail (entry != NULL); + g_return_if_fail (gcentry != NULL); g_return_if_fail (data != NULL); - gcvalue = gconf_entry_get_value (entry); - /* happens on initial notify if the key doesn't exist */ - if (gcvalue == NULL) return; - - if (data->func (gcvalue, &value, data->user_data)) + if (data->func (gcentry, &value, data->user_data)) { mozilla_pref_set (data->mozilla_pref, &value); g_value_unset (&value); } } -extern "C" guint -mozilla_notifier_add (const char *gconf_key, - const char *mozilla_pref, - PrefValueTransformFunc func, - gpointer user_data) +static guint +mozilla_notifier_add_internal (const char *gconf_key, + GConfClientNotifyFunc notify_func, + const char *mozilla_pref, + PrefValueTransformFunc func, + gpointer user_data, + GFreeFunc free_data_func) { GConfClient *client; PrefData *data; @@ -489,6 +585,7 @@ mozilla_notifier_add (const char *gconf_key, client = eel_gconf_client_get_global (); g_return_val_if_fail (client != NULL, 0); + /* FIXME: use slice allocator */ data = g_new (PrefData, 1); data->gconf_key = g_strdup (gconf_key); data->mozilla_pref = g_strdup (mozilla_pref); @@ -496,8 +593,8 @@ mozilla_notifier_add (const char *gconf_key, data->user_data = user_data; cnxn_id = gconf_client_notify_add (client, gconf_key, - (GConfClientNotifyFunc) notify_cb, - data, (GFreeFunc) free_pref_data, + notify_func, + data, free_data_func, &error); if (eel_gconf_handle_error (&error)) { @@ -517,6 +614,20 @@ mozilla_notifier_add (const char *gconf_key, return cnxn_id; } +extern "C" guint +mozilla_notifier_add (const char *gconf_key, + const char *mozilla_pref, + PrefValueTransformFunc func, + gpointer user_data) +{ + return mozilla_notifier_add_internal (gconf_key, + (GConfClientNotifyFunc) notify_cb, + mozilla_pref, + func, + user_data, + (GFreeFunc) free_pref_data); +} + static int find_data (const PrefData *a, gconstpointer idptr) @@ -596,15 +707,249 @@ migrate_font_gconf_key (const char *pixel_key, #endif -extern "C" void -mozilla_notifiers_init (void) +static gboolean +parse_pango_font (const char *font, + char **name, + int *size) +{ + PangoFontMask mask = (PangoFontMask) (PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE); + + PangoFontDescription *desc = pango_font_description_from_string (font); + if (desc == NULL || + (pango_font_description_get_set_fields (desc) & mask) != mask) + { + return FALSE; + } + + *size = PANGO_PIXELS (pango_font_description_get_size (desc)); + *name = g_strdup (pango_font_description_get_family (desc)); + + return *name != NULL && *size > 0; +} + +typedef struct +{ + guint cnxn_id; + char **font_name_prefs; + char **font_size_prefs; + char *font_name; + int font_size; + guint is_set : 1; +} DesktopFontData; + +static gboolean +transform_font_name (GConfEntry *gcentry, + GValue *value, + gpointer user_data) +{ + DesktopFontData *data = (DesktopFontData *) user_data; + GConfValue *gcvalue; + const char *font_name; + + gcvalue = gconf_entry_get_value (gcentry); + if (gconf_entry_get_is_default (gcentry) || + gcvalue == NULL || + gcvalue->type != GCONF_VALUE_STRING) + { + font_name = data->font_name; + } + else + { + font_name = gconf_value_get_string (gcvalue); + if ((font_name == NULL || font_name[0] == '\0')) + { + font_name = data->font_name; + } + } + + LOG ("%s value for key '%s'", + gconf_entry_get_is_default (gcentry) ? "default" : "NON-default", + gconf_entry_get_key (gcentry)); + + if (font_name == NULL) return FALSE; + + LOG ("Inferred font name '%s' for key '%s'", + font_name, gconf_entry_get_key (gcentry)); + + g_value_init (value, G_TYPE_STRING); + g_value_set_string (value, font_name); + + return TRUE; +} + +static gboolean +transform_font_size (GConfEntry *gcentry, + GValue *value, + gpointer user_data) +{ + DesktopFontData *data = (DesktopFontData *) user_data; + GConfValue *gcvalue; + int size = 0; + + gcvalue = gconf_entry_get_value (gcentry); + if (gconf_entry_get_is_default (gcentry) || + gcvalue == NULL || + gcvalue->type != GCONF_VALUE_INT) + { + size = data->font_size; + } + else + { + size = gconf_value_get_int (gcvalue); + } + + if (size <= 0) return FALSE; + + g_value_init (value, G_TYPE_INT); + g_value_set_int (value, size); + + return TRUE; +} + +static void +notify_desktop_font_cb (GConfClient *client, + guint cnxn_id, + GConfEntry *gcentry, + DesktopFontData *data) +{ + GConfValue *gcvalue; + char *name = NULL; + int size = 0, i; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue != NULL && + gcvalue->type == GCONF_VALUE_STRING && + parse_pango_font (gconf_value_get_string (gcvalue), &name, &size)) + { + LOG ("Desktop font %s -> name=%s, size=%d", + gconf_entry_get_key (gcentry), name, size); + + data->font_name = name; + data->font_size = size; + data->is_set = TRUE; + } + else + { + g_free (name); + g_free (data->font_name); + data->font_name = NULL; + data->font_size = 0; + data->is_set = FALSE; + } + + for (i = 0; data->font_name_prefs[i] != NULL; ++i) + { + gconf_client_notify (client, data->font_name_prefs[i]); + } + for (i = 0; data->font_size_prefs[i] != NULL; ++i) + { + gconf_client_notify (client, data->font_size_prefs[i]); + } +} + +typedef struct +{ + guint cnxn_id; + char **prefs; + int size; +} MinimumFontSizeData; + +static gboolean +transform_minimum_font_size (GConfEntry *gcentry, + GValue *value, + gpointer user_data) +{ + MinimumFontSizeData *data = (MinimumFontSizeData *) user_data; + GConfValue *gcvalue; + int size = 0; + + gcvalue = gconf_entry_get_value (gcentry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_INT) + { + size = data->size; + } + else + { + size = MAX (gconf_value_get_int (gcvalue), + data->size); + } + + if (size <= 0) return FALSE; + + g_value_init (value, G_TYPE_INT); + g_value_set_int (value, size); + + return TRUE; +} + +static void +notify_minimum_size_cb (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + MinimumFontSizeData *data) +{ + GConfValue *gcvalue; + int i; + + data->size = 0; + + gcvalue = gconf_entry_get_value (entry); + /* happens on initial notify if the key doesn't exist */ + if (gcvalue != NULL && + gcvalue->type == GCONF_VALUE_INT) + { + data->size = gconf_value_get_int (gcvalue); + data->size = MAX (data->size, 0); + } + + LOG ("Minimum font size now %d", data->size); + + for (i = 0; data->prefs[i] != NULL; ++i) + { + gconf_client_notify (client, data->prefs[i]); + } +} + +static DesktopFontData *desktop_font_data; +static MinimumFontSizeData *minimum_font_size_data; + +static void +mozilla_font_notifiers_init (void) { + static const char *types [] = { "variable", "monospace" }; const EphyFontsLanguageInfo *font_languages; guint n_font_languages, i; - eel_gconf_monitor_add ("/apps/epiphany/web"); - eel_gconf_monitor_add ("/system/proxy"); - eel_gconf_monitor_add ("/system/http_proxy"); + font_languages = ephy_font_languages (); + n_font_languages = ephy_font_n_languages (); + + desktop_font_data = g_new0 (DesktopFontData, 2); + desktop_font_data[0].font_name_prefs = g_new0 (char*, n_font_languages + 1); + desktop_font_data[0].font_size_prefs = g_new0 (char*, n_font_languages + 1); + desktop_font_data[1].font_name_prefs = g_new0 (char*, n_font_languages + 1); + desktop_font_data[1].font_size_prefs = g_new0 (char*, n_font_languages + 1); + + desktop_font_data[0].cnxn_id = + eel_gconf_notification_add (CONF_DESKTOP_FONT_VARIABLE, + (GConfClientNotifyFunc) notify_desktop_font_cb, + &desktop_font_data[0]); + eel_gconf_notify (CONF_DESKTOP_FONT_VARIABLE); + + desktop_font_data[1].cnxn_id = + eel_gconf_notification_add (CONF_DESKTOP_FONT_MONOSPACE, + (GConfClientNotifyFunc) notify_desktop_font_cb, + &desktop_font_data[1]); + eel_gconf_notify (CONF_DESKTOP_FONT_MONOSPACE); + + minimum_font_size_data = g_new0 (MinimumFontSizeData, 1); + minimum_font_size_data->prefs = g_new0 (char*, n_font_languages + 1); + + minimum_font_size_data->cnxn_id = + eel_gconf_notification_add (CONF_RENDERING_FONT_MIN_SIZE, + (GConfClientNotifyFunc) notify_minimum_size_cb, + minimum_font_size_data); + eel_gconf_notify (CONF_RENDERING_FONT_MIN_SIZE); #ifdef MIGRATE_PIXEL_SIZE gboolean migrate_size; @@ -617,23 +962,10 @@ mozilla_notifiers_init (void) } #endif - for (i = 0; i < G_N_ELEMENTS (notifier_entries); i++) - { - mozilla_notifier_add (notifier_entries[i].gconf_key, - notifier_entries[i].mozilla_pref, - notifier_entries[i].func, - notifier_entries[i].user_data); - } - - /* fonts notifiers */ - font_languages = ephy_font_languages (); - n_font_languages = ephy_font_n_languages (); - for (i=0; i < n_font_languages; i++) { const char *code = font_languages[i].code; guint k; - char *types [] = { "variable", "monospace" }; char key[255], pref[255]; #ifdef MIGRATE_PIXEL_SIZE char old_key[255]; @@ -646,8 +978,11 @@ mozilla_notifiers_init (void) g_snprintf (pref, sizeof (pref), "font.name.%s.%s", types[k], code); + desktop_font_data[k].font_name_prefs[i] = g_strdup (key); + mozilla_notifier_add (key, pref, - mozilla_notifier_transform_string, NULL); + transform_font_name, + &desktop_font_data[k]); } #ifdef MIGRATE_PIXEL_SIZE @@ -682,7 +1017,11 @@ mozilla_notifiers_init (void) g_snprintf (key, sizeof (key), "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, code); g_snprintf (pref, sizeof (pref), "font.minimum-size.%s", code); - mozilla_notifier_add (key, pref, transform_font_size, NULL); + + minimum_font_size_data->prefs[i] = g_strdup (key); + + mozilla_notifier_add (key, pref, transform_minimum_font_size, + minimum_font_size_data); #ifdef MIGRATE_PIXEL_SIZE if (migrate_size) @@ -696,7 +1035,10 @@ mozilla_notifiers_init (void) g_snprintf (key, sizeof (key), "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, code); g_snprintf (pref, sizeof (pref), "font.size.fixed.%s", code); - mozilla_notifier_add (key, pref, transform_font_size, NULL); + + desktop_font_data[1].font_size_prefs[i] = g_strdup (key); + mozilla_notifier_add (key, pref, transform_font_size, + &desktop_font_data[1]); #ifdef MIGRATE_PIXEL_SIZE if (migrate_size) @@ -710,7 +1052,10 @@ mozilla_notifiers_init (void) g_snprintf (key, sizeof (key), "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, code); g_snprintf (pref, sizeof (pref), "font.size.variable.%s", code); - mozilla_notifier_add (key, pref, transform_font_size, NULL); + + desktop_font_data[0].font_size_prefs[i] = g_strdup (key); + mozilla_notifier_add (key, pref, transform_font_size, + &desktop_font_data[0]); #ifdef MIGRATE_PIXEL_SIZE if (migrate_size) @@ -724,6 +1069,64 @@ mozilla_notifiers_init (void) } static void +mozilla_font_notifiers_shutdown (void) +{ + eel_gconf_notification_remove (desktop_font_data[0].cnxn_id); + eel_gconf_notification_remove (desktop_font_data[1].cnxn_id); + eel_gconf_notification_remove (minimum_font_size_data->cnxn_id); + + g_free (desktop_font_data[0].font_name); + g_free (desktop_font_data[1].font_name); + + g_strfreev (desktop_font_data[0].font_name_prefs); + g_strfreev (desktop_font_data[0].font_size_prefs); + g_strfreev (desktop_font_data[1].font_name_prefs); + g_strfreev (desktop_font_data[1].font_size_prefs); + g_strfreev (minimum_font_size_data->prefs); +} + +extern "C" gboolean +mozilla_notifiers_init (void) +{ + guint i; + + eel_gconf_monitor_add ("/apps/epiphany/web"); + eel_gconf_monitor_add ("/system/proxy"); + eel_gconf_monitor_add ("/system/http_proxy"); + + /* Cache the pref branch */ + nsresult rv; + nsCOMPtr<nsIPrefService> prefService + (do_GetService (NS_PREFSERVICE_CONTRACTID, &rv)); + if (NS_FAILED (rv)) + { + g_warning ("Failed to get the pref service!\n"); + return FALSE; + } + + /* the pref service conveniently implements the root pref branch */ + gPrefBranch = nsnull; + rv = CallQueryInterface (prefService, &gPrefBranch); + if (NS_FAILED (rv) || !gPrefBranch) + { + g_warning ("Failed to get the pref service!\n"); + return FALSE; + } + + for (i = 0; i < G_N_ELEMENTS (notifier_entries); i++) + { + mozilla_notifier_add (notifier_entries[i].gconf_key, + notifier_entries[i].mozilla_pref, + notifier_entries[i].func, + notifier_entries[i].user_data); + } + + mozilla_font_notifiers_init (); + + return TRUE; +} + +static void remove_notification (PrefData *data) { eel_gconf_notification_remove (data->cnxn_id); @@ -732,6 +1135,11 @@ remove_notification (PrefData *data) extern "C" void mozilla_notifiers_shutdown (void) { + NS_IF_RELEASE (gPrefBranch); + gPrefBranch = nsnull; + + mozilla_font_notifiers_shutdown (); + eel_gconf_monitor_remove ("/apps/epiphany/web"); eel_gconf_monitor_remove ("/system/proxy"); eel_gconf_monitor_remove ("/system/http_proxy"); diff --git a/embed/mozilla/mozilla-notifiers.h b/embed/mozilla/mozilla-notifiers.h index 642361c29..6b6a06eda 100644 --- a/embed/mozilla/mozilla-notifiers.h +++ b/embed/mozilla/mozilla-notifiers.h @@ -28,15 +28,15 @@ G_BEGIN_DECLS -typedef gboolean (* PrefValueTransformFunc) (GConfValue *, GValue *, gpointer); +typedef gboolean (* PrefValueTransformFunc) (GConfEntry*, GValue*, gpointer); -gboolean mozilla_notifier_transform_bool (GConfValue *, GValue *, gpointer); +gboolean mozilla_notifier_transform_bool (GConfEntry*, GValue*, gpointer); -gboolean mozilla_notifier_transform_bool_invert (GConfValue *, GValue *, gpointer); +gboolean mozilla_notifier_transform_bool_invert (GConfEntry*, GValue*, gpointer); -gboolean mozilla_notifier_transform_int (GConfValue *, GValue *, gpointer); +gboolean mozilla_notifier_transform_int (GConfEntry*, GValue*, gpointer); -gboolean mozilla_notifier_transform_string (GConfValue *, GValue *, gpointer); +gboolean mozilla_notifier_transform_string (GConfEntry*, GValue*, gpointer); guint mozilla_notifier_add (const char *gconf_key, const char *mozilla_pref, @@ -48,7 +48,7 @@ void mozilla_notifier_remove (guint id); gboolean mozilla_pref_set (const char *pref, const GValue *value); -void mozilla_notifiers_init (void); +gboolean mozilla_notifiers_init (void); void mozilla_notifiers_shutdown (void); diff --git a/lib/eel-gconf-extensions.c b/lib/eel-gconf-extensions.c index 432b0d693..d34df9f0b 100644 --- a/lib/eel-gconf-extensions.c +++ b/lib/eel-gconf-extensions.c @@ -699,3 +699,27 @@ eel_gconf_set_path (const char *key, g_free (tilde_path); g_free (converted); } + +void +eel_gconf_unset_key (const char *key) +{ + GConfClient *client; + GError *error = NULL; + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_unset (client, key, &error); + eel_gconf_handle_error (&error); +} + +void +eel_gconf_notify (const char *key) +{ + GConfClient *client; + + client = eel_gconf_client_get_global (); + g_return_if_fail (client != NULL); + + gconf_client_notify (client, key); +} diff --git a/lib/eel-gconf-extensions.h b/lib/eel-gconf-extensions.h index 410668273..de87c3973 100644 --- a/lib/eel-gconf-extensions.h +++ b/lib/eel-gconf-extensions.h @@ -76,6 +76,8 @@ void eel_gconf_set_float (const char *key, gfloat eel_gconf_get_float (const char *key); void eel_gconf_set_path (const char *key, const char *value); +void eel_gconf_unset_key (const char *key); +void eel_gconf_notify (const char *key); G_END_DECLS diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index d52da9915..6189291c8 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -368,10 +368,11 @@ popup_context_menu_cb (GtkWidget *toolbar, { if (etoolbar->priv->popup != 0) { + GtkMenu *menu; egg_editable_toolbar_set_selected (etoolbar, toolbar); g_object_notify (G_OBJECT (etoolbar), "selected"); - GtkMenu *menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager, "/ToolbarPopup")); + menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager, "/ToolbarPopup")); gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number, gtk_get_current_event_time ()); } } @@ -383,10 +384,11 @@ button_press_event_cb (GtkWidget *widget, { if (event->button == 3 && etoolbar->priv->popup != 0) { + GtkMenu *menu; egg_editable_toolbar_set_selected (etoolbar, widget); g_object_notify (G_OBJECT (etoolbar), "selected"); - GtkMenu *menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager, "/ToolbarPopup")); + menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager, "/ToolbarPopup")); gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time); return TRUE; @@ -1053,8 +1055,6 @@ static void egg_editable_toolbar_set_ui_manager (EggEditableToolbar *etoolbar, GtkUIManager *manager) { - g_return_if_fail (GTK_IS_UI_MANAGER (manager)); - GtkActionGroup *group = gtk_action_group_new ("ToolbarActions"); GtkActionEntry actions[] = { { "MoveToolItem", NULL, _("_Move on Toolbar"), NULL, @@ -1086,10 +1086,12 @@ void egg_editable_toolbar_set_selected (EggEditableToolbar *etoolbar, GtkWidget *widget) { + gboolean toolitem, toolbar; + etoolbar->priv->selected = widget; - gboolean toolitem = (gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM) != 0); - gboolean toolbar = (gtk_widget_get_ancestor (widget, GTK_TYPE_TOOLBAR) != 0); + toolitem = (gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM) != 0); + toolbar = (gtk_widget_get_ancestor (widget, GTK_TYPE_TOOLBAR) != 0); gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"), toolbar && (etoolbar->priv->edit_mode > 0)); gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"), toolitem); diff --git a/lib/ephy-dialog.c b/lib/ephy-dialog.c index f171d4dae..669f6d5d8 100644 --- a/lib/ephy-dialog.c +++ b/lib/ephy-dialog.c @@ -178,7 +178,7 @@ set_value_from_pref (PropertyInfo *info, GValue *value) case G_TYPE_STRING: g_value_init (value, G_TYPE_STRING); text = eel_gconf_get_string (info->pref); - g_value_take_string (value, text ? text : g_strdup ("")); + g_value_take_string (value, text); break; case G_TYPE_INT: g_value_init (value, G_TYPE_INT); @@ -212,8 +212,18 @@ set_pref_from_value (PropertyInfo *info, GValue *value) switch (info->data_type) { case G_TYPE_STRING: - eel_gconf_set_string (pref, g_value_get_string (value)); + { + const char *string = g_value_get_string (value); + if (string != NULL) + { + eel_gconf_set_string (pref, string); + } + else + { + eel_gconf_unset_key (pref); + } break; + } case G_TYPE_INT: eel_gconf_set_integer (pref, g_value_get_int (value)); break; @@ -412,6 +422,11 @@ set_value_from_togglebutton (PropertyInfo *info, GValue *value) active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->widget)); + if (info->apply_type & PT_INVERTED) + { + active = !active; + } + if (info->data_type == G_TYPE_BOOLEAN) { g_value_init (value, info->data_type); @@ -499,6 +514,26 @@ set_editable_from_value (PropertyInfo *info, const GValue *value) } static int +strcmp_with_null (const char *key1, + const char *key2) +{ + if (key1 == NULL && key2 == NULL) + { + return 0; + } + if (key1 == NULL) + { + return -1; + } + if (key2 == NULL) + { + return 1; + } + + return strcmp (key1, key2); +} + +static int get_index_from_value (const GValue *value, GList *string_enum) { int index = -1; @@ -509,10 +544,7 @@ get_index_from_value (const GValue *value, GList *string_enum) { val = g_value_get_string (value); - if (val) - { - s = g_list_find_custom (string_enum, val, (GCompareFunc) strcmp); - } + s = g_list_find_custom (string_enum, val, (GCompareFunc) strcmp_with_null); if (s) { @@ -538,7 +570,7 @@ compare_values (const GValue *a, const GValue *b) ta = g_value_get_string (a); tb = g_value_get_string (b); - return (ta && tb && strcmp (ta, tb) == 0); + return (strcmp_with_null (ta, tb) == 0); } else if (G_VALUE_HOLDS (a, G_TYPE_INT)) { @@ -689,6 +721,11 @@ set_togglebutton_from_value (PropertyInfo *info, const GValue *value) active = g_value_get_boolean (value); + if (info->apply_type & PT_INVERTED) + { + active = !active; + } + info->sane_state = TRUE; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->widget), active); @@ -740,7 +777,7 @@ set_pref_from_info_and_emit (PropertyInfo *info) g_signal_emit (info->dialog, signals[CHANGED], g_quark_from_string (info->id), &value); - if (info->apply_type == PT_AUTOAPPLY && info->pref != NULL) + if ((info->apply_type & PT_AUTOAPPLY) && info->pref != NULL) { set_pref_from_value (info, &value); } @@ -812,7 +849,7 @@ spinbutton_changed_cb (GtkWidget *widget, PropertyInfo *info) { GTimer *spin_timer; - if (info->apply_type != PT_AUTOAPPLY) return; + if ((info->apply_type & PT_AUTOAPPLY) == 0) return; spin_timer = g_object_get_data (G_OBJECT (info->widget), "timer"); @@ -977,7 +1014,7 @@ save_info (gpointer key, PropertyInfo *info, EphyDialog *dialog) { GValue value = { 0, }; - if (info->pref == NULL || info->apply_type != PT_NORMAL) + if (info->pref == NULL || (info->apply_type & PT_NORMAL) == 0) { return; } diff --git a/lib/ephy-dialog.h b/lib/ephy-dialog.h index e8e45ca72..6a22f585b 100644 --- a/lib/ephy-dialog.h +++ b/lib/ephy-dialog.h @@ -41,8 +41,9 @@ typedef struct _EphyDialogPrivate EphyDialogPrivate; typedef enum { - PT_NORMAL, - PT_AUTOAPPLY + PT_NORMAL = 0, + PT_AUTOAPPLY = 1 << 0, + PT_INVERTED = 1 << 1 } EphyDialogApplyType; typedef struct diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index a6db91d70..60d9a8790 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -954,3 +954,151 @@ ephy_file_launch_handler (const char *mime_type, return ret; } + +#define DELAY_MAX_TICKS 64 + +struct _EphyFileMonitor +{ + GnomeVFSMonitorHandle *handle; + EphyFileMonitorFunc callback; + EphyFileMonitorDelayFunc delay_func; + gpointer user_data; + char *uri; + guint delay; + guint timeout_id; + guint ticks; +}; + +static gboolean +ephy_file_monitor_timeout_cb (EphyFileMonitor *monitor) +{ + if (monitor->ticks > 0) + { + monitor->ticks--; + + /* Run again */ + return TRUE; + } + + if (monitor->delay_func && + monitor->delay_func (monitor, monitor->user_data)) + { + monitor->ticks = DELAY_MAX_TICKS / 2; + + /* Run again */ + return TRUE; + } + + monitor->timeout_id = 0; + + monitor->callback (monitor, monitor->uri, monitor->user_data); + + /* don't run again */ + return FALSE; +} + +static void +ephy_file_monitor_cb (GnomeVFSMonitorHandle *handle, + const char *monitor_uri, + const char *info_uri, + GnomeVFSMonitorEventType event_type, + EphyFileMonitor *monitor) +{ + LOG ("File '%s' has changed, scheduling reload", monitor_uri); + + switch (event_type) + { + case GNOME_VFS_MONITOR_EVENT_CHANGED: + case GNOME_VFS_MONITOR_EVENT_CREATED: + /* We make a lot of assumptions here, but basically we know + * that we just have to reload, by construction. + * Delay the reload a little bit so we don't endlessly + * reload while a file is written. + */ + if (monitor->ticks == 0) + { + monitor->ticks = 1; + } + else + { + /* Exponential backoff */ + monitor->ticks = MIN (monitor->ticks * 2, + DELAY_MAX_TICKS); + } + + if (monitor->timeout_id == 0) + { + monitor->timeout_id = + g_timeout_add (monitor->delay, + (GSourceFunc) ephy_file_monitor_timeout_cb, + monitor); + } + + break; + + case GNOME_VFS_MONITOR_EVENT_DELETED: + case GNOME_VFS_MONITOR_EVENT_STARTEXECUTING: + case GNOME_VFS_MONITOR_EVENT_STOPEXECUTING: + case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED: + default: + break; + } +} + +EphyFileMonitor * +ephy_file_monitor_add (const char *uri, + GnomeVFSMonitorType monitor_type, + guint delay, + EphyFileMonitorFunc callback, + EphyFileMonitorDelayFunc delay_func, + gpointer user_data) +{ + EphyFileMonitor *monitor; + + g_return_val_if_fail (uri != NULL, NULL); + g_return_val_if_fail (callback, NULL); + + monitor = g_new (EphyFileMonitor, 1); + monitor->callback = callback; + monitor->delay_func = delay_func; + monitor->user_data = user_data; + monitor->uri = g_strdup (uri); + monitor->delay = delay; + monitor->ticks = 0; + monitor->timeout_id = 0; + + if (gnome_vfs_monitor_add (&monitor->handle, uri, monitor_type, + (GnomeVFSMonitorCallback) ephy_file_monitor_cb, + monitor) != GNOME_VFS_OK) + { + LOG ("Failed to add file monitor for '%s'", uri); + + g_free (monitor->uri); + g_free (monitor); + return NULL; + } + + LOG ("File monitor for '%s' added", uri); + + return monitor; +} + +void +ephy_file_monitor_cancel (EphyFileMonitor *monitor) +{ + g_return_if_fail (monitor != NULL); + g_return_if_fail (monitor->handle != NULL); + g_return_if_fail (monitor->uri != NULL); + + LOG ("Cancelling file monitor for '%s'", monitor->uri); + + gnome_vfs_monitor_cancel (monitor->handle); + + if (monitor->timeout_id != 0) + { + g_source_remove (monitor->timeout_id); + } + + g_free (monitor->uri); + g_free (monitor); +} diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 2e5b7f111..709ff77b0 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -25,6 +25,7 @@ #include <glib.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> +#include <libgnomevfs/gnome-vfs-ops.h> G_BEGIN_DECLS @@ -35,6 +36,10 @@ typedef enum EPHY_MIME_PERMISSION_UNKNOWN = 3 } EphyMimePermission; +typedef struct _EphyFileMonitor EphyFileMonitor; +typedef void (* EphyFileMonitorFunc) (EphyFileMonitor*, const char*, gpointer); +typedef gboolean (* EphyFileMonitorDelayFunc) (EphyFileMonitor*, gpointer); + const char *ephy_file (const char *filename); const char *ephy_dot_dir (void); @@ -78,6 +83,15 @@ gboolean ephy_file_launch_handler (const char *mime_type, const char *address, guint32 user_time); +EphyFileMonitor *ephy_file_monitor_add (const char *uri, + GnomeVFSMonitorType monitor_type, + guint delay, + EphyFileMonitorFunc callback, + EphyFileMonitorDelayFunc delay_func, + gpointer user_data); + +void ephy_file_monitor_cancel (EphyFileMonitor *monitor); + G_END_DECLS #endif /* EPHY_FILE_HELPERS_H */ diff --git a/src/bookmarks/ephy-bookmark-action-group.c b/src/bookmarks/ephy-bookmark-action-group.c index e9b2c970c..4a8897e1f 100644 --- a/src/bookmarks/ephy-bookmark-action-group.c +++ b/src/bookmarks/ephy-bookmark-action-group.c @@ -114,6 +114,7 @@ node_added_cb (EphyNode *parent, gtk_action_group_add_action (actions, action); g_object_unref (action); g_free (accel); + g_free (name); ephy_bookmark_action_updated (EPHY_BOOKMARK_ACTION (action)); diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index f6f6acd89..0aa4ef175 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -1570,13 +1570,15 @@ ephy_bookmarks_get_favorites (EphyBookmarks *eb) return eb->priv->favorites; } -#ifdef ENABLE_ZEROCONF EphyNode * ephy_bookmarks_get_local (EphyBookmarks *eb) { +#ifdef ENABLE_ZEROCONF return eb->priv->local; -} +#else + return NULL; #endif +} EphyNode * ephy_bookmarks_get_not_categorized (EphyBookmarks *eb) diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c index 20e19552f..632bbda2c 100644 --- a/src/ephy-extensions-manager.c +++ b/src/ephy-extensions-manager.c @@ -538,6 +538,7 @@ ephy_extensions_manager_load_file (EphyExtensionsManager *manager, identifier); } + g_free (identifier); return; } diff --git a/src/ephy-window.c b/src/ephy-window.c index 612a55fd2..1c4178f18 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -348,6 +348,10 @@ static const GtkActionEntry ephy_popups_entries [] = { NULL, G_CALLBACK (popup_cmd_set_image_as_background) }, { "CopyImageLocation", NULL, N_("Copy I_mage Address"), NULL, NULL, G_CALLBACK (popup_cmd_copy_image_location) }, + { "StartImageAnimation", NULL, N_("St_art Animation"), NULL, + NULL, NULL }, + { "StopImageAnimation", NULL, N_("St_op Animation"), NULL, + NULL, NULL }, }; static const struct diff --git a/src/popup-commands.c b/src/popup-commands.c index 6c41ed252..f05167bb4 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -27,6 +27,7 @@ #include "ephy-prefs.h" #include "eel-gconf-extensions.h" #include "ephy-file-helpers.h" +#include "ephy-bookmarks-ui.h" #include <string.h> #include <glib/gi18n.h> @@ -126,7 +127,7 @@ popup_cmd_bookmark_link (GtkAction *action, location = rel; } - ephy_bookmarks_ui_add_bookmark (location, title, GTK_WINDOW (window)); + ephy_bookmarks_ui_add_bookmark (GTK_WIDGET (window), location, title); } static void diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 1b407519e..a850d9ad0 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -58,8 +58,11 @@ #include <gtk/gtkstock.h> #include <gtk/gtknotebook.h> #include <gtk/gtkfilechooserbutton.h> +#include <gtk/gtkmain.h> #include <string.h> +#include <libgnomevfs/gnome-vfs-utils.h> + #define CONF_FONTS_FOR_LANGUAGE "/apps/epiphany/dialogs/preferences_font_language" #define DOWNLOAD_BUTTON_WIDTH 8 @@ -120,14 +123,16 @@ enum DOWNLOAD_PATH_HBOX_PROP, /* Fonts and Colors */ - FONTS_LANGUAGE_PROP, - VARIABLE_PROP, - MONOSPACE_PROP, - FIXED_SIZE_PROP, - VARIABLE_SIZE_PROP, + USE_FONTS_PROP, MIN_SIZE_PROP, + FONT_PREFS_BUTTON_PROP, USE_COLORS_PROP, - USE_FONTS_PROP, +#ifdef HAVE_GECKO_1_8 + CSS_CONTAINER_PROP, + CSS_CHECKBOX_PROP, + CSS_EDIT_BOX_PROP, + CSS_EDIT_BUTTON_PROP, +#endif /* Privacy */ ALLOW_POPUPS_PROP, @@ -163,14 +168,16 @@ EphyDialogProperty properties [] = { "download_button_hbox", NULL, PT_NORMAL, 0 }, /* Fonts and Colors */ - { "fonts_language_combo", CONF_FONTS_FOR_LANGUAGE, PT_AUTOAPPLY, G_TYPE_STRING }, - { "variable_combo", NULL, PT_AUTOAPPLY, G_TYPE_STRING }, - { "monospace_combo", NULL, PT_AUTOAPPLY, G_TYPE_STRING }, - { "fixed_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, - { "variable_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, - { "min_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, - { "use_colors_checkbutton", CONF_RENDERING_USE_OWN_COLORS, PT_AUTOAPPLY, 0 }, - { "use_fonts_checkbutton", CONF_RENDERING_USE_OWN_FONTS, PT_AUTOAPPLY, 0 }, + { "use_fonts_checkbutton", CONF_RENDERING_USE_OWN_FONTS, PT_AUTOAPPLY | PT_INVERTED, 0 }, + { "min_size_spinbutton", CONF_RENDERING_FONT_MIN_SIZE, PT_AUTOAPPLY, 0 }, + { "font_prefs_button", NULL, PT_NORMAL, 0 }, + { "use_colors_checkbutton", CONF_RENDERING_USE_OWN_COLORS, PT_AUTOAPPLY | PT_INVERTED, 0 }, +#ifdef HAVE_GECKO_1_8 + { "css_container", NULL, PT_NORMAL, 0 }, + { "css_checkbox", CONF_USER_CSS_ENABLED, PT_AUTOAPPLY, 0 }, + { "css_edit_box", NULL, PT_NORMAL, 0 }, + { "css_edit_button", NULL, PT_NORMAL, 0 }, +#endif /* Privacy */ { "popups_allow_checkbutton", CONF_SECURITY_ALLOW_POPUPS, PT_AUTOAPPLY, 0 }, @@ -213,12 +220,44 @@ EphyDialogProperty add_lang_props [] = enum { + FONTS_WINDOW_PROP, + FONTS_LANGUAGE_PROP, + FONTS_VARIABLE_PROP, + FONTS_MONOSPACE_PROP, + FONTS_VARIABLE_SIZE_PROP, + FONTS_FIXED_SIZE_PROP, + FONTS_MIN_SIZE_PROP, +}; + +static const +EphyDialogProperty fonts_properties [] = +{ + { "fonts_dialog", NULL, PT_NORMAL, 0}, + { "fonts_language_combo", CONF_FONTS_FOR_LANGUAGE, PT_AUTOAPPLY, G_TYPE_STRING }, + { "variable_combo", NULL, PT_AUTOAPPLY, G_TYPE_STRING }, + { "monospace_combo", NULL, PT_AUTOAPPLY, G_TYPE_STRING }, + { "variable_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, + { "fixed_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, + { "min_size_spinbutton", NULL, PT_AUTOAPPLY, 0 }, + + { NULL } +}; + +enum +{ COL_FONTS_LANG_NAME, COL_FONTS_LANG_CODE }; enum { + COL_FONT_NAME, + COL_FONT_DATA, + COL_FONT_IS_SEP +}; + +enum +{ COL_LANG_NAME, COL_LANG_CODE }; @@ -235,6 +274,7 @@ struct PrefsDialogPrivate { GtkTreeView *lang_treeview; GtkTreeModel *lang_model; + EphyDialog *fonts_dialog; EphyDialog *add_lang_dialog; GtkWidget *lang_add_button; GtkWidget *lang_remove_button; @@ -278,17 +318,26 @@ static void prefs_dialog_finalize (GObject *object) { PrefsDialog *dialog = EPHY_PREFS_DIALOG (object); + PrefsDialogPrivate *priv = dialog->priv; + + if (priv->fonts_dialog != NULL) + { + g_object_remove_weak_pointer + (G_OBJECT (priv->fonts_dialog), + (gpointer *) &priv->fonts_dialog); + g_object_unref (priv->fonts_dialog); + } - if (dialog->priv->add_lang_dialog != NULL) + if (priv->add_lang_dialog != NULL) { g_object_remove_weak_pointer - (G_OBJECT (dialog->priv->add_lang_dialog), - (gpointer *) &dialog->priv->add_lang_dialog); - g_object_unref (dialog->priv->add_lang_dialog); + (G_OBJECT (priv->add_lang_dialog), + (gpointer *) &priv->add_lang_dialog); + g_object_unref (priv->add_lang_dialog); } - g_hash_table_destroy (dialog->priv->iso_639_table); - g_hash_table_destroy (dialog->priv->iso_3166_table); + g_hash_table_destroy (priv->iso_639_table); + g_hash_table_destroy (priv->iso_3166_table); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -337,58 +386,53 @@ setup_font_combo (EphyDialog *dialog, { GtkWidget *combo; GtkListStore *store; - GtkTreeModel *sortmodel; GtkTreeIter iter; GList *fonts, *l; - char *name; char key[255]; EphyEmbedSingle *single; single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); fonts = ephy_embed_single_get_font_list (single, code); + fonts = g_list_sort (fonts, (GCompareFunc) strcmp); g_snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT, type, code); - name = eel_gconf_get_string (key); - /* sanitise the pref */ - if (name == NULL || name[0] == '\0' - || g_list_find_custom (fonts, name, (GCompareFunc) strcmp) == NULL) - { - if (prop == VARIABLE_PROP) - { - eel_gconf_set_string (key, "sans-serif"); - } - else - { - eel_gconf_set_string (key, "monospace"); - } - } - g_free (name); + combo = ephy_dialog_get_control (dialog, fonts_properties[prop].id); + store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); - combo = ephy_dialog_get_control (dialog, properties[prop].id); - store = gtk_list_store_new (1, G_TYPE_STRING); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_FONT_NAME, _("Default"), + COL_FONT_DATA, NULL, + COL_FONT_IS_SEP, FALSE, + -1); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_FONT_NAME, "", + COL_FONT_DATA, "", + COL_FONT_IS_SEP, TRUE, + -1); for (l = fonts; l != NULL; l = l->next) { gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, (char *) l->data, -1); + gtk_list_store_set (store, &iter, + COL_FONT_NAME, (char *) l->data, + COL_FONT_DATA, (char *) l->data, + COL_FONT_IS_SEP, FALSE, + -1); } g_list_foreach (fonts, (GFunc) g_free, NULL); g_list_free (fonts); - sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store)); - gtk_tree_sortable_set_sort_column_id - (GTK_TREE_SORTABLE (sortmodel), 0, GTK_SORT_ASCENDING); - - ephy_dialog_set_pref (dialog, properties[prop].id, NULL); + ephy_dialog_set_pref (dialog, fonts_properties[prop].id, NULL); - gtk_combo_box_set_model (GTK_COMBO_BOX (combo), sortmodel); + gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store)); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), -1); - ephy_dialog_set_pref (dialog, properties[prop].id, key); + ephy_dialog_set_pref (dialog, fonts_properties[prop].id, key); g_object_unref (store); - g_object_unref (sortmodel); } static void @@ -404,8 +448,8 @@ fonts_language_changed_cb (EphyDialog *dialog, LOG ("fonts language combo changed, new code '%s'", code); - setup_font_combo (dialog, "variable", code, VARIABLE_PROP); - setup_font_combo (dialog, "monospace", code, MONOSPACE_PROP); + setup_font_combo (dialog, "variable", code, FONTS_VARIABLE_PROP); + setup_font_combo (dialog, "monospace", code, FONTS_MONOSPACE_PROP); g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_VAR], code); size = eel_gconf_get_integer (key); @@ -413,7 +457,7 @@ fonts_language_changed_cb (EphyDialog *dialog, { eel_gconf_set_integer (key, default_size[FONT_SIZE_VAR]); } - ephy_dialog_set_pref (dialog, properties[VARIABLE_SIZE_PROP].id, key); + ephy_dialog_set_pref (dialog, fonts_properties[FONTS_VARIABLE_SIZE_PROP].id, key); g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_FIXED], code); size = eel_gconf_get_integer (key); @@ -421,7 +465,7 @@ fonts_language_changed_cb (EphyDialog *dialog, { eel_gconf_set_integer (key, default_size[FONT_SIZE_FIXED]); } - ephy_dialog_set_pref (dialog, properties[FIXED_SIZE_PROP].id, key); + ephy_dialog_set_pref (dialog, fonts_properties[FONTS_FIXED_SIZE_PROP].id, key); g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_MIN], code); size = eel_gconf_get_integer (key); @@ -429,12 +473,38 @@ fonts_language_changed_cb (EphyDialog *dialog, { eel_gconf_set_integer (key, default_size[FONT_SIZE_MIN]); } - ephy_dialog_set_pref (dialog, properties[MIN_SIZE_PROP].id, key); + ephy_dialog_set_pref (dialog, fonts_properties[FONTS_MIN_SIZE_PROP].id, key); } static void -create_fonts_language_menu (EphyDialog *dialog) +font_prefs_dialog_response_cb (GtkWidget *widget, + int response, + EphyDialog *dialog) +{ + if (response == GTK_RESPONSE_HELP) + { + /* FIXME */ + return; + } + + g_object_unref (dialog); +} + +static gboolean +row_is_separator (GtkTreeModel *model, + GtkTreeIter *iter, + gpointer data) { + gboolean is_sep; + gtk_tree_model_get (model, iter, COL_FONT_IS_SEP, &is_sep, -1); + return is_sep; +} + +static EphyDialog * +setup_fonts_dialog (PrefsDialog *pd) +{ + EphyDialog *dialog; + GtkWidget *window, *parent, *variable_combo, *monospace_combo; GtkWidget *combo; GtkCellRenderer *renderer; GtkListStore *store; @@ -443,7 +513,51 @@ create_fonts_language_menu (EphyDialog *dialog) guint n_fonts_languages, i; const EphyFontsLanguageInfo *fonts_languages; - combo = ephy_dialog_get_control (dialog, properties[FONTS_LANGUAGE_PROP].id); + parent = ephy_dialog_get_control (EPHY_DIALOG (pd), + properties[WINDOW_PROP].id); + + dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_DIALOG, + "parent-window", parent, + NULL)); + + ephy_dialog_construct (dialog, fonts_properties, + ephy_file ("prefs-dialog.glade"), + "fonts_dialog", NULL); + + ephy_dialog_get_controls + (dialog, + fonts_properties[FONTS_WINDOW_PROP].id, &window, + fonts_properties[FONTS_LANGUAGE_PROP].id, &combo, + fonts_properties[FONTS_VARIABLE_PROP].id, &variable_combo, + fonts_properties[FONTS_MONOSPACE_PROP].id, &monospace_combo, + NULL); + + gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)), + GTK_WINDOW (window)); + g_signal_connect (window, "response", + G_CALLBACK (font_prefs_dialog_response_cb), dialog); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (variable_combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (variable_combo), renderer, + "text", COL_FONT_NAME, + NULL); + ephy_dialog_set_data_column (dialog, fonts_properties[FONTS_VARIABLE_PROP].id, + COL_FONT_DATA); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (monospace_combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (monospace_combo), renderer, + "text", COL_FONT_NAME, + NULL); + ephy_dialog_set_data_column (dialog, fonts_properties[FONTS_MONOSPACE_PROP].id, + COL_FONT_DATA); + + gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (variable_combo), + (GtkTreeViewRowSeparatorFunc) row_is_separator, + NULL, NULL); + gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (monospace_combo), + (GtkTreeViewRowSeparatorFunc) row_is_separator, + NULL, NULL); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); @@ -460,8 +574,9 @@ create_fonts_language_menu (EphyDialog *dialog) } sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store)); - gtk_tree_sortable_set_sort_column_id - (GTK_TREE_SORTABLE (sortmodel), COL_FONTS_LANG_NAME, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sortmodel), + COL_FONTS_LANG_NAME, + GTK_SORT_ASCENDING); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), sortmodel); @@ -471,7 +586,7 @@ create_fonts_language_menu (EphyDialog *dialog) "text", COL_FONTS_LANG_NAME, NULL); - ephy_dialog_set_data_column (dialog, properties[FONTS_LANGUAGE_PROP].id, COL_FONTS_LANG_CODE); + ephy_dialog_set_data_column (dialog, fonts_properties[FONTS_LANGUAGE_PROP].id, COL_FONTS_LANG_CODE); g_signal_connect (dialog, "changed::fonts_language_combo", G_CALLBACK (fonts_language_changed_cb), @@ -479,9 +594,58 @@ create_fonts_language_menu (EphyDialog *dialog) g_object_unref (store); g_object_unref (sortmodel); + + return dialog; } static void +font_prefs_button_clicked_cb (GtkWidget *button, + PrefsDialog *pd) +{ + PrefsDialogPrivate *priv = pd->priv; + + if (priv->fonts_dialog == NULL) + { + priv->fonts_dialog = setup_fonts_dialog (pd); + + g_object_add_weak_pointer + (G_OBJECT (priv->fonts_dialog), + (gpointer *) &priv->fonts_dialog); + } + + ephy_dialog_show (priv->fonts_dialog); +} + +#ifdef HAVE_GECKO_1_8 + +static void +css_checkbox_toggled (GtkToggleButton *button, + GtkWidget *widget) +{ + g_object_set (widget, "sensitive", gtk_toggle_button_get_active (button), NULL); +} + +static void +css_edit_button_clicked_cb (GtkWidget *button, + PrefsDialog *pd) +{ + char *css_file, *uri; + + css_file = g_build_filename (ephy_dot_dir (), + USER_STYLESHEET_FILENAME, + NULL); + uri = gnome_vfs_get_uri_from_local_path (css_file); + + ephy_file_launch_handler ("text/plain", uri, + gtk_get_current_event_time ()); + + g_free (css_file); + g_free (uri); +} + +#endif /* HAVE_GECKO_1_8 */ + +static void create_node_combo (EphyDialog *dialog, int prop, EphyEncodings *encodings, @@ -1250,8 +1414,10 @@ prefs_dialog_init (PrefsDialog *pd) EphyDialog *dialog = EPHY_DIALOG (pd); EphyEncodings *encodings; GtkWidget *window, *curr_button, *blank_button; - GtkWidget *variable_combo, *monospace_combo, *clear_cache_button; - GtkCellRenderer *renderer; + GtkWidget *clear_cache_button, *font_prefs_button; +#ifdef HAVE_GECKO_1_8 + GtkWidget *css_checkbox, *css_edit_box, *css_edit_button, *css_container; +#endif gboolean sensitive; pd->priv = EPHY_PREFS_DIALOG_GET_PRIVATE (pd); @@ -1270,16 +1436,18 @@ prefs_dialog_init (PrefsDialog *pd) properties[WINDOW_PROP].id, &window, properties[HOMEPAGE_CURRENT_PROP].id, &curr_button, properties[HOMEPAGE_BLANK_PROP].id, &blank_button, - properties[VARIABLE_PROP].id, &variable_combo, - properties[MONOSPACE_PROP].id, &monospace_combo, + properties[FONT_PREFS_BUTTON_PROP].id, &font_prefs_button, +#ifdef HAVE_GECKO_1_8 + properties[CSS_CHECKBOX_PROP].id, &css_checkbox, + properties[CSS_EDIT_BOX_PROP].id, &css_edit_box, + properties[CSS_EDIT_BUTTON_PROP].id, &css_edit_button, + properties[CSS_CONTAINER_PROP].id, &css_container, +#endif properties[CLEAR_CACHE_BUTTON_PROP].id, &clear_cache_button, NULL); ephy_gui_ensure_window_group (GTK_WINDOW (window)); - gtk_window_set_role (GTK_WINDOW (window), "epiphany-preferences"); - gtk_window_set_icon_name (GTK_WINDOW (window), GTK_STOCK_PREFERENCES); - g_signal_connect (window, "response", G_CALLBACK (prefs_dialog_response_cb), dialog); @@ -1293,20 +1461,19 @@ prefs_dialog_init (PrefsDialog *pd) gtk_widget_set_sensitive (curr_button, sensitive); gtk_widget_set_sensitive (blank_button, sensitive); - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (variable_combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (variable_combo), renderer, - "text", 0, - NULL); - ephy_dialog_set_data_column (dialog, properties[VARIABLE_PROP].id, 0); - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (monospace_combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (monospace_combo), renderer, - "text", 0, - NULL); - ephy_dialog_set_data_column (dialog, properties[MONOSPACE_PROP].id, 0); + g_signal_connect (font_prefs_button, "clicked", + G_CALLBACK (font_prefs_button_clicked_cb), dialog); + +#ifdef HAVE_GECKO_1_8 + css_checkbox_toggled (GTK_TOGGLE_BUTTON (css_checkbox), css_edit_box); + g_signal_connect (css_checkbox, "toggled", + G_CALLBACK (css_checkbox_toggled), css_edit_box); + + g_signal_connect (css_edit_button, "clicked", + G_CALLBACK (css_edit_button_clicked_cb), dialog); - create_fonts_language_menu (dialog); + gtk_widget_show (css_container); +#endif g_signal_connect (clear_cache_button, "clicked", G_CALLBACK (prefs_clear_cache_button_clicked_cb), dialog); diff --git a/src/window-commands.c b/src/window-commands.c index a879a4029..1a5259459 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -240,7 +240,7 @@ window_cmd_file_bookmark_page (GtkAction *action, embed = ephy_window_get_active_embed (window); g_return_if_fail (embed != NULL); - ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window), + ephy_bookmarks_ui_add_bookmark (GTK_WIDGET (window), ephy_tab_get_address (tab), ephy_tab_get_title (tab)); } |