From: Christian Dywan Date: Thu, 17 Jun 2010 18:03:11 +0000 (+0200) Subject: Refactor transferbar into MidoriTransferbar X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa08c4d1f9056eb2eae6321f228e62aa0dea758d;p=midori Refactor transferbar into MidoriTransferbar The transferbar is separated from the browser, albeit it is still created and filled from within the browser so it is not completely independent. The new class now keeps a list of TransferInfo items to keep track of transfers and queries the status from the download object. Destroying a button belonging to a transfer is connected to removing it from the list and cleaning up the info structure. Also the Clear button is updated from the destroy handler. --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index b3d8bce7..21708791 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -24,6 +24,7 @@ #include "midori-locationaction.h" #include "midori-searchaction.h" #include "midori-stock.h" +#include "midori-transferbar.h" #include "gtkiconentry.h" #include "marshal.h" @@ -86,7 +87,6 @@ struct _MidoriBrowser GtkWidget* statusbar; GtkWidget* statusbar_contents; GtkWidget* transferbar; - GtkWidget* transferbar_clear; GtkWidget* progressbar; gchar* statusbar_text; @@ -207,12 +207,6 @@ static void midori_browser_set_bookmarks (MidoriBrowser* browser, KatzeArray* bookmarks); -#if WEBKIT_CHECK_VERSION (1, 1, 3) -static void -midori_browser_add_download_item (MidoriBrowser* browser, - WebKitDownload* download); -#endif - GdkPixbuf* midori_search_action_get_icon (KatzeItem* item, GtkWidget* widget, @@ -230,6 +224,15 @@ _action_menus_activate_item_alt (GtkAction* action, static void midori_browser_add_speed_dial (MidoriBrowser* browser); +gboolean +midori_transferbar_confirm_delete (MidoriTransferbar* transferbar); + +#if WEBKIT_CHECK_VERSION (1, 1, 3) +void +midori_transferbar_add_download_item (MidoriTransferbar* transferbar, + WebKitDownload* download); +#endif + #define _action_by_name(brwsr, nme) \ gtk_action_group_get_action (brwsr->action_group, nme) #define _action_set_sensitive(brwsr, nme, snstv) \ @@ -1013,7 +1016,7 @@ midori_browser_prepare_download (MidoriBrowser* browser, } webkit_download_set_destination_uri (download, uri); - midori_browser_add_download_item (browser, download); + midori_transferbar_add_download_item (MIDORI_TRANSFERBAR (browser->transferbar), download); return TRUE; } #else @@ -1417,167 +1420,6 @@ midori_view_new_view_cb (GtkWidget* view, } #if WEBKIT_CHECK_VERSION (1, 1, 3) -static void -midori_browser_download_notify_progress_cb (WebKitDownload* download, - GParamSpec* pspec, - GtkWidget* progress) -{ - gchar* current; - gchar* total; - gchar* size_text; - gchar* text; - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), - webkit_download_get_progress (download)); - - current = g_format_size_for_display (webkit_download_get_current_size (download)); - total = g_format_size_for_display (webkit_download_get_total_size (download)); - size_text = g_strdup_printf (_("%s of %s"), current, total); - g_free (current); - g_free (total); - text = g_strdup_printf ("%s (%s)", - gtk_progress_bar_get_text (GTK_PROGRESS_BAR (progress)), - size_text); - gtk_widget_set_tooltip_text (progress, text); -} - -static void -midori_browser_download_notify_status_cb (WebKitDownload* download, - GParamSpec* pspec, - GtkWidget* button) -{ - GtkWidget* icon; - - switch (webkit_download_get_status (download)) - { - case WEBKIT_DOWNLOAD_STATUS_FINISHED: - { - MidoriBrowser* browser = midori_browser_get_for_widget (button); - - icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (button), icon); - if (g_object_get_data (G_OBJECT (download), "open-download")) - gtk_button_clicked (GTK_BUTTON (button)); - else - g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)), - "done", (void*)1); - - if (katze_object_get_boolean (browser->settings, "notify-transfer-completed")) - { - const gchar* uri = webkit_download_get_destination_uri (download); - gchar* path = soup_uri_decode (uri); - gchar* filename = g_strrstr (path, "/") + 1; - gchar* msg = g_strdup_printf ( - _("The file '%s' has been downloaded."), filename); - g_free (path); - - g_signal_emit (browser, signals[SEND_NOTIFICATION], 0, - _("Transfer completed"), msg); - - g_free (msg); - } - break; - } - case WEBKIT_DOWNLOAD_STATUS_CANCELLED: - case WEBKIT_DOWNLOAD_STATUS_ERROR: - icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (button), icon); - g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)), - "done", (void*)1); - break; - default: - break; - } -} - -static void -midori_browser_download_button_clicked_cb (GtkWidget* button, - WebKitDownload* download) -{ - MidoriBrowser* browser; - GList* buttons; - - browser = midori_browser_get_for_widget (button); - - switch (webkit_download_get_status (download)) - { - case WEBKIT_DOWNLOAD_STATUS_STARTED: - webkit_download_cancel (download); - g_object_set_data (G_OBJECT (gtk_widget_get_parent (button)), - "done", (void*)1); - break; - case WEBKIT_DOWNLOAD_STATUS_FINISHED: - { - const gchar* uri = webkit_download_get_destination_uri (download); - if (sokoke_show_uri (gtk_widget_get_screen (button), - uri, gtk_get_current_event_time (), NULL)) - gtk_widget_destroy (gtk_widget_get_parent (button)); - break; - } - case WEBKIT_DOWNLOAD_STATUS_CANCELLED: - gtk_widget_destroy (gtk_widget_get_parent (button)); - default: - break; - } - - buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar)); - if (g_list_length (buttons) == 1) - gtk_widget_hide (browser->transferbar_clear); - g_list_free (buttons); -} - -static void -midori_browser_add_download_item (MidoriBrowser* browser, - WebKitDownload* download) -{ - GtkWidget* box; - GtkWidget* icon; - GtkWidget* button; - GtkWidget* progress; - const gchar* uri; - gint width; - - box = gtk_hbox_new (FALSE, 0); - /* icon = gtk_image_new_from_stock (STOCK_TRANSFER, GTK_ICON_SIZE_MENU); - gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0); */ - progress = gtk_progress_bar_new (); - gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progress), - PANGO_ELLIPSIZE_MIDDLE); - if ((uri = webkit_download_get_destination_uri (download))) - { - gchar* path = soup_uri_decode (uri); - gchar* filename = g_strrstr (path, "/") + 1; - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename); - g_free (path); - } - else - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), - webkit_download_get_suggested_filename (download)); - sokoke_widget_get_text_size (progress, "M", &width, NULL); - gtk_widget_set_size_request (progress, width * 10, -1); - /* Avoid a bug in WebKit */ - if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_CREATED) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), - webkit_download_get_progress (download)); - gtk_box_pack_start (GTK_BOX (box), progress, FALSE, FALSE, 0); - icon = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU); - button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); - gtk_container_add (GTK_CONTAINER (button), icon); - gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); - gtk_widget_show_all (box); - gtk_box_pack_start (GTK_BOX (browser->transferbar), box, FALSE, FALSE, 0); - gtk_widget_show (browser->transferbar_clear); - - g_signal_connect (download, "notify::progress", - G_CALLBACK (midori_browser_download_notify_progress_cb), progress); - g_signal_connect (download, "notify::status", - G_CALLBACK (midori_browser_download_notify_status_cb), button); - g_signal_connect (button, "clicked", - G_CALLBACK (midori_browser_download_button_clicked_cb), download); -} - static void midori_view_download_save_as_response_cb (GtkWidget* dialog, @@ -1675,26 +1517,6 @@ midori_view_download_requested_cb (GtkWidget* view, } #endif -static void -midori_browser_transferbar_clear_clicked_cb (GtkWidget* button, - MidoriBrowser* browser) -{ - GList* buttons; - guint i; - GtkWidget* item; - - buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar)); - i = 0; - while ((item = g_list_nth_data (buttons, i++))) - if (g_object_get_data (G_OBJECT (item), "done")) - gtk_widget_destroy (item); - g_list_free (buttons); - buttons = gtk_container_get_children (GTK_CONTAINER (browser->transferbar)); - if (g_list_length (buttons) == 1) - gtk_widget_hide (browser->transferbar_clear); - g_list_free (buttons); -} - static void midori_view_search_text_cb (GtkWidget* view, gboolean found, @@ -1919,35 +1741,7 @@ 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; + return midori_transferbar_confirm_delete (MIDORI_TRANSFERBAR (browser->transferbar)); } static void @@ -6243,7 +6037,6 @@ midori_browser_init (MidoriBrowser* browser) GtkRcStyle* rcstyle; GtkWidget* label; GtkWidget* scrolled; - GtkWidget* icon; browser->settings = midori_web_settings_new (); browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY); @@ -6758,17 +6551,11 @@ midori_browser_init (MidoriBrowser* browser) gtk_box_pack_start (GTK_BOX (browser->statusbar_contents), browser->progressbar, FALSE, FALSE, 3); - browser->transferbar = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (browser->statusbar_contents), - browser->transferbar, FALSE, FALSE, 3); + browser->transferbar = g_object_new (MIDORI_TYPE_TRANSFERBAR, NULL); + gtk_box_pack_start (GTK_BOX (browser->statusbar_contents), browser->transferbar, FALSE, FALSE, 3); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->transferbar), FALSE); gtk_widget_show (browser->transferbar); - browser->transferbar_clear = gtk_button_new_with_label (_("Clear All")); - icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (browser->transferbar_clear), icon); - g_signal_connect (browser->transferbar_clear, "clicked", - G_CALLBACK (midori_browser_transferbar_clear_clicked_cb), browser); - gtk_box_pack_end (GTK_BOX (browser->transferbar), browser->transferbar_clear, - FALSE, FALSE, 0); + g_signal_connect (browser->statusbar, "button-press-event", G_CALLBACK (midori_browser_menu_button_press_event_cb), browser); diff --git a/midori/wscript_build b/midori/wscript_build index bb76c6f0..27de582b 100644 --- a/midori/wscript_build +++ b/midori/wscript_build @@ -11,8 +11,8 @@ libs = 'M UNIQUE LIBSOUP GMODULE GTHREAD LIBIDN GIO GTK SQLITE ' \ if progressive or Options.commands['check']: obj = bld.new_task_gen ('cc', 'staticlib') obj.target = 'midori-core' - obj.includes = '.. ../katze .' - obj.find_sources_in_dirs ('../katze . ../panels', excludes=['main.c']) + obj.includes = '.. ../katze . ../toolbars' + obj.find_sources_in_dirs ('../katze . ../panels ../toolbars', excludes=['main.c']) obj.uselib = libs obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal') obj.install_path = None diff --git a/po/POTFILES.in b/po/POTFILES.in index faa2a58d..3c47d866 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ midori/midori-view.c midori/midori-preferences.c midori/midori-searchaction.c midori/sokoke.c +toolbars/midori-transferbar.c panels/midori-bookmarks.c panels/midori-console.c panels/midori-extensions.c diff --git a/toolbars/midori-transferbar.c b/toolbars/midori-transferbar.c new file mode 100644 index 00000000..3309e892 --- /dev/null +++ b/toolbars/midori-transferbar.c @@ -0,0 +1,297 @@ +/* + Copyright (C) 2010 Christian Dywan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +#include "midori-transferbar.h" + +#include "midori-browser.h" +#include "sokoke.h" + +#include + +struct _MidoriTransferbar +{ + GtkToolbar parent_instance; + + GList* infos; + GtkToolItem* clear; +}; + +struct _MidoriTransferbarClass +{ + GtkToolbarClass parent_class; +}; + +G_DEFINE_TYPE (MidoriTransferbar, midori_transferbar, GTK_TYPE_TOOLBAR); + +static void +midori_transferbar_class_init (MidoriTransferbarClass* class) +{ + /* Nothing to do */ +} + +#if WEBKIT_CHECK_VERSION (1, 1, 3) +typedef struct +{ + WebKitDownload* download; + GtkWidget* button; + GtkWidget* toolitem; + MidoriTransferbar* transferbar; +} TransferInfo; + +static gboolean +midori_transferbar_info_free (gpointer data) +{ + TransferInfo* info = data; + MidoriTransferbar* transferbar = info->transferbar; + + transferbar->infos = g_list_remove (transferbar->infos, info); + g_object_unref (info->download); + gtk_widget_destroy (info->toolitem); + g_free (info); + + if (!transferbar->infos || !g_list_nth_data (transferbar->infos, 0)) + gtk_widget_hide (GTK_WIDGET (transferbar->clear)); + + return FALSE; +} + +static void +midori_transferbar_button_destroy_cb (GtkWidget* button, + TransferInfo* info) +{ + g_idle_add (midori_transferbar_info_free, info); +} + +static void +midori_transferbar_download_notify_progress_cb (WebKitDownload* download, + GParamSpec* pspec, + GtkWidget* progress) +{ + gchar* current; + gchar* total; + gchar* size_text; + gchar* text; + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), + webkit_download_get_progress (download)); + + current = g_format_size_for_display (webkit_download_get_current_size (download)); + total = g_format_size_for_display (webkit_download_get_total_size (download)); + size_text = g_strdup_printf (_("%s of %s"), current, total); + g_free (current); + g_free (total); + text = g_strdup_printf ("%s (%s)", + gtk_progress_bar_get_text (GTK_PROGRESS_BAR (progress)), + size_text); + gtk_widget_set_tooltip_text (progress, text); +} + +static void +midori_transferbar_download_notify_status_cb (WebKitDownload* download, + GParamSpec* pspec, + TransferInfo* info) +{ + GtkWidget* button = info->button; + GtkWidget* icon; + + switch (webkit_download_get_status (download)) + { + case WEBKIT_DOWNLOAD_STATUS_FINISHED: + { + MidoriBrowser* browser = midori_browser_get_for_widget (button); + MidoriWebSettings* settings = midori_browser_get_settings (browser); + + icon = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); + gtk_button_set_image (GTK_BUTTON (button), icon); + if (g_object_get_data (G_OBJECT (download), "open-download")) + gtk_button_clicked (GTK_BUTTON (button)); + + if (katze_object_get_boolean (settings, "notify-transfer-completed")) + { + const gchar* uri = webkit_download_get_destination_uri (download); + gchar* path = soup_uri_decode (uri); + gchar* filename = g_strrstr (path, "/") + 1; + gchar* msg = g_strdup_printf ( + _("The file '%s' has been downloaded."), filename); + g_free (path); + g_signal_emit_by_name (browser, "send-notification", + _("Transfer completed"), msg); + g_free (msg); + } + break; + } + case WEBKIT_DOWNLOAD_STATUS_CANCELLED: + case WEBKIT_DOWNLOAD_STATUS_ERROR: + icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU); + gtk_button_set_image (GTK_BUTTON (button), icon); + break; + default: + break; + } +} + +static void +midori_transferbar_download_button_clicked_cb (GtkWidget* button, + TransferInfo* info) +{ + WebKitDownload* download = info->download; + + switch (webkit_download_get_status (download)) + { + case WEBKIT_DOWNLOAD_STATUS_STARTED: + webkit_download_cancel (download); + break; + case WEBKIT_DOWNLOAD_STATUS_FINISHED: + { + const gchar* uri = webkit_download_get_destination_uri (download); + if (sokoke_show_uri (gtk_widget_get_screen (button), + uri, gtk_get_current_event_time (), NULL)) + gtk_widget_destroy (button); + break; + } + case WEBKIT_DOWNLOAD_STATUS_CANCELLED: + gtk_widget_destroy (button); + default: + break; + } +} + +void +midori_transferbar_add_download_item (MidoriTransferbar* transferbar, + WebKitDownload* download) +{ + GtkWidget* box; + GtkWidget* icon; + GtkToolItem* toolitem; + GtkWidget* button; + GtkWidget* progress; + const gchar* uri; + gint width; + TransferInfo* info; + + box = gtk_hbox_new (FALSE, 0); + progress = gtk_progress_bar_new (); + gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progress), + PANGO_ELLIPSIZE_MIDDLE); + if ((uri = webkit_download_get_destination_uri (download))) + { + gchar* path = soup_uri_decode (uri); + gchar* filename = g_strrstr (path, "/") + 1; + gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename); + g_free (path); + } + else + gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), + webkit_download_get_suggested_filename (download)); + sokoke_widget_get_text_size (progress, "M", &width, NULL); + gtk_widget_set_size_request (progress, width * 10, 1); + /* Avoid a bug in WebKit */ + if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_CREATED) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), + webkit_download_get_progress (download)); + gtk_box_pack_start (GTK_BOX (box), progress, FALSE, FALSE, 0); + icon = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_MENU); + button = gtk_button_new (); + gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); + gtk_container_add (GTK_CONTAINER (button), icon); + gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); + toolitem = gtk_tool_item_new (); + gtk_container_add (GTK_CONTAINER (toolitem), box); + gtk_widget_show_all (GTK_WIDGET (toolitem)); + gtk_toolbar_insert (GTK_TOOLBAR (transferbar), toolitem, 0); + gtk_widget_show (GTK_WIDGET (transferbar->clear)); + + info = g_new (TransferInfo, 1); + info->download = g_object_ref (download); + info->button = button; + info->toolitem = GTK_WIDGET (toolitem); + info->transferbar = transferbar; + g_signal_connect (button, "destroy", + G_CALLBACK (midori_transferbar_button_destroy_cb), info); + transferbar->infos = g_list_prepend (transferbar->infos, info); + + g_signal_connect (download, "notify::progress", + G_CALLBACK (midori_transferbar_download_notify_progress_cb), progress); + g_signal_connect (download, "notify::status", + G_CALLBACK (midori_transferbar_download_notify_status_cb), info); + g_signal_connect (button, "clicked", + G_CALLBACK (midori_transferbar_download_button_clicked_cb), info); +} + +static void +midori_transferbar_clear_clicked_cb (GtkWidget* button, + MidoriTransferbar* transferbar) +{ + GList* list; + + for (list = transferbar->infos; list != NULL; list = g_list_next (list)) + { + TransferInfo* info = list->data; + WebKitDownloadStatus status = webkit_download_get_status (info->download); + if (status == WEBKIT_DOWNLOAD_STATUS_ERROR + || status == WEBKIT_DOWNLOAD_STATUS_CANCELLED + || status == WEBKIT_DOWNLOAD_STATUS_FINISHED) + { + gtk_widget_destroy (info->button); + } + } +} +#endif + +static void +midori_transferbar_init (MidoriTransferbar* transferbar) +{ + gtk_toolbar_set_style (GTK_TOOLBAR (transferbar), GTK_TOOLBAR_BOTH_HORIZ); + gtk_toolbar_set_icon_size (GTK_TOOLBAR (transferbar), GTK_ICON_SIZE_MENU); + + transferbar->clear = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR); + gtk_tool_button_set_label (GTK_TOOL_BUTTON (transferbar->clear), _("Clear All")); + gtk_tool_item_set_is_important (transferbar->clear, TRUE); + g_signal_connect (transferbar->clear, "clicked", + G_CALLBACK (midori_transferbar_clear_clicked_cb), transferbar); + gtk_toolbar_insert (GTK_TOOLBAR (transferbar), transferbar->clear, -1); + + transferbar->infos = NULL; +} + +gboolean +midori_transferbar_confirm_delete (MidoriTransferbar* transferbar) +{ + GtkWidget* dialog = NULL; + gboolean cancel = FALSE; + + if (transferbar->infos || g_list_nth_data (transferbar->infos, 0)) + { + GtkWidget* widget = gtk_widget_get_toplevel (GTK_WIDGET (transferbar)); + 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.")); + } + if (dialog != NULL) + { + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) + cancel = TRUE; + gtk_widget_destroy (dialog); + } + + return cancel; +} + diff --git a/toolbars/midori-transferbar.h b/toolbars/midori-transferbar.h new file mode 100644 index 00000000..76e252b2 --- /dev/null +++ b/toolbars/midori-transferbar.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2010 Christian Dywan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +#ifndef __MIDORI_TRANSFERBAR_H__ +#define __MIDORI_TRANSFERBAR_H__ + +#include + +G_BEGIN_DECLS + +#define MIDORI_TYPE_TRANSFERBAR \ + (midori_transferbar_get_type ()) +#define MIDORI_TRANSFERBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbar)) +#define MIDORI_TRANSFERBAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbarClass)) +#define MIDORI_IS_TRANSFERBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_TRANSFERBAR)) +#define MIDORI_IS_TRANSFERBAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_TRANSFERBAR)) +#define MIDORI_TRANSFERBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_TRANSFERBAR, MidoriTransferbarClass)) + +typedef struct _MidoriTransferbar MidoriTransferbar; +typedef struct _MidoriTransferbarClass MidoriTransferbarClass; + +GType +midori_transferbar_get_type (void); + +G_END_DECLS + +#endif /* __MIDORI_TRANSFERBAR_H__ */