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
=== modified file 'src/dm-plugin/dm-source.cpp'
--- src/dm-plugin/dm-source.cpp 2015-11-30 12:56:34 +0000
+++ src/dm-plugin/dm-source.cpp 2015-11-30 12:56:34 +0000
@@ -206,6 +206,12 @@
206 }206 }
207 }207 }
208208
209 bool can_resume() const override
210 {
211 return state==PAUSED;
212 }
213
214
209private:215private:
210216
211 void emit_changed_soon()217 void emit_changed_soon()
@@ -548,7 +554,7 @@
548 const auto object_path = m_ccad_path.c_str();554 const auto object_path = m_ccad_path.c_str();
549 const auto interface_name = DM_DOWNLOAD_IFACE_NAME;555 const auto interface_name = DM_DOWNLOAD_IFACE_NAME;
550556
551 g_debug("%s transfer %s calling '%s'", G_STRLOC, id.c_str(), method_name);557 g_debug("%s transfer %s calling '%s' with '%s'", G_STRLOC, id.c_str(), method_name, object_path);
552558
553 g_dbus_connection_call(m_bus, bus_name, object_path, interface_name,559 g_dbus_connection_call(m_bus, bus_name, object_path, interface_name,
554 method_name, nullptr, nullptr,560 method_name, nullptr, nullptr,
@@ -733,6 +739,10 @@
733 auto transfer = find_transfer_by_id(id);739 auto transfer = find_transfer_by_id(id);
734 g_return_if_fail(transfer);740 g_return_if_fail(transfer);
735 transfer->cancel();741 transfer->cancel();
742
743 // remove transfer from the list if canceled
744 m_removed_ccad.insert(transfer->ccad_path());
745 m_model->remove(id);
736 }746 }
737747
738 void clear(const Transfer::Id& id)748 void clear(const Transfer::Id& id)
739749
=== modified file 'src/view-gmenu.cpp'
--- src/view-gmenu.cpp 2015-09-08 18:10:37 +0000
+++ src/view-gmenu.cpp 2015-11-30 12:56:34 +0000
@@ -291,8 +291,13 @@
291291
292 virtual ~Menu()292 virtual ~Menu()
293 {293 {
294 if (m_update_header_tag)294 if (m_update_header_tag > 0)
295 g_source_remove(m_update_header_tag);295 {
296 g_source_remove(m_update_header_tag);
297 // commit any pending change on header
298 update_header();
299 }
300
296 g_clear_object(&m_menu);301 g_clear_object(&m_menu);
297 }302 }
298303
@@ -377,8 +382,9 @@
377 int n_failed = 0;382 int n_failed = 0;
378 int n_paused = 0;383 int n_paused = 0;
379384
380 for (const auto& transfer : m_model->get_all())385 for (auto it=m_visible_transfers.cbegin(); it!=m_visible_transfers.cend(); ++it)
381 {386 {
387 auto transfer = m_model->get((*it).first);
382 switch (transfer->state)388 switch (transfer->state)
383 {389 {
384 case Transfer::RUNNING:390 case Transfer::RUNNING:
@@ -423,10 +429,12 @@
423 currently incomplete because they're either ongoing or paused. */429 currently incomplete because they're either ongoing or paused. */
424 bool header_should_be_visible() const430 bool header_should_be_visible() const
425 {431 {
426 for (const auto& transfer : m_model->get_all())432 for (auto it=m_visible_transfers.cbegin(); it!=m_visible_transfers.cend(); ++it)
427 if (transfer->state != Transfer::FINISHED)433 {
428 return true;434 auto transfer = m_model->get((*it).first);
429435 if (transfer->state != Transfer::FINISHED)
436 return true;
437 }
430 return false;438 return false;
431 }439 }
432440
@@ -692,6 +700,19 @@
692 void update(const Transfer::Id& id)700 void update(const Transfer::Id& id)
693 {701 {
694 const auto t = m_model->get(id);702 const auto t = m_model->get(id);
703
704 // For now we do not want to keep canceled or error downloads on the list
705 // the app will handle it internally
706 switch (t->state)
707 {
708 case Transfer::CANCELED:
709 case Transfer::ERROR:
710 remove(id);
711 return;
712 default:
713 break;
714 }
715
695 g_return_if_fail(t);716 g_return_if_fail(t);
696717
697 // if the transfer already has a menu item, find it718 // if the transfer already has a menu item, find it

Subscribers

People subscribed via source and target branches