Merge lp:~ricotz/slingshot/port-gmenu3 into lp:~elementary-pantheon/slingshot/trunk

Proposed by Rico Tzschichholz on 2014-02-23
Status: Merged
Approved by: Corentin Noël on 2014-02-23
Approved revision: 405
Merged at revision: 405
Proposed branch: lp:~ricotz/slingshot/port-gmenu3
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 227 lines (+59/-67)
3 files modified
CMakeLists.txt (+2/-2)
src/Backend/App.vala (+24/-8)
src/Backend/AppSystem.vala (+33/-57)
To merge this branch: bzr merge lp:~ricotz/slingshot/port-gmenu3
Reviewer Review Type Date Requested Status
Corentin Noël 2014-02-23 Approve on 2014-02-23
Tom Beckmann 2014-02-23 Pending
Review via email: mp+207833@code.launchpad.net

This proposal supersedes a proposal from 2012-09-15.

Description of the change

Transition to use libgnome-menu-3.0

To post a comment you must log in.
Tom Beckmann (tombeckmann) wrote : Posted in a previous version of this proposal

Working perfectly now.

review: Approve
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

This branch can be modified as the vapi is now provided by vala on Isis

review: Needs Fixing
Corentin Noël (tintou) : Posted in a previous version of this proposal
review: Approve
Corentin Noël (tintou) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-01-31 17:57:40 +0000
3+++ CMakeLists.txt 2014-02-23 17:12:47 +0000
4@@ -54,7 +54,7 @@
5 message ("-- Zeitgeist integration disabled")
6 endif ()
7
8-set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;gee-1.0;libgnome-menu;libwnck-3.0;gdk-x11-3.0;${UNITY_DEPS};")
9+set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;gee-1.0;libgnome-menu-3.0;libwnck-3.0;gdk-x11-3.0;${UNITY_DEPS};")
10 set (UI_DEPS "gtk+-3.0>=3.2.0;granite;${ZEITGEIST_DEPS};")
11
12 find_package (PkgConfig)
13@@ -62,7 +62,7 @@
14
15 find_package (Vala REQUIRED)
16 include (ValaVersion)
17-ensure_vala_version ("0.15.1" MINIMUM)
18+ensure_vala_version ("0.18.0" MINIMUM)
19
20 include (ValaPrecompile)
21 vala_precompile (VALA_C ${APPNAME}
22
23=== modified file 'src/Backend/App.vala'
24--- src/Backend/App.vala 2014-01-31 17:57:40 +0000
25+++ src/Backend/App.vala 2014-02-23 17:12:47 +0000
26@@ -24,7 +24,7 @@
27 public string exec { get; private set; }
28 public string icon_name { get; private set; default = ""; }
29 public string[] keywords { get; private set;}
30- public Gdk.Pixbuf icon { get; private set; }
31+ public Gdk.Pixbuf? icon { get; private set; default = null; }
32 public double popularity { get; set; }
33 public double relevancy { get; set; }
34 public string desktop_path { get; private set; }
35@@ -36,18 +36,34 @@
36 public signal void launched (App app);
37
38 public App (GMenu.TreeEntry entry) {
39- name = entry.get_display_name ();
40- description = entry.get_comment () ?? name;
41- exec = entry.get_exec ();
42+ unowned GLib.DesktopAppInfo info = entry.get_app_info ();
43+ name = info.get_display_name ().dup ();
44+ description = info.get_description ().dup () ?? name;
45+ exec = info.get_commandline ().dup ();
46 desktop_id = entry.get_desktop_file_id ();
47- icon_name = entry.get_icon () ?? "application-default-icon";
48 desktop_path = entry.get_desktop_file_path ();
49 #if HAVE_UNITY
50 keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id);
51 #endif
52- generic_name = entry.get_generic_name ();
53-
54- update_icon ();
55+ generic_name = info.get_generic_name ();
56+
57+ if (info.get_icon () is ThemedIcon) {
58+ icon_name = (info.get_icon () as ThemedIcon).get_names ()[0].dup ();
59+ } else if (info.get_icon () is LoadableIcon) {
60+ try {
61+ var ios = (info.get_icon () as LoadableIcon).load (0, null, null);
62+ icon = new Gdk.Pixbuf.from_stream_at_scale (ios, Slingshot.settings.icon_size,
63+ Slingshot.settings.icon_size, true, null);
64+ } catch {
65+ icon_name = "application-default-icon";
66+ }
67+ } else {
68+ icon_name = "application-default-icon";
69+ }
70+
71+ if (icon == null)
72+ update_icon ();
73+
74 Slingshot.icon_theme.changed.connect (update_icon);
75 }
76
77
78=== modified file 'src/Backend/AppSystem.vala'
79--- src/Backend/AppSystem.vala 2014-01-31 15:20:32 +0000
80+++ src/Backend/AppSystem.vala 2014-02-23 17:12:47 +0000
81@@ -27,7 +27,6 @@
82 #endif
83
84 public signal void changed ();
85- private bool index_changed = false;
86
87 construct {
88
89@@ -36,43 +35,43 @@
90 rl_service.update_complete.connect (update_popularity);
91 #endif
92
93- apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED);
94- apps_menu.add_monitor ((menu) => {
95-
96- debug ("Apps menu tree changed. Updating…");
97- index_changed = true;
98- update_app_system ();
99- changed ();
100-
101- });
102-
103- apps_menu.set_sort_key (GMenu.TreeSortKey.DISPLAY_NAME);
104+ apps_menu = new GMenu.Tree ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED | GMenu.TreeFlags.SORT_DISPLAY_NAME);
105+ apps_menu.changed.connect (update_app_system);
106+
107+ apps = new Gee.HashMap<string, Gee.ArrayList<App>> ();
108+ categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
109+
110 update_app_system ();
111
112 }
113
114 private void update_app_system () {
115
116+ debug ("Updating Applications menu tree...");
117 #if HAVE_ZEITGEIST
118 rl_service.refresh_popularity ();
119 #endif
120
121+ apps_menu.load_sync ();
122+
123 update_categories_index ();
124 update_apps ();
125
126+ changed ();
127+
128 }
129
130 private void update_categories_index () {
131
132- var root_tree = apps_menu.get_root_directory ();
133-
134- if (categories == null || index_changed) {
135- categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
136-
137- foreach (GMenu.TreeItem item in root_tree.get_contents ()) {
138- if (item.get_type () == GMenu.TreeItemType.DIRECTORY)
139- if (((GMenu.TreeDirectory) item).get_is_nodisplay () == false)
140- categories.add ((GMenu.TreeDirectory) item);
141+ categories.clear ();
142+
143+ var iter = apps_menu.get_root_directory ().iter ();
144+ GMenu.TreeItemType type;
145+ while ((type = iter.next ()) != GMenu.TreeItemType.INVALID) {
146+ if (type == GMenu.TreeItemType.DIRECTORY) {
147+ var dir = iter.get_directory ();
148+ if (!dir.get_is_nodisplay ())
149+ categories.add (dir);
150 }
151 }
152
153@@ -89,21 +88,10 @@
154
155 private void update_apps () {
156
157- if (index_changed) {
158- apps.clear ();
159- apps = null;
160- index_changed = false;
161- }
162-
163- if (apps == null) {
164-
165- apps = new Gee.HashMap<string, Gee.ArrayList<App>> ();
166-
167- foreach (GMenu.TreeDirectory cat in categories) {
168- apps.set (cat.get_name (), get_apps_by_category (cat));
169- }
170-
171- }
172+ apps.clear ();
173+
174+ foreach (var cat in categories)
175+ apps.set (cat.get_name (), get_apps_by_category (cat));
176
177 }
178
179@@ -117,39 +105,27 @@
180
181 var app_list = new Gee.ArrayList<App> ();
182
183- foreach (GMenu.TreeItem item in category.get_contents ()) {
184- App app;
185- switch (item.get_type ()) {
186+ var iter = category.iter ();
187+ GMenu.TreeItemType type;
188+ while ((type = iter.next ()) != GMenu.TreeItemType.INVALID) {
189+ switch (type) {
190 case GMenu.TreeItemType.DIRECTORY:
191- app_list.add_all (get_apps_by_category ((GMenu.TreeDirectory) item));
192+ app_list.add_all (get_apps_by_category (iter.get_directory ()));
193 break;
194 case GMenu.TreeItemType.ENTRY:
195- if (is_entry ((GMenu.TreeEntry) item)) {
196- app = new App ((GMenu.TreeEntry) item);
197+ var app = new App (iter.get_entry ());
198 #if HAVE_ZEITGEIST
199- app.launched.connect (rl_service.app_launched);
200+ app.launched.connect (rl_service.app_launched);
201 #endif
202- app_list.add (app);
203- }
204+ app_list.add (app);
205 break;
206 }
207 }
208+
209 return app_list;
210
211 }
212
213- private bool is_entry (GMenu.TreeEntry entry) {
214-
215- if (entry.get_launch_in_terminal () == false
216- && entry.get_is_excluded () == false
217- && entry.get_is_nodisplay () == false) {
218- return true;
219- } else {
220- return false;
221- }
222-
223- }
224-
225 public Gee.HashMap<string, Gee.ArrayList<App>> get_apps () {
226
227 return apps;

Subscribers

People subscribed via source and target branches