aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-10-27 04:02:22 +0800
committerChristian Persch <chpe@src.gnome.org>2004-10-27 04:02:22 +0800
commite254f96f141f66bd7669426d3a8543047d734bfa (patch)
tree35d93f1b6a42509fbcc3886a46bec12248ceab56 /src
parentc463cbf5210374398fd6897eedbc2b3b2c2578f6 (diff)
downloadgsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar.gz
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar.bz2
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar.lz
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar.xz
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.tar.zst
gsoc2013-epiphany-e254f96f141f66bd7669426d3a8543047d734bfa.zip
Use new gtk+ HIG message dialogue API. Fixes bug #130232.
2004-10-26 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-gui.c: (ephy_gui_confirm_overwrite_file): * src/bookmarks/ephy-new-bookmark.c: (duplicate_dialog_construct): * src/ephy-history-window.c: (confirmation_dialog_response_cb), (confirmation_dialog_construct), (cmd_clear): * src/ephy-session.c: (offer_to_resume): * src/ephy-window.c: (confirm_close_with_modified_forms): Use new gtk+ HIG message dialogue API. Fixes bug #130232.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-new-bookmark.c67
-rw-r--r--src/ephy-history-window.c113
-rw-r--r--src/ephy-session.c76
-rw-r--r--src/ephy-window.c60
4 files changed, 87 insertions, 229 deletions
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index 9592f686e..1b37f6fa5 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -22,6 +22,13 @@
#include "config.h"
#endif
+#include "ephy-new-bookmark.h"
+#include "ephy-state.h"
+#include "ephy-topics-selector.h"
+#include "ephy-debug.h"
+#include "ephy-stock-icons.h"
+#include "ephy-gui.h"
+
#include <gtk/gtktable.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkentry.h>
@@ -31,16 +38,11 @@
#include <gtk/gtkimage.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkeditable.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkmessagedialog.h>
#include <glib/gi18n.h>
#include <string.h>
-#include "ephy-new-bookmark.h"
-#include "ephy-state.h"
-#include "ephy-topics-selector.h"
-#include "ephy-debug.h"
-#include "ephy-stock-icons.h"
-#include "ephy-gui.h"
-
static void ephy_new_bookmark_class_init (EphyNewBookmarkClass *klass);
static void ephy_new_bookmark_init (EphyNewBookmark *editor);
static void ephy_new_bookmark_finalize (GObject *object);
@@ -304,55 +306,20 @@ duplicate_dialog_construct (GtkWindow *parent,
const char *title)
{
GtkWidget *dialog;
- GtkWidget *hbox, *vbox, *label, *image;
char *str, *tmp_str, *tmp_title;
- /* FIXME: We "should" use gtk_message dialog here
- * but it doesn't support markup of text yet
- * so we build our own. See bug 65501.
- */
-
- dialog = gtk_dialog_new_with_buttons (_("Duplicated Bookmark"),
- GTK_WINDOW (parent),
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
-
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
tmp_title = g_markup_printf_escaped ("<b>%s</b>", title);
tmp_str = g_strdup_printf (_("A bookmark titled %s already exists for this page."),
- tmp_title);
+ tmp_title);
str = g_strconcat ("<big>", tmp_str, "</big>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- g_free (tmp_title);
- g_free (tmp_str);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_INFO, GTK_BUTTONS_OK, NULL);
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str);
g_free (str);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Duplicated Bookmark"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
return dialog;
}
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index bfcb06a50..303ebc3a7 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -41,6 +41,8 @@
#include <gtk/gtkcombobox.h>
#include <gtk/gtkuimanager.h>
#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkmessagedialog.h>
#include <glib/gi18n.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <string.h>
@@ -226,99 +228,42 @@ static GtkRadioActionEntry ephy_history_radio_entries [] =
};
static guint ephy_history_n_radio_entries = G_N_ELEMENTS (ephy_history_radio_entries);
-
static void
-confirmation_dialog_response_cb (GtkDialog *dialog, gint response,
+confirmation_dialog_response_cb (GtkWidget *dialog,
+ int response,
EphyHistoryWindow *editor)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- if (response != GTK_RESPONSE_OK)
- return;
+ gtk_widget_destroy (dialog);
- ephy_history_clear (editor->priv->history);
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ ephy_history_clear (editor->priv->history);
+ }
}
static GtkWidget *
confirmation_dialog_construct (EphyHistoryWindow *editor)
{
GtkWidget *dialog;
- GtkWidget *label;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *image;
- GtkWidget *button;
- GtkWidget *align;
- char *str;
-
- dialog = gtk_dialog_new_with_buttons (_("Clear History"),
- GTK_WINDOW (editor),
- GTK_DIALOG_DESTROY_WITH_PARENT |
- GTK_DIALOG_NO_SEPARATOR,
- NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- button = gtk_button_new ();
- gtk_widget_show (button);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_widget_show (align);
- gtk_container_add (GTK_CONTAINER (button), align);
-
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_widget_show (hbox);
- gtk_container_add (GTK_CONTAINER (align), hbox);
-
- image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
- label = gtk_label_new_with_mnemonic (_("C_lear"));
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- str = g_strconcat ("<b><big>", _("Clear browsing history?"),
- "</big></b>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- g_free (str);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
-
- label = gtk_label_new (_("Clearing the browsing history will cause all"
- " history links to be permanently deleted."));
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
+ dialog = gtk_message_dialog_new
+ (GTK_WINDOW (editor),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("Clear browsing history?"));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("Clearing the browsing history will cause all"
+ " history links to be permanently deleted."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("C_lear"), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Clear History"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
g_signal_connect (dialog, "response",
G_CALLBACK (confirmation_dialog_response_cb),
@@ -334,8 +279,8 @@ cmd_clear (GtkAction *action,
if (editor->priv->confirmation_dialog == NULL)
{
editor->priv->confirmation_dialog = confirmation_dialog_construct (editor);
- g_object_add_weak_pointer (G_OBJECT(editor->priv->confirmation_dialog),
- (gpointer *)&editor->priv->confirmation_dialog);
+ g_object_add_weak_pointer (G_OBJECT (editor->priv->confirmation_dialog),
+ (gpointer *) &editor->priv->confirmation_dialog);
}
gtk_widget_show (editor->priv->confirmation_dialog);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 9a857ab83..42a6b8af5 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -39,12 +39,13 @@
#include <glib/gi18n.h>
#include <string.h>
-#include <gtk/gtkdialog.h>
#include <gtk/gtkimage.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkmessagedialog.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
@@ -365,60 +366,29 @@ static gboolean
offer_to_resume (EphySession *session)
{
GtkWidget *dialog;
- GtkWidget *label;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *image;
- char *str;
int response;
- dialog = gtk_dialog_new_with_buttons
- (_("Crash Recovery"), NULL,
- GTK_DIALOG_NO_SEPARATOR,
- _("_Don't Recover"), GTK_RESPONSE_CANCEL,
- _("_Recover"), GTK_RESPONSE_OK,
- NULL);
+ dialog = gtk_message_dialog_new
+ (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("Epiphany appears to have crashed or been killed the last time it was run."));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("You can recover the opened tabs and windows."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Don't Recover"), GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Recover"), GTK_RESPONSE_ACCEPT);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Crash Recovery"));
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
session->priv->resume_dialog = dialog;
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (hbox)), 5);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image,
- TRUE, TRUE, 0);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox,
- TRUE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_widget_show (label);
- str = g_strconcat ("<b>", _("Epiphany appears to have crashed or been killed the last time it was run."),
- "</b>", NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- g_free (str);
-
- label = gtk_label_new (_("You can recover the opened tabs and windows."));
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (vbox), label,
- TRUE, TRUE, 0);
response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -426,7 +396,7 @@ offer_to_resume (EphySession *session)
session->priv->resume_dialog = NULL;
- return (response == GTK_RESPONSE_OK);
+ return (response == GTK_RESPONSE_ACCEPT);
}
/**
diff --git a/src/ephy-window.c b/src/ephy-window.c
index fd683a529..fc7a6aa37 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -668,57 +668,33 @@ static gboolean
confirm_close_with_modified_forms (EphyWindow *window)
{
GtkWidget *dialog;
- GtkWidget *hbox, *vbox, *label, *image;
- char *text;
int response;
- dialog = gtk_dialog_new_with_buttons ("",
- GTK_WINDOW (window),
- GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("Close _Document"), GTK_RESPONSE_OK,
- NULL);
-
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
-
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ dialog = gtk_message_dialog_new
+ (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ _("There are unsubmitted changes to form elements."));
+
+ gtk_message_dialog_format_secondary_text
+ (GTK_MESSAGE_DIALOG (dialog),
+ _("If you close the document anyway, "
+ "you will lose that information."));
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("Close _Document"), GTK_RESPONSE_ACCEPT);
- text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- _("There are unsubmitted changes to form elements."),
- _("If you close the document anyway, you will lose that information."));
- gtk_label_set_markup (GTK_LABEL (label), text);
- g_free (text);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
- gtk_widget_show (label);
+ /* FIXME set title */
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
- return response == GTK_RESPONSE_OK;
+ return response == GTK_RESPONSE_ACCEPT;
}
static void