[Xfce4-commits] <midori:master> Rewrite Transfers as an extension

Christian Dywan noreply at xfce.org
Tue Apr 23 01:02:01 CEST 2013


Updating branch refs/heads/master
         to 0154afe578459664641d75c92f262d53bb0e32b8 (commit)
       from f76ad33e2499014af95c08f74f8217465368c9eb (commit)

commit 0154afe578459664641d75c92f262d53bb0e32b8
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Apr 23 00:45:42 2013 +0200

    Rewrite Transfers as an extension

 extensions/transfers.vala     |  488 +++++++++++++++++++++++++++++++++++++
 katze/katze.vapi              |    2 +
 midori/midori-app.c           |    2 +-
 midori/midori-browser.c       |   37 +---
 midori/midori-frontend.c      |    4 -
 midori/midori-stock.h         |    2 +-
 midori/midori-view.c          |    4 +-
 midori/midori.vapi            |    4 +
 panels/midori-transfers.c     |  539 -----------------------------------------
 panels/midori-transfers.h     |   43 ----
 po/POTFILES.in                |    3 +-
 toolbars/midori-transferbar.c |  296 ----------------------
 toolbars/midori-transferbar.h |   40 ---
 13 files changed, 500 insertions(+), 964 deletions(-)

diff --git a/extensions/transfers.vala b/extensions/transfers.vala
new file mode 100644
index 0000000..9d4d7c7
--- /dev/null
+++ b/extensions/transfers.vala
@@ -0,0 +1,488 @@
+/*
+   Copyright (C) 2009-2013 Christian Dywan <christian at twotoasts.de>
+
+   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.
+*/
+
+namespace Gtk {
+    extern static void widget_size_request (Gtk.Widget widget, out Gtk.Requisition requisition);
+}
+
+namespace Sokoke {
+    extern static bool show_uri (Gdk.Screen screen, string uri, uint32 timestamp) throws Error;
+    extern static void widget_get_text_size (Gtk.Widget widget, string sample, out int width, out int height);
+}
+
+namespace Transfers {
+    private class Transfer : GLib.Object {
+        internal WebKit.Download download;
+
+        internal signal void changed ();
+        internal signal void remove ();
+        internal signal void removed ();
+
+        internal Transfer (WebKit.Download download) {
+            this.download = download;
+            download.notify["status"].connect (transfer_changed);
+            download.notify["progress"].connect (transfer_changed);
+        }
+
+        void transfer_changed (GLib.ParamSpec pspec) {
+            changed ();
+        }
+    }
+
+    private class Sidebar : Gtk.VBox, Midori.Viewable {
+        Gtk.Toolbar? toolbar = null;
+        Gtk.ToolButton clear;
+        Gtk.ListStore store = new Gtk.ListStore (1, typeof (Transfer));
+        Gtk.TreeView treeview;
+        Katze.Array array;
+
+        public unowned string get_stock_id () {
+            return Midori.Stock.TRANSFER;
+        }
+
+        public unowned string get_label () {
+            return _("Transfers");
+        }
+
+        public Gtk.Widget get_toolbar () {
+            if (toolbar == null) {
+                toolbar = new Gtk.Toolbar ();
+                toolbar.set_icon_size (Gtk.IconSize.BUTTON);
+                toolbar.insert (new Gtk.ToolItem (), -1);
+                var separator = new Gtk.SeparatorToolItem ();
+                separator.draw = false;
+                separator.set_expand (true);
+                toolbar.insert (separator, -1);
+                clear = new Gtk.ToolButton.from_stock (Gtk.STOCK_CLEAR);
+                clear.label = _("Clear All");
+                clear.is_important = true;
+                clear.clicked.connect (clear_clicked);
+                clear.sensitive = !array.is_empty ();
+                toolbar.insert (clear, -1);
+                toolbar.show_all ();
+            }
+            return toolbar;
+        }
+
+        void clear_clicked () {
+            foreach (GLib.Object item in array.get_items ()) {
+                var transfer = item as Transfer;
+                if (Midori.Download.is_finished (transfer.download))
+                    transfer.remove ();
+            }
+        }
+
+        public Sidebar (Katze.Array array) {
+            Gtk.TreeViewColumn column;
+
+            treeview = new Gtk.TreeView.with_model (store);
+            treeview.headers_visible = false;
+
+            store.set_sort_column_id (0, Gtk.SortType.ASCENDING);
+            store.set_sort_func (0, tree_sort_func);
+
+            column = new Gtk.TreeViewColumn ();
+            Gtk.CellRendererPixbuf renderer_icon = new Gtk.CellRendererPixbuf ();
+            column.pack_start (renderer_icon, false);
+            column.set_cell_data_func (renderer_icon, on_render_icon);
+            treeview.append_column (column);
+
+            column = new Gtk.TreeViewColumn ();
+            column.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
+            Gtk.CellRendererProgress renderer_progress = new Gtk.CellRendererProgress ();
+            column.pack_start (renderer_progress, true);
+            column.set_expand (true);
+            column.set_cell_data_func (renderer_progress, on_render_text);
+            treeview.append_column (column);
+
+            column = new Gtk.TreeViewColumn ();
+            Gtk.CellRendererPixbuf renderer_button = new Gtk.CellRendererPixbuf ();
+            column.pack_start (renderer_button, false);
+            column.set_cell_data_func (renderer_button, on_render_button);
+            treeview.append_column (column);
+
+            treeview.row_activated.connect (row_activated);
+            treeview.button_release_event.connect (button_released);
+            treeview.popup_menu.connect (menu_popup);
+            treeview.show ();
+            pack_start (treeview, true, true, 0);
+
+            this.array = array;
+            array.add_item.connect (transfer_added);
+            array.remove_item.connect_after (transfer_removed);
+            foreach (GLib.Object item in array.get_items ())
+                transfer_added (item);
+        }
+
+        void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
+            Gtk.TreeIter iter;
+            if (store.get_iter (out iter, path)) {
+                Transfer transfer;
+                store.get (iter, 0, out transfer);
+
+                if (Midori.Download.action_clear (transfer.download, treeview))
+                    transfer.remove ();
+            }
+        }
+
+        bool button_released (Gdk.EventButton event) {
+            if (event.button == 3)
+                return show_popup_menu (event);
+            return false;
+        }
+
+        bool menu_popup () {
+            return show_popup_menu (null);
+        }
+
+        bool show_popup_menu (Gdk.EventButton? event) {
+            Gtk.TreeIter iter;
+            if (treeview.get_selection ().get_selected (null, out iter)) {
+                Transfer transfer;
+                store.get (iter, 0, out transfer);
+
+                bool finished = transfer.download.status == WebKit.DownloadStatus.FINISHED;
+                var menu = new Gtk.Menu ();
+                var menuitem = new Gtk.ImageMenuItem.from_stock (Gtk.STOCK_OPEN, null);
+                menuitem.activate.connect (() => {
+                    Midori.Download.open (transfer.download, treeview);
+                });
+                menuitem.sensitive = finished;
+                menu.append (menuitem);
+                menuitem = new Gtk.ImageMenuItem.with_mnemonic (_("Open Destination _Folder"));
+                menuitem.image = new Gtk.Image.from_stock (Gtk.STOCK_DIRECTORY, Gtk.IconSize.MENU);
+                menuitem.activate.connect (() => {
+                    var folder = GLib.File.new_for_uri (transfer.download.destination_uri);
+                    Sokoke.show_uri (get_screen (), folder.get_parent ().get_uri (), 0);
+                });
+                menu.append (menuitem);
+                menuitem = new Gtk.ImageMenuItem.with_mnemonic (_("Copy Link Loc_ation"));
+                menuitem.activate.connect (() => {
+                    string uri = transfer.download.destination_uri;
+                    get_clipboard (Gdk.SELECTION_PRIMARY).set_text (uri, -1);
+                    get_clipboard (Gdk.SELECTION_CLIPBOARD).set_text (uri, -1);
+                });
+                menuitem.image = new Gtk.Image.from_stock (Gtk.STOCK_COPY, Gtk.IconSize.MENU);
+                menu.append (menuitem);
+                menu.show_all ();
+                // Katze.widget_popup (treeview, menu, null, Katze.MenuPosition.CURSOR);
+                menu.popup (null, null, null, event != null ? event.button : 0, event != null ? event.time : 0);
+
+                return true;
+            }
+            return false;
+        }
+
+        int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
+            Transfer transfer1, transfer2;
+            model.get (a, 0, out transfer1);
+            model.get (b, 0, out transfer2);
+            return transfer1.download.status - transfer2.download.status;
+        }
+
+        void transfer_changed () {
+            treeview.queue_draw ();
+        }
+
+        void transfer_added (GLib.Object item) {
+            var transfer = item as Transfer;
+            Gtk.TreeIter iter;
+            store.append (out iter);
+            store.set (iter, 0, transfer);
+            transfer.changed.connect (transfer_changed);
+            clear.sensitive = true;
+        }
+
+        void transfer_removed (GLib.Object item) {
+            var transfer = item as Transfer;
+            transfer.changed.disconnect (transfer_changed);
+            Gtk.TreeIter iter;
+            if (store.iter_children (out iter, null)) {
+                do {
+                    Transfer found;
+                    store.get (iter, 0, out found);
+                    if (transfer == found) {
+                        store.remove (iter);
+                        break;
+                    }
+                } while (store.iter_next (ref iter));
+            }
+            if (array.is_empty ())
+                clear.sensitive = false;
+        }
+
+        void on_render_icon (Gtk.CellLayout column, Gtk.CellRenderer renderer,
+            Gtk.TreeModel model, Gtk.TreeIter iter) {
+
+            Transfer transfer;
+            model.get (iter, 0, out transfer);
+            string content_type = Midori.Download.get_content_type (transfer.download, null);
+            var icon = GLib.ContentType.get_icon (content_type) as ThemedIcon;
+            icon.append_name ("text-html");
+            renderer.set ("gicon", icon,
+                          "stock-size", Gtk.IconSize.DND,
+                          "xpad", 1, "ypad", 12);
+        }
+
+        void on_render_text (Gtk.CellLayout column, Gtk.CellRenderer renderer,
+            Gtk.TreeModel model, Gtk.TreeIter iter) {
+
+            Transfer transfer;
+            model.get (iter, 0, out transfer);
+            string tooltip = Midori.Download.get_tooltip (transfer.download);
+            double progress = Midori.Download.get_progress (transfer.download);
+            renderer.set ("text", tooltip,
+                          "value", (int)(progress * 100));
+        }
+
+        void on_render_button (Gtk.CellLayout column, Gtk.CellRenderer renderer,
+            Gtk.TreeModel model, Gtk.TreeIter iter) {
+
+            Transfer transfer;
+            model.get (iter, 0, out transfer);
+            string stock_id = Midori.Download.action_stock_id (transfer.download);
+            renderer.set ("stock-id", stock_id,
+                          "stock-size", Gtk.IconSize.MENU);
+        }
+    }
+
+    private class TransferButton : Gtk.ToolItem {
+        Transfer transfer;
+        Gtk.ProgressBar progress;
+        Gtk.Image icon;
+        Gtk.Button button;
+
+        public TransferButton (Transfer transfer) {
+            this.transfer = transfer;
+
+            var box = new Gtk.HBox (false, 0);
+            progress = new Gtk.ProgressBar ();
+#if HAVE_GTK3
+            progress.show_text = true;
+#endif
+            progress.ellipsize = Pango.EllipsizeMode.MIDDLE;
+            string filename = Path.get_basename (transfer.download.destination_uri);
+            progress.text = filename;
+            int width;
+            Sokoke.widget_get_text_size (progress, "M", out width, null);
+            progress.set_size_request (width * 10, 1);
+            box.pack_start (progress, false, false, 0);
+
+            icon = new Gtk.Image ();
+            button = new Gtk.Button ();
+            button.relief = Gtk.ReliefStyle.NONE;
+            button.focus_on_click = false;
+            button.clicked.connect (button_clicked);
+            button.add (icon);
+            box.pack_start (button, false, false, 0);
+
+            add (box);
+            show_all ();
+
+            transfer.changed.connect (transfer_changed);
+            transfer_changed ();
+            transfer.removed.connect (transfer_removed);
+        }
+
+        void button_clicked () {
+            if (Midori.Download.action_clear (transfer.download, button))
+                transfer.remove ();
+        }
+
+        void transfer_changed () {
+            progress.fraction = Midori.Download.get_progress (transfer.download);
+            progress.tooltip_text = Midori.Download.get_tooltip (transfer.download);
+            string stock_id = Midori.Download.action_stock_id (transfer.download);
+            icon.set_from_stock (stock_id, Gtk.IconSize.MENU);
+        }
+
+        void transfer_removed () {
+            destroy ();
+        }
+    }
+
+    private class Toolbar : Gtk.Toolbar {
+        Katze.Array array;
+        Gtk.ToolButton clear;
+
+        void clear_clicked () {
+            foreach (GLib.Object item in array.get_items ()) {
+                var transfer = item as Transfer;
+                if (Midori.Download.is_finished (transfer.download))
+                    array.remove_item (item);
+            }
+        }
+
+        public Toolbar (Katze.Array array) {
+            set_icon_size (Gtk.IconSize.BUTTON);
+            set_style (Gtk.ToolbarStyle.BOTH_HORIZ);
+            show_arrow = false;
+
+            clear = new Gtk.ToolButton.from_stock (Gtk.STOCK_CLEAR);
+            clear.label = _("Clear All");
+            clear.is_important = true;
+            clear.clicked.connect (clear_clicked);
+            clear.sensitive = !array.is_empty ();
+            insert (clear, -1);
+            show_all ();
+
+            this.array = array;
+            array.add_item.connect (transfer_added);
+            array.remove_item.connect_after (transfer_removed);
+            foreach (GLib.Object item in array.get_items ())
+                transfer_added (item);
+        }
+
+        void transfer_added (GLib.Object item) {
+            var transfer = item as Transfer;
+            insert (new TransferButton (transfer), -1);
+            clear.sensitive = true;
+
+            Gtk.Requisition req;
+            Gtk.widget_size_request (parent, out req);
+            int reqwidth = req.width;
+            int winwidth;
+            (get_toplevel () as Gtk.Window).get_size (out winwidth, null);
+            if (reqwidth > winwidth)
+                clear_clicked ();
+        }
+
+        void transfer_removed (GLib.Object item) {
+            if (array.is_empty ())
+                clear.sensitive = false;
+        }
+    }
+
+    private class Manager : Midori.Extension {
+        internal Katze.Array array;
+        internal GLib.List<Gtk.Widget> widgets;
+
+        void download_added (WebKit.Download download) {
+            var transfer = new Transfer (download);
+            transfer.remove.connect (transfer_remove);
+            transfer.changed.connect (transfer_changed);
+            array.remove_item.connect (transfer_removed);
+            array.add_item (transfer);
+        }
+
+        void transfer_changed (Transfer transfer) {
+            if (transfer.download.get_status () == WebKit.DownloadStatus.FINISHED) {
+                /* FIXME: The following 2 blocks ought to be done in core */
+                var type = Midori.Download.get_type (transfer.download);
+                if (type == Midori.DownloadType.OPEN) {
+                    if (Midori.Download.action_clear (transfer.download, widgets.nth_data (0)))
+                        transfer.remove ();
+                }
+
+                string uri = transfer.download.destination_uri;
+                string filename = Path.get_basename (uri);
+                var item = new Katze.Item ();
+                item.uri = uri;
+                item.name = filename;
+                Midori.Browser.update_history (item, "download", "create");
+                if (!Midori.Download.has_wrong_checksum (transfer.download))
+                    Gtk.RecentManager.get_default ().add_item (uri);
+
+                string msg = _("The file '<b>%s</b>' has been downloaded.").printf (filename);
+                get_app ().send_notification (_("Transfer completed"), msg);
+            }
+        }
+
+        void transfer_remove (Transfer transfer) {
+            array.remove_item (transfer);
+        }
+
+        void transfer_removed (GLib.Object item) {
+            var transfer = item as Transfer;
+            transfer.removed ();
+        }
+
+        bool browser_closed (Gtk.Widget widget, Gdk.EventAny event) {
+            var browser = widget as Midori.Browser;
+            bool pending_downloads = false;
+            foreach (GLib.Object item in array.get_items ()) {
+                var transfer = item as Transfer;
+                if (!Midori.Download.is_finished (transfer.download)) {
+                    pending_downloads = true;
+                    break;
+                }
+            }
+            if (pending_downloads) {
+                var dialog = new Gtk.MessageDialog (browser,
+                    Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                    Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
+                    _("Some files are being downloaded"));
+                dialog.title = _("Some files are being downloaded");
+                dialog.add_buttons (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+                                    _("_Quit Midori"), Gtk.ResponseType.ACCEPT);
+                dialog.format_secondary_text (
+                    _("The transfers will be cancelled if Midori quits."));
+                bool cancel = dialog.run () != Gtk.ResponseType.ACCEPT;
+                dialog.destroy ();
+                return cancel;
+            }
+            return false;
+        }
+
+        void browser_added (Midori.Browser browser) {
+            var viewable = new Sidebar (array);
+            viewable.show ();
+            browser.panel.append_page (viewable);
+            widgets.append (viewable);
+            var toolbar = new Toolbar (array);
+#if HAVE_GTK3
+            browser.statusbar.pack_end (toolbar);
+#else
+            browser.statusbar.pack_start (toolbar);
+#endif
+            widgets.append (toolbar);
+            // TODO: popover
+            // TODO: progress in dock item
+            browser.add_download.connect (download_added);
+            browser.delete_event.connect (browser_closed);
+        }
+
+        void activated (Midori.App app) {
+            array = new Katze.Array (typeof (Transfer));
+            widgets = new GLib.List<Gtk.Widget> ();
+            foreach (var browser in app.get_browsers ())
+                browser_added (browser);
+            app.add_browser.connect (browser_added);
+        }
+
+        void deactivated () {
+            var app = get_app ();
+            app.add_browser.disconnect (browser_added);
+            foreach (var browser in app.get_browsers ()) {
+                browser.add_download.disconnect (download_added);
+                browser.delete_event.disconnect (browser_closed);
+            }
+            foreach (var widget in widgets)
+                widget.destroy ();
+            array.remove_item.disconnect (transfer_removed);
+        }
+
+        internal Manager () {
+            GLib.Object (name: _("Transfer Manager"),
+                         description: _("View downloaded files"),
+                         version: "0.1" + Midori.VERSION_SUFFIX,
+                         authors: "Christian Dywan <christian at twotoasts.de>");
+
+            this.activate.connect (activated);
+            this.deactivate.connect (deactivated);
+        }
+    }
+}
+
+public Midori.Extension extension_init () {
+    return new Transfers.Manager ();
+}
+
diff --git a/katze/katze.vapi b/katze/katze.vapi
index 776b06f..79ee32c 100644
--- a/katze/katze.vapi
+++ b/katze/katze.vapi
@@ -13,10 +13,12 @@ namespace Katze {
         public signal void remove_item (GLib.Object item);
         public uint get_length ();
         public GLib.List<unowned Item> get_items ();
+        public bool is_empty ();
     }
 
     [CCode (cheader_filename = "katze/katze.h")]
     public class Item : GLib.Object {
+        public Item ();
         public string? uri { get; set; }
         public string? name { get; set; }
         public string? text { get; set; }
diff --git a/midori/midori-app.c b/midori/midori-app.c
index cf59605..f25c78a 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -1364,7 +1364,7 @@ midori_app_setup (gint               *argc,
         { STOCK_SCRIPT,       N_("_Userscripts") },
         { STOCK_STYLE,        N_("User_styles") },
         { STOCK_TAB_NEW,      N_("New _Tab") },
-        { STOCK_TRANSFER,     N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J },
+        { MIDORI_STOCK_TRANSFER,     N_("_Transfers"), GDK_CONTROL_MASK | GDK_SHIFT_MASK, GDK_KEY_J },
         { MIDORI_STOCK_PLUGINS,      N_("Netscape p_lugins") },
         { STOCK_USER_TRASH,   N_("_Closed Tabs") },
         { STOCK_WINDOW_NEW,   N_("New _Window") },
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 4ad67bf..0f83c0d 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -22,7 +22,6 @@
 #include "midori-locationaction.h"
 #include "midori-searchaction.h"
 #include "midori-findbar.h"
-#include "midori-transferbar.h"
 #include "midori-platform.h"
 #include "midori-privatedata.h"
 #include "midori-core.h"
@@ -77,7 +76,6 @@ struct _MidoriBrowser
 
     GtkWidget* statusbar;
     GtkWidget* statusbar_contents;
-    GtkWidget* transferbar;
     gchar* statusbar_text;
 
     gint last_window_width, last_window_height;
@@ -211,21 +209,11 @@ midori_browser_set_bookmarks (MidoriBrowser* browser,
 static void
 midori_browser_add_speed_dial (MidoriBrowser* browser);
 
-gboolean
-midori_transferbar_confirm_delete (MidoriTransferbar* transferbar);
-
 static void
 midori_browser_notebook_size_allocate_cb (GtkWidget*     notebook,
                                           GdkRectangle*  allocation,
                                           MidoriBrowser* browser);
 
-void
-midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
-                                      WebKitDownload*    download);
-void
-midori_transferbar_check_size (GtkWidget*         statusbar,
-                               MidoriTransferbar* transferbar);
-
 #define _action_by_name(brwsr, nme) \
     gtk_action_group_get_action (brwsr->action_group, nme)
 #define _action_set_sensitive(brwsr, nme, snstv) \
@@ -1109,9 +1097,6 @@ midori_browser_prepare_download (MidoriBrowser*  browser,
         return FALSE;
     webkit_download_set_destination_uri (download, uri);
     g_signal_emit (browser, signals[ADD_DOWNLOAD], 0, download);
-    midori_transferbar_add_download_item (MIDORI_TRANSFERBAR (browser->transferbar), download);
-    midori_transferbar_check_size (browser->statusbar,
-        MIDORI_TRANSFERBAR (browser->transferbar));
     return TRUE;
 #else
     return FALSE;
@@ -1955,14 +1940,6 @@ 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);
-    return midori_transferbar_confirm_delete (MIDORI_TRANSFERBAR (browser->transferbar));
-}
-
 static void
 midori_browser_class_init (MidoriBrowserClass* class)
 {
@@ -2077,8 +2054,7 @@ midori_browser_class_init (MidoriBrowserClass* class)
      * @download: a new download
      *
      * Emitted when a new download was accepted and is
-     * about to start, before the browser adds items
-     * to the transferbar.
+     * about to start. Download UI should hook up here.
      *
      * Emitting this signal manually is equal to a
      * user initiating and confirming a download
@@ -2199,7 +2175,6 @@ 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;
@@ -6434,16 +6409,6 @@ midori_browser_init (MidoriBrowser* browser)
     #endif
     gtk_box_pack_start (GTK_BOX (vbox), browser->statusbar, FALSE, FALSE, 0);
 
-    browser->transferbar = g_object_new (MIDORI_TYPE_TRANSFERBAR, NULL);
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    /* FIXME: Transfers should go between text and statusbar features like GTK+2 */
-    gtk_box_pack_end (GTK_BOX (browser->statusbar_contents), browser->transferbar, FALSE, FALSE, 3);
-    #else
-    gtk_box_pack_start (GTK_BOX (browser->statusbar_contents), browser->transferbar, FALSE, FALSE, 3);
-    #endif
-    gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->transferbar), FALSE);
-    gtk_widget_show (browser->transferbar);
-
     g_signal_connect (browser->statusbar, "button-press-event",
         G_CALLBACK (midori_browser_menu_button_press_event_cb), browser);
 
