diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-10-31 06:58:12 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-10-31 06:58:12 +0800 |
commit | 362396c2bf69c659b5fcea2eaf3ed17b6ff93b09 (patch) | |
tree | 14f36a7f87ca3e938a14e43efa13a0b14d196a4d | |
parent | 87e9353728c1115e7f60b1f7bb63e79723888907 (diff) | |
download | gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar.gz gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar.bz2 gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar.lz gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar.xz gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.tar.zst gsoc2013-epiphany-362396c2bf69c659b5fcea2eaf3ed17b6ff93b09.zip |
Remove glade callbacks, and connect from code instead.
2005-10-30 Christian Persch <chpe@cvs.gnome.org>
* data/glade/epiphany.glade:
* data/glade/prefs-dialog.glade:
* data/glade/print.glade:
* embed/downloader-view.c: (update_buttons),
(downloader_view_build_ui), (download_dialog_pause),
(download_dialog_stop), (download_dialog_response_cb),
(download_dialog_delete_event_cb):
* embed/print-dialog.c: (ephy_print_setup_dialog_response_cb),
(ephy_print_setup_dialog_new):
* src/ephy-encoding-dialog.c: (ephy_encoding_dialog_init):
* src/pdm-dialog.c: (show_cookies_properties),
(cookies_properties_clicked_cb), (pdm_dialog_cookies_construct),
(passwords_show_toggled_cb), (pdm_dialog_passwords_construct),
(pdm_dialog_response_cb), (pdm_dialog_init), (pdm_dialog_finalize):
* src/prefs-dialog.c: (create_language_section),
(prefs_dialog_response_cb), (prefs_clear_cache_button_clicked_cb),
(set_homepage_entry), (prefs_homepage_current_button_clicked_cb),
(prefs_homepage_blank_button_clicked_cb), (prefs_dialog_init):
Remove glade callbacks, and connect from code instead.
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | data/glade/epiphany.glade | 211 | ||||
-rw-r--r-- | data/glade/prefs-dialog.glade | 8 | ||||
-rw-r--r-- | data/glade/print.glade | 3 | ||||
-rw-r--r-- | embed/downloader-view.c | 61 | ||||
-rwxr-xr-x | embed/print-dialog.c | 32 | ||||
-rw-r--r-- | src/ephy-encoding-dialog.c | 13 | ||||
-rwxr-xr-x | src/pdm-dialog.c | 402 | ||||
-rw-r--r-- | src/prefs-dialog.c | 196 |
9 files changed, 486 insertions, 463 deletions
@@ -1,5 +1,28 @@ 2005-10-30 Christian Persch <chpe@cvs.gnome.org> + * data/glade/epiphany.glade: + * data/glade/prefs-dialog.glade: + * data/glade/print.glade: + * embed/downloader-view.c: (update_buttons), + (downloader_view_build_ui), (download_dialog_pause), + (download_dialog_stop), (download_dialog_response_cb), + (download_dialog_delete_event_cb): + * embed/print-dialog.c: (ephy_print_setup_dialog_response_cb), + (ephy_print_setup_dialog_new): + * src/ephy-encoding-dialog.c: (ephy_encoding_dialog_init): + * src/pdm-dialog.c: (show_cookies_properties), + (cookies_properties_clicked_cb), (pdm_dialog_cookies_construct), + (passwords_show_toggled_cb), (pdm_dialog_passwords_construct), + (pdm_dialog_response_cb), (pdm_dialog_init), (pdm_dialog_finalize): + * src/prefs-dialog.c: (create_language_section), + (prefs_dialog_response_cb), (prefs_clear_cache_button_clicked_cb), + (set_homepage_entry), (prefs_homepage_current_button_clicked_cb), + (prefs_homepage_blank_button_clicked_cb), (prefs_dialog_init): + + Remove glade callbacks, and connect from code instead. + +2005-10-30 Christian Persch <chpe@cvs.gnome.org> + * lib/ephy-module.c: (ephy_module_load): Don't use BIND_LAZY when enabling debugging. That way we can find diff --git a/data/glade/epiphany.glade b/data/glade/epiphany.glade index 3a8897127..f9e34bfa0 100644 --- a/data/glade/epiphany.glade +++ b/data/glade/epiphany.glade @@ -4,116 +4,6 @@ <glade-interface> <requires lib="gnome"/> -<widget class="GtkWindow" id="download_manager_dialog"> - <property name="border_width">12</property> - <property name="title" translatable="yes">Downloads</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <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="focus_on_map">True</property> - <property name="urgency_hint">False</property> - <signal name="delete_event" handler="download_dialog_delete_cb"/> - - <child> - <widget class="GtkVBox" id="vbox106"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkHButtonBox" id="hbuttonbox10"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkButton" id="pause_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <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> - - <child> - <widget class="GtkButton" id="abort_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <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> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox107"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow1134"> - <property name="height_request">100</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTreeView" id="clist"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">True</property> - <property name="rules_hint">False</property> - <property name="reorderable">False</property> - <property name="enable_search">True</property> - <property name="fixed_height_mode">False</property> - <property name="hover_selection">False</property> - <property name="hover_expand">False</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - <widget class="GtkDialog" id="pdm_dialog"> <property name="border_width">5</property> <property name="width_request">400</property> @@ -132,7 +22,6 @@ <property name="focus_on_map">True</property> <property name="urgency_hint">False</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"/> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog-vbox27"> @@ -256,7 +145,6 @@ <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> </widget> @@ -376,7 +264,6 @@ <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> - <signal name="toggled" handler="pdm_dialog_passwords_show_cb" last_modification_time="Sat, 22 Oct 2005 20:04:26 GMT"/> </widget> <packing> <property name="padding">0</property> @@ -449,7 +336,6 @@ <property name="focus_on_map">True</property> <property name="urgency_hint">False</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"/> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog-vbox30"> @@ -651,4 +537,101 @@ </child> </widget> +<widget class="GtkDialog" id="download_manager_dialog"> + <property name="border_width">5</property> + <property name="title" translatable="yes">Downloads</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <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_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox31"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area31"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="pause_button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">DYNAMIC</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">1</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="abort_button"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <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> + <property name="response_id">2</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1134"> + <property name="border_width">5</property> + <property name="height_request">100</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="clist"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade index 5421ba76b..80ac0519f 100644 --- a/data/glade/prefs-dialog.glade +++ b/data/glade/prefs-dialog.glade @@ -20,7 +20,6 @@ <property name="focus_on_map">True</property> <property name="urgency_hint">False</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"/> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog-vbox2"> @@ -208,7 +207,6 @@ <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> @@ -221,7 +219,6 @@ <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> </widget> @@ -1276,7 +1273,6 @@ <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> </widget> @@ -1562,7 +1558,6 @@ <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="language_editor_add_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:13:44 GMT"/> </widget> </child> @@ -1575,7 +1570,6 @@ <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="language_editor_remove_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:17 GMT"/> </widget> </child> @@ -1588,7 +1582,6 @@ <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="language_editor_up_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:30 GMT"/> </widget> </child> @@ -1601,7 +1594,6 @@ <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <signal name="clicked" handler="language_editor_down_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:43 GMT"/> </widget> </child> </widget> diff --git a/data/glade/print.glade b/data/glade/print.glade index 801921abd..ba430a5f3 100644 --- a/data/glade/print.glade +++ b/data/glade/print.glade @@ -18,6 +18,7 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> <property name="has_separator">False</property> <child internal-child="vbox"> @@ -42,7 +43,6 @@ <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <property name="response_id">-7</property> - <signal name="clicked" handler="ephy_print_setup_dialog_close_button_cb" last_modification_time="Sat, 06 Dec 2003 10:22:18 GMT"/> </widget> </child> @@ -56,7 +56,6 @@ <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <property name="response_id">-11</property> - <signal name="clicked" handler="ephy_print_setup_dialog_help_button_cb" last_modification_time="Sun, 04 Jan 2004 20:17:34 GMT"/> </widget> </child> </widget> diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 9ac47c3ca..4877f03df 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -105,6 +105,12 @@ EphyDialogProperty properties [] = { NULL } }; +enum +{ + RESPONSE_PAUSE = 1, + RESPONSE_STOP = 2 +}; + static void downloader_view_build_ui (DownloaderView *dv); static void @@ -113,15 +119,14 @@ static void downloader_view_finalize (GObject *object); static void downloader_view_init (DownloaderView *dv); - -/* Callbacks */ -void -download_dialog_pause_cb (GtkButton *button, DownloaderView *dv); -void -download_dialog_abort_cb (GtkButton *button, DownloaderView *dv); -gboolean -download_dialog_delete_cb (GtkWidget *window, GdkEventAny *event, - DownloaderView *dv); +static void +download_dialog_response_cb (GtkWidget *dialog, + int response, + DownloaderView *dv); +static gboolean +download_dialog_delete_event_cb (GtkWidget *window, + GdkEventAny *event, + DownloaderView *dv); static GObjectClass *parent_class = NULL; @@ -365,7 +370,8 @@ update_buttons (DownloaderView *dv) } gtk_widget_set_sensitive (dv->priv->pause_button, pause_enabled); gtk_widget_set_sensitive (dv->priv->abort_button, abort_enabled); - gtk_button_set_label (GTK_BUTTON (dv->priv->pause_button), label_pause ? _("_Pause") : _("_Resume")); + gtk_button_set_label (GTK_BUTTON (dv->priv->pause_button), + label_pause ? _("_Pause") : _("_Resume")); } static void @@ -625,6 +631,11 @@ downloader_view_build_ui (DownloaderView *dv) properties[PROP_ABORT_BUTTON].id, &priv->abort_button, NULL); + g_signal_connect (priv->window, "response", + G_CALLBACK (download_dialog_response_cb), dv); + g_signal_connect (priv->window, "delete-event", + G_CALLBACK (download_dialog_delete_event_cb), dv); + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)), GTK_SELECTION_BROWSE); @@ -695,8 +706,8 @@ downloader_view_build_ui (DownloaderView *dv) g_signal_connect (selection, "changed", G_CALLBACK (selection_changed), dv); } -void -download_dialog_pause_cb (GtkButton *button, DownloaderView *dv) +static void +download_dialog_pause (DownloaderView *dv) { GtkTreeSelection *selection; GtkTreeModel *model; @@ -794,8 +805,8 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download) } } -void -download_dialog_abort_cb (GtkButton *button, DownloaderView *dv) +static void +download_dialog_stop (DownloaderView *dv) { GValue val = {0, }; GtkTreeSelection *selection; @@ -818,9 +829,25 @@ download_dialog_abort_cb (GtkButton *button, DownloaderView *dv) g_value_unset (&val); } -gboolean -download_dialog_delete_cb (GtkWidget *window, GdkEventAny *event, - DownloaderView *dv) +static void +download_dialog_response_cb (GtkWidget *dialog, + int response, + DownloaderView *dv) +{ + if (response == RESPONSE_PAUSE) + { + download_dialog_pause (dv); + } + else if (response == RESPONSE_STOP) + { + download_dialog_stop (dv); + } +} + +static gboolean +download_dialog_delete_event_cb (GtkWidget *window, + GdkEventAny *event, + DownloaderView *dv) { /* FIXME multi-head */ if (egg_tray_manager_check_running (gdk_screen_get_default ())) diff --git a/embed/print-dialog.c b/embed/print-dialog.c index 05b93749e..a2eb47d33 100755 --- a/embed/print-dialog.c +++ b/embed/print-dialog.c @@ -80,14 +80,6 @@ EphyDialogProperty setup_props [] = { NULL } }; -void ephy_print_dialog_response_cb (GtkDialog *dialog, - int response, - EmbedPrintInfo *info); -void ephy_print_setup_dialog_close_button_cb (GtkWidget *widget, - EphyDialog *dialog); -void ephy_print_setup_dialog_help_button_cb (GtkWidget *widget, - EphyDialog *dialog); - void ephy_print_info_free (EmbedPrintInfo *info) { @@ -346,18 +338,18 @@ ephy_print_do_print_and_free (EmbedPrintInfo *info) info); } -void -ephy_print_setup_dialog_close_button_cb (GtkWidget *widget, - EphyDialog *dialog) +static void +ephy_print_setup_dialog_response_cb (GtkWidget *widget, + int response, + EphyDialog *dialog) { - g_object_unref (dialog); -} + if (response == GTK_RESPONSE_HELP) + { + ephy_gui_help (GTK_WINDOW (widget), "epiphany", "using-print-setup"); + return; + } -void -ephy_print_setup_dialog_help_button_cb (GtkWidget *widget, - EphyDialog *dialog) -{ - ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "using-print-setup"); + g_object_unref (dialog); } static GtkWidget * @@ -483,7 +475,9 @@ ephy_print_setup_dialog_new (void) window = ephy_dialog_get_control (dialog, setup_props[SETUP_WINDOW_PROP].id); gtk_window_set_icon_name (GTK_WINDOW (window), STOCK_PRINT_SETUP); - + g_signal_connect (window, "response", + G_CALLBACK (ephy_print_setup_dialog_response_cb), dialog); + paper_selector_hbox = ephy_dialog_get_control (dialog, setup_props[PAPER_SELECTOR_PROP].id); gtk_box_pack_start_defaults (GTK_BOX (paper_selector_hbox), diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index 8d9f1cb71..261b8f4b5 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -43,6 +43,7 @@ enum { + WINDOW_PROP, SCROLLED_WINDOW_PROP, AUTOMATIC_PROP, MANUAL_PROP @@ -51,6 +52,7 @@ enum static const EphyDialogProperty properties [] = { + { "encoding_dialog", NULL, PT_NORMAL, 0 }, { "scrolled_window", NULL, PT_NORMAL, 0 }, { "automatic_button", NULL, PT_NORMAL, 0 }, { "manual_button", NULL, PT_NORMAL, 0 }, @@ -73,9 +75,6 @@ struct _EphyEncodingDialogPrivate static void ephy_encoding_dialog_class_init (EphyEncodingDialogClass *klass); static void ephy_encoding_dialog_init (EphyEncodingDialog *ge); -void ephy_encoding_dialog_response_cb (GtkWidget *widget, - int response, - EphyEncodingDialog *dialog); static GObjectClass *parent_class = NULL; @@ -223,7 +222,7 @@ activate_choice (EphyEncodingDialog *dialog) } } -void +static void ephy_encoding_dialog_response_cb (GtkWidget *widget, int response, EphyEncodingDialog *dialog) @@ -286,7 +285,7 @@ automatic_toggled_cb (GtkToggleButton *button, EphyEncodingDialog *dialog) static void ephy_encoding_dialog_init (EphyEncodingDialog *dialog) { - GtkWidget *treeview, *scroller, *button; + GtkWidget *treeview, *scroller, *button, *window; GtkTreeSelection *selection; EphyNode *node; @@ -302,6 +301,10 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog) "encoding_dialog", NULL); + window = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[WINDOW_PROP].id); + g_signal_connect (window, "response", + G_CALLBACK (ephy_encoding_dialog_response_cb), dialog); + dialog->priv->filter = ephy_node_filter_new (); node = ephy_encodings_get_all (dialog->priv->encodings); diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index a71cc7411..6fb5e444a 100755 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -127,17 +127,6 @@ static void pdm_dialog_class_init (PdmDialogClass *klass); static void pdm_dialog_init (PdmDialog *dialog); static void pdm_dialog_finalize (GObject *object); -/* Glade callbacks */ -void pdm_dialog_close_button_clicked_cb (GtkWidget *button, - PdmDialog *dialog); -void pdm_dialog_cookies_properties_button_clicked_cb (GtkWidget *button, - PdmDialog *dialog); -void pdm_dialog_passwords_show_cb (GtkWidget *checkbox, - PdmDialog *dialog); -void pdm_dialog_response_cb (GtkDialog *widget, - int response, - PdmDialog *dialog); - static GObjectClass *parent_class = NULL; GType @@ -361,6 +350,156 @@ setup_action (PdmActionInfo *action) /* "Cookies" tab */ static void +show_cookies_properties (PdmDialog *dialog, + EphyCookie *info) +{ + GtkWidget *gdialog; + GtkWidget *table; + GtkWidget *label; + GtkWidget *parent; + GtkWidget *dialog_vbox; + char *str; + + parent = ephy_dialog_get_control (EPHY_DIALOG(dialog), + properties[PROP_WINDOW].id); + + gdialog = gtk_dialog_new_with_buttons + (_("Cookie Properties"), + GTK_WINDOW (parent), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLOSE, 0, NULL); + ephy_state_add_window (GTK_WIDGET (gdialog), "cookie_properties", + -1, -1, FALSE, + EPHY_STATE_WINDOW_SAVE_SIZE | EPHY_STATE_WINDOW_SAVE_POSITION); + gtk_dialog_set_has_separator (GTK_DIALOG(gdialog), FALSE); + gtk_container_set_border_width (GTK_CONTAINER (gdialog), 5); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (gdialog)->vbox), 2); + + table = gtk_table_new (2, 4, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 5); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_widget_show (table); + + str = g_strconcat ("<b>", _("Content:"), "</b>", NULL); + label = gtk_label_new (str); + g_free (str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, + GTK_FILL, GTK_FILL, 0, 0); + + label = gtk_label_new (info->value); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1); + + str = g_strconcat ("<b>", _("Path:"), "</b>", NULL); + label = gtk_label_new (str); + g_free (str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, + GTK_FILL, GTK_FILL, 0, 0); + + label = gtk_label_new (info->path); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2); + + str = g_strconcat ("<b>", _("Send for:"), "</b>", NULL); + label = gtk_label_new (str); + g_free (str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, + GTK_FILL, GTK_FILL, 0, 0); + + label = gtk_label_new (info->is_secure ? _("Encrypted connections only") : _("Any type of connection") ); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3); + + str = g_strconcat ("<b>", _("Expires:"), "</b>", NULL); + label = gtk_label_new (str); + g_free (str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0); + gtk_widget_show (label); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, + GTK_FILL, GTK_FILL, 0, 0); + + if (info->is_session) + { + str = g_strdup (_("End of current session")); + } + else + { + struct tm t; + char s[128]; + const char *fmt_hack = "%c"; + strftime (s, sizeof(s), fmt_hack, localtime_r (&info->expires, &t)); + str = g_locale_to_utf8 (s, -1, NULL, NULL, NULL); + } + label = gtk_label_new (str); + g_free (str); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_widget_show (label); + gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4); + + dialog_vbox = GTK_DIALOG(gdialog)->vbox; + gtk_box_pack_start (GTK_BOX(dialog_vbox), + table, + FALSE, FALSE, 0); + + gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)), + GTK_WINDOW (gdialog)); + + gtk_dialog_run (GTK_DIALOG (gdialog)); + + gtk_widget_destroy (gdialog); +} + +static void +cookies_properties_clicked_cb (GtkWidget *button, + PdmDialog *dialog) +{ + GtkTreeModel *model; + GValue val = {0, }; + GtkTreeIter iter; + GtkTreePath *path; + EphyCookie *cookie; + GList *l; + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (dialog->priv->cookies->treeview); + l = gtk_tree_selection_get_selected_rows + (selection, &model); + + path = (GtkTreePath *)l->data; + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get_value + (model, &iter, COL_COOKIES_DATA, &val); + cookie = (EphyCookie *) g_value_get_boxed (&val); + + show_cookies_properties (dialog, cookie); + + g_value_unset (&val); + + g_list_foreach (l, (GFunc)gtk_tree_path_free, NULL); + g_list_free (l); +} + +static void cookies_treeview_selection_changed_cb (GtkTreeSelection *selection, PdmDialog *dialog) { @@ -383,11 +522,17 @@ pdm_dialog_cookies_construct (PdmActionInfo *info) GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *selection; + GtkWidget *button; LOG ("pdm_dialog_cookies_construct"); - treeview = GTK_TREE_VIEW (ephy_dialog_get_control - (EPHY_DIALOG (dialog), properties[PROP_COOKIES_TREEVIEW].id)); + ephy_dialog_get_controls (EPHY_DIALOG (dialog), + properties[PROP_COOKIES_TREEVIEW].id, &treeview, + properties[PROP_COOKIES_PROPERTIES].id, &button, + NULL); + + g_signal_connect (button, "clicked", + G_CALLBACK (cookies_properties_clicked_cb), dialog); /* set tree model */ liststore = gtk_list_store_new (4, @@ -624,6 +769,23 @@ pdm_dialog_cookie_remove (PdmActionInfo *info, /* "Passwords" tab */ static void +passwords_show_toggled_cb (GtkWidget *button, + PdmDialog *dialog) +{ + GtkTreeView *treeview; + GtkTreeViewColumn *column; + gboolean active; + + treeview = GTK_TREE_VIEW (ephy_dialog_get_control + (EPHY_DIALOG(dialog), properties[PROP_PASSWORDS_TREEVIEW].id)); + column = gtk_tree_view_get_column (treeview, COL_PASSWORDS_PASSWORD); + + active = gtk_toggle_button_get_active ((GTK_TOGGLE_BUTTON (button))); + + gtk_tree_view_column_set_visible (column, active); +} + +static void pdm_dialog_passwords_construct (PdmActionInfo *info) { PdmDialog *dialog = info->dialog; @@ -632,11 +794,17 @@ pdm_dialog_passwords_construct (PdmActionInfo *info) GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *selection; + GtkWidget *button; LOG ("pdm_dialog_passwords_construct"); - treeview = GTK_TREE_VIEW (ephy_dialog_get_control - (EPHY_DIALOG(dialog), properties[PROP_PASSWORDS_TREEVIEW].id)); + ephy_dialog_get_controls (EPHY_DIALOG (dialog), + properties[PROP_PASSWORDS_TREEVIEW].id, &treeview, + properties[PROP_PASSWORDS_SHOW].id, &button, + NULL); + + g_signal_connect (button, "toggled", + G_CALLBACK (passwords_show_toggled_cb), dialog); /* set tree model */ liststore = gtk_list_store_new (4, @@ -816,6 +984,23 @@ sync_notebook_tab (GtkWidget *notebook, } static void +pdm_dialog_response_cb (GtkDialog *widget, + int response, + PdmDialog *dialog) +{ + switch (response) + { + case GTK_RESPONSE_CLOSE: + g_object_unref (dialog); + break; + case GTK_RESPONSE_HELP: + pdm_dialog_show_help (dialog); + break; + default: + break; + } +} +static void pdm_dialog_init (PdmDialog *dialog) { PdmActionInfo *cookies, *passwords; @@ -836,6 +1021,8 @@ pdm_dialog_init (PdmDialog *dialog) gtk_window_set_icon_name (GTK_WINDOW (window), "web-browser"); + g_signal_connect (window, "response", + G_CALLBACK (pdm_dialog_response_cb), dialog); /** * Group all Properties and Remove buttons in the same size group to * avoid the little jerk you get otherwise when switching pages because @@ -901,188 +1088,3 @@ pdm_dialog_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } - -static void -show_cookies_properties (PdmDialog *dialog, - EphyCookie *info) -{ - GtkWidget *gdialog; - GtkWidget *table; - GtkWidget *label; - GtkWidget *parent; - GtkWidget *dialog_vbox; - char *str; - - parent = ephy_dialog_get_control (EPHY_DIALOG(dialog), - properties[PROP_WINDOW].id); - - gdialog = gtk_dialog_new_with_buttons - (_("Cookie Properties"), - GTK_WINDOW (parent), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, 0, NULL); - ephy_state_add_window (GTK_WIDGET (gdialog), "cookie_properties", - -1, -1, FALSE, - EPHY_STATE_WINDOW_SAVE_SIZE | EPHY_STATE_WINDOW_SAVE_POSITION); - gtk_dialog_set_has_separator (GTK_DIALOG(gdialog), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (gdialog), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (gdialog)->vbox), 2); - - table = gtk_table_new (2, 4, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), 5); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); - gtk_widget_show (table); - - str = g_strconcat ("<b>", _("Content:"), "</b>", NULL); - label = gtk_label_new (str); - g_free (str); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, - GTK_FILL, GTK_FILL, 0, 0); - - label = gtk_label_new (info->value); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1); - - str = g_strconcat ("<b>", _("Path:"), "</b>", NULL); - label = gtk_label_new (str); - g_free (str); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, - GTK_FILL, GTK_FILL, 0, 0); - - label = gtk_label_new (info->path); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2); - - str = g_strconcat ("<b>", _("Send for:"), "</b>", NULL); - label = gtk_label_new (str); - g_free (str); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, - GTK_FILL, GTK_FILL, 0, 0); - - label = gtk_label_new (info->is_secure ? _("Encrypted connections only") : _("Any type of connection") ); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3); - - str = g_strconcat ("<b>", _("Expires:"), "</b>", NULL); - label = gtk_label_new (str); - g_free (str); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, - GTK_FILL, GTK_FILL, 0, 0); - - if (info->is_session) - { - str = g_strdup (_("End of current session")); - } - else - { - struct tm t; - char s[128]; - const char *fmt_hack = "%c"; - strftime (s, sizeof(s), fmt_hack, localtime_r (&info->expires, &t)); - str = g_locale_to_utf8 (s, -1, NULL, NULL, NULL); - } - label = gtk_label_new (str); - g_free (str); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - gtk_widget_show (label); - gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4); - - dialog_vbox = GTK_DIALOG(gdialog)->vbox; - gtk_box_pack_start (GTK_BOX(dialog_vbox), - table, - FALSE, FALSE, 0); - - gtk_window_group_add_window (ephy_gui_ensure_window_group (GTK_WINDOW (parent)), - GTK_WINDOW (gdialog)); - - gtk_dialog_run (GTK_DIALOG (gdialog)); - - gtk_widget_destroy (gdialog); -} - -void -pdm_dialog_cookies_properties_button_clicked_cb (GtkWidget *button, - PdmDialog *dialog) -{ - GtkTreeModel *model; - GValue val = {0, }; - GtkTreeIter iter; - GtkTreePath *path; - EphyCookie *cookie; - GList *l; - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (dialog->priv->cookies->treeview); - l = gtk_tree_selection_get_selected_rows - (selection, &model); - - path = (GtkTreePath *)l->data; - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get_value - (model, &iter, COL_COOKIES_DATA, &val); - cookie = (EphyCookie *) g_value_get_boxed (&val); - - show_cookies_properties (dialog, cookie); - - g_value_unset (&val); - - g_list_foreach (l, (GFunc)gtk_tree_path_free, NULL); - g_list_free (l); -} - -void -pdm_dialog_passwords_show_cb (GtkWidget *button, - PdmDialog *dialog) -{ - GtkTreeView *treeview; - GtkTreeViewColumn *column; - gboolean active; - - treeview = GTK_TREE_VIEW (ephy_dialog_get_control - (EPHY_DIALOG(dialog), properties[PROP_PASSWORDS_TREEVIEW].id)); - column = gtk_tree_view_get_column (treeview, COL_PASSWORDS_PASSWORD); - - active = gtk_toggle_button_get_active ((GTK_TOGGLE_BUTTON (button))); - - gtk_tree_view_column_set_visible (column, active); -} - -void -pdm_dialog_response_cb (GtkDialog *widget, - gint response, - PdmDialog *dialog) -{ - switch (response) - { - case GTK_RESPONSE_CLOSE: - g_object_unref (dialog); - break; - case GTK_RESPONSE_HELP: - pdm_dialog_show_help (dialog); - break; - default: - break; - } -} diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index e0ad5891a..2ec678c6b 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -66,27 +66,6 @@ static void prefs_dialog_class_init (PrefsDialogClass *klass); static void prefs_dialog_init (PrefsDialog *pd); -/* Glade callbacks */ -void prefs_clear_cache_button_clicked_cb (GtkWidget *button, - gpointer data); -void prefs_dialog_response_cb (GtkDialog *widget, - gint response_id, - 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 language_editor_add_button_clicked_cb (GtkWidget *button, - PrefsDialog *pd); -void language_editor_remove_button_clicked_cb (GtkWidget *button, - PrefsDialog *pd); -void language_editor_up_button_clicked_cb (GtkWidget *button, - PrefsDialog *pd); -void language_editor_down_button_clicked_cb (GtkWidget *button, - PrefsDialog *pd); - #include "languages.h" static const char * const cookies_accept_enum [] = @@ -156,6 +135,7 @@ enum ALLOW_JS_PROP, ACCEPT_COOKIES_PROP, DISK_CACHE_PROP, + CLEAR_CACHE_BUTTON_PROP, /* Language */ AUTO_ENCODING_PROP, @@ -198,6 +178,7 @@ EphyDialogProperty properties [] = { "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 }, + { "clear_cache_button", NULL, PT_NORMAL, 0 }, /* Languages */ { "auto_encoding_combo", CONF_LANGUAGE_AUTODETECT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING }, @@ -889,7 +870,7 @@ setup_add_language_dialog (PrefsDialog *pd) return dialog; } -void +static void language_editor_add_button_clicked_cb (GtkWidget *button, PrefsDialog *pd) { @@ -905,7 +886,7 @@ language_editor_add_button_clicked_cb (GtkWidget *button, ephy_dialog_show (pd->priv->add_lang_dialog); } -void +static void language_editor_remove_button_clicked_cb (GtkWidget *button, PrefsDialog *pd) { @@ -924,7 +905,7 @@ language_editor_remove_button_clicked_cb (GtkWidget *button, language_editor_update_buttons (pd); } -void +static void language_editor_up_button_clicked_cb (GtkWidget *button, PrefsDialog *pd) { @@ -956,7 +937,7 @@ language_editor_up_button_clicked_cb (GtkWidget *button, language_editor_update_buttons (pd); } -void +static void language_editor_down_button_clicked_cb (GtkWidget *button, PrefsDialog *pd) { @@ -1024,6 +1005,15 @@ create_language_section (EphyDialog *dialog) properties[LANGUAGE_DOWN_BUTTON_PROP].id, &pd->priv->lang_down_button, NULL); + g_signal_connect (pd->priv->lang_add_button, "clicked", + G_CALLBACK (language_editor_add_button_clicked_cb), dialog); + g_signal_connect (pd->priv->lang_remove_button, "clicked", + G_CALLBACK (language_editor_remove_button_clicked_cb), dialog); + g_signal_connect (pd->priv->lang_up_button, "clicked", + G_CALLBACK (language_editor_up_button_clicked_cb), dialog); + g_signal_connect (pd->priv->lang_down_button, "clicked", + G_CALLBACK (language_editor_down_button_clicked_cb), dialog); + /* setup the languages treeview */ pd->priv->lang_treeview = treeview; @@ -1181,14 +1171,83 @@ create_download_path_button (EphyDialog *dialog) gtk_widget_set_sensitive (button, eel_gconf_key_is_writable (CONF_STATE_DOWNLOAD_DIR)); g_free (dir); } - + +static void +prefs_dialog_response_cb (GtkDialog *widget, + int response, + EphyDialog *dialog) +{ + if (response == GTK_RESPONSE_HELP) + { + prefs_dialog_show_help (dialog); + return; + } + + g_object_unref (dialog); +} + +static void +prefs_clear_cache_button_clicked_cb (GtkWidget *button, + PrefsDialog *dialog) +{ + EphyEmbedShell *shell; + EphyEmbedSingle *single; + EphyFaviconCache *cache; + + shell = ephy_embed_shell_get_default (); + + single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (shell)); + ephy_embed_single_clear_cache (single); + + cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell)); + ephy_favicon_cache_clear (cache); +} + +static void +set_homepage_entry (EphyDialog *dialog, + const char *new_location) +{ + GValue value = { 0, }; + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, new_location); + ephy_dialog_set_value (dialog, properties[HOMEPAGE_ENTRY_PROP].id, &value); + g_value_unset (&value); +} + +static void +prefs_homepage_current_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog) +{ + EphySession *session; + EphyWindow *window; + EphyTab *tab; + + session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ())); + window = ephy_session_get_active_window (session); + + /* can't do anything in this case */ + if (window == NULL) return; + + tab = ephy_window_get_active_tab (window); + g_return_if_fail (tab != NULL); + + set_homepage_entry (dialog, ephy_tab_get_address (tab)); +} + +static void +prefs_homepage_blank_button_clicked_cb (GtkWidget *button, + EphyDialog *dialog) +{ + set_homepage_entry (dialog, NULL); +} static void prefs_dialog_init (PrefsDialog *pd) { EphyDialog *dialog = EPHY_DIALOG (pd); EphyEncodings *encodings; GtkWidget *window, *curr_button, *blank_button; - GtkWidget *variable_combo, *monospace_combo; + GtkWidget *variable_combo, *monospace_combo, *clear_cache_button; GtkCellRenderer *renderer; gboolean sensitive; @@ -1210,10 +1269,19 @@ prefs_dialog_init (PrefsDialog *pd) properties[HOMEPAGE_BLANK_PROP].id, &blank_button, properties[VARIABLE_PROP].id, &variable_combo, properties[MONOSPACE_PROP].id, &monospace_combo, + properties[CLEAR_CACHE_BUTTON_PROP].id, &clear_cache_button, NULL); gtk_window_set_icon_name (GTK_WINDOW (window), GTK_STOCK_PREFERENCES); + g_signal_connect (window, "response", + G_CALLBACK (prefs_dialog_response_cb), dialog); + + g_signal_connect (curr_button, "clicked", + G_CALLBACK (prefs_homepage_current_button_clicked_cb), dialog); + g_signal_connect (blank_button, "clicked", + G_CALLBACK (prefs_homepage_blank_button_clicked_cb), dialog); + /* set homepage button sensitivity */ sensitive = eel_gconf_key_is_writable (CONF_GENERAL_HOMEPAGE); gtk_widget_set_sensitive (curr_button, sensitive); @@ -1234,6 +1302,9 @@ prefs_dialog_init (PrefsDialog *pd) create_fonts_language_menu (dialog); + g_signal_connect (clear_cache_button, "clicked", + G_CALLBACK (prefs_clear_cache_button_clicked_cb), dialog); + encodings = EPHY_ENCODINGS (ephy_embed_shell_get_encodings (EPHY_EMBED_SHELL (ephy_shell))); @@ -1248,74 +1319,3 @@ prefs_dialog_init (PrefsDialog *pd) create_download_path_button (dialog); } - -void -prefs_dialog_response_cb (GtkDialog *widget, - gint response_id, - EphyDialog *dialog) -{ - if (response_id == GTK_RESPONSE_CLOSE) - { - g_object_unref (dialog); - } - else if (response_id == GTK_RESPONSE_HELP) - { - prefs_dialog_show_help (dialog); - } -} - -void -prefs_clear_cache_button_clicked_cb (GtkWidget *button, - gpointer data) -{ - EphyEmbedShell *shell; - EphyEmbedSingle *single; - EphyFaviconCache *cache; - - shell = ephy_embed_shell_get_default (); - - single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (shell)); - ephy_embed_single_clear_cache (single); - - cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell)); - ephy_favicon_cache_clear (cache); -} - -static void -set_homepage_entry (EphyDialog *dialog, - const char *new_location) -{ - GValue value = { 0, }; - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, new_location); - ephy_dialog_set_value (dialog, properties[HOMEPAGE_ENTRY_PROP].id, &value); - g_value_unset (&value); -} - -void -prefs_homepage_current_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog) -{ - EphySession *session; - EphyWindow *window; - EphyTab *tab; - - session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ())); - window = ephy_session_get_active_window (session); - - /* can't do anything in this case */ - if (window == NULL) return; - - tab = ephy_window_get_active_tab (window); - g_return_if_fail (tab != NULL); - - set_homepage_entry (dialog, ephy_tab_get_address (tab)); -} - -void -prefs_homepage_blank_button_clicked_cb (GtkWidget *button, - EphyDialog *dialog) -{ - set_homepage_entry (dialog, NULL); -} |