Merge lp:~donadigo/appcenter/uninstall-progress into lp:~elementary-apps/appcenter/appcenter

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 227
Merged at revision: 230
Proposed branch: lp:~donadigo/appcenter/uninstall-progress
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 208 lines (+69/-54)
4 files modified
src/Core/ChangeInformation.vala (+1/-1)
src/Core/Package.vala (+5/-2)
src/Views/AppInfoView.vala (+27/-24)
src/Widgets/PackageRow.vala (+36/-27)
To merge this branch: bzr merge lp:~donadigo/appcenter/uninstall-progress
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+298586@code.launchpad.net

Commit message

* Show progress on uninstalling apps.
* Show correct buttons after action.

Description of the change

This branch fixes not having feedback on uninstalling apps.
It also fixes some of the troubles with current updating the action_button visibility.

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

It seems like if you install from the PackageRow that the AppInfo View is not updated anymore and the other way around also

227. By Adam Bieńkowski

Show uninstall progress

Revision history for this message
Danielle Foré (danrabbit) wrote :

Works as expected :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Core/ChangeInformation.vala'
2--- src/Core/ChangeInformation.vala 2015-12-14 00:01:37 +0000
3+++ src/Core/ChangeInformation.vala 2016-06-29 21:41:03 +0000
4@@ -26,7 +26,7 @@
5 public Gee.TreeSet<Pk.Details> details { public get; private set; }
6 public bool can_cancel { public get; private set; default=true; }
7 private Gee.HashMap<string, double?> change_progress;
8- private Pk.Status status;
9+ public Pk.Status status;
10 private double progress;
11 public ChangeInformation () {
12
13
14=== modified file 'src/Core/Package.vala'
15--- src/Core/Package.vala 2016-06-24 17:12:09 +0000
16+++ src/Core/Package.vala 2016-06-29 21:41:03 +0000
17@@ -104,10 +104,13 @@
18 changing = true;
19 changed ();
20 try {
21- yield AppCenterCore.Client.get_default ().remove_package (this, (progress, type) => {}, action_cancellable);
22- changing = false;
23+ yield AppCenterCore.Client.get_default ().remove_package (this, (progress, type) => {change_information.ProgressCallback (progress, type);}, action_cancellable);
24+ installed_packages.clear ();
25+ change_information.clear ();
26 installed = false;
27+ changing = false;
28 } catch (Error e) {
29+ change_information.reset ();
30 changing = false;
31 throw e;
32 }
33
34=== modified file 'src/Views/AppInfoView.vala'
35--- src/Views/AppInfoView.vala 2016-06-28 22:48:28 +0000
36+++ src/Views/AppInfoView.vala 2016-06-29 21:41:03 +0000
37@@ -78,29 +78,8 @@
38 uninstall_button.hide ();
39 }
40
41- package.notify["update-available"].connect (() => {
42- if (package.update_available) {
43- action_button.label = _("Update");
44- } else {
45- action_button.no_show_all = true;
46- action_button.hide ();
47- }
48- });
49-
50- package.notify["installed"].connect (() => {
51- if (package.installed && package.update_available) {
52- action_button.label = _("Update");
53- action_button.no_show_all = false;
54- } else if (package.installed) {
55- action_button.hide ();
56- action_button.no_show_all = true;
57- } else {
58- action_button.label = _("Install");
59- action_button.no_show_all = false;
60- uninstall_button.no_show_all = true;
61- uninstall_button.hide ();
62- }
63- });
64+ package.notify["installed"].connect (() => update_buttons ());
65+ package.notify["update-available"].connect (() => update_buttons ());
66
67 package.change_information.bind_property ("can-cancel", cancel_button, "sensitive", GLib.BindingFlags.SYNC_CREATE);
68 package.change_information.progress_changed.connect (() => update_progress ());
69@@ -278,6 +257,11 @@
70
71 private void update_status () {
72 progress_bar.text = package.change_information.get_status ();
73+ if (package.change_information.status == Pk.Status.FINISHED) {
74+ action_stack.set_visible_child_name ("buttons");
75+ } else {
76+ action_stack.set_visible_child_name ("progress");
77+ }
78 }
79
80 private void update_progress () {
81@@ -290,6 +274,25 @@
82 }
83 }
84
85+ private void update_buttons () {
86+ if (package.installed) {
87+ if (package.update_available) {
88+ action_button.label = _("Update");
89+ action_button.no_show_all = false;
90+ action_button.show_all ();
91+ } else {
92+ action_button.no_show_all = true;
93+ action_button.hide ();
94+ uninstall_button.no_show_all = false;
95+ uninstall_button.show_all ();
96+ }
97+ } else {
98+ action_button.label = _("Install");
99+ action_button.no_show_all = false;
100+ action_button.show_all ();
101+ }
102+ }
103+
104 private void action_cancelled () {
105 package.action_cancellable.cancel ();
106 }
107@@ -306,7 +309,7 @@
108 action_button.hide ();
109 if (package.component.id != "xxx-os-updates") {
110 uninstall_button.no_show_all = false;
111- uninstall_button.show ();
112+ uninstall_button.show_all ();
113 }
114
115 // Add this app to the Installed Apps View
116
117=== modified file 'src/Widgets/PackageRow.vala'
118--- src/Widgets/PackageRow.vala 2016-06-28 22:48:28 +0000
119+++ src/Widgets/PackageRow.vala 2016-06-29 21:41:03 +0000
120@@ -47,33 +47,8 @@
121 action_stack.hide ();
122 }
123
124- package.notify["installed"].connect (() => {
125- if (package.installed && package.update_available) {
126- action_button.label = _("Update");
127- action_stack.no_show_all = false;
128- action_stack.show ();
129- } else if (package.installed) {
130- action_stack.no_show_all = true;
131- action_stack.hide ();
132- } else {
133- action_button.label = _("Install");
134- action_stack.no_show_all = false;
135- action_stack.show ();
136- }
137- changed ();
138- });
139-
140- package.notify["update-available"].connect (() => {
141- if (package.update_available) {
142- action_button.label = _("Update");
143- action_stack.no_show_all = false;
144- action_stack.show_all ();
145- } else {
146- action_stack.no_show_all = true;
147- action_stack.hide ();
148- }
149- changed ();
150- });
151+ package.notify["installed"].connect (() => update_buttons ());
152+ package.notify["update-available"].connect (() => update_buttons ());
153
154 package.change_information.bind_property ("can-cancel", cancel_button, "sensitive", GLib.BindingFlags.SYNC_CREATE);
155 package.change_information.progress_changed.connect (() => update_progress ());
156@@ -142,6 +117,13 @@
157
158 private void update_status () {
159 progress_bar.text = package.change_information.get_status ();
160+ if (package.change_information.status == Pk.Status.FINISHED) {
161+ action_stack.set_visible_child_name ("buttons");
162+ } else {
163+ action_stack.set_visible_child_name ("progress");
164+ action_stack.no_show_all = false;
165+ action_stack.show_all ();
166+ }
167 }
168
169 private void update_progress () {
170@@ -149,11 +131,38 @@
171 if (progress < 1.0f) {
172 action_stack.set_visible_child_name ("progress");
173 progress_bar.fraction = progress;
174+ action_stack.no_show_all = false;
175+ action_stack.show_all ();
176 } else {
177 action_stack.set_visible_child_name ("buttons");
178 }
179 }
180
181+ private void update_buttons () {
182+ if (package.installed) {
183+ if (package.update_available) {
184+ action_button.label = _("Update");
185+ action_button.no_show_all = false;
186+ action_button.show_all ();
187+
188+ action_stack.no_show_all = false;
189+ action_stack.show_all ();
190+ } else {
191+ action_stack.no_show_all = true;
192+ action_stack.hide ();
193+ }
194+ } else {
195+ action_button.label = _("Install");
196+ action_button.no_show_all = false;
197+ action_button.show_all ();
198+
199+ action_stack.no_show_all = false;
200+ action_stack.show_all ();
201+ }
202+
203+ changed ();
204+ }
205+
206 private void action_cancelled () {
207 package.action_cancellable.cancel ();
208 }

Subscribers

People subscribed via source and target branches