Merge lp:~donadigo/appcenter/main-window-cache into lp:~elementary-apps/appcenter/appcenter

Proposed by Adam Bieńkowski
Status: Rejected
Rejected by: Danielle Foré
Proposed branch: lp:~donadigo/appcenter/main-window-cache
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 90 lines (+16/-29)
2 files modified
src/Application.vala (+14/-15)
src/MainWindow.vala (+2/-14)
To merge this branch: bzr merge lp:~donadigo/appcenter/main-window-cache
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+314782@code.launchpad.net

Commit message

* Cache main window once to show it immediately to the user

Description of the change

This branch does some changes to how the main window is handeled / shown. Since appcenter is always running, the main window can be cached and kept in the memory while in trunk it gets destroyed and rebuilt again when user wants to open it.

With this branch there should be a noticeable speed increase when opening the window.

Keep in mind that this branch is *experimental*, it increases memory use in the system and should be heavily tested before merging it.

To post a comment you must log in.
376. By Adam Bieńkowski

Don't get the client explicitly on activate

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

This kind of seems like a not great idea to me. I don't think there's a need to prioritize launching appcenter faster. It already launches fast. I think the fact that we don't hold onto that memory in the background is a feature

Unmerged revisions

376. By Adam Bieńkowski

Don't get the client explicitly on activate

375. By Adam Bieńkowski

Some experimental improvements to how main window is handeled

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Application.vala'
2--- src/Application.vala 2016-12-28 16:29:00 +0000
3+++ src/Application.vala 2017-01-15 14:50:52 +0000
4@@ -94,35 +94,34 @@
5 activate ();
6 }
7
8+ public override void startup () {
9+ base.startup ();
10+
11+ main_window = new MainWindow (this);
12+ add_window (main_window);
13+
14+ var client = AppCenterCore.Client.get_default ();
15+ client.update_cache.begin (true);
16+ }
17+
18 public override void activate () {
19- var client = AppCenterCore.Client.get_default ();
20 if (silent) {
21 NetworkMonitor.get_default ().network_changed.connect ((available) => {
22 schedule_cache_update (!available);
23 });
24
25- client.update_cache.begin (true);
26 silent = false;
27 hold ();
28 return;
29 }
30
31- if (main_window == null) {
32- client.update_cache.begin (true);
33-
34- main_window = new MainWindow (this);
35- main_window.destroy.connect (() => {
36- main_window = null;
37- });
38-
39- add_window (main_window);
40- main_window.show_all ();
41- if (show_updates) {
42- main_window.go_to_installed ();
43- }
44+ main_window.show_all ();
45+ if (show_updates) {
46+ main_window.go_to_installed ();
47 }
48
49 if (link != null) {
50+ var client = AppCenterCore.Client.get_default ();
51 var package = client.get_package_for_id (link);
52 if (package != null) {
53 main_window.show_package (package);
54
55=== modified file 'src/MainWindow.vala'
56--- src/MainWindow.vala 2016-12-27 23:21:25 +0000
57+++ src/MainWindow.vala 2017-01-15 14:50:52 +0000
58@@ -27,7 +27,6 @@
59 private Gtk.Button return_button;
60 private Gtk.Button search_all_button;
61 private Gtk.Stack button_stack;
62- private ulong task_finished_connection = 0U;
63 private Gee.Deque<string> return_button_history;
64
65 public static Views.InstalledView installed_view { get; private set; }
66@@ -166,22 +165,11 @@
67
68 unowned AppCenterCore.Client client = AppCenterCore.Client.get_default ();
69 if (client.has_tasks ()) {
70- if (task_finished_connection != 0U) {
71- client.disconnect (task_finished_connection);
72- }
73-
74- hide ();
75- task_finished_connection = client.notify["task-count"].connect (() => {
76- if (!visible && client.task_count == 0) {
77- destroy ();
78- }
79- });
80-
81 client.cancel_updates (false); //Timeouts keep running
82- return true;
83 }
84
85- return false;
86+ hide ();
87+ return true;
88 }
89
90 public void show_package (AppCenterCore.Package package) {

Subscribers

People subscribed via source and target branches