diff --git a/midori/midori-frontend.c b/midori/midori-frontend.c
index 02f58d5..e05dde8 100644
--- a/midori/midori-frontend.c
+++ b/midori/midori-frontend.c
@@ -19,7 +19,6 @@
 #include "midori-panel.h"
 #include "panels/midori-bookmarks.h"
 #include "panels/midori-history.h"
-#include "panels/midori-transfers.h"
 #include "sokoke.h"
 #include <glib/gi18n-lib.h>
 
@@ -267,9 +266,6 @@ midori_app_add_browser_cb (MidoriApp*     app,
     addon = g_object_new (MIDORI_TYPE_HISTORY, "app", app, "visible", TRUE, NULL);
     midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
 
-    addon = g_object_new (MIDORI_TYPE_TRANSFERS, "app", app, "visible", TRUE, NULL);
-    midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon));
-
     /* Extensions */
     g_signal_connect (browser, "show-preferences",
         G_CALLBACK (midori_browser_privacy_preferences_cb), app);
diff --git a/midori/midori-stock.h b/midori/midori-stock.h
index e674c37..0ce7184 100644
--- a/midori/midori-stock.h
+++ b/midori/midori-stock.h
@@ -20,7 +20,7 @@
 #define MIDORI_STOCK_WEB_BROWSER "web-browser"
 #define STOCK_NEWS_FEED          "internet-news-reader"
 #define STOCK_STYLE              "preferences-desktop-theme"
