Merge lp:~renatofilho/indicator-transfer/resume-only-paused-downloads into lp:indicator-transfer/15.10

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 47
Merged at revision: 39
Proposed branch: lp:~renatofilho/indicator-transfer/resume-only-paused-downloads
Merge into: lp:indicator-transfer/15.10
Prerequisite: lp:~renatofilho/indicator-transfer/app-id-dm
Diff against target: 104 lines (+39/-8)
2 files modified
src/dm-plugin/dm-source.cpp (+11/-1)
src/view-gmenu.cpp (+28/-7)
To merge this branch: bzr merge lp:~renatofilho/indicator-transfer/resume-only-paused-downloads
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Michael Sheldon (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+276752@code.launchpad.net

Commit message

Only allow resume paused downloads.

Download manager does not support resume canceled downloads.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
44. By Renato Araujo Oliveira Filho

Fix compilation.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
45. By Renato Araujo Oliveira Filho

Remove transfer from indicator if canceled.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
46. By Renato Araujo Oliveira Filho

Make the menu invisible if the download list is empty.
Remove from the list canceled downloads.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
47. By Renato Araujo Oliveira Filho

Parent merged.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looks good, and works well

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

Patch LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dm-plugin/dm-source.cpp'
2--- src/dm-plugin/dm-source.cpp 2015-11-30 12:56:34 +0000
3+++ src/dm-plugin/dm-source.cpp 2015-11-30 12:56:34 +0000
4@@ -206,6 +206,12 @@
5 }
6 }
7
8+ bool can_resume() const override
9+ {
10+ return state==PAUSED;
11+ }
12+
13+
14 private:
15
16 void emit_changed_soon()
17@@ -548,7 +554,7 @@
18 const auto object_path = m_ccad_path.c_str();
19 const auto interface_name = DM_DOWNLOAD_IFACE_NAME;
20
21- g_debug("%s transfer %s calling '%s'", G_STRLOC, id.c_str(), method_name);
22+ g_debug("%s transfer %s calling '%s' with '%s'", G_STRLOC, id.c_str(), method_name, object_path);
23
24 g_dbus_connection_call(m_bus, bus_name, object_path, interface_name,
25 method_name, nullptr, nullptr,
26@@ -733,6 +739,10 @@
27 auto transfer = find_transfer_by_id(id);
28 g_return_if_fail(transfer);
29 transfer->cancel();
30+
31+ // remove transfer from the list if canceled
32+ m_removed_ccad.insert(transfer->ccad_path());
33+ m_model->remove(id);
34 }
35
36 void clear(const Transfer::Id& id)
37
38=== modified file 'src/view-gmenu.cpp'
39--- src/view-gmenu.cpp 2015-09-08 18:10:37 +0000
40+++ src/view-gmenu.cpp 2015-11-30 12:56:34 +0000
41@@ -291,8 +291,13 @@
42
43 virtual ~Menu()
44 {
45- if (m_update_header_tag)
46- g_source_remove(m_update_header_tag);
47+ if (m_update_header_tag > 0)
48+ {
49+ g_source_remove(m_update_header_tag);
50+ // commit any pending change on header
51+ update_header();
52+ }
53+
54 g_clear_object(&m_menu);
55 }
56
57@@ -377,8 +382,9 @@
58 int n_failed = 0;
59 int n_paused = 0;
60
61- for (const auto& transfer : m_model->get_all())
62+ for (auto it=m_visible_transfers.cbegin(); it!=m_visible_transfers.cend(); ++it)
63 {
64+ auto transfer = m_model->get((*it).first);
65 switch (transfer->state)
66 {
67 case Transfer::RUNNING:
68@@ -423,10 +429,12 @@
69 currently incomplete because they're either ongoing or paused. */
70 bool header_should_be_visible() const
71 {
72- for (const auto& transfer : m_model->get_all())
73- if (transfer->state != Transfer::FINISHED)
74- return true;
75-
76+ for (auto it=m_visible_transfers.cbegin(); it!=m_visible_transfers.cend(); ++it)
77+ {
78+ auto transfer = m_model->get((*it).first);
79+ if (transfer->state != Transfer::FINISHED)
80+ return true;
81+ }
82 return false;
83 }
84
85@@ -692,6 +700,19 @@
86 void update(const Transfer::Id& id)
87 {
88 const auto t = m_model->get(id);
89+
90+ // For now we do not want to keep canceled or error downloads on the list
91+ // the app will handle it internally
92+ switch (t->state)
93+ {
94+ case Transfer::CANCELED:
95+ case Transfer::ERROR:
96+ remove(id);
97+ return;
98+ default:
99+ break;
100+ }
101+
102 g_return_if_fail(t);
103
104 // if the transfer already has a menu item, find it

Subscribers

People subscribed via source and target branches