[Xfce4-commits] <midori:master> Clear downloads when the transferbar is full

Christian Dywan noreply at xfce.org
Mon Oct 17 02:52:02 CEST 2011


Updating branch refs/heads/master
         to eb45219936b39e44c824a15a606164ff369c0a81 (commit)
       from a8bf171c62b155cabf477632548d9efb1719ed53 (commit)

commit eb45219936b39e44c824a15a606164ff369c0a81
Author: Walther Maldonado <walther.md at gmail.com>
Date:   Sat Oct 15 19:00:21 2011 +0200

    Clear downloads when the transferbar is full
    
    Fixes: https://bugs.launchpad.net/midori/+bug/851452

 midori/midori-browser.c       |    5 +++++
 toolbars/midori-transferbar.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 1208c27..bd0db5c 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -235,6 +235,9 @@ _midori_browser_update_notebook (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)
@@ -984,6 +987,8 @@ midori_browser_prepare_download (MidoriBrowser*  browser,
     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;
 }
 
diff --git a/toolbars/midori-transferbar.c b/toolbars/midori-transferbar.c
index 56ed20e..52426ff 100644
--- a/toolbars/midori-transferbar.c
+++ b/toolbars/midori-transferbar.c
@@ -228,6 +228,35 @@ midori_transferbar_download_button_clicked_cb (GtkWidget*    button,
 }
 
 void
+midori_transferbar_check_size (GtkWidget* statusbar,
+                               MidoriTransferbar* transferbar)
+{
+  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;
+      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);
+      }
+    }
+  }
+}
+
+void
 midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
                                       WebKitDownload*    download)
 {


More information about the Xfce4-commits mailing list