[Xfce4-commits] <midori:master> Show dialog if quitting while files are being downloaded
Christian Dywan
noreply at xfce.org
Sun May 23 01:10:02 CEST 2010
Updating branch refs/heads/master
to 8cb761239f85264d488eb0d04c37679e299e17ee (commit)
from 533db989d3e52fd7fb9143476be0e023663287f2 (commit)
commit 8cb761239f85264d488eb0d04c37679e299e17ee
Author: Christian Dywan <christian at twotoasts.de>
Date: Sat May 22 23:48:03 2010 +0200
Show dialog if quitting while files are being downloaded
midori/midori-browser.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index ad5e391..2bf7c97 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -1899,6 +1899,42 @@ midori_browser_key_press_event (GtkWidget* widget,
return widget_class->key_press_event (widget, event);
}
+static gboolean
+midori_browser_delete_event (GtkWidget* widget,
+ GdkEventAny* event)
+{
+ MidoriBrowser* browser = MIDORI_BROWSER (widget);
+ GList* children;
+ GtkWidget* dialog = NULL;
+ gboolean cancel = FALSE;
+
+ children = gtk_container_get_children (GTK_CONTAINER (browser->transferbar));
+ if (g_list_length (children) > 1)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
+ _("Some files are being downloaded"));
+ gtk_window_set_title (GTK_WINDOW (dialog),
+ _("Some files are being downloaded"));
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Quit Midori"), GTK_RESPONSE_ACCEPT);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("The transfers will be cancelled if Midori quits."));
+ }
+ g_list_free (children);
+ if (dialog != NULL)
+ {
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
+ cancel = TRUE;
+ gtk_widget_destroy (dialog);
+ }
+
+ return cancel;
+}
+
static void
midori_browser_class_init (MidoriBrowserClass* class)
{
@@ -2062,6 +2098,7 @@ midori_browser_class_init (MidoriBrowserClass* class)
gtkwidget_class = GTK_WIDGET_CLASS (class);
gtkwidget_class->key_press_event = midori_browser_key_press_event;
+ gtkwidget_class->delete_event = midori_browser_delete_event;
gobject_class = G_OBJECT_CLASS (class);
gobject_class->dispose = midori_browser_dispose;
More information about the Xfce4-commits
mailing list