Merge lp:~benwaffle/appcenter/buttons into lp:~elementary-apps/appcenter/appcenter

Proposed by Ben
Status: Merged
Approved by: Danielle Foré
Approved revision: 218
Merged at revision: 218
Proposed branch: lp:~benwaffle/appcenter/buttons
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 189 lines (+75/-42)
2 files modified
src/Views/AppListView.vala (+1/-3)
src/Widgets/PackageRow.vala (+74/-39)
To merge this branch: bzr merge lp:~benwaffle/appcenter/buttons
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Adam Bieńkowski (community) testing Needs Fixing
Review via email: mp+298054@code.launchpad.net

Commit message

Fix only update buttons showing up in search results

Description of the change

Fix bug 1593609. Now, the search results have the same buttons as the App Info view (most of the code was copied from there). Perhaps we should consider creating a new widget for the install/update/uninstall/progressbar group in the future.

To post a comment you must log in.
lp:~benwaffle/appcenter/buttons updated
211. By Ben

Don't offer to uninstall OS updates

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

It seems good to me, but "Update all" button is not the same width as the other buttons in the list. Also I wouldn't throw criticals in these catch () statements, warning should be enough.

review: Needs Fixing (testing)
lp:~benwaffle/appcenter/buttons updated
212. By Ben

remove uninstall button in search and update views

213. By Ben

Remove suggested-action from individual update button

214. By Ben

fix margins for update button sizegroup

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

Please merge trunk

I feel like using a symbolic cancel icon is a regression from trunk. Using the label button keeps the UI from shifting and is also a clearer and larger click target

Currently in trunk, after installing the button with change to "uninstall". In your branch it remains as "install"

review: Needs Fixing
lp:~benwaffle/appcenter/buttons updated
215. By Ben

Merge trunk

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

As mentioned previously, please use the cancel label button instead of process-stop-symbolic

review: Needs Fixing
lp:~benwaffle/appcenter/buttons updated
216. By Ben

Use text cancel button

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

* Doesn't look like the Cancel button has been added to the sizegroup
* Also looks like there is no column_spacing in progress_grid

review: Needs Fixing
lp:~benwaffle/appcenter/buttons updated
217. By Ben

make cancel button look better

218. By Ben

