Merge lp:~ddieter/appcenter/appcenter-version-info into lp:~elementary-apps/appcenter/appcenter

Proposed by Dieter Debast
Status: Merged
Approved by: Danielle Foré
Approved revision: 315
Merged at revision: 396
Proposed branch: lp:~ddieter/appcenter/appcenter-version-info
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 304 lines (+122/-40)
6 files modified
src/AbstractAppContainer.vala (+6/-5)
src/Core/Client.vala (+6/-0)
src/Core/Package.vala (+23/-15)
src/Views/AppInfoView.vala (+15/-1)
src/Views/AppListView.vala (+2/-2)
src/Widgets/PackageRow.vala (+70/-17)
To merge this branch: bzr merge lp:~ddieter/appcenter/appcenter-version-info
Reviewer Review Type Date Requested Status
Jeremy Wootten code, function Approve
Review via email: mp+307578@code.launchpad.net

Commit message

* Show package versions in update tabs instead of summary
* Show the version of available updates in the info view instead of installed version

Description of the change

The installed view now shows the versions of the packages that are installed. When an update is available, it will show the version of the update.

Now this also shows the version of an update in the info view of an application, as this wasn't the case before (bug or intentional?).

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

It seems like with this branch there is now a wait before AppInfoView loads. Previously the view was shown instantly and the version information would populate when it was able to be fetched. This branch feels much slower since there is lag between clicking and when the page opens.

313. By Dieter Debast

Fix lag when opening AppInfoView

Revision history for this message
Dieter Debast (ddieter) wrote :

I don't notice that delay on my computer. Is it better now after my latest commit?

314. By Dieter Debast

Merge with trunk

Revision history for this message
Dieter Debast (ddieter) wrote :

Merged with the changes from trunk. Please check if I didn't break any changes during resolving conflicts.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

It seems to work OK, I did not notice any significant speed hit.

There a few issues with the code style - see in line.

review: Needs Fixing (code)
315. By Dieter Debast

Improved code style

Revision history for this message
Dieter Debast (ddieter) wrote :

Thanks, I removed the update_state method and made the class abstract as you suggested.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Thanks Dieter. Looks good now.