-#define STOCK_TRANSFER           "package"
+#define MIDORI_STOCK_TRANSFER    "package"
 #define MIDORI_STOCK_PLUGINS     "application-x-shockwave-flash"
 #define STOCK_BOOKMARK_ADD       "bookmark-new"
 #define STOCK_IMAGE              "image-x-generic"
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 3dc9710..aa405d2 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3232,8 +3232,8 @@ midori_view_download_requested_cb (GtkWidget*      web_view,
     if (screen)
     {
         icon_theme = gtk_icon_theme_get_for_screen (screen);
-        if (gtk_icon_theme_has_icon (icon_theme, STOCK_TRANSFER))
-            gtk_window_set_icon_name (GTK_WINDOW (dialog), STOCK_TRANSFER);
+        if (gtk_icon_theme_has_icon (icon_theme, MIDORI_STOCK_TRANSFER))
+            gtk_window_set_icon_name (GTK_WINDOW (dialog), MIDORI_STOCK_TRANSFER);
         else
             gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
     }
diff --git a/midori/midori.vapi b/midori/midori.vapi
index 71bfcdc..292412d 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -8,6 +8,7 @@ namespace Midori {
     public const string VERSION_SUFFIX;
     namespace Stock {
         public const string WEB_BROWSER;
+        public const string TRANSFER;
         public const string PLUGINS;
     }
 
@@ -51,6 +52,7 @@ namespace Midori {
         public signal void remove_browser (Browser browser);
         [HasEmitter]
         public signal void quit ();
+        public void send_notification (string title, string message);
     }
 
     [CCode (cheader_filename = "midori/midori.h")]
@@ -109,6 +111,8 @@ namespace Midori {
         public signal void populate_tool_menu (Gtk.Menu menu);
         [HasEmitter]
         public signal void quit ();
+        public signal void send_notification (string title, string message);
+        public static void update_history (Katze.Item item, string type, string event);
     }
 
     [CCode (cheader_filename = "midori/midori.h")]
diff --git a/panels/midori-transfers.c b/panels/midori-transfers.c
deleted file mode 100644
index a4f222c..0000000
--- a/panels/midori-transfers.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- Copyright (C) 2009 Christian Dywan <christian at twotoasts.de>
-
- 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-transfers.h"
-
-#include "midori-app.h"
-#include "midori-browser.h"
-#include "midori-platform.h"
-#include "midori-view.h"
-#include "midori-core.h"
-
-#include <glib/gi18n.h>
-
-struct _MidoriTransfers
-{
-    GtkVBox parent_instance;
-
-    GtkWidget* toolbar;
-    GtkWidget* treeview;
-    MidoriApp* app;
-};
-
-struct _MidoriTransfersClass
-{
-    GtkVBoxClass parent_class;
-};
-
-static void
-midori_transfers_viewable_iface_init (MidoriViewableIface* iface);
-
-G_DEFINE_TYPE_WITH_CODE (MidoriTransfers, midori_transfers, GTK_TYPE_VBOX,
-                         G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
-                             midori_transfers_viewable_iface_init));
-
-enum
-{
-    PROP_0,
-
-    PROP_APP
-};
-
-static void
-midori_transfers_set_property (GObject*      object,
-                               guint         prop_id,
-                               const GValue* value,
-                               GParamSpec*   pspec);
-
-static void
-midori_transfers_get_property (GObject*    object,
-                               guint       prop_id,
-                               GValue*     value,
-                               GParamSpec* pspec);
-
-static void
-midori_transfers_class_init (MidoriTransfersClass* class)
-{
-    GObjectClass* gobject_class;
-    GParamFlags flags;
-
-    gobject_class = G_OBJECT_CLASS (class);
-    gobject_class->set_property = midori_transfers_set_property;
-    gobject_class->get_property = midori_transfers_get_property;
-
-    flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
-
-    g_object_class_install_property (gobject_class,
-                                     PROP_APP,
-                                     g_param_spec_object (
-                                     "app",
-                                     "App",
-                                     "The app",
-                                     MIDORI_TYPE_APP,
-                                     flags));
-}
-
-static const gchar*
-midori_transfers_get_label (MidoriViewable* viewable)
-{
-    return _("Transfers");
-}
-
-static const gchar*
-midori_transfers_get_stock_id (MidoriViewable* viewable)
-{
-    return STOCK_TRANSFER;
-}
-
-static void
-midori_transfers_button_clear_clicked_cb (GtkToolItem*    toolitem,
-                                         MidoriTransfers* transfers)
-{
-    GtkTreeModel* model = gtk_tree_view_get_model (
-        GTK_TREE_VIEW (transfers->treeview));
-    GtkTreeIter iter;
-    gint n = 0;
-    while ((gtk_tree_model_iter_nth_child (model, &iter, NULL, n++)))
-    {
-        WebKitDownload* download;
-
-        gtk_tree_model_get (model, &iter, 1, &download, -1);
-
-        if (midori_download_is_finished (download))
-        {
-            gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-            n--; /* Decrement n since we just removed it */
-        }
-        g_object_unref (download);
-    }
-}
-
-static GtkWidget*
-midori_transfers_get_toolbar (MidoriViewable* transfers)
-{
-    if (!MIDORI_TRANSFERS (transfers)->toolbar)
-    {
-        GtkWidget* toolbar;
-        GtkToolItem* toolitem;
-
-        toolbar = gtk_toolbar_new ();
-        gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
-        toolitem = gtk_tool_item_new ();
-        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
-        gtk_widget_show (GTK_WIDGET (toolitem));
-        toolitem = gtk_separator_tool_item_new ();
-        gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem),
-                                          FALSE);
-        gtk_tool_item_set_expand (toolitem, TRUE);
-        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
-        gtk_widget_show (GTK_WIDGET (toolitem));
-        toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLEAR);
-        gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Clear All"));
-        gtk_tool_item_set_is_important (toolitem, TRUE);
-        g_signal_connect (toolitem, "clicked",
-            G_CALLBACK (midori_transfers_button_clear_clicked_cb), transfers);
-        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
-        gtk_widget_show (GTK_WIDGET (toolitem));
-        MIDORI_TRANSFERS (transfers)->toolbar = toolbar;
-    }
-
-    return MIDORI_TRANSFERS (transfers)->toolbar;
-}
-
-static void
-midori_transfers_viewable_iface_init (MidoriViewableIface* iface)
-{
-    iface->get_stock_id = midori_transfers_get_stock_id;
-    iface->get_label = midori_transfers_get_label;
-    iface->get_toolbar = midori_transfers_get_toolbar;
-}
-
-static void
-midori_transfers_download_notify_progress_cb (WebKitDownload*  download,
-                                              GParamSpec*      pspec,
-                                              MidoriTransfers* transfers)
-{
-    /* FIXME: Update only the appropriate row */
-    gtk_widget_queue_draw (transfers->treeview);
-}
-
-static void
-midori_transfers_download_notify_status_cb (WebKitDownload*  download,
-                                            GParamSpec*      pspec,
-                                            MidoriTransfers* transfers)
-{
-    /* FIXME: Update only the appropriate row */
-    gtk_widget_queue_draw (transfers->treeview);
-}
-
-static void
-midori_transfers_browser_add_download_cb (MidoriBrowser*   browser,
-                                          WebKitDownload*  download,
-                                          MidoriTransfers* transfers)
-{
-    GtkTreeView* treeview;
-    GtkTreeModel* model;
-
-    treeview = GTK_TREE_VIEW (transfers->treeview);
-    model = gtk_tree_view_get_model (treeview);
-    gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
-                                       NULL, G_MAXINT,
-                                       0, NULL, 1, download, -1);
-    g_signal_connect (download, "notify::progress",
-        G_CALLBACK (midori_transfers_download_notify_progress_cb), transfers);
-    g_signal_connect (download, "notify::status",
-        G_CALLBACK (midori_transfers_download_notify_status_cb), transfers);
-}
-
-static void
-midori_transfers_set_property (GObject*      object,
-                               guint         prop_id,
-                               const GValue* value,
-                               GParamSpec*   pspec)
-{
-    MidoriTransfers* transfers = MIDORI_TRANSFERS (object);
-
-    switch (prop_id)
-    {
-    case PROP_APP:
-        transfers->app = g_value_get_object (value);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
-    }
-}
-
-static void
-midori_transfers_get_property (GObject*    object,
-                               guint       prop_id,
-                               GValue*     value,
-                               GParamSpec* pspec)
-{
-    MidoriTransfers* transfers = MIDORI_TRANSFERS (object);
-
-    switch (prop_id)
-    {
-    case PROP_APP:
-        g_value_set_object (value, transfers->app);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
-    }
-}
-
-static void
-midori_transfers_treeview_render_icon_cb (GtkTreeViewColumn* column,
-                                          GtkCellRenderer*   renderer,
-                                          GtkTreeModel*      model,
-                                          GtkTreeIter*       iter,
-                                          GtkWidget*         treeview)
-{
-    WebKitDownload* download;
-    gchar* content_type;
-    GIcon* icon;
-
-    gtk_tree_model_get (model, iter, 1, &download, -1);
-    content_type = midori_download_get_content_type (download, NULL);
-    icon = g_content_type_get_icon (content_type);
-    g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
-
-    g_object_set (renderer, "gicon", icon,
-                  "stock-size", GTK_ICON_SIZE_DND,
-                  "xpad", 1, "ypad", 12, NULL);
-    g_free (content_type);
-    g_object_unref (icon);
-    g_object_unref (download);
-}
-
-static void
-midori_transfers_treeview_render_text_cb (GtkTreeViewColumn* column,
-                                          GtkCellRenderer*   renderer,
-                                          GtkTreeModel*      model,
-                                          GtkTreeIter*       iter,
-                                          GtkWidget*         treeview)
-{
-    WebKitDownload* download;
-    gchar* tooltip;
-    gdouble progress;
-
-    gtk_tree_model_get (model, iter, 1, &download, -1);
-
-    tooltip = midori_download_get_tooltip (download);
-    progress = midori_download_get_progress (download);
-    g_object_set (renderer, "text", tooltip,
-                  "value", (gint)(progress * 100),
-                  "xpad", 1, "ypad", 6, NULL);
-    g_free (tooltip);
-    g_object_unref (download);
-}
-
-static void
-midori_transfers_treeview_render_button_cb (GtkTreeViewColumn* column,
-                                            GtkCellRenderer*   renderer,
-                                            GtkTreeModel*      model,
-                                            GtkTreeIter*       iter,
-                                            GtkWidget*         treeview)
-{
-    WebKitDownload* download;
-    const gchar* stock_id;
-
-    gtk_tree_model_get (model, iter, 1, &download, -1);
-
-    stock_id = midori_download_action_stock_id (download);
-    g_object_set (renderer, "stock-id", stock_id,
-                  "stock-size", GTK_ICON_SIZE_MENU, NULL);
-
-    g_object_unref (download);
-}
-
-static void
-midori_transfers_treeview_row_activated_cb (GtkTreeView*       treeview,
-                                            GtkTreePath*       path,
-                                            GtkTreeViewColumn* column,
-                                            MidoriTransfers*   transfers)
-{
-    GtkTreeModel* model = gtk_tree_view_get_model (treeview);
-    GtkTreeIter iter;
-    if (gtk_tree_model_get_iter (model, &iter, path))
-    {
-        WebKitDownload* download;
-
-        gtk_tree_model_get (model, &iter, 1, &download, -1);
-
-        if (midori_download_action_clear (download, GTK_WIDGET (treeview), NULL))
-            gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-        g_object_unref (download);
-    }
-}
-
-static void
-midori_transfers_hierarchy_changed_cb (MidoriTransfers* transfers,
-                                       GtkWidget*       old_parent)
-{
-    MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (transfers));
-    if (MIDORI_IS_BROWSER (browser))
-        g_signal_connect (browser, "add-download",
-            G_CALLBACK (midori_transfers_browser_add_download_cb), transfers);
-    if (old_parent)
-        g_signal_handlers_disconnect_by_func (old_parent,
-            midori_transfers_browser_add_download_cb, transfers);
-}
-
-static GtkWidget*
-midori_transfers_popup_menu_item (GtkMenu*         menu,
-                                  const gchar*     stock_id,
-                                  const gchar*     label,
-                                  WebKitDownload*  download,
-                                  gpointer         callback,
-                                  gboolean         enabled,
-                                  MidoriTransfers* transfers)
-{
-    GtkWidget* menuitem;
-
-    menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
-    if (label)
-        gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
-                                          GTK_BIN (menuitem))), label);
-
-    if (!enabled)
-        gtk_widget_set_sensitive (menuitem, FALSE);
-
-    g_object_set_data (G_OBJECT (menuitem), "WebKitDownload", download);
-
-    if (callback)
-        g_signal_connect (menuitem, "activate", G_CALLBACK (callback), transfers);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-    gtk_widget_show (menuitem);
-
-    return menuitem;
-}
-
-static void
-midori_transfers_open_activate_cb (GtkWidget*       menuitem,
-                                   MidoriTransfers* transfers)
-{
-#ifndef HAVE_WEBKIT2
-    WebKitDownload* download;
-    const gchar* uri;
-
-    download = g_object_get_data (G_OBJECT (menuitem), "WebKitDownload");
-    g_return_if_fail (download != NULL);
-
-    uri = webkit_download_get_destination_uri (download);
-    sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (transfers->treeview)),
-                     uri, gtk_get_current_event_time (), NULL);
-#endif
-}
-
-static void
-midori_transfers_open_folder_activate_cb (GtkWidget*       menuitem,
-                                          MidoriTransfers* transfers)
-{
-#ifndef HAVE_WEBKIT2
-    WebKitDownload* download;
-    const gchar* uri;
-    GFile* file;
-    GFile* folder;
-
-    download = g_object_get_data (G_OBJECT (menuitem), "WebKitDownload");
-    g_return_if_fail (download != NULL);
-
-    uri = webkit_download_get_destination_uri (download);
-    file = g_file_new_for_uri (uri);
-    if ((folder = g_file_get_parent (file)))
-    {
-        gchar* folder_uri = g_file_get_uri (folder);
-        sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (transfers->treeview)),
-            folder_uri, gtk_get_current_event_time (), NULL);
-        g_free (folder_uri);
-        g_object_unref (folder);
-    }
-    g_object_unref (file);
-#endif
-}
-
-static void
-midori_transfers_copy_address_activate_cb (GtkWidget*       menuitem,
-                                           MidoriTransfers* transfers)
-{
-#ifndef HAVE_WEBKIT2
-    WebKitDownload* download;
-    const gchar* uri;
-    GtkClipboard* clipboard;
-
-    download = g_object_get_data (G_OBJECT (menuitem), "WebKitDownload");
-    g_return_if_fail (download != NULL);
-
-    uri = webkit_download_get_uri (download);
-    clipboard = gtk_clipboard_get_for_display (
-        gtk_widget_get_display (GTK_WIDGET (menuitem)),
-        GDK_SELECTION_CLIPBOARD);
-    gtk_clipboard_set_text (clipboard, uri, -1);
-#endif
-}
-
-static void
-midori_transfers_popup (GtkWidget*       widget,
-                        GdkEventButton*  event,
-                        WebKitDownload*  download,
-                        MidoriTransfers* transfers)
-{
-#ifndef HAVE_WEBKIT2
-    GtkWidget* menu;
-    gboolean finished = FALSE;
-
-    if (webkit_download_get_status (download) == WEBKIT_DOWNLOAD_STATUS_FINISHED)
-        finished = TRUE;
-
-    menu = gtk_menu_new ();
-    midori_transfers_popup_menu_item (GTK_MENU (menu), GTK_STOCK_OPEN, NULL, download,
-        midori_transfers_open_activate_cb, finished, transfers);
-    midori_transfers_popup_menu_item (GTK_MENU (menu), GTK_STOCK_DIRECTORY,
-        _("Open Destination _Folder"), download,
-        midori_transfers_open_folder_activate_cb, TRUE, transfers);
-    midori_transfers_popup_menu_item (GTK_MENU (menu), GTK_STOCK_COPY,
-        _("Copy Link Loc_ation"), download,
-        midori_transfers_copy_address_activate_cb, TRUE, transfers);
-
-    katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
-#endif
-}
-
-static gboolean
-midori_transfers_popup_menu_cb (GtkWidget*       widget,
-                                MidoriTransfers* transfers)
-{
-    GtkTreeModel* model;
-    GtkTreeIter iter;
-
-    if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
-    {
-        WebKitDownload* download;
-
-        gtk_tree_model_get (model, &iter, 1, &download, -1);
-
-        midori_transfers_popup (widget, NULL, download, transfers);
-        g_object_unref (download);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static gboolean
-midori_transfers_button_release_event_cb (GtkWidget*      widget,
-                                         GdkEventButton*  event,
-                                         MidoriTransfers* transfers)
-{
-    GtkTreeModel* model;
-    GtkTreeIter iter;
-
-    if (event->button != 3)
-        return FALSE;
-
-    if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
-    {
-        WebKitDownload* download;
-
-        gtk_tree_model_get (model, &iter, 1, &download, -1);
-
-        midori_transfers_popup (widget, NULL, download, transfers);
-        g_object_unref (download);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static void
-midori_transfers_init (MidoriTransfers* transfers)
-{
-    /* Create the treeview */
-    GtkTreeViewColumn* column;
-    GtkCellRenderer* renderer_pixbuf;
-    GtkCellRenderer* renderer_text;
-    GtkListStore* treestore = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_OBJECT);
-    transfers->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
-    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (transfers->treeview), FALSE);
-    column = gtk_tree_view_column_new ();
-    gtk_tree_view_column_set_expand (column, TRUE);
-    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
-    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
-    gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
-        (GtkTreeCellDataFunc)midori_transfers_treeview_render_icon_cb,
-        transfers->treeview, NULL);
-    renderer_text = gtk_cell_renderer_progress_new ();
-    gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
-    gtk_tree_view_column_set_cell_data_func (column, renderer_text,
-        (GtkTreeCellDataFunc)midori_transfers_treeview_render_text_cb,
-        transfers->treeview, NULL);
-    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
-    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
-    gtk_tree_view_column_set_cell_data_func (column, renderer_pixbuf,
-        (GtkTreeCellDataFunc)midori_transfers_treeview_render_button_cb,
-        transfers->treeview, NULL);
-    gtk_tree_view_append_column (GTK_TREE_VIEW (transfers->treeview), column);
-    g_object_unref (treestore);
-    g_object_connect (transfers->treeview,
-        "signal::row-activated",
-        midori_transfers_treeview_row_activated_cb, transfers,
-        "signal::button-release-event",
-        midori_transfers_button_release_event_cb, transfers,
-        "signal::popup-menu",
-        midori_transfers_popup_menu_cb, transfers,
-        NULL);
-    gtk_widget_show (transfers->treeview);
-    gtk_box_pack_start (GTK_BOX (transfers), transfers->treeview, TRUE, TRUE, 0);
-
-    g_signal_connect (transfers, "hierarchy-changed",
-        G_CALLBACK (midori_transfers_hierarchy_changed_cb), NULL);
-}
-
diff --git a/panels/midori-transfers.h b/panels/midori-transfers.h
deleted file mode 100644
index 1174ac9..0000000
--- a/panels/midori-transfers.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright (C) 2009 Christian Dywan <christian at twotoasts.de>
-
- 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_TRANSFERS_H__
-#define __MIDORI_TRANSFERS_H__
-
-#include "midori-core.h"
-
-G_BEGIN_DECLS
-
-#define MIDORI_TYPE_TRANSFERS \
-    (midori_transfers_get_type ())
-#define MIDORI_TRANSFERS(obj) \
-    (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_TRANSFERS, MidoriTransfers))
-#define MIDORI_TRANSFERS_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_TRANSFERS, MidoriTransfersClass))
-#define MIDORI_IS_TRANSFERS(obj) \
-    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_TRANSFERS))
-#define MIDORI_IS_TRANSFERS_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_TRANSFERS))
-#define MIDORI_TRANSFERS_GET_CLASS(obj) \
-    (G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_TRANSFERS, MidoriTransfersClass))
-
-typedef struct _MidoriTransfers                MidoriTransfers;
-typedef struct _MidoriTransfersClass           MidoriTransfersClass;
-
-GType
-midori_transfers_get_type               (void);
-
-GtkWidget*
-midori_transfers_new                    (void);
-
-G_END_DECLS
-
-#endif /* __MIDORI_TRANSFERS_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c0b1680..d7021f3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,11 +21,9 @@ midori/midori-historycompletion.vala
 midori/midori-searchcompletion.vala
 midori/sokoke.c
 toolbars/midori-findbar.c