make sure cancel button is exactly the same as the install

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Views/AppListView.vala'
2--- src/Views/AppListView.vala 2016-06-25 15:34:25 +0000
3+++ src/Views/AppListView.vala 2016-06-26 23:17:14 +0000
4@@ -71,7 +71,7 @@
5
6 public void add_package (AppCenterCore.Package package) {
7 var row = new Widgets.PackageRow (package);
8- update_button_group.add_widget (row.update_button);
9+ update_button_group.add_widget (row.action_button);
10 update_button_group.add_widget (row.cancel_button);
11 row.show_all ();
12 list_box.add (row);
13@@ -126,7 +126,6 @@
14 [CCode (instance_pos = -1)]
15 private void package_row_update_header (Widgets.PackageRow row, Widgets.PackageRow? before) {
16 bool update_available = row.package.update_available;
17- row.action_stack.visible = row.package.update_available;
18 if (before == null && update_available) {
19 var updates_grid = get_updates_grid ();
20 row.set_header (updates_grid);
21@@ -142,7 +141,6 @@
22 var updated_grid = new Gtk.Grid ();
23 updated_grid.orientation = Gtk.Orientation.HORIZONTAL;
24 updated_grid.column_spacing = 12;
25- updated_grid.margin = 6;
26 if (updating_cache) {
27 updated_grid.halign = Gtk.Align.CENTER;
28 var updating_label = new Gtk.Label (_("Searching for updates…"));
29
30=== modified file 'src/Widgets/PackageRow.vala'
31--- src/Widgets/PackageRow.vala 2016-06-21 18:28:52 +0000
32+++ src/Widgets/PackageRow.vala 2016-06-26 23:17:14 +0000
33@@ -27,12 +27,12 @@
34 Gtk.Label package_name;
35 Gtk.Label package_summary;
36
37- public Gtk.Button update_button;
38+ // The action button covers Install and Update
39+ public Gtk.Button action_button;
40+ Gtk.ProgressBar progress_bar;
41+ Gtk.Label progress_label;
42 public Gtk.Button cancel_button;
43- public Gtk.Stack action_stack;
44- Gtk.Grid update_grid;
45- Gtk.ProgressBar update_progressbar;
46- Gtk.Label update_label;
47+ Gtk.Stack action_stack;
48
49 public PackageRow (Package package) {
50 this.package = package;
51@@ -41,11 +41,38 @@
52 package_summary.ellipsize = Pango.EllipsizeMode.END;
53 image.gicon = package.get_icon ();
54
55+ if (package.update_available) {
56+ action_button.label = _("Update");
57+ } else if (package.installed) {
58+ action_stack.no_show_all = true;
59+ action_stack.hide ();
60+ }
61+
62 package.notify["installed"].connect (() => {
63+ if (package.installed && package.update_available) {
64+ action_button.label = _("Update");
65+ action_stack.no_show_all = false;
66+ action_stack.show ();
67+ } else if (package.installed) {
68+ action_stack.no_show_all = true;
69+ action_stack.hide ();
70+ } else {
71+ action_button.label = _("Install");
72+ action_stack.no_show_all = false;
73+ action_stack.show ();
74+ }
75 changed ();
76 });
77
78 package.notify["update-available"].connect (() => {
79+ if (package.update_available) {
80+ action_button.label = _("Update");
81+ action_stack.no_show_all = false;
82+ action_stack.show_all ();
83+ } else {
84+ action_stack.no_show_all = true;
85+ action_stack.hide ();
86+ }
87 changed ();
88 });
89
90@@ -81,28 +108,32 @@
91 ((Gtk.Misc) package_summary).xalign = 0;
92
93 action_stack = new Gtk.Stack ();
94-
95- update_button = new Gtk.Button.with_label (_("Update"));
96- update_button.halign = Gtk.Align.END;
97- update_button.valign = Gtk.Align.CENTER;
98- update_button.margin_end = 6;
99- update_button.clicked.connect (() => update_package.begin ());
100-
101- update_label = new Gtk.Label (null);
102- update_progressbar = new Gtk.ProgressBar ();
103- update_progressbar.margin_end = 12;
104+ action_stack.transition_type = Gtk.StackTransitionType.CROSSFADE;
105+ action_stack.hhomogeneous = false;
106+
107+ progress_bar = new Gtk.ProgressBar ();
108+
109+ progress_label = new Gtk.Label (null);
110
111 cancel_button = new Gtk.Button.with_label (_("Cancel"));
112+ cancel_button.margin_end = 6;
113 cancel_button.valign = Gtk.Align.CENTER;
114- cancel_button.margin_end = 6;
115-
116- update_grid = new Gtk.Grid ();
117- update_grid.attach (update_label, 0, 0, 1, 1);
118- update_grid.attach (update_progressbar, 0, 1, 1, 1);
119- update_grid.attach (cancel_button, 1, 0, 1, 2);
120-
121- action_stack.add (update_button);
122- action_stack.add (update_grid);
123+
124+ action_button = new Gtk.Button.with_label (_("Install"));
125+ action_button.margin_end = 6;
126+ action_button.valign = Gtk.Align.CENTER;
127+ action_button.clicked.connect (() => action_clicked.begin ());
128+
129+ var progress_grid = new Gtk.Grid ();
130+ progress_grid.valign = Gtk.Align.CENTER;
131+ progress_grid.row_spacing = 6;
132+ progress_grid.column_spacing = 6;
133+ progress_grid.attach (progress_label, 0, 0, 1, 1);
134+ progress_grid.attach (progress_bar, 0, 1, 1, 1);
135+ progress_grid.attach (cancel_button, 1, 0, 1, 2);
136+
137+ action_stack.add_named (action_button, "buttons");
138+ action_stack.add_named (progress_grid, "progress");
139
140 grid.attach (image, 0, 0, 1, 2);
141 grid.attach (package_name, 1, 0, 1, 1);
142@@ -115,28 +146,32 @@
143 });
144 }
145
146- private async void update_package () {
147- try {
148- update_button.sensitive = false;
149- yield package.update ();
150- } catch (Error e) {
151- critical (e.message);
152- }
153-
154- update_button.sensitive = true;
155- }
156-
157 private void update_status () {
158- update_label.label = package.change_information.get_status ();
159+ progress_label.label = package.change_information.get_status ();
160 }
161
162 private void update_progress () {
163 var progress = package.change_information.get_progress ();
164 if (progress < 1.0f) {
165- action_stack.set_visible_child (update_grid);
166- update_progressbar.fraction = progress;
167+ action_stack.set_visible_child_name ("progress");
168+ progress_bar.fraction = progress;
169 } else {
170- action_stack.set_visible_child (update_button);
171+ action_stack.set_visible_child_name ("buttons");
172+ }
173+ }
174+
175+ private async void action_clicked () {
176+ try {
177+ if (package.update_available) {
178+ yield package.update ();
179+ } else {
180+ yield package.install ();
181+ }
182+ action_stack.no_show_all = true;
183+ action_stack.hide ();
184+ } catch (Error e) {
185+ critical (e.message);
186+ action_stack.set_visible_child_name ("buttons");
187 }
188 }
189 }

Subscribers

People subscribed via source and target branches

to all changes: