Merge lp:~kalikiana/midori/manydowns into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6183
Merged at revision: 6185
Proposed branch: lp:~kalikiana/midori/manydowns
Merge into: lp:midori
Diff against target: 57 lines (+24/-2)
1 file modified
extensions/transfers.vala (+24/-2)
To merge this branch: bzr merge lp:~kalikiana/midori/manydowns
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+166483@code.launchpad.net

Commit message

Collect multiple download notifications within a minute

Description of the change

Collect multiple download notifications within a minute

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

If several files finnish in close succession they will now be merged into one notification bubble.

Revision history for this message
André Stösel (ivaldi) wrote :

I fixed a little bug and slightly optimized the behavior.

https://code.launchpad.net/~ivaldi/midori/manydowns/+merge/166567

Revision history for this message
André Stösel (ivaldi) :
review: Needs Fixing
lp:~kalikiana/midori/manydowns updated
6183. By Cris Dywan

Merge lp:~ivaldi/midori/manydowns

Revision history for this message
André Stösel (ivaldi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/transfers.vala'
2--- extensions/transfers.vala 2013-05-15 19:52:41 +0000
3+++ extensions/transfers.vala 2013-05-30 18:26:27 +0000
4@@ -411,6 +411,8 @@
5 private class Manager : Midori.Extension {
6 internal Katze.Array array;
7 internal GLib.List<Gtk.Widget> widgets;
8+ internal GLib.List<string> notifications;
9+ internal uint notification_timeout;
10
11 void download_added (WebKit.Download download) {
12 var transfer = new Transfer (download);
13@@ -420,6 +422,21 @@
14 array.add_item (transfer);
15 }
16
17+ bool notification_timeout_triggered () {
18+ notification_timeout = 0;
19+ if (notifications.length () > 0) {
20+ string filename = notifications.nth_data(0);
21+ string msg;
22+ if (notifications.length () == 1)
23+ msg = _("The file '<b>%s</b>' has been downloaded.").printf (filename);
24+ else
25+ msg = _("'<b>%s</b>' and %d other files have been downloaded.").printf (filename, notifications.length ());
26+ get_app ().send_notification (_("Transfer completed"), msg);
27+ notifications = new GLib.List<string> ();
28+ }
29+ return false;
30+ }
31+
32 void transfer_changed (Transfer transfer) {
33 if (transfer.succeeded) {
34 /* FIXME: The following 2 blocks ought to be done in core */
35@@ -437,8 +454,11 @@
36 if (!Midori.Download.has_wrong_checksum (transfer.download))
37 Gtk.RecentManager.get_default ().add_item (uri);
38
39- string msg = _("The file '<b>%s</b>' has been downloaded.").printf (filename);
40- get_app ().send_notification (_("Transfer completed"), msg);
41+ notifications.append (filename);
42+ if (notification_timeout == 0) {
43+ notification_timeout_triggered ();
44+ notification_timeout = Midori.Timeout.add_seconds (60, notification_timeout_triggered);
45+ }
46 }
47 }
48
49@@ -495,6 +515,8 @@
50 void activated (Midori.App app) {
51 array = new Katze.Array (typeof (Transfer));
52 widgets = new GLib.List<Gtk.Widget> ();
53+ notifications = new GLib.List<string> ();
54+ notification_timeout = 0;
55 foreach (var browser in app.get_browsers ())
56 browser_added (browser);
57 app.add_browser.connect (browser_added);

Subscribers

People subscribed via source and target branches

to all changes: