Merge lp:~ruben-reina-dev/appcenter/installed-apps-list-fixes into lp:~elementary-apps/appcenter/appcenter

Proposed by Rubén Reina
Status: Merged
Approved by: Danielle Foré
Approved revision: 218
Merged at revision: 217
Proposed branch: lp:~ruben-reina-dev/appcenter/installed-apps-list-fixes
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 124 lines (+36/-7)
4 files modified
src/MainWindow.vala (+2/-1)
src/Views/AppInfoView.vala (+6/-4)
src/Views/AppListView.vala (+10/-0)
src/Views/InstalledView.vala (+18/-2)
To merge this branch: bzr merge lp:~ruben-reina-dev/appcenter/installed-apps-list-fixes
Reviewer Review Type Date Requested Status
Danielle Foré testing Approve
Adam Bieńkowski (community) code Approve
Review via email: mp+298372@code.launchpad.net

Commit message

roperly refresh the Installed Apps list when an app is installed or uninstalled from any App Info View

Description of the change

Properly refresh the Installed Apps list when an app is installed or uninstalled from any App Info View.

The list is updated in an non-blocking and optimized way.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Thank you for your submission. Corentin is the best person to review this branch, please be patient until he has time for it.

In the mean time, I plan on creating more AppCenter bounties in the very near future. So please continue checking for new bounties.

Thanks again for your submission.

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

Some things about the code:
* I am not sure if a separate installed_view variable is needed here. In vala you can use something like:
"get; private set;"

* We use "lower_case" variables, and we should keep that also there, the name "mainWindow" should become "main_window" to keep the same code style.

* I don't like the use of get_toplevel () here. Maybe you could try to get make installed_view a static object, this way, you wouldn't need to get the MainWindow instance. If not, you can use Gtk's built in functions to get that window like this:

var main_window = (MainWindow)((Gtk.Application)Application.get_default ()).get_active_window ();
Also, make sure that the instance of MainWindow is not null, before doing any operations with it.

Otherwise, it looks OK.

review: Needs Fixing (code)
Revision history for this message
Rubén Reina (ruben-reina-dev) wrote :

Hello Adam,

Thank you for your tips and suggestions, they were really useful!

I have added the following changes to the branch:
1. "installed_view" variable in MainWindow is now a static auto-generated
property "public static Views.InstalledView installed_view { get; private
set; }". It always will be assigned because in the "static constructor" of
the MainWindow the variable is assigned with an instance of InstalledView
2. Fix code style issue.

The branch is ready to be reviewed again, so please, check it again when
you can.
Thank you.

2016-06-25 22:26 GMT+02:00 Adam Bieńkowski <email address hidden>:

> Review: Needs Fixing code
>
> Some things about the code:
> * I am not sure if a separate installed_view variable is needed here. In
> vala you can use something like:
> "get; private set;"
>
> * We use "lower_case" variables, and we should keep that also there, the
> name "mainWindow" should become "main_window" to keep the same code style.
>
> * I don't like the use of get_toplevel () here. Maybe you could try to get
> make installed_view a static object, this way, you wouldn't need to get the
> MainWindow instance. If not, you can use Gtk's built in functions to get
> that window like this:
>
> var main_window = (MainWindow)((Gtk.Application)Application.get_default
> ()).get_active_window ();
> Also, make sure that the instance of MainWindow is not null, before doing
> any operations with it.
>
> Otherwise, it looks OK.
> --
>
> https://code.launchpad.net/~ruben-reina-dev/appcenter/installed-apps-list-fixes/+merge/298372
> You are the owner of
> lp:~ruben-reina-dev/appcenter/installed-apps-list-fixes.
>

Revision history for this message
Rubén Reina (ruben-reina-dev) wrote :

Thanks to you Cody. I will check those bounties for sure when I have time.

2016-06-25 21:43 GMT+02:00 Cody Garver <email address hidden>:

> Thank you for your submission. Corentin is the best person to review this
> branch, please be patient until he has time for it.
>
> In the mean time, I plan on creating more AppCenter bounties in the very
> near future. So please continue checking for new bounties.
>
> Thanks again for your submission.
> --
>
> https://code.launchpad.net/~ruben-reina-dev/appcenter/installed-apps-list-fixes/+merge/298372
> You are the owner of
> lp:~ruben-reina-dev/appcenter/installed-apps-list-fixes.
>

217. By Ruben Reina <email address hidden>

Updated with base

218. By Ruben Reina <email address hidden>

Code fixes proposed after the first review

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

Thank you for updating the branch! It looks very clean now. I'm not sure stars replaced in the license headers, but I'll approve it. Note that I did not compile / test it.

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

