diff options
author | David Bordoley <bordoley@msu.edu> | 2003-04-26 00:31:05 +0800 |
---|---|---|
committer | Dave Bordoley <Bordoley@src.gnome.org> | 2003-04-26 00:31:05 +0800 |
commit | e22d66b927f60c384f96c47aa5d4519ceb4f9c47 (patch) | |
tree | 0390a6dcd3e6e35385c310f2bf9058c40894f113 | |
parent | 98f768009939e3b06f2777ccb4307245f0637f36 (diff) | |
download | gsoc2013-epiphany-e22d66b927f60c384f96c47aa5d4519ceb4f9c47.tar.gz gsoc2013-epiphany-e22d66b927f60c384f96c47aa5d4519ceb4f9c47.tar.zst gsoc2013-epiphany-e22d66b927f60c384f96c47aa5d4519ceb4f9c47.zip |
Hookup to the response signal instead of using gtk_dialog_run. Prevents us
2003-04-25 David Bordoley <bordoley@msu.edu>
* src/ephy-history-window.c: (cmd_bookmark_page):
* src/popup-commands.c: (popup_cmd_bookmark_link):
* src/window-commands.c: (window_cmd_file_bookmark_page):
Hookup to the response signal instead of using gtk_dialog_run.
Prevents us from going modal.
* src/bookmarks/ephy-new-bookmark.c: (response_cb),
(ephy_new_bookmark_response_cb):
* src/bookmarks/ephy-new-bookmark.h
Add a convenience callback function, that callers can
use to destroy the dialog after a response.
* src/ephy-shell.c: (ephy_shell_command_cb):
Use a callback to the gtk_widget_destroy on the "response"
signal instead of using gtk_dialog_run. eg. don't go modal.
Some code cleanups too.
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | src/bookmarks/ephy-new-bookmark.c | 23 | ||||
-rw-r--r-- | src/bookmarks/ephy-new-bookmark.h | 6 | ||||
-rw-r--r-- | src/ephy-history-window.c | 6 | ||||
-rw-r--r-- | src/ephy-shell.c | 72 | ||||
-rw-r--r-- | src/popup-commands.c | 6 | ||||
-rw-r--r-- | src/window-commands.c | 6 |
7 files changed, 89 insertions, 52 deletions
@@ -1,3 +1,25 @@ +2003-04-25 David Bordoley <bordoley@msu.edu> + + * src/ephy-history-window.c: (cmd_bookmark_page): + * src/popup-commands.c: (popup_cmd_bookmark_link): + * src/window-commands.c: (window_cmd_file_bookmark_page): + + Hookup to the response signal instead of using gtk_dialog_run. + Prevents us from going modal. + + * src/bookmarks/ephy-new-bookmark.c: (response_cb), + (ephy_new_bookmark_response_cb): + * src/bookmarks/ephy-new-bookmark.h + + Add a convenience callback function, that callers can + use to destroy the dialog after a response. + + * src/ephy-shell.c: (ephy_shell_command_cb): + + Use a callback to the gtk_widget_destroy on the "response" + signal instead of using gtk_dialog_run. eg. don't go modal. + Some code cleanups too. + 2003-04-25 Xan Lopez <xan@masilla.org> * lib/ephy-node.c: (ephy_node_class_init), (ephy_node_has_child), diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c index e3a50f3a5..6394a308f 100644 --- a/src/bookmarks/ephy-new-bookmark.c +++ b/src/bookmarks/ephy-new-bookmark.c @@ -177,9 +177,9 @@ ephy_new_bookmark_add (EphyNewBookmark *new_bookmark) } static void -ephy_new_bookmark_response_cb (GtkDialog *dialog, - int response_id, - EphyNewBookmark *new_bookmark) +response_cb (EphyNewBookmark *new_bookmark, + int response_id, + gpointer user_data) { switch (response_id) { @@ -270,7 +270,7 @@ ephy_new_bookmark_construct (EphyNewBookmark *editor) gtk_container_set_border_width (GTK_CONTAINER (editor), 6); g_signal_connect (G_OBJECT (editor), "response", - G_CALLBACK (ephy_new_bookmark_response_cb), + G_CALLBACK (response_cb), editor); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (editor)->vbox), 12); @@ -397,3 +397,18 @@ ephy_new_bookmark_get_id (EphyNewBookmark *bookmark) return bookmark->priv->id; } +/* Convenience function for callers */ + +void +ephy_new_bookmark_response_cb (EphyNewBookmark *bookmark, + int response_id, + gpointer user_data) +{ + switch (response_id) + { + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_OK: + gtk_widget_destroy (GTK_WIDGET (bookmark)); + break; + } +} diff --git a/src/bookmarks/ephy-new-bookmark.h b/src/bookmarks/ephy-new-bookmark.h index 7e351dc55..39c1f2f4a 100644 --- a/src/bookmarks/ephy-new-bookmark.h +++ b/src/bookmarks/ephy-new-bookmark.h @@ -65,6 +65,12 @@ void ephy_new_bookmark_set_smarturl (EphyNewBookmark *bookmark, gulong ephy_new_bookmark_get_id (EphyNewBookmark *bookmark); +/* Convenience function for callers */ + +void ephy_new_bookmark_response_cb (EphyNewBookmark *bookmark, + int response_id, + gpointer user_data); + G_END_DECLS diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index dcbaf2e89..cb6fc9a27 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -378,8 +378,10 @@ cmd_bookmark_page (EggAction *action, (bookmarks, window, location); ephy_new_bookmark_set_title (EPHY_NEW_BOOKMARK (new_bookmark), title); - gtk_dialog_run (GTK_DIALOG (new_bookmark)); - gtk_widget_destroy (new_bookmark); + g_signal_connect (G_OBJECT (new_bookmark), "response", + G_CALLBACK (ephy_new_bookmark_response_cb), + NULL); + gtk_widget_show (new_bookmark); } g_list_free (selection); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 2f21091ac..1975d0f7c 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -141,6 +141,9 @@ ephy_shell_command_cb (EphyEmbedShell *shell, { EphyBookmarks *bookmarks; GtkWidget *dialog; + const gchar *message = NULL; + GtkMessageType message_type = GTK_MESSAGE_INFO; + EphyWindow *window; bookmarks = ephy_shell_get_bookmarks (EPHY_SHELL (shell)); @@ -148,72 +151,42 @@ ephy_shell_command_cb (EphyEmbedShell *shell, { if (ephy_bookmarks_import_mozilla (bookmarks, param)) { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Mozilla bookmarks imported successfully.")); + message_type = GTK_MESSAGE_INFO; + message = _("Mozilla bookmarks imported successfully."); } else { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Importing Mozilla bookmarks failed.")); + message_type = GTK_MESSAGE_ERROR; + message = _("Importing Mozilla bookmarks failed."); } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); } else if (strcmp (command, "import-galeon-bookmarks") == 0) { if (ephy_bookmarks_import_xbel (bookmarks, param, _("Galeon"))) { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Galeon bookmarks imported successfully.")); + message_type = GTK_MESSAGE_INFO; + message = _("Galeon bookmarks imported successfully."); } else { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Importing Galeon bookmarks failed.")); + message_type = GTK_MESSAGE_ERROR; + message = _("Importing Galeon bookmarks failed."); } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); } else if (strcmp (command, "import-konqueror-bookmarks") == 0) { if (ephy_bookmarks_import_xbel (bookmarks, param, _("Konqueror"))) { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Konqueror bookmarks imported successfully.")); + message_type = GTK_MESSAGE_INFO; + message = _("Konqueror bookmarks imported successfully."); } else { - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Importing Konqueror bookmarks failed.")); + message_type = GTK_MESSAGE_ERROR; + message = _("Importing Konqueror bookmarks failed."); } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); } else if (strcmp (command, "configure-network") == 0) { @@ -221,6 +194,21 @@ ephy_shell_command_cb (EphyEmbedShell *shell, NULL, FALSE); } + + if (message != NULL) + { + window = ephy_shell_get_active_window (EPHY_SHELL (shell)); + dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GTK_DIALOG_DESTROY_WITH_PARENT, + message_type, + GTK_BUTTONS_OK, + message); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + g_signal_connect_swapped (G_OBJECT (dialog), "response", + G_CALLBACK (gtk_widget_destroy), + G_OBJECT (dialog)); + gtk_widget_show (dialog); + } } static void diff --git a/src/popup-commands.c b/src/popup-commands.c index 2e2bb9080..a32a33618 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -162,8 +162,10 @@ popup_cmd_bookmark_link (EggAction *action, (EPHY_NEW_BOOKMARK (new_bookmark), title); ephy_new_bookmark_set_smarturl (EPHY_NEW_BOOKMARK (new_bookmark), rel); - gtk_dialog_run (GTK_DIALOG (new_bookmark)); - gtk_widget_destroy (new_bookmark); + g_signal_connect (G_OBJECT (new_bookmark), "response", + G_CALLBACK (ephy_new_bookmark_response_cb), + NULL); + gtk_widget_show (new_bookmark); } void diff --git a/src/window-commands.c b/src/window-commands.c index 8e128e775..032ce0775 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -282,8 +282,10 @@ window_cmd_file_bookmark_page (EggAction *action, (EPHY_NEW_BOOKMARK (new_bookmark), title); ephy_new_bookmark_set_icon (EPHY_NEW_BOOKMARK (new_bookmark), icon); - gtk_dialog_run (GTK_DIALOG (new_bookmark)); - gtk_widget_destroy (new_bookmark); + g_signal_connect (G_OBJECT (new_bookmark), "response", + G_CALLBACK (ephy_new_bookmark_response_cb), + NULL); + gtk_widget_show (new_bookmark); } void |