review: Approve (code, function)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/AbstractAppContainer.vala'
2--- src/AbstractAppContainer.vala 2017-01-01 16:05:55 +0000
3+++ src/AbstractAppContainer.vala 2017-02-05 15:49:51 +0000
4@@ -104,11 +104,9 @@
5
6 protected virtual void set_up_package (uint icon_size = 48) {
7 package_name.label = package.get_name ();
8- package_summary.label = package.get_summary ();
9- package_summary.ellipsize = Pango.EllipsizeMode.END;
10 image.gicon = package.get_icon (icon_size);
11
12- package.notify["state"].connect (update_state);
13+ package.notify["state"].connect (() => update_state ());
14
15 package.change_information.bind_property ("can-cancel", cancel_button, "sensitive", GLib.BindingFlags.SYNC_CREATE);
16 package.change_information.progress_changed.connect (update_progress);
17@@ -116,10 +114,10 @@
18
19 update_progress_status ();
20 update_progress ();
21- update_state ();
22+ update_state (true);
23 }
24
25- protected virtual void update_state () {
26+ protected virtual void update_state (bool first_update = false) {
27 update_action ();
28 }
29
30@@ -171,6 +169,9 @@
31 case AppCenterCore.Package.State.UPDATE_AVAILABLE:
32 action_button.label = _("Update");
33
34+ action_button.no_show_all = false;
35+ action_button.show_all ();
36+
37 if (show_open && package.get_can_launch ()) {
38 open_button.no_show_all = false;
39 open_button.show ();
40
41=== modified file 'src/Core/Client.vala'
42--- src/Core/Client.vala 2016-12-28 16:29:00 +0000
43+++ src/Core/Client.vala 2017-02-05 15:49:51 +0000
44@@ -189,6 +189,11 @@
45 string[] packages_array = {};
46 results.get_package_array ().foreach ((pk_package) => {
47 packages_array += pk_package.get_id ();
48+ unowned string pkg_name = pk_package.get_name ();
49+ var package = package_list.get (pkg_name);
50+ if (package != null) {
51+ package.latest_version = pk_package.get_version ();
52+ }
53 });
54
55 // We need a null to show to PackageKit that it's then end of the array.
56@@ -238,6 +243,7 @@
57 var package = package_list.get (pk_package.get_name ());
58 if (package != null) {
59 package.installed_packages.add (pk_package);
60+ package.latest_version = pk_package.get_version ();
61 package.update_state ();
62 packages.add (package);
63 }
64
65=== modified file 'src/Core/Package.vala'
66--- src/Core/Package.vala 2017-01-01 16:05:55 +0000
67+++ src/Core/Package.vala 2017-02-05 15:49:51 +0000
68@@ -82,7 +82,11 @@
69
70 private string? name = null;
71 private string? summary = null;
72- private string? version = null;
73+ private string? _latest_version = null;
74+ public string? latest_version {
75+ private get { return _latest_version; }
76+ internal set { _latest_version = convert_version (value); }
77+ }
78 private Pk.Package? pk_package = null;
79
80 construct {
81@@ -303,24 +307,28 @@
82 }
83
84 public string? get_version () {
85- if (version != null) {
86- return version;
87+ if (latest_version != null) {
88+ return latest_version;
89 }
90
91 var package = find_package ();
92 if (package != null) {
93- string returned = package.get_version ();
94- returned = returned.split ("+", 2)[0];
95- returned = returned.split ("-", 2)[0];
96- returned = returned.split ("~", 2)[0];
97- if (":" in returned) {
98- returned = returned.split (":", 2)[1];
99- }
100-
101- version = returned;
102- }
103-
104- return version;
105+ latest_version = package.get_version ();
106+ }
107+
108+ return latest_version;
109+ }
110+
111+ private string convert_version (string version) {
112+ string returned = version;
113+ returned = returned.split ("+", 2)[0];
114+ returned = returned.split ("-", 2)[0];
115+ returned = returned.split ("~", 2)[0];
116+ if (":" in returned) {
117+ returned = returned.split (":", 2)[1];
118+ }
119+
120+ return returned;
121 }
122
123 public bool get_can_launch () {
124
125=== modified file 'src/Views/AppInfoView.vala'
126--- src/Views/AppInfoView.vala 2017-01-01 16:05:55 +0000
127+++ src/Views/AppInfoView.vala 2017-02-05 15:49:51 +0000
128@@ -141,9 +141,23 @@
129 open_button.get_style_context ().add_class ("h3");
130 }
131
132+ protected override void set_up_package (uint icon_size = 48) {
133+ package_summary.label = package.get_summary ();
134+ package_summary.ellipsize = Pango.EllipsizeMode.END;
135+ base.set_up_package (icon_size);
136+ }
137+
138+ protected override void update_state (bool first_update = false) {
139+ if (!first_update) {
140+ app_version.label = package.get_version ();
141+ }
142+
143+ update_action ();
144+ }
145+
146 private async void load_extensions () {
147 package.component.get_addons ().@foreach ((extension) => {
148- var row = new Widgets.PackageRow (new AppCenterCore.Package (extension), null);
149+ var row = new Widgets.PackageRow.list (new AppCenterCore.Package (extension), null, false);
150 if (extension_box != null) {
151 extension_box.add (row);
152 }
153
154=== modified file 'src/Views/AppListView.vala'
155--- src/Views/AppListView.vala 2017-01-01 16:05:55 +0000
156+++ src/Views/AppListView.vala 2017-02-05 15:49:51 +0000
157@@ -26,7 +26,7 @@
158 public AppListView () {}
159
160 protected override Widgets.AppListRow make_row (AppCenterCore.Package package) {
161- return (Widgets.AppListRow)(new Widgets.PackageRow (package, action_button_group));
162+ return (Widgets.AppListRow)(new Widgets.PackageRow.list (package, action_button_group, false));
163 }
164 }
165
166@@ -88,7 +88,7 @@
167 protected override void after_add_remove_change_row () {update_headers ();}
168
169 protected override Widgets.AppListRow make_row (AppCenterCore.Package package) {
170- return (Widgets.AppListRow)(new Widgets.PackageRow (package, action_button_group));
171+ return (Widgets.AppListRow)(new Widgets.PackageRow.installed (package, action_button_group, false));
172 }
173
174 protected override void on_package_changing (AppCenterCore.Package package, bool is_changing) {
175
176=== modified file 'src/Widgets/PackageRow.vala'
177--- src/Widgets/PackageRow.vala 2017-01-01 16:05:55 +0000
178+++ src/Widgets/PackageRow.vala 2017-02-05 15:49:51 +0000
179@@ -20,10 +20,18 @@
180
181 namespace AppCenter.Widgets {
182 public class PackageRow : Gtk.ListBoxRow, AppListRow {
183- PackageRowGrid grid;
184+ AbstractPackageRowGrid grid;
185
186- public PackageRow (AppCenterCore.Package package, Gtk.SizeGroup? size_group) {
187- grid = new PackageRowGrid (package, size_group);
188+ public PackageRow.installed (AppCenterCore.Package package, Gtk.SizeGroup? size_group, bool show_uninstall = true) {
189+ grid = new InstalledPackageRowGrid (package, size_group, show_uninstall);
190+ add (grid);
191+ grid.changed.connect (() => {
192+ changed ();
193+ });
194+ }
195+
196+ public PackageRow.list (AppCenterCore.Package package, Gtk.SizeGroup? size_group, bool show_uninstall = true) {
197+ grid = new ListPackageRowGrid (package, size_group, show_uninstall);
198 add (grid);
199 grid.changed.connect (() => {
200 changed ();
201@@ -58,7 +66,7 @@
202 return true;
203 }
204
205- private class PackageRowGrid : AbstractAppContainer {
206+ private abstract class AbstractPackageRowGrid : AbstractAppContainer {
207 public signal void changed ();
208
209 construct {
210@@ -79,24 +87,15 @@
211 package_name.valign = Gtk.Align.END;
212 ((Gtk.Misc) package_name).xalign = 0;
213
214- package_summary = new Gtk.Label (null);
215- package_summary.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
216- package_summary.hexpand = true;
217- package_summary.valign = Gtk.Align.START;
218- ((Gtk.Misc) package_summary).xalign = 0;
219-
220-
221 attach (image, 0, 0, 1, 2);
222 attach (package_name, 1, 0, 1, 1);
223- attach (package_summary, 1, 1, 1, 1);
224 attach (action_stack, 2, 0, 1, 2);
225 }
226
227- public PackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? size_group) {
228+ public AbstractPackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? size_group, bool show_uninstall = true) {
229 this.package = package;
230- this.show_uninstall = false;
231+ this.show_uninstall = show_uninstall;
232 this.show_open = false;
233- set_up_package ();
234
235 if (size_group != null) {
236 size_group.add_widget (action_button);
237@@ -104,11 +103,65 @@
238 size_group.add_widget (uninstall_button);
239 }
240 }
241-
242- protected override void update_state () {
243+ }
244+
245+ private class InstalledPackageRowGrid : AbstractPackageRowGrid {
246+ Gtk.Label app_version;
247+
248+ construct {
249+ app_version = new Gtk.Label (null);
250+ app_version.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
251+ app_version.hexpand = true;
252+ app_version.valign = Gtk.Align.START;
253+ ((Gtk.Misc) app_version).xalign = 0;
254+
255+ attach (app_version, 1, 1, 1, 1);
256+ }
257+
258+ public InstalledPackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? size_group, bool show_uninstall = true) {
259+ base (package, size_group, show_uninstall);
260+ set_up_package ();
261+ }
262+
263+ protected override void set_up_package (uint icon_size = 48) {
264+ app_version.label = package.get_version ();
265+ app_version.ellipsize = Pango.EllipsizeMode.END;
266+
267+ base.set_up_package (icon_size);
268+ }
269+
270+ protected override void update_state (bool first_update = false) {
271+ if (!first_update) {
272+ app_version.label = package.get_version ();
273+ }
274+
275 update_action ();
276 changed ();
277 }
278 }
279+
280+ private class ListPackageRowGrid : AbstractPackageRowGrid {
281+
282+ construct {
283+ package_summary = new Gtk.Label (null);
284+ package_summary.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
285+ package_summary.hexpand = true;
286+ package_summary.valign = Gtk.Align.START;
287+ ((Gtk.Misc) package_summary).xalign = 0;
288+
289+ attach (package_summary, 1, 1, 1, 1);
290+ }
291+
292+ public ListPackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? size_group, bool show_uninstall = true) {
293+ base (package, size_group, show_uninstall);
294+ set_up_package ();
295+ }
296+
297+ protected override void set_up_package (uint icon_size = 48) {
298+ package_summary.label = package.get_summary ();
299+ package_summary.ellipsize = Pango.EllipsizeMode.END;
300+ base.set_up_package (icon_size);
301+ }
302+ }
303 }
304 }

Subscribers

People subscribed via source and target branches