I built and testing the branch and can confirm that it works as expected

review: Approve (testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/MainWindow.vala'
2--- src/MainWindow.vala 2016-06-19 21:09:16 +0000
3+++ src/MainWindow.vala 2016-06-26 10:34:12 +0000
4@@ -22,10 +22,11 @@
5 private Gtk.SearchEntry search_entry;
6 private Views.CategoryView category_view;
7 private Views.FeaturedView featured_view;
8- private Views.InstalledView installed_view;
9 private Views.SearchView search_view;
10 private Gtk.Button return_button;
11 private ulong task_finished_connection = 0U;
12+
13+ public static Views.InstalledView installed_view { get; private set; }
14
15 public MainWindow (Gtk.Application app) {
16 Object (application: app);
17
18=== modified file 'src/Views/AppInfoView.vala'
19--- src/Views/AppInfoView.vala 2016-06-24 17:12:09 +0000
20+++ src/Views/AppInfoView.vala 2016-06-26 10:34:12 +0000
21@@ -279,8 +279,6 @@
22 }
23
24 private async void action_clicked () {
25- var treeset = new Gee.TreeSet<AppCenterCore.Package> ();
26- treeset.add (package);
27 try {
28 if (package.update_available) {
29 yield package.update ();
30@@ -294,6 +292,9 @@
31 uninstall_button.no_show_all = false;
32 uninstall_button.show ();
33 }
34+
35+ // Add this app to the Installed Apps View
36+ MainWindow.installed_view.add_app.begin (package);
37 }
38 } catch (Error e) {
39 critical (e.message);
40@@ -302,13 +303,14 @@
41 }
42
43 private async void uninstall_clicked () {
44- var treeset = new Gee.TreeSet<AppCenterCore.Package> ();
45- treeset.add (package);
46 try {
47 yield package.uninstall ();
48 action_button.label = _("Install");
49 uninstall_button.no_show_all = true;
50 uninstall_button.hide ();
51+
52+ // Remove this app from the Installed Apps View
53+ MainWindow.installed_view.remove_app.begin (package);
54 } catch (Error e) {
55 critical (e.message);
56 action_stack.set_visible_child_name ("buttons");
57
58=== modified file 'src/Views/AppListView.vala'
59--- src/Views/AppListView.vala 2016-06-15 23:49:38 +0000
60+++ src/Views/AppListView.vala 2016-06-26 10:34:12 +0000
61@@ -76,6 +76,16 @@
62 row.show_all ();
63 list_box.add (row);
64 }
65+
66+ public void remove_package (AppCenterCore.Package package) {
67+ var pkg_rows = list_box.get_children ();
68+ foreach (var row in pkg_rows) {
69+ if (((Widgets.PackageRow) row).package == package) {
70+ row.destroy ();
71+ break;
72+ }
73+ }
74+ }
75
76 public Gee.Collection<AppCenterCore.Package> get_packages () {
77 var tree_set = new Gee.TreeSet<AppCenterCore.Package> ();
78
79=== modified file 'src/Views/InstalledView.vala'
80--- src/Views/InstalledView.vala 2016-06-15 16:34:56 +0000
81+++ src/Views/InstalledView.vala 2016-06-26 10:34:12 +0000
82@@ -6,12 +6,12 @@
83 * it under the terms of the GNU General Public License as published by
84 * the Free Software Foundation, either version 3 of the License, or
85 * (at your option) any later version.
86- *
87+ *
88 * This program is distributed in the hope that it will be useful,
89 * but WITHOUT ANY WARRANTY; without even the implied warranty of
90 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91 * GNU General Public License for more details.
92- *
93+ *
94 * You should have received a copy of the GNU General Public License
95 * along with this program. If not, see <http://www.gnu.org/licenses/>.
96 *
97@@ -50,6 +50,7 @@
98
99 public async void get_apps () {
100 unowned Client client = Client.get_default ();
101+
102 var installed_apps = yield client.get_installed_applications ();
103 foreach (var app in installed_apps) {
104 app_list_view.add_package (app);
105@@ -57,4 +58,19 @@
106
107 yield client.get_updates ();
108 }
109+
110+ public async void add_app (AppCenterCore.Package package) {
111+ unowned Client client = Client.get_default ();
112+ var installed_apps = yield client.get_installed_applications ();
113+ foreach (var app in installed_apps) {
114+ if (app == package) {
115+ app_list_view.add_package (app);
116+ break;
117+ }
118+ }
119+ }
120+
121+ public async void remove_app (AppCenterCore.Package package) {
122+ app_list_view.remove_package (package);
123+ }
124 }

Subscribers

People subscribed via source and target branches