diff options
-rw-r--r-- | ChangeLog | 81 | ||||
-rw-r--r-- | data/glade/epiphany.glade | 43 | ||||
-rw-r--r-- | data/glade/prefs-dialog.glade | 187 | ||||
-rw-r--r-- | embed/downloader-view.c | 18 | ||||
-rwxr-xr-x | embed/find-dialog.c | 96 | ||||
-rwxr-xr-x | embed/print-dialog.c | 91 | ||||
-rw-r--r-- | src/ephy-encoding-dialog.c | 28 | ||||
-rw-r--r-- | src/ephy-shell.c | 22 | ||||
-rw-r--r-- | src/ephy-shell.h | 2 | ||||
-rw-r--r-- | src/language-editor.c | 277 | ||||
-rw-r--r-- | src/language-editor.h | 17 | ||||
-rwxr-xr-x | src/pdm-dialog.c | 81 | ||||
-rw-r--r-- | src/prefs-dialog.c | 1176 | ||||
-rw-r--r-- | src/prefs-dialog.h | 8 | ||||
-rw-r--r-- | src/window-commands.c | 4 |
15 files changed, 952 insertions, 1179 deletions
@@ -1,3 +1,84 @@ +2003-11-30 Christian Persch <chpe@cvs.gnome.org> + + * configure.in: + * data/glade/epiphany.glade: + * data/glade/prefs-dialog.glade: + * embed/downloader-view.c: (downloader_view_build_ui): + * embed/ephy-embed-dialog.c: (ephy_embed_dialog_new_with_parent): + * embed/ephy-encodings.c: (ephy_encodings_get_detectors): + * embed/ephy-encodings.h: + * embed/find-dialog.c: (update_navigation_controls), + (set_properties), (impl_show), (find_dialog_class_init), + (find_dialog_init), (find_dialog_new_with_parent): + * embed/print-dialog.c: (impl_show), (print_dialog_init), + (print_dialog_new_with_parent), (print_get_info): + * lib/ephy-dialog.c: (ephy_dialog_get_type), (lookup_info), + (set_sensitivity), (set_value_from_pref), (set_pref_from_value), + (set_value_from_editable), (set_value_from_optionmenu), + (set_value_from_combobox), (get_radio_button_active_index), + (set_value_from_radiobuttongroup), (set_value_from_spin_button), + (set_value_from_togglebutton), (set_value_from_info), + (set_editable_from_value), (get_index_from_value), + (set_optionmenu_from_value), (compare_values), + (set_combo_box_from_value), (set_radiobuttongroup_from_value), + (set_spin_button_from_value), (set_togglebutton_from_value), + (set_info_from_value), (set_pref_from_info), + (togglebutton_clicked_cb), (radiobutton_clicked_cb), + (spinbutton_timeout_cb), (spinbutton_changed_cb), (changed_cb), + (set_info_from_pref), (connect_signals), (disconnect_signals), + (init_props), (load_info), (save_info), (setup_default_size), + (dialog_destroy_cb), (impl_construct), (impl_show), + (ephy_dialog_set_modal), (ephy_dialog_add_enum), + (ephy_dialog_set_data_column), (ephy_dialog_set_pref), + (ephy_dialog_set_size_group), (ephy_dialog_construct), + (ephy_dialog_show), (ephy_dialog_run), (ephy_dialog_get_control), + (ephy_dialog_get_value), (ephy_dialog_set_value), (free_prop_info), + (ephy_dialog_init), (ephy_dialog_dispose), (ephy_dialog_finalize), + (ephy_dialog_set_parent), (ephy_dialog_set_property), + (ephy_dialog_get_property), (ephy_dialog_class_init), + (ephy_dialog_new), (ephy_dialog_new_with_parent): + * lib/ephy-dialog.h: + * lib/ephy-file-chooser.c: (ephy_file_chooser_new): + * src/ephy-encoding-dialog.c: (sync_embed_cb), + (sync_parent_window_cb), (activate_choice), + (view_node_selected_cb), (view_node_activated_cb), + (ephy_encoding_dialog_init), (ephy_encoding_dialog_new): + * src/ephy-shell.c: (ephy_shell_finalize), + (ephy_shell_get_pdm_dialog), (ephy_shell_get_prefs_dialog): + * src/ephy-shell.h: + * src/language-editor.c: (language_editor_get_type), + (language_editor_class_init), (language_editor_update_pref), + (language_editor_add_button_clicked_cb), + (language_editor_set_view), (language_editor_init), + (language_editor_new), (language_editor_set_model), + (language_editor_add): + * src/language-editor.h: + * src/pdm-dialog.c: (pdm_dialog_show_help), + (action_treeview_selection_changed_cb), (setup_action), + (cookies_treeview_selection_changed_cb), + (pdm_dialog_cookies_construct), (pdm_dialog_passwords_construct), + (pdm_dialog_init), (show_cookies_properties): + * src/prefs-dialog.c: (prefs_dialog_get_type), + (prefs_dialog_class_init), (prefs_dialog_show_help), + (setup_font_combo), (fonts_language_combo_changed_cb), + (create_fonts_language_menu), (create_node_combo), + (language_combo_changed_cb), (create_language_menu), + (get_download_button_label), (create_download_path_label), + (prefs_dialog_init), (prefs_dialog_response_cb), + (set_homepage_entry), (prefs_homepage_current_button_clicked_cb), + (prefs_homepage_blank_button_clicked_cb), + (language_dialog_changed_cb), + (prefs_language_more_button_clicked_cb), + (download_path_response_cb), + (prefs_download_path_button_clicked_cb): + * src/prefs-dialog.h: + * src/window-commands.c: (window_cmd_edit_prefs): + + Improved API and implementation of EphyDialog. Add support for + new combo box, and removed optionmenu. + + Port all dialogues to new API and use combobox instead of optionmenus. + 2003-11-30 Chris Lahey <clahey@ximian.com> Marco Pesenti Gritti <marco@gnome.org> diff --git a/data/glade/epiphany.glade b/data/glade/epiphany.glade index b80aaf0ec..f6da961e5 100644 --- a/data/glade/epiphany.glade +++ b/data/glade/epiphany.glade @@ -12,6 +12,11 @@ <property name="modal">False</property> <property name="resizable">False</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">False</property> <child internal-child="vbox"> @@ -33,6 +38,7 @@ <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">0</property> <signal name="clicked" handler="find_close_button_clicked_cb"/> </widget> @@ -44,6 +50,7 @@ <property name="can_default">True</property> <property name="can_focus">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="response_id">0</property> <signal name="clicked" handler="find_prev_button_clicked_cb"/> @@ -54,6 +61,10 @@ <property name="yalign">0.5</property> <property name="xscale">0</property> <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> <child> <widget class="GtkHBox" id="hbox85"> @@ -112,6 +123,7 @@ <property name="has_default">True</property> <property name="can_focus">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="response_id">0</property> <signal name="clicked" handler="find_next_button_clicked_cb"/> @@ -122,6 +134,10 @@ <property name="yalign">0.5</property> <property name="xscale">0</property> <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> <child> <widget class="GtkHBox" id="hbox84"> @@ -259,6 +275,7 @@ <property name="label" translatable="yes">C_ase sensitive</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> @@ -278,6 +295,7 @@ <property name="label" translatable="yes">_Wrap around</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> @@ -308,6 +326,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <signal name="delete_event" handler="download_dialog_delete_cb"/> <child> @@ -330,6 +353,7 @@ <property name="label" translatable="yes">_Pause</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="download_dialog_pause_cb" last_modification_time="Sat, 01 Jun 2002 23:54:37 GMT"/> </widget> </child> @@ -342,6 +366,7 @@ <property name="label">gtk-stop</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="download_dialog_abort_cb" last_modification_time="Sat, 01 Jun 2002 23:54:50 GMT"/> </widget> </child> @@ -408,6 +433,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">False</property> <signal name="response" handler="pdm_dialog_response_cb" last_modification_time="Tue, 17 Jun 2003 22:37:44 GMT"/> @@ -430,6 +460,7 @@ <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> @@ -442,6 +473,7 @@ <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> @@ -514,6 +546,7 @@ <property name="label">gtk-remove</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> </widget> </child> @@ -526,6 +559,7 @@ <property name="label">gtk-properties</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="pdm_dialog_cookies_properties_button_clicked_cb" last_modification_time="Thu, 20 Jun 2002 08:12:23 GMT"/> </widget> </child> @@ -611,6 +645,7 @@ <property name="label">gtk-remove</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> </widget> </child> </widget> @@ -666,6 +701,11 @@ <property name="default_height">420</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">False</property> <signal name="response" handler="ephy_encoding_dialog_response_cb" last_modification_time="Thu, 16 Oct 2003 17:19:06 GMT"/> @@ -688,6 +728,7 @@ <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> @@ -720,6 +761,7 @@ <property name="label" translatable="yes"><b>_Automatic</b></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> @@ -806,6 +848,7 @@ <property name="label" translatable="yes"><b>Use a different _encoding:</b></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> diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade index 6953594ea..65f2eb942 100644 --- a/data/glade/prefs-dialog.glade +++ b/data/glade/prefs-dialog.glade @@ -2,6 +2,7 @@ <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> +<requires lib="gnome"/> <widget class="GtkDialog" id="prefs_dialog"> <property name="border_width">5</property> @@ -11,6 +12,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">False</property> <signal name="response" handler="prefs_dialog_response_cb" last_modification_time="Sat, 10 May 2003 09:37:44 GMT"/> @@ -33,6 +39,7 @@ <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> @@ -45,6 +52,7 @@ <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> @@ -204,6 +212,7 @@ <property name="label" translatable="yes">Set to Current _Page</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="prefs_homepage_current_button_clicked_cb"/> </widget> </child> @@ -216,6 +225,7 @@ <property name="label" translatable="yes">Set to _Blank Page</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="prefs_homepage_blank_button_clicked_cb" last_modification_time="Tue, 14 May 2002 10:37:08 GMT"/> </widget> </child> @@ -333,7 +343,7 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">download_path_button</property> + <property name="mnemonic_widget">download_path_button</property> </widget> <packing> <property name="padding">0</property> @@ -346,9 +356,13 @@ <widget class="GtkButton" id="download_path_button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> - <signal name="clicked" handler="prefs_download_path_button_clicked_cb"/> + <property name="focus_on_click">True</property> + <signal name="clicked" handler="prefs_download_path_button_clicked_cb"/> + + <child> + <placeholder/> + </child> </widget> <packing> <property name="padding">0</property> @@ -366,11 +380,11 @@ <child> <widget class="GtkCheckButton" id="auto_open_downloads_checkbutton"> - <property name="visible">False</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Automatically open "safe" downloads</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> @@ -527,7 +541,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">fonts_language_optionmenu</property> </widget> <packing> <property name="padding">0</property> @@ -537,16 +550,8 @@ </child> <child> - <widget class="GtkOptionMenu" id="fonts_language_optionmenu"> + <widget class="GtkComboBox" id="fonts_language_combo"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="menu2"> - <property name="visible">True</property> - </widget> - </child> </widget> <packing> <property name="padding">0</property> @@ -617,7 +622,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">combo-entry1</property> </widget> <packing> <property name="left_attach">0</property> @@ -642,7 +646,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">combo-entry5</property> </widget> <packing> <property name="left_attach">0</property> @@ -655,84 +658,6 @@ </child> <child> - <widget class="GtkCombo" id="variable_combo"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="combo-entry1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="combo-list1"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="monospace_combo"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="combo-entry5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="combo-list5"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</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> @@ -800,6 +725,32 @@ <property name="y_options"></property> </packing> </child> + + <child> + <widget class="GtkComboBox" id="variable_combo"> + <property name="visible">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</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="monospace_combo"> + <property name="visible">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">fill</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> @@ -822,6 +773,7 @@ <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> @@ -927,6 +879,7 @@ <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> @@ -1065,6 +1018,7 @@ <property name="label" translatable="yes">Allow popup _windows</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> @@ -1083,6 +1037,7 @@ <property name="label" translatable="yes">Enable _Java</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> @@ -1101,6 +1056,7 @@ <property name="label" translatable="yes">Enable Java_Script</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> @@ -1200,6 +1156,7 @@ <property name="label" translatable="yes">_Always accept</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> @@ -1218,6 +1175,7 @@ <property name="label" translatable="yes">Only _from sites you visit</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> @@ -1237,6 +1195,7 @@ <property name="label" translatable="yes">_Never accept</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> @@ -1355,7 +1314,7 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">disk_cache_spin</property> + <property name="mnemonic_widget">disk_cache_spin</property> </widget> <packing> <property name="padding">0</property> @@ -1430,6 +1389,7 @@ <property name="label" translatable="yes">Cl_ear</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="prefs_clear_cache_button_clicked_cb" last_modification_time="Sat, 07 Jun 2003 11:07:21 GMT"/> </widget> </child> @@ -1587,7 +1547,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">default_encoding_optionmenu</property> </widget> <packing> <property name="padding">0</property> @@ -1597,10 +1556,8 @@ </child> <child> - <widget class="GtkOptionMenu" id="default_encoding_optionmenu"> + <widget class="GtkComboBox" id="default_encoding_combo"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> </widget> <packing> <property name="padding">0</property> @@ -1635,7 +1592,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">auto_encoding_optionmenu</property> </widget> <packing> <property name="padding">0</property> @@ -1645,16 +1601,8 @@ </child> <child> - <widget class="GtkOptionMenu" id="auto_encoding_optionmenu"> + <widget class="GtkComboBox" id="auto_encoding_combo"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="menu6"> - <property name="visible">True</property> - </widget> - </child> </widget> <packing> <property name="padding">0</property> @@ -1776,7 +1724,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">language_optionmenu</property> </widget> <packing> <property name="padding">0</property> @@ -1786,10 +1733,8 @@ </child> <child> - <widget class="GtkOptionMenu" id="language_optionmenu"> + <widget class="GtkComboBox" id="language_combo"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> </widget> <packing> <property name="padding">0</property> @@ -1803,9 +1748,10 @@ <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Mo_re...</property> + <property name="label" translatable="yes">_More...</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="prefs_language_more_button_clicked_cb" last_modification_time="Tue, 14 May 2002 11:07:13 GMT"/> </widget> <packing> @@ -1894,6 +1840,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</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_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">False</property> <child internal-child="vbox"> @@ -1915,6 +1866,7 @@ <property name="label">gtk-add</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">0</property> </widget> </child> @@ -1927,6 +1879,7 @@ <property name="label">gtk-remove</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">0</property> </widget> </child> @@ -1939,6 +1892,7 @@ <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> <signal name="clicked" handler="language_editor_close_button_cb" last_modification_time="Thu, 16 May 2002 18:58:11 GMT"/> </widget> @@ -1978,7 +1932,6 @@ <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">languages_optionmenu</property> </widget> <packing> <property name="padding">0</property> @@ -1988,10 +1941,8 @@ </child> <child> - <widget class="GtkOptionMenu" id="languages_optionmenu"> + <widget class="GtkComboBox" id="languages_combo"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> </widget> <packing> <property name="padding">0</property> diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 4682b9c76..2ae57ce31 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -84,12 +84,12 @@ enum static const EphyDialogProperty properties [] = { - { PROP_WINDOW, "download_manager_dialog", NULL, PT_NORMAL, NULL}, - { PROP_TREEVIEW, "clist", NULL, PT_NORMAL, NULL }, - { PROP_PAUSE_BUTTON, "pause_button", NULL, PT_NORMAL, NULL }, - { PROP_ABORT_BUTTON, "abort_button", NULL, PT_NORMAL, NULL }, + { "download_manager_dialog", NULL, PT_NORMAL, 0 }, + { "clist", NULL, PT_NORMAL, 0 }, + { "pause_button", NULL, PT_NORMAL, 0 }, + { "abort_button", NULL, PT_NORMAL, 0 }, - { -1, NULL, NULL } + { NULL } }; static void @@ -409,10 +409,10 @@ downloader_view_build_ui (DownloaderView *dv) "download_manager_dialog"); /* lookup needed widgets */ - priv->window = ephy_dialog_get_control(d, PROP_WINDOW); - priv->treeview = ephy_dialog_get_control (d, PROP_TREEVIEW); - priv->pause_button = ephy_dialog_get_control (d, PROP_PAUSE_BUTTON); - priv->abort_button = ephy_dialog_get_control (d, PROP_ABORT_BUTTON); + priv->window = ephy_dialog_get_control(d, properties[PROP_WINDOW].id); + priv->treeview = ephy_dialog_get_control (d, properties[PROP_TREEVIEW].id); + priv->pause_button = ephy_dialog_get_control (d, properties[PROP_PAUSE_BUTTON].id); + priv->abort_button = ephy_dialog_get_control (d, properties[PROP_ABORT_BUTTON].id); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), GTK_SELECTION_SINGLE); diff --git a/embed/find-dialog.c b/embed/find-dialog.c index ace630cda..932511cec 100755 --- a/embed/find-dialog.c +++ b/embed/find-dialog.c @@ -47,6 +47,7 @@ static GObjectClass *parent_class = NULL; struct FindDialogPrivate { EphyEmbed *old_embed; + gboolean initialised; }; enum @@ -62,13 +63,13 @@ enum static const EphyDialogProperty properties [] = { - { WINDOW_PROP, "find_dialog", NULL, PT_NORMAL, NULL }, - { MATCH_CASE_PROP, "case_check", CONF_FIND_MATCH_CASE, PT_NORMAL, NULL }, - { AUTOWRAP_PROP, "wrap_check", CONF_FIND_AUTOWRAP, PT_NORMAL, NULL }, - { WORD_PROP, "find_entry", CONF_FIND_WORD, PT_NORMAL, NULL }, - { BACK_BUTTON, "back_button", NULL, PT_NORMAL, NULL }, - { FORWARD_BUTTON, "forward_button", NULL, PT_NORMAL, NULL }, - { -1, NULL, NULL } + { "find_dialog", NULL, PT_NORMAL, 0 }, + { "case_check", CONF_FIND_MATCH_CASE, PT_NORMAL, 0 }, + { "wrap_check", CONF_FIND_AUTOWRAP, PT_NORMAL, 0 }, + { "find_entry", CONF_FIND_WORD, PT_NORMAL, 0 }, + { "back_button", NULL, PT_NORMAL, 0 }, + { "forward_button", NULL, PT_NORMAL, 0 }, + { NULL } }; GType @@ -105,41 +106,15 @@ update_navigation_controls (FindDialog *dialog, gboolean prev, gboolean next) { GtkWidget *button; - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), BACK_BUTTON); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[BACK_BUTTON].id); gtk_widget_set_sensitive (button, prev); - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), FORWARD_BUTTON); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[FORWARD_BUTTON].id); gtk_widget_set_sensitive (button, next); } -static void -impl_show (EphyDialog *dialog) -{ - - EPHY_DIALOG_CLASS (parent_class)->show (dialog); - - /* Focus the text entry. This will correctly select or leave - * unselected the existing text in the entry depending on the - * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc. - */ - gtk_widget_grab_focus (ephy_dialog_get_control (dialog, WORD_PROP)); -} - -static void -find_dialog_class_init (FindDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EphyDialogClass *ephy_dialog_class; - - parent_class = g_type_class_peek_parent (klass); - ephy_dialog_class = EPHY_DIALOG_CLASS (klass); - - object_class->finalize = find_dialog_finalize; - - ephy_dialog_class->show = impl_show; - - g_type_class_add_private (object_class, sizeof (FindDialogPrivate)); -} static void set_properties (FindDialog *find_dialog) @@ -153,8 +128,10 @@ set_properties (FindDialog *find_dialog) EphyDialog *dialog = EPHY_DIALOG (find_dialog); EphyEmbed *embed; + if (!find_dialog->priv->initialised) return; + /* get the search string from the entry field */ - ephy_dialog_get_value (dialog, WORD_PROP, &word); + ephy_dialog_get_value (dialog, properties[WORD_PROP].id, &word); search_string = g_strdup (g_value_get_string (&word)); g_value_unset (&word); @@ -167,11 +144,11 @@ set_properties (FindDialog *find_dialog) return; } - ephy_dialog_get_value (dialog, MATCH_CASE_PROP, &match_case); + ephy_dialog_get_value (dialog, properties[MATCH_CASE_PROP].id, &match_case); b_match_case = g_value_get_boolean (&match_case); g_value_unset (&match_case); - ephy_dialog_get_value (dialog, AUTOWRAP_PROP, &wrap); + ephy_dialog_get_value (dialog, properties[AUTOWRAP_PROP].id, &wrap); b_wrap = g_value_get_boolean (&wrap); g_value_unset (&wrap); @@ -185,6 +162,39 @@ set_properties (FindDialog *find_dialog) } static void +impl_show (EphyDialog *dialog) +{ + EPHY_DIALOG_CLASS (parent_class)->show (dialog); + + EPHY_FIND_DIALOG (dialog)->priv->initialised = TRUE; + + set_properties (EPHY_FIND_DIALOG (dialog)); + + /* Focus the text entry. This will correctly select or leave + * unselected the existing text in the entry depending on the + * 'gtk-entry-select-on-focus = 0 / 1' setting in user's gtkrc. + */ + gtk_widget_grab_focus (ephy_dialog_get_control + (dialog, properties[WORD_PROP].id)); +} + +static void +find_dialog_class_init (FindDialogClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + EphyDialogClass *ephy_dialog_class; + + parent_class = g_type_class_peek_parent (klass); + ephy_dialog_class = EPHY_DIALOG_CLASS (klass); + + object_class->finalize = find_dialog_finalize; + + ephy_dialog_class->show = impl_show; + + g_type_class_add_private (object_class, sizeof (FindDialogPrivate)); +} + +static void sync_page_change (EphyEmbed *embed, const char *address, FindDialog *dialog) { g_return_if_fail (EPHY_IS_EMBED (embed)); @@ -238,6 +248,7 @@ find_dialog_init (FindDialog *dialog) dialog->priv = EPHY_FIND_DIALOG_GET_PRIVATE (dialog); dialog->priv->old_embed = NULL; + dialog->priv->initialised = FALSE; ephy_dialog_construct (EPHY_DIALOG(dialog), properties, @@ -245,7 +256,8 @@ find_dialog_init (FindDialog *dialog) "find_dialog"); update_navigation_controls (dialog, TRUE, TRUE); - window = ephy_dialog_get_control (EPHY_DIALOG (dialog), WINDOW_PROP); + window = ephy_dialog_get_control (EPHY_DIALOG (dialog), + properties[WINDOW_PROP].id); icon = gtk_widget_render_icon (window, GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, @@ -293,7 +305,7 @@ find_dialog_new_with_parent (GtkWidget *window, dialog = EPHY_FIND_DIALOG (g_object_new (EPHY_TYPE_FIND_DIALOG, "embed", embed, - "ParentWindow", window, + "parent-window", window, NULL)); return EPHY_DIALOG(dialog); diff --git a/embed/print-dialog.c b/embed/print-dialog.c index 0cbe44d59..e09b1a6c9 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -100,28 +100,28 @@ enum static const EphyDialogProperty properties [] = { - { WINDOW_PROP, "print_dialog", NULL, PT_NORMAL, NULL }, - { PRINTON_PROP, "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, NULL }, - { PRINTER_PROP, "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, NULL }, - { FILE_PROP, "file_entry", CONF_PRINT_FILE, PT_NORMAL, NULL }, - { PAPER_PROP,"A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, NULL }, - { TOP_PROP, "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, NULL }, - { BOTTOM_PROP, "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, NULL }, - { LEFT_PROP,"left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, NULL }, - { RIGHT_PROP, "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, NULL }, - { PAGE_TITLE_PROP, "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, NULL }, - { PAGE_URL_PROP, "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, NULL }, - { PAGE_NUMBERS_PROP, "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, NULL }, - { DATE_PROP, "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, NULL }, - { ALL_PAGES_PROP, "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, NULL }, - { TO_PROP, "to_spinbutton", NULL, PT_NORMAL, NULL }, - { FROM_PROP, "from_spinbutton", NULL, PT_NORMAL, NULL }, - { COLOR_PROP, "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, NULL }, - { ORIENTATION_PROP, "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, NULL }, - { PREVIEW_PROP, "preview_button", NULL, PT_NORMAL, NULL }, - { SELECTION_PROP, "selection_radiobutton", NULL, PT_NORMAL, NULL}, - - { -1, NULL, NULL } + { "print_dialog", NULL, PT_NORMAL, 0 }, + { "printer_radiobutton", CONF_PRINT_PRINTON, PT_NORMAL, 0 }, + { "printer_entry", CONF_PRINT_PRINTER, PT_NORMAL, 0 }, + { "file_entry", CONF_PRINT_FILE, PT_NORMAL, 0 }, + { "A4_radiobutton", CONF_PRINT_PAPER, PT_NORMAL, G_TYPE_STRING }, + { "top_spinbutton", CONF_PRINT_TOP_MARGIN, PT_NORMAL, 0 }, + { "bottom_spinbutton", CONF_PRINT_BOTTOM_MARGIN, PT_NORMAL, 0 }, + { "left_spinbutton", CONF_PRINT_LEFT_MARGIN, PT_NORMAL, 0 }, + { "right_spinbutton", CONF_PRINT_RIGHT_MARGIN, PT_NORMAL, 0 }, + { "print_page_title_checkbutton", CONF_PRINT_PAGE_TITLE, PT_NORMAL, 0 }, + { "print_page_url_checkbutton", CONF_PRINT_PAGE_URL, PT_NORMAL, 0 }, + { "print_page_numbers_checkbutton", CONF_PRINT_PAGE_NUMBERS, PT_NORMAL, 0 }, + { "print_date_checkbutton", CONF_PRINT_DATE, PT_NORMAL, 0 }, + { "all_pages_radiobutton", CONF_PRINT_ALL_PAGES, PT_NORMAL, 0 }, + { "to_spinbutton", NULL, PT_NORMAL, 0 }, + { "from_spinbutton", NULL, PT_NORMAL, 0 }, + { "print_color_radiobutton", CONF_PRINT_COLOR, PT_NORMAL, 0 }, + { "orient_p_radiobutton", CONF_PRINT_ORIENTATION, PT_NORMAL, 0 }, + { "preview_button", NULL, PT_NORMAL, 0 }, + { "selection_radiobutton", NULL, PT_NORMAL, 0 }, + + { NULL } }; static const @@ -176,7 +176,7 @@ impl_show (EphyDialog *dialog) /* disappear preview button */ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), - PREVIEW_PROP); + properties[PREVIEW_PROP].id); gtk_widget_hide (button); } @@ -187,7 +187,7 @@ impl_show (EphyDialog *dialog) /* Make selection button disabled */ widget = ephy_dialog_get_control (EPHY_DIALOG (dialog), - SELECTION_PROP); + properties[SELECTION_PROP].id); gtk_widget_set_sensitive (widget, FALSE); @@ -195,7 +195,7 @@ impl_show (EphyDialog *dialog) { GtkWidget *all_pages; all_pages = ephy_dialog_get_control (EPHY_DIALOG (dialog), - ALL_PAGES_PROP); + properties[ALL_PAGES_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (all_pages), TRUE); } } @@ -237,9 +237,10 @@ print_dialog_init (PrintDialog *dialog) properties, "print.glade", "print_dialog"); - dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog), WINDOW_PROP); + dialog->priv->window = ephy_dialog_get_control (EPHY_DIALOG(dialog), + properties[WINDOW_PROP].id); - ephy_dialog_add_enum (EPHY_DIALOG (dialog), PAPER_PROP, + ephy_dialog_add_enum (EPHY_DIALOG (dialog), properties[PAPER_PROP].id, n_paper_format_enum, paper_format_enum); icon = gtk_widget_render_icon (dialog->priv->window, @@ -278,7 +279,7 @@ print_dialog_new_with_parent (GtkWidget *window, dialog = EPHY_PRINT_DIALOG (g_object_new (EPHY_TYPE_PRINT_DIALOG, "embed", embed, - "ParentWindow", window, + "parent-window", window, NULL)); if (ret_info != NULL) @@ -330,15 +331,15 @@ print_get_info (EphyDialog *dialog) info = g_new0 (EmbedPrintInfo, 1); - ephy_dialog_get_value (dialog, PRINTON_PROP, &print_to_file); + ephy_dialog_get_value (dialog, properties[PRINTON_PROP].id, &print_to_file); info->print_to_file = g_value_get_int (&print_to_file); g_value_unset (&print_to_file); - ephy_dialog_get_value (dialog, PRINTER_PROP, &printer); + ephy_dialog_get_value (dialog, properties[PRINTER_PROP].id, &printer); info->printer = g_strdup (g_value_get_string (&printer)); g_value_unset (&printer); - ephy_dialog_get_value (dialog, FILE_PROP, &file); + ephy_dialog_get_value (dialog, properties[FILE_PROP].id, &file); filename = g_value_get_string (&file); if (filename != NULL) { @@ -350,64 +351,64 @@ print_get_info (EphyDialog *dialog) } g_value_unset (&file); - ephy_dialog_get_value (dialog, BOTTOM_PROP, &bottom_margin); + ephy_dialog_get_value (dialog, properties[BOTTOM_PROP].id, &bottom_margin); info->bottom_margin = g_value_get_float (&bottom_margin); g_value_unset (&bottom_margin); - ephy_dialog_get_value (dialog, LEFT_PROP, &left_margin); + ephy_dialog_get_value (dialog, properties[LEFT_PROP].id, &left_margin); info->left_margin = g_value_get_float (&left_margin); g_value_unset (&left_margin); - ephy_dialog_get_value (dialog, TOP_PROP, &top_margin); + ephy_dialog_get_value (dialog, properties[TOP_PROP].id, &top_margin); info->top_margin = g_value_get_float (&top_margin); g_value_unset (&top_margin); - ephy_dialog_get_value (dialog, RIGHT_PROP, &right_margin); + ephy_dialog_get_value (dialog, properties[RIGHT_PROP].id, &right_margin); info->right_margin = g_value_get_float (&right_margin); g_value_unset (&right_margin); - ephy_dialog_get_value (dialog, FROM_PROP, &from_page); + ephy_dialog_get_value (dialog, properties[FROM_PROP].id, &from_page); info->from_page = g_value_get_float (&from_page); g_value_unset (&from_page); - ephy_dialog_get_value (dialog, TO_PROP, &to_page); + ephy_dialog_get_value (dialog, properties[TO_PROP].id, &to_page); info->to_page = g_value_get_float (&to_page); g_value_unset (&to_page); - ephy_dialog_get_value (dialog, PAPER_PROP, &paper); + ephy_dialog_get_value (dialog, properties[PAPER_PROP].id, &paper); info->paper = g_strdup (paper_format_enum[g_value_get_int (&paper)]); g_value_unset (&paper); - ephy_dialog_get_value (dialog, ALL_PAGES_PROP, &pages); + ephy_dialog_get_value (dialog, properties[ALL_PAGES_PROP].id, &pages); info->pages = g_value_get_int (&pages); g_value_unset (&pages); - ephy_dialog_get_value (dialog, COLOR_PROP, &print_color); + ephy_dialog_get_value (dialog, properties[COLOR_PROP].id, &print_color); info->print_color = !g_value_get_int (&print_color); g_value_unset (&print_color); - ephy_dialog_get_value (dialog, ORIENTATION_PROP, &orientation); + ephy_dialog_get_value (dialog, properties[ORIENTATION_PROP].id, &orientation); info->orientation = g_value_get_int (&orientation); g_value_unset (&orientation); info->frame_type = 0; - ephy_dialog_get_value (dialog, PAGE_TITLE_PROP, &page_title); + ephy_dialog_get_value (dialog, properties[PAGE_TITLE_PROP].id, &page_title); info->header_left_string = g_value_get_boolean (&page_title) ? g_strdup ("&T") : g_strdup (""); g_value_unset (&page_title); - ephy_dialog_get_value (dialog, PAGE_URL_PROP, &page_url); + ephy_dialog_get_value (dialog, properties[PAGE_URL_PROP].id, &page_url); info->header_right_string = g_value_get_boolean (&page_url) ? g_strdup ("&U") : g_strdup (""); g_value_unset (&page_url); - ephy_dialog_get_value (dialog, PAGE_NUMBERS_PROP, &page_numbers); + ephy_dialog_get_value (dialog, properties[PAGE_NUMBERS_PROP].id, &page_numbers); info->footer_left_string = g_value_get_boolean (&page_numbers) ? g_strdup ("&PT") : g_strdup (""); g_value_unset (&page_numbers); - ephy_dialog_get_value (dialog, DATE_PROP, &date); + ephy_dialog_get_value (dialog, properties[DATE_PROP].id, &date); info->footer_right_string = g_value_get_boolean (&date) ? g_strdup ("&D") : g_strdup (""); g_value_unset (&date); diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index 6338c93a6..7c6efd7f6 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -51,11 +51,11 @@ enum static const EphyDialogProperty properties [] = { - { SCROLLED_WINDOW_PROP, "scrolled_window", NULL, PT_NORMAL, NULL }, - { AUTOMATIC_PROP, "automatic_button", NULL, PT_NORMAL, NULL }, - { AUTOMATIC_PROP, "manual_button", NULL, PT_NORMAL, NULL }, + { "scrolled_window", NULL, PT_NORMAL, 0 }, + { "automatic_button", NULL, PT_NORMAL, 0 }, + { "manual_button", NULL, PT_NORMAL, 0 }, - { -1, NULL, NULL } + { NULL } }; #define EPHY_ENCODING_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ENCODING_DIALOG, EphyEncodingDialogPrivate)) @@ -161,7 +161,7 @@ sync_embed_cb (EphyEncodingDialog *dialog, GParamSpec *pspec, gpointer dummy) is_automatic = encoding_is_automatic (info); - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), AUTOMATIC_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), is_automatic); ephy_encoding_info_free (info); @@ -188,7 +188,7 @@ sync_parent_window_cb (EphyEncodingDialog *dialog, GParamSpec *pspec, gpointer d g_return_if_fail (dialog->priv->window == NULL); g_value_init (&value, GTK_TYPE_WIDGET); - g_object_get_property (G_OBJECT (dialog), "ParentWindow", &value); + g_object_get_property (G_OBJECT (dialog), "parent-window", &value); window = EPHY_WINDOW (g_value_get_object (&value)); g_value_unset (&value); @@ -215,7 +215,7 @@ activate_choice (EphyEncodingDialog *dialog) info = ephy_embed_get_encoding_info (embed); if (info == NULL) return; - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), AUTOMATIC_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id); is_automatic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); if (is_automatic) @@ -265,7 +265,7 @@ view_node_selected_cb (EphyNodeView *view, if (dialog->priv->update_tag) return; - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), MANUAL_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); activate_choice (dialog); @@ -282,7 +282,7 @@ view_node_activated_cb (GtkWidget *view, if (dialog->priv->update_tag) return; - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), MANUAL_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); activate_choice (dialog); @@ -350,20 +350,20 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog) gtk_widget_show (treeview); scroller = ephy_dialog_get_control - (EPHY_DIALOG (dialog), SCROLLED_WINDOW_PROP); + (EPHY_DIALOG (dialog), properties[SCROLLED_WINDOW_PROP].id); gtk_container_add (GTK_CONTAINER (scroller), treeview); - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), AUTOMATIC_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id); gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (button)->child), TRUE); g_signal_connect (button, "toggled", G_CALLBACK (automatic_toggled_cb), dialog); - button = ephy_dialog_get_control (EPHY_DIALOG (dialog), MANUAL_PROP); + button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id); gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (button)->child), TRUE); dialog->priv->enc_view = treeview; - g_signal_connect (G_OBJECT (dialog), "notify::ParentWindow", + g_signal_connect (G_OBJECT (dialog), "notify::parent-window", G_CALLBACK (sync_parent_window_cb), NULL); g_signal_connect (G_OBJECT (dialog), "notify::embed", G_CALLBACK (sync_embed_cb), NULL); @@ -402,6 +402,6 @@ EphyEncodingDialog * ephy_encoding_dialog_new (EphyWindow *parent) { return g_object_new (EPHY_TYPE_ENCODING_DIALOG, - "ParentWindow", parent, + "parent-window", parent, NULL); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index a759d0133..62f12f860 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -33,6 +33,7 @@ #include "ephy-bookmarks-editor.h" #include "ephy-history-window.h" #include "pdm-dialog.h" +#include "prefs-dialog.h" #include "ephy-debug.h" #include "ephy-extensions-manager.h" #include "toolbar.h" @@ -73,6 +74,7 @@ struct EphyShellPrivate GtkWidget *bme; GtkWidget *history_window; GObject *pdm_dialog; + GObject *prefs_dialog; GList *del_on_exit; guint server_timeout; }; @@ -503,6 +505,12 @@ ephy_shell_finalize (GObject *object) g_object_unref (gs->priv->pdm_dialog); } + LOG ("Unref prefs dialog") + if (gs->priv->prefs_dialog) + { + g_object_unref (gs->priv->prefs_dialog); + } + LOG ("Unref bookmarks") if (gs->priv->bookmarks) { @@ -810,6 +818,20 @@ ephy_shell_get_pdm_dialog (EphyShell *shell) return shell->priv->pdm_dialog; } +GObject * +ephy_shell_get_prefs_dialog (EphyShell *shell) +{ + if (shell->priv->prefs_dialog == NULL) + { + shell->priv->prefs_dialog = g_object_new (EPHY_TYPE_PREFS_DIALOG, NULL); + + g_object_add_weak_pointer (shell->priv->prefs_dialog, + (gpointer *) &shell->priv->prefs_dialog); + } + + return shell->priv->prefs_dialog; +} + void ephy_shell_delete_on_exit (EphyShell *gs, const char *path) { diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 219942f41..c114d415f 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -137,6 +137,8 @@ GtkWidget *ephy_shell_get_history_window (EphyShell *gs); GObject *ephy_shell_get_pdm_dialog (EphyShell *shell); +GObject *ephy_shell_get_prefs_dialog (EphyShell *shell); + void ephy_shell_delete_on_exit (EphyShell *gs, const char *path); diff --git a/src/language-editor.c b/src/language-editor.c index 016ebd259..28d09515f 100644 --- a/src/language-editor.c +++ b/src/language-editor.c @@ -21,6 +21,7 @@ #include "language-editor.h" #include "ephy-gui.h" #include "eel-gconf-extensions.h" +#include "ephy-debug.h" #include <gtk/gtklabel.h> #include <gtk/gtkoptionmenu.h> @@ -31,30 +32,31 @@ #include <gtk/gtktreeselection.h> #include <gtk/gtkliststore.h> #include <gtk/gtkcellrenderertext.h> +#include <glib/gi18n.h> enum { - COL_DESCRIPTION, - COL_DATA + COL_DESCRIPTION, + COL_DATA }; enum { - TREEVIEW_PROP, - ADD_PROP, - REMOVE_PROP, - LANGUAGE_PROP + TREEVIEW_PROP, + ADD_PROP, + REMOVE_PROP, + LANGUAGE_PROP }; static const EphyDialogProperty properties [] = { - { TREEVIEW_PROP, "languages_treeview", NULL, PT_NORMAL, NULL }, - { ADD_PROP, "add_button", NULL, PT_NORMAL, NULL }, - { REMOVE_PROP, "remove_button", NULL, PT_NORMAL, NULL }, - { LANGUAGE_PROP, "languages_optionmenu", NULL, PT_NORMAL, NULL }, + { "languages_treeview", NULL, PT_NORMAL, 0 }, + { "add_button", NULL, PT_NORMAL, 0 }, + { "remove_button", NULL, PT_NORMAL, 0 }, + { "languages_combo", NULL, PT_NORMAL, 0 }, - { -1, NULL, NULL } + { NULL } }; #define EPHY_LANGUAGE_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditorPrivate)) @@ -63,75 +65,71 @@ struct LanguageEditorPrivate { GtkWidget *treeview; GtkTreeModel *model; - GtkWidget *optionmenu; }; +static void language_editor_class_init (LanguageEditorClass *klass); +static void language_editor_init (LanguageEditor *ge); + +/* Glade callbacks */ + +void language_editor_close_button_cb (GtkWidget *button, + EphyDialog *dialog); + enum { CHANGED, LAST_SIGNAL }; -static void -language_editor_class_init (LanguageEditorClass *klass); -static void -language_editor_init (LanguageEditor *ge); - -/* Glade callbacks */ - -void -language_editor_close_button_cb (GtkWidget *button, EphyDialog *dialog); +static gint signals[LAST_SIGNAL]; static GObjectClass *parent_class = NULL; -static gint signals[LAST_SIGNAL]; - GType language_editor_get_type (void) { - static GType language_editor_type = 0; - - if (language_editor_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (LanguageEditorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) language_editor_class_init, - NULL, - NULL, /* class_data */ - sizeof (LanguageEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) language_editor_init - }; - - language_editor_type = g_type_register_static (EPHY_TYPE_DIALOG, - "LanguageEditor", - &our_info, 0); - } - - return language_editor_type; + static GType type = 0; + if (type == 0) + { + static const GTypeInfo our_info = + { + sizeof (LanguageEditorClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) language_editor_class_init, + NULL, + NULL, /* class_data */ + sizeof (LanguageEditor), + 0, /* n_preallocs */ + (GInstanceInitFunc) language_editor_init + }; + + type = g_type_register_static (EPHY_TYPE_DIALOG, + "LanguageEditor", + &our_info, 0); + } + + return type; } static void language_editor_class_init (LanguageEditorClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_peek_parent (klass); signals[CHANGED] = g_signal_new ("changed", G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (LanguageEditorClass, changed), - NULL, NULL, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (LanguageEditorClass, changed), + NULL, NULL, g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); + G_TYPE_NONE, + 1, + G_TYPE_POINTER); g_type_class_add_private (object_class, sizeof(LanguageEditorPrivate)); } @@ -140,8 +138,7 @@ static void language_editor_update_pref (LanguageEditor *editor) { GtkTreeIter iter; - int index; - GSList *strings = NULL; + GSList *codes = NULL; if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (editor->priv->model), &iter)) { @@ -150,46 +147,49 @@ language_editor_update_pref (LanguageEditor *editor) do { - GValue val = {0, }; + GValue value = {0, }; + gtk_tree_model_get_value (GTK_TREE_MODEL (editor->priv->model), - &iter, COL_DATA, &val); - index = g_value_get_int (&val); - g_value_unset (&val); + &iter, COL_DATA, &value); + + codes = g_slist_append (codes, g_value_dup_string (&value)); - strings = g_slist_append(strings, GINT_TO_POINTER(index)); + g_value_unset (&value); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (editor->priv->model), &iter)); - g_signal_emit (editor, signals[CHANGED], 0, strings); + g_signal_emit (editor, signals[CHANGED], 0, codes); - g_slist_free (strings); + g_slist_foreach (codes, (GFunc) g_free, NULL); + g_slist_free (codes); } static void language_editor_add_button_clicked_cb (GtkButton *button, LanguageEditor *editor) { - const char *description; + GtkWidget *combo; + GtkTreeModel *model; GtkTreeIter iter; - GtkWidget *menu; - GtkWidget *item; - int history; + char *code = NULL, *desc = NULL; + int index; - history = gtk_option_menu_get_history (GTK_OPTION_MENU(editor->priv->optionmenu)); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(editor->priv->optionmenu)); - item = gtk_menu_get_active (GTK_MENU(menu)); - description = (const char *) g_object_get_data (G_OBJECT(item), "desc"); + combo = ephy_dialog_get_control (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); + index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); - g_return_if_fail (description != NULL); + if (gtk_tree_model_iter_nth_child (model, &iter, NULL, index)) + { + gtk_tree_model_get (model, &iter, + 0, &desc, + 1, &code, + -1); - gtk_list_store_append (GTK_LIST_STORE (editor->priv->model), - &iter); + language_editor_add (editor, code, desc); - gtk_list_store_set (GTK_LIST_STORE (editor->priv->model), - &iter, - COL_DESCRIPTION, description, - COL_DATA, history, - -1); + g_free (desc); + g_free (code); + } language_editor_update_pref (editor); } @@ -245,63 +245,59 @@ static void language_editor_set_view (LanguageEditor *ge, GtkWidget *treeview, GtkWidget *add_button, - GtkWidget *remove_button, - GtkWidget *optionmenu) + GtkWidget *remove_button) { GtkTreeViewColumn *column; - GtkCellRenderer *renderer; + GtkCellRenderer *renderer; GtkListStore *liststore; GtkTreeSelection *selection; ge->priv->treeview = treeview; - ge->priv->optionmenu = optionmenu; gtk_tree_view_set_reorderable (GTK_TREE_VIEW(ge->priv->treeview), TRUE); - liststore = gtk_list_store_new (2, - G_TYPE_STRING, - G_TYPE_INT); + liststore = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); ge->priv->model = GTK_TREE_MODEL (liststore); - gtk_tree_view_set_model (GTK_TREE_VIEW(ge->priv->treeview), - ge->priv->model); + gtk_tree_view_set_model (GTK_TREE_VIEW(ge->priv->treeview), + ge->priv->model); g_object_unref (ge->priv->model); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(ge->priv->treeview), - FALSE); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(ge->priv->treeview), + FALSE); - renderer = gtk_cell_renderer_text_new (); + renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(ge->priv->treeview), - 0, "Language", - renderer, - "text", 0, - NULL); - column = gtk_tree_view_get_column (GTK_TREE_VIEW(ge->priv->treeview), 0); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_sort_column_id (column, COL_DESCRIPTION); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(ge->priv->treeview), + 0, "Language", + renderer, + "text", 0, + NULL); + column = gtk_tree_view_get_column (GTK_TREE_VIEW(ge->priv->treeview), 0); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_column_set_sort_column_id (column, COL_DESCRIPTION); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(ge->priv->treeview)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); /* Connect treeview signals */ g_signal_connect - (G_OBJECT (ge->priv->treeview), + (G_OBJECT (ge->priv->treeview), "drag_end", - G_CALLBACK(language_editor_treeview_drag_end_cb), + G_CALLBACK (language_editor_treeview_drag_end_cb), ge); /* Connect buttons signals */ g_signal_connect - (G_OBJECT (add_button), + (G_OBJECT (add_button), "clicked", - G_CALLBACK(language_editor_add_button_clicked_cb), + G_CALLBACK (language_editor_add_button_clicked_cb), ge); g_signal_connect - (G_OBJECT (remove_button), + (G_OBJECT (remove_button), "clicked", - G_CALLBACK(language_editor_remove_button_clicked_cb), + G_CALLBACK (language_editor_remove_button_clicked_cb), ge); } @@ -309,60 +305,67 @@ static void language_editor_init (LanguageEditor *le) { GtkWidget *treeview; - GtkWidget *optionmenu; GtkWidget *add_button; GtkWidget *remove_button; le->priv = EPHY_LANGUAGE_EDITOR_GET_PRIVATE (le); ephy_dialog_construct (EPHY_DIALOG(le), - properties, - "prefs-dialog.glade", - "languages_dialog"); - - treeview = ephy_dialog_get_control (EPHY_DIALOG(le), - TREEVIEW_PROP); - add_button = ephy_dialog_get_control (EPHY_DIALOG(le), - ADD_PROP); - remove_button = ephy_dialog_get_control (EPHY_DIALOG(le), - REMOVE_PROP); - optionmenu = ephy_dialog_get_control (EPHY_DIALOG(le), - LANGUAGE_PROP); - - language_editor_set_view (le, treeview, add_button, remove_button, - optionmenu); + properties, + "prefs-dialog.glade", + "languages_dialog"); + + treeview = ephy_dialog_get_control (EPHY_DIALOG(le), properties[TREEVIEW_PROP].id); + add_button = ephy_dialog_get_control (EPHY_DIALOG(le), properties[ADD_PROP].id); + remove_button = ephy_dialog_get_control (EPHY_DIALOG(le), properties[REMOVE_PROP].id); + + language_editor_set_view (le, treeview, add_button, remove_button); } LanguageEditor * language_editor_new (GtkWidget *parent) { return EPHY_LANGUAGE_EDITOR (g_object_new (EPHY_TYPE_LANGUAGE_EDITOR, - "ParentWindow", parent, - NULL)); + "parent-window", parent, + NULL)); } void -language_editor_set_menu (LanguageEditor *editor, - GtkWidget *menu) +language_editor_set_model (LanguageEditor *editor, + GtkTreeModel *model) { - gtk_option_menu_set_menu (GTK_OPTION_MENU(editor->priv->optionmenu), - menu); + GtkWidget *combo; + GtkCellRenderer *renderer; + + combo = ephy_dialog_get_control (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id); + + gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), + renderer, + TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", COL_DESCRIPTION, + NULL); + + ephy_dialog_set_data_column (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id, COL_DATA); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); } void -language_editor_add (LanguageEditor *ge, - const char *language, - int id) +language_editor_add (LanguageEditor *editor, + const char *code, + const char *desc) { GtkTreeIter iter; - gtk_list_store_append (GTK_LIST_STORE (ge->priv->model), - &iter); + gtk_list_store_append (GTK_LIST_STORE (editor->priv->model), &iter); - gtk_list_store_set (GTK_LIST_STORE (ge->priv->model), - &iter, - COL_DESCRIPTION, language, - COL_DATA, id, + gtk_list_store_set (GTK_LIST_STORE (editor->priv->model), &iter, + COL_DESCRIPTION, desc, + COL_DATA, code, -1); } diff --git a/src/language-editor.h b/src/language-editor.h index 4a2cce30c..ee5a62193 100644 --- a/src/language-editor.h +++ b/src/language-editor.h @@ -22,6 +22,7 @@ #include "ephy-dialog.h" #include <gtk/gtkwidget.h> +#include <gtk/gtktreemodel.h> #include <glib-object.h> #include <glib.h> @@ -34,9 +35,9 @@ G_BEGIN_DECLS #define EPHY_IS_LANGUAGE_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LANGUAGE_EDITOR)) #define EPHY_LANGUAGE_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditorClass)) -typedef struct LanguageEditor LanguageEditor; -typedef struct LanguageEditorClass LanguageEditorClass; -typedef struct LanguageEditorPrivate LanguageEditorPrivate; +typedef struct LanguageEditor LanguageEditor; +typedef struct LanguageEditorClass LanguageEditorClass; +typedef struct LanguageEditorPrivate LanguageEditorPrivate; struct LanguageEditor { @@ -50,19 +51,19 @@ struct LanguageEditorClass { EphyDialogClass parent_class; - void (* changed) (GSList *languages); + void (* changed) (GSList *codes); }; GType language_editor_get_type (void); LanguageEditor *language_editor_new (GtkWidget *parent); -void language_editor_set_menu (LanguageEditor *editor, - GtkWidget *menu); +void language_editor_set_model (LanguageEditor *editor, + GtkTreeModel *model); void language_editor_add (LanguageEditor *editor, - const char *language, - int id); + const char *code, + const char *desc); G_END_DECLS diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index d1534de15..ecd7a73b7 100755 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -74,18 +74,6 @@ struct PdmDialogPrivate enum { - PROP_WINDOW, - PROP_NOTEBOOK, - PROP_COOKIES_TREEVIEW, - PROP_COOKIES_REMOVE, - PROP_PASSWORDS_TREEVIEW, - PROP_PASSWORDS_REMOVE, - PROP_DIALOG, - PROP_COOKIES_PROPERTIES -}; - -enum -{ COL_COOKIES_HOST, COL_COOKIES_NAME, COL_COOKIES_PATH, @@ -99,21 +87,40 @@ enum COL_PASSWORDS_DATA }; +enum +{ + PROP_WINDOW, + PROP_NOTEBOOK, + PROP_COOKIES_TREEVIEW, + PROP_COOKIES_REMOVE, + PROP_COOKIES_PROPERTIES, + PROP_PASSWORDS_TREEVIEW, + PROP_PASSWORDS_REMOVE +}; + static const EphyDialogProperty properties [] = { - { PROP_WINDOW, "pdm_dialog", NULL, PT_NORMAL, NULL }, - { PROP_NOTEBOOK, "pdm_notebook", NULL, PT_NORMAL, NULL }, + { "pdm_dialog", NULL, PT_NORMAL, 0 }, + { "pdm_notebook", NULL, PT_NORMAL, 0 }, + + { "cookies_treeview", NULL, PT_NORMAL, 0 }, + { "cookies_remove_button", NULL, PT_NORMAL, 0 }, + { "cookies_properties_button", NULL, PT_NORMAL, 0 }, + { "passwords_treeview", NULL, PT_NORMAL, 0 }, + { "passwords_remove_button", NULL, PT_NORMAL, 0 }, - { PROP_COOKIES_TREEVIEW, "cookies_treeview", NULL, PT_NORMAL, NULL }, - { PROP_COOKIES_REMOVE, "cookies_remove_button", NULL, PT_NORMAL, NULL }, - { PROP_PASSWORDS_TREEVIEW, "passwords_treeview", NULL, PT_NORMAL, NULL }, - { PROP_PASSWORDS_REMOVE, "passwords_remove_button", NULL, PT_NORMAL, NULL }, - { PROP_DIALOG, "pdm_dialog", NULL, PT_NORMAL, NULL }, - { PROP_COOKIES_PROPERTIES, "cookies_properties_button", NULL, PT_NORMAL, NULL }, + { NULL } +}; - { -1, NULL, NULL } +static const +char *size_group [] = +{ + "cookies_remove_button", + "cookies_properties_button", + "passwords_remove_button" }; +const guint n_size_group = G_N_ELEMENTS (size_group); static void pdm_dialog_class_init (PdmDialogClass *klass); static void pdm_dialog_init (PdmDialog *dialog); @@ -178,20 +185,20 @@ static void pdm_dialog_show_help (PdmDialog *pd) { GtkWidget *notebook, *window; - gint id; + int id; /* FIXME: Once we actually have documentation we * should point these at the correct links. */ - gchar *help_preferences[] = { + char *help_preferences[] = { "pdm", "pdm" }; - window = ephy_dialog_get_control (EPHY_DIALOG (pd), PROP_WINDOW); + window = ephy_dialog_get_control (EPHY_DIALOG (pd), properties[PROP_WINDOW].id); g_return_if_fail (GTK_IS_WINDOW (window)); - notebook = ephy_dialog_get_control (EPHY_DIALOG (pd), PROP_NOTEBOOK); + notebook = ephy_dialog_get_control (EPHY_DIALOG (pd), properties[PROP_NOTEBOOK].id); g_return_if_fail (notebook != NULL); id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); @@ -210,7 +217,7 @@ action_treeview_selection_changed_cb (GtkTreeSelection *selection, has_selection = gtk_tree_selection_count_selected_rows (selection) > 0; - widget = ephy_dialog_get_control (d, action->remove_id); + widget = ephy_dialog_get_control (d, properties[action->remove_id].id); gtk_widget_set_sensitive (widget, has_selection); } @@ -332,7 +339,7 @@ setup_action (PdmActionInfo *action) GtkTreeSelection *selection; widget = ephy_dialog_get_control (EPHY_DIALOG(action->dialog), - action->remove_id); + properties[action->remove_id].id); g_signal_connect (widget, "clicked", G_CALLBACK (pdm_dialog_remove_button_clicked_cb), action); @@ -361,7 +368,7 @@ cookies_treeview_selection_changed_cb (GtkTreeSelection *selection, has_selection = gtk_tree_selection_count_selected_rows (selection) == 1; - widget = ephy_dialog_get_control (d, PROP_COOKIES_PROPERTIES); + widget = ephy_dialog_get_control (d, properties[PROP_COOKIES_PROPERTIES].id); gtk_widget_set_sensitive (widget, has_selection); } @@ -378,7 +385,7 @@ pdm_dialog_cookies_construct (PdmActionInfo *info) LOG ("pdm_dialog_cookies_construct") treeview = GTK_TREE_VIEW (ephy_dialog_get_control - (EPHY_DIALOG (dialog), PROP_COOKIES_TREEVIEW)); + (EPHY_DIALOG (dialog), properties[PROP_COOKIES_TREEVIEW].id)); /* set tree model */ liststore = gtk_list_store_new (4, @@ -636,7 +643,7 @@ pdm_dialog_passwords_construct (PdmActionInfo *info) LOG ("pdm_dialog_passwords_construct") treeview = GTK_TREE_VIEW (ephy_dialog_get_control - (EPHY_DIALOG(dialog), PROP_PASSWORDS_TREEVIEW)); + (EPHY_DIALOG(dialog), properties[PROP_PASSWORDS_TREEVIEW].id)); /* set tree model */ liststore = gtk_list_store_new (3, @@ -775,14 +782,6 @@ pdm_dialog_init (PdmDialog *dialog) PdmActionInfo *cookies, *passwords; GtkWidget *notebook; - const int props[] = - { - PROP_COOKIES_REMOVE, - PROP_COOKIES_PROPERTIES, - PROP_PASSWORDS_REMOVE - }; - const guint n_props = G_N_ELEMENTS (props); - dialog->priv = EPHY_PDM_DIALOG_GET_PRIVATE (dialog); dialog->priv->cookies = NULL; @@ -798,7 +797,7 @@ pdm_dialog_init (PdmDialog *dialog) * avoid the little jerk you get otherwise when switching pages because * one set of buttons is wider than another. */ - ephy_dialog_set_size_group (EPHY_DIALOG (dialog), (int*) props, n_props); + ephy_dialog_set_size_group (EPHY_DIALOG (dialog), size_group, n_size_group); cookies = g_new0 (PdmActionInfo, 1); cookies->construct = pdm_dialog_cookies_construct; @@ -830,7 +829,7 @@ pdm_dialog_init (PdmDialog *dialog) cookies->construct (cookies); passwords->construct (passwords); - notebook = ephy_dialog_get_control (EPHY_DIALOG (dialog), PROP_NOTEBOOK); + notebook = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[PROP_NOTEBOOK].id); sync_notebook_tab (notebook, NULL, 0, dialog); g_signal_connect (G_OBJECT (notebook), "switch_page", G_CALLBACK (sync_notebook_tab), dialog); @@ -862,7 +861,7 @@ show_cookies_properties (PdmDialog *dialog, char *str; parent = ephy_dialog_get_control (EPHY_DIALOG(dialog), - PROP_DIALOG); + properties[PROP_WINDOW].id); gdialog = gtk_dialog_new_with_buttons (_("Cookie Properties"), diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 83b149163..e9e2a207f 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti + * Copyright (C) 200-2003 Marco Pesenti Gritti + * Copyright (C) 2003 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,6 +40,8 @@ #include "ephy-debug.h" #include "ephy-ellipsizing-label.h" #include "ephy-file-chooser.h" +#include "ephy-tree-model-node.h" +#include "ephy-tree-model-sort.h" #include <glib/gi18n.h> #include <gtk/gtkframe.h> @@ -46,42 +49,37 @@ #include <gtk/gtkvbox.h> #include <gtk/gtkradiobutton.h> #include <gtk/gtktogglebutton.h> +#include <gtk/gtkcombobox.h> +#include <gtk/gtktreemodel.h> +#include <gtk/gtkliststore.h> #include <gtk/gtkimage.h> #include <gtk/gtklabel.h> #include <gtk/gtkstock.h> #include <string.h> -static void -prefs_dialog_class_init (PrefsDialogClass *klass); -static void -prefs_dialog_init (PrefsDialog *pd); -static void -prefs_dialog_finalize (GObject *object); +#define CONF_FONTS_FOR_LANGUAGE "/apps/epiphany/dialogs/preferences_font_language" -/* Glade callbacks */ -void -prefs_proxy_auto_url_reload_cb (GtkWidget *button, - EphyDialog *dialog); -void -prefs_clear_cache_button_clicked_cb (GtkWidget *button, - gpointer data); -void -prefs_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer data); -void -fonts_language_optionmenu_changed_cb (GtkWidget *optionmenu, EphyDialog *dialog); -void -prefs_homepage_current_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog); -void -prefs_homepage_blank_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog); -void -prefs_language_more_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog); +static void prefs_dialog_class_init (PrefsDialogClass *klass); +static void prefs_dialog_init (PrefsDialog *pd); -void -prefs_download_path_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog); +/* Glade callbacks */ +void prefs_proxy_auto_url_reload_cb (GtkWidget *button, + EphyDialog *dialog); +void prefs_clear_cache_button_clicked_cb (GtkWidget *button, + gpointer data); +void prefs_dialog_response_cb (GtkDialog *widget, + gint response_id, + EphyDialog *dialog); +void fonts_language_combo_changed_cb (GtkComboBox *combo, + EphyDialog *dialog); +void prefs_homepage_current_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog); +void prefs_homepage_blank_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog); +void prefs_language_more_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog); +void prefs_download_path_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog); static const struct @@ -186,13 +184,21 @@ enum }; const -char *size_prefs[] = +char *size_prefs [] = { CONF_RENDERING_FONT_FIXED_SIZE, CONF_RENDERING_FONT_VAR_SIZE, CONF_RENDERING_FONT_MIN_SIZE }; +const +int default_size [] = +{ + 10, + 11, + 7 +}; + enum { WINDOW_PROP, @@ -229,75 +235,76 @@ enum AUTO_ENCODING_LABEL_PROP }; -#define CONF_FONTS_FOR_LANGUAGE "/apps/epiphany/dialogs/preferences_font_language" - static const EphyDialogProperty properties [] = { - { WINDOW_PROP, "prefs_dialog", NULL, PT_NORMAL, NULL }, - { NOTEBOOK_PROP, "prefs_notebook", NULL, PT_NORMAL, NULL }, + { "prefs_dialog", NULL, PT_NORMAL, 0}, + { "prefs_notebook", NULL, PT_NORMAL, 0}, /* General */ - { HOMEPAGE_ENTRY_PROP, "homepage_entry", CONF_GENERAL_HOMEPAGE, PT_AUTOAPPLY, NULL }, - { AUTO_OPEN_PROP, "auto_open_downloads_checkbutton", CONF_AUTO_OPEN_DOWNLOADS, PT_AUTOAPPLY, NULL}, - { DOWNLOAD_PATH_BUTTON_PROP, "download_path_button", NULL, PT_NORMAL, NULL }, + { "homepage_entry", CONF_GENERAL_HOMEPAGE, PT_AUTOAPPLY, G_TYPE_STRING }, + { "auto_open_downloads_checkbutton", CONF_AUTO_OPEN_DOWNLOADS, PT_AUTOAPPLY, 0 }, + { "download_path_button", NULL, PT_NORMAL, 0 }, /* Fonts and Colors */ - { FONTS_LANGUAGE_PROP, "fonts_language_optionmenu", CONF_FONTS_FOR_LANGUAGE, PT_AUTOAPPLY, NULL }, - { VARIABLE_PROP, "variable_combo", NULL, PT_NORMAL, NULL }, - { MONOSPACE_PROP, "monospace_combo", NULL, PT_NORMAL, NULL }, - { FIXED_SIZE_PROP, "fixed_size_spinbutton", NULL, PT_NORMAL, NULL }, - { VARIABLE_SIZE_PROP, "variable_size_spinbutton", NULL, PT_NORMAL, NULL }, - { MIN_SIZE_PROP, "min_size_spinbutton", NULL, PT_NORMAL, NULL }, - { USE_COLORS_PROP, "use_colors_checkbutton", CONF_RENDERING_USE_OWN_COLORS, PT_AUTOAPPLY, NULL }, - { USE_FONTS_PROP, "use_fonts_checkbutton", CONF_RENDERING_USE_OWN_FONTS, PT_AUTOAPPLY, NULL }, + { "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 }, /* Privacy */ - { ALLOW_POPUPS_PROP, "popups_allow_checkbutton", CONF_SECURITY_ALLOW_POPUPS, PT_AUTOAPPLY, NULL }, - { ALLOW_JAVA_PROP, "enable_java_checkbutton", CONF_SECURITY_JAVA_ENABLED, PT_AUTOAPPLY, NULL }, - { ALLOW_JS_PROP, "enable_javascript_checkbutton", CONF_SECURITY_JAVASCRIPT_ENABLED, PT_AUTOAPPLY, NULL }, - { ACCEPT_COOKIES_PROP, "cookies_radiobutton", CONF_SECURITY_COOKIES_ACCEPT, PT_AUTOAPPLY, NULL }, - { DISK_CACHE_PROP, "disk_cache_spin", CONF_NETWORK_CACHE_SIZE, PT_AUTOAPPLY, NULL }, + { "popups_allow_checkbutton", CONF_SECURITY_ALLOW_POPUPS, PT_AUTOAPPLY, 0 }, + { "enable_java_checkbutton", CONF_SECURITY_JAVA_ENABLED, PT_AUTOAPPLY, 0 }, + { "enable_javascript_checkbutton", CONF_SECURITY_JAVASCRIPT_ENABLED, PT_AUTOAPPLY, 0 }, + { "cookies_radiobutton", CONF_SECURITY_COOKIES_ACCEPT, PT_AUTOAPPLY, G_TYPE_STRING }, + { "disk_cache_spin", CONF_NETWORK_CACHE_SIZE, PT_AUTOAPPLY, 0 }, /* Languages */ - { AUTO_ENCODING_PROP, "auto_encoding_optionmenu", CONF_LANGUAGE_AUTODETECT_ENCODING, PT_AUTOAPPLY, NULL }, - { DEFAULT_ENCODING_PROP, "default_encoding_optionmenu", CONF_LANGUAGE_DEFAULT_ENCODING, PT_AUTOAPPLY, NULL }, - { LANGUAGE_PROP, "language_optionmenu", NULL, PT_NORMAL, NULL }, - { LANGUAGE_LABEL_PROP, "language_label", NULL, PT_NORMAL, NULL }, - { DEFAULT_ENCODING_LABEL_PROP, "default_encoding_label", NULL, PT_NORMAL, NULL }, - { AUTO_ENCODING_LABEL_PROP, "auto_encoding_label", NULL, PT_NORMAL, NULL }, - - { -1, NULL, NULL } + { "auto_encoding_combo", CONF_LANGUAGE_AUTODETECT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING }, + { "default_encoding_combo", CONF_LANGUAGE_DEFAULT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING }, + { "language_combo", NULL, PT_NORMAL, G_TYPE_STRING }, + { "language_label", NULL, PT_NORMAL, 0 }, + { "default_encoding_label", NULL, PT_NORMAL, 0 }, + { "auto_encoding_label", NULL, PT_NORMAL, 0 }, + + { NULL } }; -static -int lang_size_group [] = +static const +char *lang_size_group [] = { - LANGUAGE_LABEL_PROP, - DEFAULT_ENCODING_LABEL_PROP, - AUTO_ENCODING_LABEL_PROP + "language_label", + "default_encoding_label", + "auto_encoding_label" }; + static guint n_lang_size_group = G_N_ELEMENTS (lang_size_group); +enum +{ + COL_FONTS_LANG_NAME, + COL_FONTS_LANG_CODE +}; -typedef struct +enum { - gchar *name; - gchar *key; - gchar *code; -} EphyLangItem; + COL_LANG_NAME, + COL_LANG_CODE +}; + +enum +{ + COL_ENC_NAME, + COL_ENC_CODE +}; #define EPHY_PREFS_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_PREFS_DIALOG, PrefsDialogPrivate)) struct PrefsDialogPrivate { - GtkWidget *notebook; - GtkWidget *window; - - GList *langs; - GList *fonts_languages; - - guint language; - gboolean switching; }; static GObjectClass *parent_class = NULL; @@ -305,701 +312,368 @@ static GObjectClass *parent_class = NULL; GType prefs_dialog_get_type (void) { - static GType prefs_dialog_type = 0; - - if (prefs_dialog_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (PrefsDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) prefs_dialog_class_init, - NULL, - NULL, /* class_data */ - sizeof (PrefsDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) prefs_dialog_init - }; - - prefs_dialog_type = g_type_register_static (EPHY_TYPE_DIALOG, - "PrefsDialog", - &our_info, 0); - } - - return prefs_dialog_type; - -} - -EphyDialog * -prefs_dialog_new (GtkWidget *parent) -{ - EphyDialog *dialog; + static GType type = 0; - dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_PREFS_DIALOG, - "ParentWindow", parent, - NULL)); + if (type == 0) + { + static const GTypeInfo our_info = + { + sizeof (PrefsDialogClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) prefs_dialog_class_init, + NULL, + NULL, /* class_data */ + sizeof (PrefsDialog), + 0, /* n_preallocs */ + (GInstanceInitFunc) prefs_dialog_init + }; + + type = g_type_register_static (EPHY_TYPE_DIALOG, + "PrefsDialog", + &our_info, 0); + } - return dialog; + return type; } static void prefs_dialog_class_init (PrefsDialogClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = prefs_dialog_finalize; + parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (object_class, sizeof(PrefsDialogPrivate)); } static void -free_lang_item (EphyLangItem *item, gpointer user_data) +prefs_dialog_show_help (EphyDialog *dialog) { - if (item == NULL) return; - - g_free (item->name); - g_free (item->key); - g_free (item->code); - g_free (item); -} - -static void -prefs_dialog_finalize (GObject *object) -{ - PrefsDialog *pd = EPHY_PREFS_DIALOG (object); - GtkWidget *button; - - /* Free the ellipsizing label in the button */ - button = ephy_dialog_get_control (EPHY_DIALOG (pd), DOWNLOAD_PATH_BUTTON_PROP); - gtk_widget_destroy (GTK_WIDGET (GTK_BIN (button)->child)); - - g_list_foreach (pd->priv->langs, (GFunc) free_lang_item, NULL); - g_list_free (pd->priv->langs); - - g_list_foreach (pd->priv->fonts_languages, (GFunc) g_free, NULL); - g_list_free (pd->priv->fonts_languages); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -prefs_dialog_show_help (PrefsDialog *pd) -{ - gint id; + GtkWidget *window, *notebook; + int id; /* FIXME: Once we actually have documentation we * should point these at the correct links. */ - gchar *help_preferences[] = { + char *help_preferences[] = { "setting-preferences", "setting-preferences", "setting-preferences", "setting-preferences" }; - id = gtk_notebook_get_current_page (GTK_NOTEBOOK (pd->priv->notebook)); - - ephy_gui_help (GTK_WINDOW (pd->priv->window), "epiphany", help_preferences[id]); -} - -static const char * -get_current_language_code (PrefsDialog *dialog) -{ - GList *lang; - const EphyFontsLanguageInfo *info; + window = ephy_dialog_get_control (dialog, properties[WINDOW_PROP].id); + notebook = ephy_dialog_get_control (dialog, properties[NOTEBOOK_PROP].id); - lang = g_list_nth (dialog->priv->fonts_languages, dialog->priv->language); - g_assert (lang != NULL); - info = (EphyFontsLanguageInfo *) lang->data; + id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + id = CLAMP (id, 0, 3); - return info->code; + ephy_gui_help (GTK_WINDOW (window), "epiphany", help_preferences[id]); } static void -setup_font_menu (PrefsDialog *dialog, - const char *type, - GtkWidget *combo) +setup_font_combo (EphyDialog *dialog, + const char *type, + const char *code, + int prop) { - GList *fonts = NULL; - gchar *name; + GtkWidget *combo; + GtkListStore *store; + GtkTreeIter iter; + GList *fonts, *l; + char *name; char key[255]; - GtkWidget *entry = GTK_COMBO(combo)->entry; EphyEmbedSingle *single; single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell)); + fonts = ephy_embed_single_get_font_list (single, code); - fonts = ephy_embed_single_get_font_list - (single, get_current_language_code (dialog)); - - /* Get the default font */ - g_snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT, type, - get_current_language_code (dialog)); + g_snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT, type, code); name = eel_gconf_get_string (key); - if (name == NULL) + + /* sanitise the pref */ + if (name == NULL || name[0] == '\0' + || g_list_find_custom (fonts, name, (GCompareFunc) strcmp) == NULL) { - if (strcmp (type, "variable") == 0) + if (prop == VARIABLE_PROP) { - name = g_strdup ("sans-serif"); + eel_gconf_set_string (key, "sans-serif"); } else { - name = g_strdup ("monospace"); + eel_gconf_set_string (key, "monospace"); } } - - /* set popdown doesnt like NULL */ - if (fonts == NULL) - { - fonts = g_list_alloc (); - } - - gtk_combo_set_popdown_strings (GTK_COMBO(combo), fonts); - - /* set the default value */ - if (name != NULL) - { - int pos = 0; - - gtk_editable_delete_text (GTK_EDITABLE(entry), 0, -1); - gtk_editable_insert_text (GTK_EDITABLE(entry), - name, strlen (name), - &pos); - } - g_free (name); - g_list_foreach (fonts, (GFunc)g_free, NULL); - g_list_free (fonts); -} + combo = ephy_dialog_get_control (dialog, properties[prop].id); + store = gtk_list_store_new (1, G_TYPE_STRING); -static void -save_font_menu (PrefsDialog *dialog, - int type, - GtkWidget *entry) -{ - char *name; - char key[255]; - - name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - - /* do not save empty fonts */ - if (!name || *name == '\0') + for (l = fonts; l != NULL; l = l->next) { - g_free (name); - return; + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, 0, (char *) l->data, -1); } + g_list_foreach (fonts, (GFunc) g_free, NULL); + g_list_free (fonts); - g_snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT, - fonts_types[type], - get_current_language_code (dialog)); - eel_gconf_set_string (key, name); - g_free (name); -} - -static void -font_entry_changed_cb (GtkWidget *entry, PrefsDialog *dialog) -{ - int type; - - if (dialog->priv->switching) return; - - type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(entry), - "type")); - save_font_menu (dialog, type, entry); -} - -static void -attach_font_signal (PrefsDialog *dialog, int prop, - gpointer type) -{ - GtkWidget *combo; - GtkWidget *entry; - - combo = ephy_dialog_get_control (EPHY_DIALOG(dialog), - prop); - entry = GTK_COMBO(combo)->entry; - g_object_set_data (G_OBJECT(entry), "type", type); - g_signal_connect (entry, "changed", - G_CALLBACK(font_entry_changed_cb), - dialog); -} - -static void -attach_fonts_signals (PrefsDialog *dialog) -{ - attach_font_signal (dialog, VARIABLE_PROP, - GINT_TO_POINTER(FONT_TYPE_VARIABLE)); - attach_font_signal (dialog, MONOSPACE_PROP, - GINT_TO_POINTER(FONT_TYPE_MONOSPACE)); -} - -static void -size_spinbutton_changed_cb (GtkWidget *spin, PrefsDialog *dialog) -{ - int type; - char key[255]; - - if (dialog->priv->switching) return; - - type = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(spin), "type")); - - g_snprintf (key, 255, "%s_%s", - size_prefs[type], - get_current_language_code (dialog)); - eel_gconf_set_integer (key, gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin))); -} - -static void -attach_size_controls_signals (PrefsDialog *dialog) -{ - GtkWidget *spin; - - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - FIXED_SIZE_PROP); - g_object_set_data (G_OBJECT(spin), "type", - GINT_TO_POINTER(FONT_SIZE_FIXED)); - g_signal_connect (spin, "value_changed", - G_CALLBACK(size_spinbutton_changed_cb), - dialog); + ephy_dialog_set_pref (dialog, properties[prop].id, NULL); - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - VARIABLE_SIZE_PROP); - g_object_set_data (G_OBJECT(spin), "type", - GINT_TO_POINTER(FONT_SIZE_VAR)); - g_signal_connect (spin, "value_changed", - G_CALLBACK(size_spinbutton_changed_cb), - dialog); + gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store)); - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - MIN_SIZE_PROP); - g_object_set_data (G_OBJECT(spin), "type", - GINT_TO_POINTER(FONT_SIZE_MIN)); - g_signal_connect (spin, "value_changed", - G_CALLBACK(size_spinbutton_changed_cb), - dialog); + ephy_dialog_set_pref (dialog, properties[prop].id, key); } -static void -setup_size_control (PrefsDialog *dialog, - const char *pref, - int default_size, - GtkWidget *spin) +void +fonts_language_combo_changed_cb (GtkComboBox *combo, + EphyDialog *dialog) { - char key[255]; + GValue value = { 0, }; + const char *code; + char key[128]; int size; - g_snprintf (key, 255, "%s_%s", pref, - get_current_language_code (dialog)); - size = eel_gconf_get_integer (key); + ephy_dialog_get_value (dialog, properties[FONTS_LANGUAGE_PROP].id, &value); + code = g_value_get_string (&value); - if (size == 0) size = default_size; + setup_font_combo (dialog, "variable", code, VARIABLE_PROP); + setup_font_combo (dialog, "monospace", code, MONOSPACE_PROP); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(spin), size); -} - -static void -setup_size_controls (PrefsDialog *dialog) -{ - GtkWidget *spin; + g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_VAR], code); + size = eel_gconf_get_integer (key); + if (size <= 0) + { + eel_gconf_set_integer (key, default_size[FONT_SIZE_VAR]); + } + ephy_dialog_set_pref (dialog, properties[VARIABLE_SIZE_PROP].id, key); - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - FIXED_SIZE_PROP); - setup_size_control (dialog, CONF_RENDERING_FONT_FIXED_SIZE, 10, spin); + g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_FIXED], code); + size = eel_gconf_get_integer (key); + if (size <= 0) + { + eel_gconf_set_integer (key, default_size[FONT_SIZE_FIXED]); + } + ephy_dialog_set_pref (dialog, properties[FIXED_SIZE_PROP].id, key); - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - VARIABLE_SIZE_PROP); - setup_size_control (dialog, CONF_RENDERING_FONT_VAR_SIZE, 11, spin); + g_snprintf (key, sizeof (key), "%s_%s", size_prefs[FONT_SIZE_MIN], code); + size = eel_gconf_get_integer (key); + if (size <= 0) + { + eel_gconf_set_integer (key, default_size[FONT_SIZE_MIN]); + } + ephy_dialog_set_pref (dialog, properties[MIN_SIZE_PROP].id, key); - spin = ephy_dialog_get_control (EPHY_DIALOG(dialog), - MIN_SIZE_PROP); - setup_size_control (dialog, CONF_RENDERING_FONT_MIN_SIZE, 7, spin); + g_value_unset (&value); } static void -setup_fonts (PrefsDialog *dialog) +create_fonts_language_menu (EphyDialog *dialog) { GtkWidget *combo; - - dialog->priv->switching = TRUE; - - combo = ephy_dialog_get_control (EPHY_DIALOG(dialog), - VARIABLE_PROP); - setup_font_menu (dialog, "variable", combo); - - combo = ephy_dialog_get_control (EPHY_DIALOG(dialog), - MONOSPACE_PROP); - setup_font_menu (dialog, "monospace", combo); - - dialog->priv->switching = FALSE; -} - -static int -fonts_language_info_cmp (const EphyFontsLanguageInfo *i1, - const EphyFontsLanguageInfo *i2) -{ - return g_utf8_collate (i1->title, i2->title); -} - -static void -create_fonts_language_menu (PrefsDialog *dialog) -{ - GtkWidget *optionmenu, *menu; - GList *list = NULL, *l; + GtkCellRenderer *renderer; + GtkListStore *store; + GtkTreeModel *sortmodel; + GtkTreeIter iter; guint n_fonts_languages, i; - char **lang_codes; const EphyFontsLanguageInfo *fonts_languages; - optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog), - FONTS_LANGUAGE_PROP); + combo = ephy_dialog_get_control (dialog, properties[FONTS_LANGUAGE_PROP].id); - menu = gtk_menu_new (); + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); fonts_languages = ephy_font_languages (); n_fonts_languages = ephy_font_n_languages (); for (i = 0; i < n_fonts_languages; i++) { - EphyFontsLanguageInfo *info; - - info = g_new0 (EphyFontsLanguageInfo, 1); - info->title = _(fonts_languages[i].title); - info->code = fonts_languages[i].code; - - list = g_list_prepend (list, info); - } - - dialog->priv->fonts_languages = - g_list_sort (list, (GCompareFunc) fonts_language_info_cmp); - - for (l = dialog->priv->fonts_languages; l != NULL; l = l->next) - { - EphyFontsLanguageInfo *info = (EphyFontsLanguageInfo *) l->data; - GtkWidget *item; - - item = gtk_menu_item_new_with_label (info->title); - gtk_menu_shell_append (GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_FONTS_LANG_NAME, _(fonts_languages[i].title), + COL_FONTS_LANG_CODE, fonts_languages[i].code, + -1); } - gtk_option_menu_set_menu (GTK_OPTION_MENU(optionmenu), menu); + 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); - lang_codes = g_new0 (char *, n_fonts_languages); - for (l = dialog->priv->fonts_languages, i=0; l != NULL; l = l->next) - { - EphyFontsLanguageInfo *info = (EphyFontsLanguageInfo *) l->data; + gtk_combo_box_set_model (GTK_COMBO_BOX (combo), sortmodel); - lang_codes[i] = info->code; + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", COL_FONTS_LANG_NAME, + NULL); - i++; - } - ephy_dialog_add_enum (EPHY_DIALOG (dialog), FONTS_LANGUAGE_PROP, - n_fonts_languages, (const char **) lang_codes); - /* the entries themselves are const, so don't use g_strfreev here */ - g_free (lang_codes); + ephy_dialog_set_data_column (dialog, properties[FONTS_LANGUAGE_PROP].id, COL_FONTS_LANG_CODE); - dialog->priv->language = - gtk_option_menu_get_history (GTK_OPTION_MENU (optionmenu)); - - g_signal_connect (optionmenu, "changed", - G_CALLBACK (fonts_language_optionmenu_changed_cb), + g_signal_connect (combo, "changed", + G_CALLBACK (fonts_language_combo_changed_cb), dialog); } -static int -find_encoding_in_list_cmp (gconstpointer info, const char *encoding) -{ - EphyNode *node = (EphyNode *) info; - const char *code; - - code = ephy_node_get_property_string - (node, EPHY_NODE_ENCODING_PROP_ENCODING); - - return strcmp (code, encoding); -} - -static int -sort_encodings (gconstpointer a, gconstpointer b) -{ - EphyNode *node1 = (EphyNode *) a; - EphyNode *node2 = (EphyNode *) b; - const char *key1, *key2; - - key1 = ephy_node_get_property_string - (node1, EPHY_NODE_ENCODING_PROP_COLLATION_KEY); - key2 = ephy_node_get_property_string - (node2, EPHY_NODE_ENCODING_PROP_COLLATION_KEY); - - return strcmp (key1, key2); -} - -static int -sort_detectors (gconstpointer a, gconstpointer b) -{ - EphyNode *node1 = (EphyNode *) a; - EphyNode *node2 = (EphyNode *) b; - const char *code1, *code2; - - code1 = ephy_node_get_property_string - (node1, EPHY_NODE_ENCODING_PROP_ENCODING); - code2 = ephy_node_get_property_string - (node2, EPHY_NODE_ENCODING_PROP_ENCODING); - - /* "" is the code for No Autodetector; make sure it's first - * in the list. - */ - if (strcmp (code1, "") == 0) - { - return -1; - } - if (strcmp (code2, "") == 0) - { - return 1; - } - - return sort_encodings (a, b); -} - static void -create_optionmenu (PrefsDialog *dialog, - int property, - GList *list, +create_node_combo (EphyDialog *dialog, + int prop, + EphyEncodings *encodings, + EphyNode *node, const char *key, const char *default_value) { - GList *element, *l; - GtkWidget *menu, *optionmenu; - char *value; - char **codes; - guint pos, i, num; - - menu = gtk_menu_new (); - - optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog), - property); - - num = g_list_length (list); - codes = g_new0 (char *, num); + EphyTreeModelNode *node_model; + GtkTreeModel *sort_model; + GtkComboBox *combo; + GtkCellRenderer *renderer; + char *code; + int title_col, data_col; - for (l = list, i=0; l != NULL; l = l->next, i++) + code = eel_gconf_get_string (key); + if (code == NULL || ephy_encodings_get_node (encodings, code) == NULL) { - EphyNode *node = (EphyNode *) l->data; - const char *title, *code; - GtkWidget *item; - - title = ephy_node_get_property_string - (node, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED); - - item = gtk_menu_item_new_with_label (title); - gtk_menu_shell_append (GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - - code = ephy_node_get_property_string - (node, EPHY_NODE_ENCODING_PROP_ENCODING); - codes[i] = (char *) code; + /* safe default */ + eel_gconf_set_string (key, default_value); } + g_free (code); - gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + combo = GTK_COMBO_BOX (ephy_dialog_get_control (dialog, properties[prop].id)); - /* init value */ - value = eel_gconf_get_string (key); - /* fallback */ - if (value == NULL || value[0] == '\0') - { - g_free (value); - value = g_strdup (default_value); - } + node_model = ephy_tree_model_node_new (node, NULL); - element = g_list_find_custom (list, value, - (GCompareFunc) find_encoding_in_list_cmp); - g_free (value); - pos = g_list_position (list, element); + title_col = ephy_tree_model_node_add_prop_column + (node_model, G_TYPE_STRING, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED); + data_col = ephy_tree_model_node_add_prop_column + (node_model, G_TYPE_STRING, EPHY_NODE_ENCODING_PROP_ENCODING); - ephy_dialog_add_enum (EPHY_DIALOG (dialog), property, - num, (const char **) codes); + sort_model = ephy_tree_model_sort_new (GTK_TREE_MODEL (node_model)); - gtk_option_menu_set_history (GTK_OPTION_MENU(optionmenu), pos); + gtk_tree_sortable_set_sort_column_id + (GTK_TREE_SORTABLE (sort_model), title_col, GTK_SORT_ASCENDING); - /* the entries themselves are const, so we don't use g_strfreev here */ - g_free (codes); -} + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (sort_model)); -static gint -compare_lang_items (const EphyLangItem *i1, const EphyLangItem *i2) -{ - return strcmp (i1->key, i2->key); -} + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", title_col, + NULL); -static gint -find_lang_code (const EphyLangItem *i1, const gchar *code) -{ - return strcmp (i1->code, code); + ephy_dialog_set_data_column (dialog, properties[prop].id, data_col); } static void -create_languages_list (PrefsDialog *dialog) +language_combo_changed_cb (GtkComboBox *combo, + EphyDialog *dialog) { - GList *list = NULL, *lang; - GSList *pref_list, *l; - EphyLangItem *item; - const gchar *code; - guint i; - - for (i = 0; i < n_languages; i++) - { - item = g_new0 (EphyLangItem, 1); - - item->name = g_strdup (_(languages[i].name)); - item->key = g_utf8_collate_key (item->name, -1); - item->code = g_strdup (languages[i].code); - - list = g_list_prepend (list, item); - } - - /* add custom languages */ - pref_list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); - - for (l = pref_list; l != NULL; l = l->next) - { - code = (const gchar*) l->data; - - lang = g_list_find_custom (list, code, - (GCompareFunc) find_lang_code); - - if (lang == NULL) - { - /* not found in list */ - item = g_new0 (EphyLangItem, 1); - - item->name = g_strdup_printf (_("Custom [%s]"), code); - item->key = g_utf8_collate_key (item->name, -1); - item->code = g_strdup (code); - - list = g_list_prepend (list, item); - } - } - - if (pref_list) - { - g_slist_foreach (pref_list, (GFunc) g_free, NULL); - g_slist_free (pref_list); - } - - list = g_list_sort (list, (GCompareFunc) compare_lang_items); - - dialog->priv->langs = list; -} + GValue value = { 0, }; + GSList *list; -static GtkWidget * -general_prefs_new_language_menu (PrefsDialog *dialog) -{ - GList *l; - GtkWidget *menu; - EphyLangItem *li; + list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); + /* delete the first list item */ + list = g_slist_remove_link (list, list); - menu = gtk_menu_new (); + ephy_dialog_get_value (dialog, properties[LANGUAGE_PROP].id, &value); - for (l = dialog->priv->langs; l != NULL; l = l->next) - { - GtkWidget *item; + /* add the new language code upfront */ + list = g_slist_prepend (list, g_value_dup_string (&value)); + g_value_unset (&value); - li = (EphyLangItem*) l->data; - item = gtk_menu_item_new_with_label (li->name); - gtk_menu_shell_append (GTK_MENU_SHELL(menu), item); - gtk_widget_show (item); - g_object_set_data (G_OBJECT (item), "desc", li->name); - } + eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list); - return menu; + g_slist_foreach (list, (GFunc) g_free, NULL); + g_slist_free (list); } static void -language_menu_changed_cb (GtkOptionMenu *option_menu, - gpointer data) +create_language_menu (EphyDialog *dialog) { - gint i; - GSList *list = NULL; - GList *lang = NULL; - - g_return_if_fail (EPHY_IS_PREFS_DIALOG (data)); + GtkComboBox *combo; + GtkListStore *store; + GtkTreeModel *sortmodel; + GtkTreeIter iter; + GtkCellRenderer *renderer; + int i; + GSList *list, *l; + /* init value from first element of the list */ list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); - g_return_if_fail (list != NULL); - /* Subst the first item according to the optionmenu */ - i = gtk_option_menu_get_history (option_menu); + combo = GTK_COMBO_BOX (ephy_dialog_get_control + (dialog, properties[LANGUAGE_PROP].id)); - lang = g_list_nth (EPHY_PREFS_DIALOG (data)->priv->langs, i); + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - if (lang) + for (i = 0; i < n_languages; i++) { - g_free (list->data); - list->data = g_strdup (((EphyLangItem *) lang->data)->code); + gtk_list_store_append (store, &iter); - eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list); + gtk_list_store_set (store, &iter, + COL_LANG_NAME, _(languages[i].name), + COL_LANG_CODE, languages[i].code, + -1); } - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); -} - -static void -create_language_menu (PrefsDialog *dialog) -{ - GtkWidget *optionmenu; - GtkWidget *menu; - const gchar *code; - gint i = 0; - GSList *list; - GList *lang; - - optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog), - LANGUAGE_PROP); - - menu = general_prefs_new_language_menu (dialog); - - gtk_option_menu_set_menu (GTK_OPTION_MENU(optionmenu), menu); - - /* init value from first element of the list */ - list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); - if (list) + /* add additional list items */ + for (l = list; l != NULL; l = l->next) { - code = (const gchar *) list->data; - lang = g_list_find_custom (dialog->priv->langs, code, - (GCompareFunc)find_lang_code); + const char *code = (const char *) l->data; + int i; + + if (code == NULL) continue; - if (lang) + for (i = 0; i < n_languages; i++) { - i = g_list_position (dialog->priv->langs, lang); + if (strcmp (languages[i].code, code) == 0) break; } - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); + /* code isn't in stock list */ + if (i == n_languages) + { + char *text; + + text = g_strdup_printf (_("Custom [%s]"), code); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + COL_LANG_NAME, text, + COL_LANG_CODE, code, + -1); + g_free (text); + } } - gtk_option_menu_set_history (GTK_OPTION_MENU(optionmenu), i); + sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store)); + gtk_tree_sortable_set_sort_column_id + (GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING); - g_signal_connect (optionmenu, "changed", - G_CALLBACK (language_menu_changed_cb), - dialog); -} + gtk_combo_box_set_model (combo, sortmodel); -static void -set_homepage_entry (EphyDialog *dialog, - const char *new_location) -{ - GtkWidget *entry; - int pos = 0; + ephy_dialog_set_data_column + (dialog, properties[LANGUAGE_PROP].id, COL_LANG_CODE); - entry = ephy_dialog_get_control (dialog, HOMEPAGE_ENTRY_PROP); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", COL_LANG_NAME, + NULL); - gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1); - gtk_editable_insert_text (GTK_EDITABLE (entry), new_location, - strlen (new_location), - &pos); + g_signal_connect (combo, "changed", + G_CALLBACK (language_combo_changed_cb), dialog); + + /* set combo from first element of the list */ + if (list && list->data) + { + const char *code = (const char *) list->data; + GValue value = { 0, }; + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, code); + ephy_dialog_set_value (dialog, properties[LANGUAGE_PROP].id, &value); + g_value_unset (&value); + } + + g_slist_foreach (list, (GFunc) g_free, NULL); + g_slist_free (list); } static char* @@ -1011,7 +685,7 @@ get_download_button_label () tmp = g_build_filename (g_get_home_dir (), "Desktop", NULL); desktop_path = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL); g_free (tmp); - if (!g_utf8_collate (key, desktop_path)) + if (g_utf8_collate (key, desktop_path) == 0) { g_free (key); label = g_strdup (_("Desktop")); @@ -1026,18 +700,17 @@ get_download_button_label () } static void -create_download_path_label (PrefsDialog *pd) +create_download_path_label (EphyDialog *dialog) { - char *dir; GtkWidget *button, *label; - EphyDialog *dialog = EPHY_DIALOG (pd); + char *dir; - button = ephy_dialog_get_control (dialog, DOWNLOAD_PATH_BUTTON_PROP); + button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id); dir = get_download_button_label (); label = ephy_ellipsizing_label_new (dir); ephy_ellipsizing_label_set_mode ((EphyEllipsizingLabel*)label, - EPHY_ELLIPSIZE_START); + EPHY_ELLIPSIZE_START); gtk_container_add (GTK_CONTAINER (button), label); g_free (dir); gtk_widget_show (label); @@ -1048,70 +721,77 @@ prefs_dialog_init (PrefsDialog *pd) { EphyDialog *dialog = EPHY_DIALOG (pd); EphyEncodings *encodings; + GtkWidget *window; GdkPixbuf *icon; - GList *list; + GtkCellRenderer *renderer; + GtkWidget *combo; pd->priv = EPHY_PREFS_DIALOG_GET_PRIVATE (pd); - ephy_dialog_construct (EPHY_DIALOG (pd), + ephy_dialog_construct (dialog, properties, "prefs-dialog.glade", "prefs_dialog"); - ephy_dialog_add_enum (EPHY_DIALOG (pd), ACCEPT_COOKIES_PROP, + ephy_dialog_add_enum (dialog, properties[ACCEPT_COOKIES_PROP].id, n_cookies_accept_enum, cookies_accept_enum); - ephy_dialog_set_size_group (EPHY_DIALOG (pd), lang_size_group, + ephy_dialog_set_size_group (dialog, lang_size_group, n_lang_size_group); - pd->priv->window = ephy_dialog_get_control (dialog, WINDOW_PROP); - pd->priv->notebook = ephy_dialog_get_control (dialog, NOTEBOOK_PROP); - pd->priv->langs = NULL; - pd->priv->fonts_languages = NULL; + window = ephy_dialog_get_control (dialog, properties[WINDOW_PROP].id); - icon = gtk_widget_render_icon (pd->priv->window, + icon = gtk_widget_render_icon (window, GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU, "prefs_dialog"); - gtk_window_set_icon (GTK_WINDOW (pd->priv->window), icon); + gtk_window_set_icon (GTK_WINDOW (window), icon); g_object_unref(icon); - pd->priv->switching = FALSE; - create_fonts_language_menu (pd); - attach_fonts_signals (pd); - attach_size_controls_signals (pd); - create_languages_list (pd); + combo = ephy_dialog_get_control (dialog, properties[VARIABLE_PROP].id); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", 0, + NULL); + ephy_dialog_set_data_column (dialog, properties[VARIABLE_PROP].id, 0); + combo = ephy_dialog_get_control (dialog, properties[MONOSPACE_PROP].id); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", 0, + NULL); + ephy_dialog_set_data_column (dialog, properties[MONOSPACE_PROP].id, 0); + + create_fonts_language_menu (dialog); encodings = EPHY_ENCODINGS (ephy_embed_shell_get_encodings (EPHY_EMBED_SHELL (ephy_shell))); - list = ephy_encodings_get_encodings (encodings, LG_ALL); - list = g_list_sort (list, (GCompareFunc) sort_encodings); - create_optionmenu (pd, DEFAULT_ENCODING_PROP, list, + create_node_combo (dialog, DEFAULT_ENCODING_PROP, encodings, + ephy_encodings_get_all (encodings), CONF_LANGUAGE_DEFAULT_ENCODING, "ISO-8859-1"); - g_list_free (list); - - list = ephy_encodings_get_detectors (encodings); - list = g_list_sort (list, (GCompareFunc) sort_detectors); - create_optionmenu (pd, AUTO_ENCODING_PROP, list, + create_node_combo (dialog, AUTO_ENCODING_PROP, encodings, + ephy_encodings_get_detectors (encodings), CONF_LANGUAGE_AUTODETECT_ENCODING, ""); - g_list_free (list); - create_language_menu (pd); - create_download_path_label (pd); + create_language_menu (dialog); + + create_download_path_label (dialog); } void -prefs_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer data) +prefs_dialog_response_cb (GtkDialog *widget, + gint response_id, + EphyDialog *dialog) { if (response_id == GTK_RESPONSE_CLOSE) { - gtk_widget_destroy (GTK_WIDGET(dialog)); + g_object_unref (dialog); } else if (response_id == GTK_RESPONSE_HELP) { - PrefsDialog *pd = (PrefsDialog *)data; - prefs_dialog_show_help (pd); + prefs_dialog_show_help (dialog); } } @@ -1127,20 +807,16 @@ prefs_clear_cache_button_clicked_cb (GtkWidget *button, ephy_embed_single_clear_cache (single); } -void -fonts_language_optionmenu_changed_cb (GtkWidget *optionmenu, - EphyDialog *dialog) +static void +set_homepage_entry (EphyDialog *dialog, + char *new_location) { - guint i; - PrefsDialog *pd = EPHY_PREFS_DIALOG (dialog); - - i = gtk_option_menu_get_history - (GTK_OPTION_MENU (optionmenu)); + GValue value = { 0, }; - pd->priv->language = i; - - setup_fonts (pd); - setup_size_controls (pd); + g_value_init (&value, G_TYPE_STRING); + g_value_take_string (&value, new_location); + ephy_dialog_set_value (dialog, properties[HOMEPAGE_ENTRY_PROP].id, &value); + g_value_unset (&value); } void @@ -1161,81 +837,33 @@ prefs_homepage_current_button_clicked_cb (GtkWidget *button, location = ephy_embed_get_location (embed, TRUE); set_homepage_entry (dialog, location); - g_free (location); } void prefs_homepage_blank_button_clicked_cb (GtkWidget *button, EphyDialog *dialog) { - set_homepage_entry (dialog, ""); -} - -static void -fill_language_editor (LanguageEditor *le, PrefsDialog *dialog) -{ - GSList *strings; - GSList *tmp; - GList *lang; - gint i; - const gchar *code; - EphyLangItem *li; - - strings = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); - g_return_if_fail (strings != NULL); - - for (tmp = strings; tmp != NULL; tmp = g_slist_next (tmp)) - { - code = (const gchar *) tmp->data; - - lang = g_list_find_custom (dialog->priv->langs, code, - (GCompareFunc) find_lang_code); - - if (lang) - { - i = g_list_position (dialog->priv->langs, lang); - li = (EphyLangItem *) lang->data; - - language_editor_add (le, li->name, i); - } - } - - g_slist_foreach (strings, (GFunc) g_free, NULL); - g_slist_free (strings); + set_homepage_entry (dialog, NULL); } static void language_dialog_changed_cb (LanguageEditor *le, GSList *list, - PrefsDialog *dialog) + EphyDialog *dialog) { - GtkWidget *optionmenu; - const GSList *l; - GSList *langs = NULL; - GList *lang; - gint i; - EphyLangItem *li; - - optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog), - LANGUAGE_PROP); - gtk_option_menu_set_history (GTK_OPTION_MENU(optionmenu), - GPOINTER_TO_INT(list->data)); + LOG ("language_dialog_changed_cb") - for (l = list; l != NULL; l = l->next) + if (list && list->data) { - i = GPOINTER_TO_INT (l->data); - lang = g_list_nth (dialog->priv->langs, i); + GValue value = { 0, }; - if (lang) - { - li = (EphyLangItem *) lang->data; - - langs = g_slist_append (langs, li->code); - } + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, (char *) list->data); + ephy_dialog_set_value (dialog, properties[LANGUAGE_PROP].id, &value); + g_value_unset (&value); } - eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, langs); - g_slist_free (langs); + eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list); } void @@ -1243,22 +871,53 @@ prefs_language_more_button_clicked_cb (GtkWidget *button, EphyDialog *dialog) { LanguageEditor *editor; - GtkWidget *menu; - GtkWidget *toplevel; + GtkWidget *window, *combo; + GtkTreeModel *model; + GSList *codes, *l; + + window = ephy_dialog_get_control (dialog, properties[WINDOW_PROP].id); + combo = ephy_dialog_get_control (dialog, properties[LANGUAGE_PROP].id); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); + + editor = language_editor_new (window); + language_editor_set_model (editor, model); + + codes = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE); + for (l = codes; l != NULL; l = l->next) + { + const char *code = (const char *) l->data; + int i; + + if (code == NULL) continue; + + for (i = 0; i < n_languages; i++) + { + if (strcmp (languages[i].code, code) == 0) break; + } - menu = general_prefs_new_language_menu (EPHY_PREFS_DIALOG (dialog)); + if (i == n_languages) + { + char *desc; + desc = g_strdup_printf (_("Custom [%s]"), code); + language_editor_add (editor, code, desc);\ + g_free (desc); + } + else + { + language_editor_add (editor, code, _(languages[i].name)); + } + } + g_slist_foreach (codes, (GFunc) g_free, NULL); + g_slist_free (codes); - toplevel = gtk_widget_get_toplevel (button); - editor = language_editor_new (toplevel); - language_editor_set_menu (editor, menu); - fill_language_editor (editor, EPHY_PREFS_DIALOG (dialog)); - ephy_dialog_set_modal (EPHY_DIALOG(editor), TRUE); + /* FIXME: make it only modal to prefs dialogue, not to all windows */ + ephy_dialog_set_modal (EPHY_DIALOG (editor), TRUE); g_signal_connect (editor, "changed", - G_CALLBACK(language_dialog_changed_cb), + G_CALLBACK (language_dialog_changed_cb), dialog); - ephy_dialog_show (EPHY_DIALOG(editor)); + ephy_dialog_show (EPHY_DIALOG (editor)); } static void @@ -1276,9 +935,9 @@ download_path_response_cb (GtkDialog *fc, gint response, EphyDialog *dialog) eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, dir); - button = ephy_dialog_get_control (dialog, DOWNLOAD_PATH_BUTTON_PROP); + button = ephy_dialog_get_control (dialog, properties[DOWNLOAD_PATH_BUTTON_PROP].id); label = get_download_button_label (); - ephy_ellipsizing_label_set_text ((EphyEllipsizingLabel*)GTK_BIN (button)->child, + ephy_ellipsizing_label_set_text ((EphyEllipsizingLabel*) GTK_BIN (button)->child, label); g_free (dir); g_free (label); @@ -1294,10 +953,11 @@ prefs_download_path_button_clicked_cb (GtkWidget *button, { GtkWidget *parent; EphyFileChooser *fc; - parent = ephy_dialog_get_control (dialog, WINDOW_PROP); + + parent = ephy_dialog_get_control (dialog, properties[WINDOW_PROP].id); fc = ephy_file_chooser_new (_("Select a directory"), - GTK_WIDGET (parent), + GTK_WIDGET (parent), GTK_FILE_CHOOSER_ACTION_OPEN, NULL); gtk_file_chooser_set_folder_mode (GTK_FILE_CHOOSER (fc), TRUE); diff --git a/src/prefs-dialog.h b/src/prefs-dialog.h index dad8dfc00..caceec2d3 100644 --- a/src/prefs-dialog.h +++ b/src/prefs-dialog.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS #define EPHY_IS_PREFS_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_PREFS_DIALOG)) #define EPHY_PREFS_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_PREFS_DIALOG, PrefsDialogClass)) -typedef struct PrefsDialog PrefsDialog; -typedef struct PrefsDialogClass PrefsDialogClass; -typedef struct PrefsDialogPrivate PrefsDialogPrivate; +typedef struct PrefsDialog PrefsDialog; +typedef struct PrefsDialogClass PrefsDialogClass; +typedef struct PrefsDialogPrivate PrefsDialogPrivate; struct PrefsDialog { @@ -52,8 +52,6 @@ struct PrefsDialogClass GType prefs_dialog_get_type (void); -EphyDialog *prefs_dialog_new (GtkWidget *parent); - G_END_DECLS #endif diff --git a/src/window-commands.c b/src/window-commands.c index 25ee9bff7..f519297e6 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -41,7 +41,6 @@ #include "ephy-state.h" #include "ephy-gui.h" #include "ephy-zoom.h" -#include "prefs-dialog.h" #include "ephy-toolbars-model.h" #include "egg-editable-toolbar.h" #include "egg-toolbar-editor.h" @@ -780,7 +779,8 @@ window_cmd_edit_prefs (GtkAction *action, { EphyDialog *dialog; - dialog = prefs_dialog_new (GTK_WIDGET (window)); + dialog = EPHY_DIALOG (ephy_shell_get_prefs_dialog (ephy_shell)); + ephy_dialog_show (dialog); } |