]> spindle.queued.net Git - midori/commitdiff
Clear downloads when the transferbar is full
authorWalther Maldonado <walther.md@gmail.com>
Sat, 15 Oct 2011 17:00:21 +0000 (19:00 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 17 Oct 2011 00:47:56 +0000 (02:47 +0200)
Fixes: https://bugs.launchpad.net/midori/+bug/851452
midori/midori-browser.c
toolbars/midori-transferbar.c

index 1208c2758bd05bb61f38b8781bddd91e1059e927..bd0db5cd0815d345e84204d4f49a1dde8c2da6e4 100644 (file)
@@ -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;
 }
 
index 56ed20eb119c6820979fe8eb6fcae7d795b7a881..52426ff89982d8e2ab1faf00de59ebdfaa0fe124 100644 (file)
@@ -227,6 +227,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)