-toolbars/midori-transferbar.c
 panels/midori-bookmarks.c
 panels/midori-extensions.c
 panels/midori-history.c
-panels/midori-transfers.c
 katze/katze-http-auth.c
 katze/katze-throbber.c
 katze/katze-utils.c
@@ -86,3 +84,4 @@ extensions/cookie-permissions/cookie-permission-manager.c
 extensions/cookie-permissions/cookie-permission-manager.h
 extensions/cookie-permissions/main.c
 extensions/apps.vala
+extensions/transfers.vala
diff --git a/toolbars/midori-transferbar.c b/toolbars/midori-transferbar.c
deleted file mode 100644
index 34abb72..0000000
--- a/toolbars/midori-transferbar.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
-
- 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 "midori-core.h"
-#include "sokoke.h"
-
-#include <glib/gi18n.h>
-
-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 */
-}
-
-typedef struct
-{
-    WebKitDownload* download;
-    GtkWidget* button;
-    GtkWidget* toolitem;
-    MidoriTransferbar* transferbar;
-} TransferInfo;
-
-static gboolean
-midori_transferbar_info_free (TransferInfo* info)
-{
-    MidoriTransferbar* transferbar = info->transferbar;
-
-    transferbar->infos = g_list_remove (transferbar->infos, info);
-    g_object_unref (info->download);
-    g_slice_free (TransferInfo, info);
-
-    return FALSE;
-}
-
-static void
-midori_transferbar_info_destroy (TransferInfo* info)
-{
-    MidoriTransferbar* transferbar = info->transferbar;
-
-    gtk_widget_destroy (info->toolitem);
-
-    if (!transferbar->infos || !g_list_nth_data (transferbar->infos, 0))
-        gtk_widget_hide (GTK_WIDGET (transferbar->clear));
-}
-
-static void
-midori_transferbar_download_notify_progress_cb (WebKitDownload* download,
-                                                GParamSpec*     pspec,
-                                                GtkWidget*      progress)
-{
-    gchar* tooltip;
-    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
-        midori_download_get_progress (download));
-    tooltip = midori_download_get_tooltip (download);
-    gtk_widget_set_tooltip_text (progress, tooltip);
-    g_free (tooltip);
-}
-
-static void
-midori_transferbar_download_notify_status_cb (WebKitDownload* download,
-                                              GParamSpec*     pspec,
-                                              TransferInfo*   info)
-{
-#ifndef HAVE_WEBKIT2
-    GtkWidget* button = info->button;
-
-    const gchar* stock_id = midori_download_action_stock_id (download);
-    GtkWidget* icon = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
-    gtk_button_set_image (GTK_BUTTON (button), icon);
-
-    if (webkit_download_get_status (download) == WEBKIT_DOWNLOAD_STATUS_FINISHED)
-    {
-            MidoriBrowser* browser = midori_browser_get_for_widget (button);
-            MidoriDownloadType type = midori_download_get_type (download);
-
-            if (type == MIDORI_DOWNLOAD_OPEN)
-                gtk_button_clicked (GTK_BUTTON (button));
-
-            {
-                const gchar* uri = webkit_download_get_destination_uri (download);
-                gchar* filename = g_path_get_basename (uri);
-                gchar* msg = g_strdup_printf (
-                    _("The file '<b>%s</b>' has been downloaded."), filename);
-                KatzeItem* item = katze_item_new ();
-                item->uri = (gchar*)uri;
-                item->name = filename;
-                g_signal_emit_by_name (browser, "send-notification",
-                                       _("Transfer completed"), msg);
-                g_free (msg);
-                midori_browser_update_history (item, "download", "create");
-                item->uri = item->name = NULL;
-                g_object_unref (item);
-                g_free (filename);
-            }
-
-            if (!midori_download_has_wrong_checksum (download))
-                 gtk_recent_manager_add_item (gtk_recent_manager_get_default (),
-                    webkit_download_get_destination_uri (download));
-    }
-#endif
-}
-
-static void
-midori_transferbar_download_button_clicked_cb (GtkWidget*    button,
-                                               TransferInfo* info)
-{
-    WebKitDownload* download = info->download;
-    if (midori_download_action_clear (download, button, NULL))
-        midori_transferbar_info_destroy (info);
-}
-
-void
-midori_transferbar_check_size (GtkWidget* statusbar,
-                               MidoriTransferbar* transferbar)
-{
-#ifndef HAVE_WEBKIT2
-  GtkWidget* window;
-  GtkRequisition req;
-  gint reqwidth, winwidth;
-  gtk_widget_size_request (statusbar, &req);
-  reqwidth = req.width;
-  window = gtk_widget_get_toplevel (GTK_WIDGET(transferbar));
-  gtk_window_get_size (GTK_WINDOW(window), &winwidth, NULL);
-
-  if (reqwidth > winwidth)
-  {
-    GList* list;
-    for (list = transferbar->infos; list != NULL; list = g_list_next (list))
-    {
-      TransferInfo* info = list->data;
-      if (midori_download_is_finished (info->download)
-       || webkit_download_get_status (info->download) == WEBKIT_DOWNLOAD_STATUS_STARTED)
-          midori_transferbar_info_destroy (info);
-    }
-  }
-#endif
-}
-
-void
-midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
-                                      WebKitDownload*    download)
-{
-#ifndef HAVE_WEBKIT2
-    GtkWidget* box;
-    GtkWidget* icon;
-    GtkToolItem* toolitem;
-    GtkWidget* button;
-    GtkWidget* progress;
-    const gchar* filename;
-    gint width;
-    TransferInfo* info;
-
-    box = gtk_hbox_new (FALSE, 0);
-    progress = gtk_progress_bar_new ();
-    #if GTK_CHECK_VERSION (3, 0, 0)
-    gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (progress), TRUE);
-    #endif
-    gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (progress), PANGO_ELLIPSIZE_MIDDLE);
-    filename = g_strrstr (webkit_download_get_destination_uri (download), "/") + 1;
-    gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename);
-    sokoke_widget_get_text_size (progress, "M", &width, NULL);
-    gtk_widget_set_size_request (progress, width * 10, 1);
-    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
-        midori_download_get_progress (download));
-    gtk_box_pack_start (GTK_BOX (box), progress, FALSE, FALSE, 0);
-    icon = gtk_image_new_from_stock (
-        midori_download_action_stock_id (download), 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_slice_new (TransferInfo);
-    info->download = g_object_ref (download);
-    info->button = button;
-    info->toolitem = GTK_WIDGET (toolitem);
-    info->transferbar = transferbar;
-    g_signal_connect_swapped (button, "destroy",
-                      G_CALLBACK (midori_transferbar_info_free), 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);
-#endif
-}
-
-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;
-        if (midori_download_is_finished (info->download))
-            midori_transferbar_info_destroy (info);
-    }
-}
-
-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;
-    GList* list;
-    gboolean all_done = TRUE;
-
-    for (list = transferbar->infos; list != NULL; list = g_list_next (list))
-    {
-        TransferInfo* info = list->data;
-        if (!midori_download_is_finished (info->download))
-        {
-            all_done = FALSE;
-            break;
-        }
-    }
-
-    if (!all_done)
-    {
-        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_ACCEPT)
-            cancel = TRUE;
-        gtk_widget_destroy (dialog);
-    }
-
-    return cancel;
-}
-
diff --git a/toolbars/midori-transferbar.h b/toolbars/midori-transferbar.h
deleted file mode 100644
index 76e252b..0000000
--- a/toolbars/midori-transferbar.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
-
- 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 <gtk/gtk.h>
-
-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__ */


More information about the Xfce4-commits mailing list