Merge lp:~stolowski/unity-lens-applications/use-libgnome-menu3 into lp:unity-lens-applications

Proposed by Paweł Stołowski
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: 318
Merged at revision: 315
Proposed branch: lp:~stolowski/unity-lens-applications/use-libgnome-menu3
Merge into: lp:unity-lens-applications
Diff against target: 266 lines (+75/-52)
6 files modified
configure.ac (+2/-2)
src/Makefile.am (+2/-2)
src/daemon.vala (+13/-4)
src/unity-package-search.cc (+56/-41)
tests/unit/Makefile.am (+1/-1)
vapi/unity-package-search.deps (+1/-2)
To merge this branch: bzr merge lp:~stolowski/unity-lens-applications/use-libgnome-menu3
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michal Hruby (community) Approve
Unity Team Pending
Review via email: mp+130509@code.launchpad.net

Commit message

Migrated the code to libgnome-menu-3 API. Require valac 0.18.

Description of the change

Migrated the code to libgnome-menu-3 API. Require valac 0.18 (because there is no lignome-menu-3 vapi for earlier valac).

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Looking good. +1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-10-10 09:22:14 +0000
3+++ configure.ac 2012-10-22 15:00:28 +0000
4@@ -15,7 +15,7 @@
5 # Init the other things we depend on
6 #############################################
7 AM_MAINTAINER_MODE
8-AM_PROG_VALAC([0.16.0])
9+AM_PROG_VALAC([0.18.0])
10 AS_IF([test -z "$VALAC"], [AC_MSG_ERROR(["No valac compiler found."])])
11 AC_PROG_CC
12 AC_PROG_CXX
13@@ -65,7 +65,7 @@
14 dee-1.0 >= 0.5.16
15 zeitgeist-1.0 >= 0.3.8
16 unity >= 6.7.0
17- libgnome-menu)
18+ libgnome-menu-3.0 >= 3.6.0)
19
20 AC_SUBST(LENS_DAEMON_CFLAGS)
21 AC_SUBST(LENS_DAEMON_LIBS)
22
23=== modified file 'src/Makefile.am'
24--- src/Makefile.am 2012-10-15 08:16:11 +0000
25+++ src/Makefile.am 2012-10-22 15:00:28 +0000
26@@ -35,7 +35,7 @@
27 --pkg zeitgeist-1.0 \
28 --pkg unity \
29 --pkg gee-1.0 \
30- --pkg libgnome-menu \
31+ --pkg libgnome-menu-3.0 \
32 --pkg unity-package-search \
33 --pkg unity-ratings-db \
34 --target-glib=2.26 \
35@@ -72,7 +72,7 @@
36 $(NULL)
37
38 unity-package-search.o : $(srcdir)/unity-package-search.cc $(srcdir)/unity-package-search.h
39- $(AM_V_GEN)$(CXX) -g $(unity_package_search_libs) -DGMENU_I_KNOW_THIS_IS_UNSTABLE `pkg-config --cflags --libs glib-2.0 libgnome-menu unity gee-1.0` -c $(srcdir)/unity-package-search.cc
40+ $(AM_V_GEN)$(CXX) -g $(unity_package_search_libs) -DGMENU_I_KNOW_THIS_IS_UNSTABLE `pkg-config --cflags --libs glib-2.0 libgnome-menu-3.0 unity gee-1.0` -c $(srcdir)/unity-package-search.cc
41
42 unity-ratings-db.o : $(srcdir)/unity-ratings-db.c $(srcdir)/unity-ratings-db.h
43 $(AM_V_CC)$(CC) -g $(unity_ratings_db_libs) `pkg-config --cflags --libs glib-2.0` -c $(srcdir)/unity-ratings-db.c
44
45=== modified file 'src/daemon.vala'
46--- src/daemon.vala 2012-10-16 10:33:26 +0000
47+++ src/daemon.vala 2012-10-22 15:00:28 +0000
48@@ -354,10 +354,19 @@
49 * the Installed and Availabale categorys. If a NoDisplay app is installed,
50 * eg. Evince, it wont otherwise be in the menu index, only in the
51 * S-C index - thus show up in the Available category */
52- app_menu = GMenu.Tree.lookup ("unity-lens-applications.menu",
53- GMenu.TreeFlags.INCLUDE_NODISPLAY);
54-
55- app_menu.add_monitor ((menu) => {
56+ app_menu = new GMenu.Tree ("unity-lens-applications.menu",
57+ GMenu.TreeFlags.INCLUDE_NODISPLAY);
58+
59+ try
60+ {
61+ app_menu.load_sync (); //FIXME: libgnome-menu doesn't provide async method (yet?)
62+ }
63+ catch (GLib.Error e)
64+ {
65+ warning ("Failed to load menu entries: %s", e.message);
66+ }
67+
68+ app_menu.changed.connect (() => {
69 /* Reschedule the timeout if we already have one. The menu tree triggers
70 * many change events during app installation. This way we wait the full
71 * delay *after* the last change event has triggered */
72
73=== modified file 'src/unity-package-search.cc'
74--- src/unity-package-search.cc 2012-10-09 15:26:49 +0000
75+++ src/unity-package-search.cc 2012-10-22 15:00:28 +0000
76@@ -137,11 +137,14 @@
77 static void
78 index_menu_item (Xapian::WritableDatabase *db,
79 Xapian::TermGenerator *indexer,
80- GMenuTreeItem *item)
81+ GMenuTreeDirectory *item)
82 {
83- Xapian::Document doc;
84- GSList *iter;
85 GMenuTreeEntry *entry;
86+ GMenuTreeDirectory *dir;
87+ GMenuTreeIter *iter;
88+ GDesktopAppInfo *info;
89+ GAppInfo *app_info;
90+ GMenuTreeItemType item_type;
91 UnityAppInfoManager *appman;
92 gchar **cats, **keywords;
93 gchar *dum1, *dum2, *dum3;
94@@ -151,47 +154,59 @@
95 g_return_if_fail (indexer != NULL);
96 g_return_if_fail (item != NULL);
97
98- switch (gmenu_tree_item_get_type (item))
99+ iter = gmenu_tree_directory_iter (item);
100+ while ((item_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID)
101 {
102- case GMENU_TREE_ITEM_INVALID:
103- return;
104+ Xapian::Document doc;
105+
106+ switch (item_type)
107+ {
108 case GMENU_TREE_ITEM_DIRECTORY:
109 /* Recurse into directory */
110- iter = gmenu_tree_directory_get_contents (GMENU_TREE_DIRECTORY (item));
111- for (; iter != NULL; iter = iter->next)
112- {
113- index_menu_item (db, indexer, GMENU_TREE_ITEM (iter->data));
114- }
115+ dir = gmenu_tree_iter_get_directory (iter);
116+ index_menu_item (db, indexer, dir);
117 break;
118 case GMENU_TREE_ITEM_ENTRY:
119 /* Add this entry to the index */
120- entry = GMENU_TREE_ENTRY (item);
121+ entry = gmenu_tree_iter_get_entry (iter);
122+ info = gmenu_tree_entry_get_app_info (entry);
123+ app_info = G_APP_INFO (info);
124
125 /* Store relevant values */
126- if (gmenu_tree_entry_get_display_name (entry))
127- doc.add_value (XAPIAN_VALUE_APPNAME, gmenu_tree_entry_get_display_name (entry));
128- if (gmenu_tree_entry_get_icon (entry))
129- doc.add_value (XAPIAN_VALUE_ICON, gmenu_tree_entry_get_icon (entry));
130+ if (g_app_info_get_display_name (app_info))
131+ doc.add_value (XAPIAN_VALUE_APPNAME, g_app_info_get_display_name (app_info));
132+
133+ if (g_app_info_get_icon (app_info))
134+ {
135+ gchar *icon_str = g_icon_to_string (g_app_info_get_icon (app_info));
136+ if (icon_str != NULL)
137+ {
138+ doc.add_value (XAPIAN_VALUE_ICON, icon_str);
139+ g_free (icon_str);
140+ }
141+ }
142 if (gmenu_tree_entry_get_desktop_file_id (entry))
143+ {
144 doc.add_value (XAPIAN_VALUE_DESKTOP_FILE, gmenu_tree_entry_get_desktop_file_id (entry));
145-
146+ }
147+
148 /* Index full text data */
149 indexer->set_document(doc);
150- if (gmenu_tree_entry_get_display_name (entry))
151- {
152- dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_display_name (entry));
153- indexer->index_text(dum1, 5);
154- g_free (dum1);
155- }
156- if (gmenu_tree_entry_get_name (entry))
157- {
158- dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_name (entry));
159- indexer->index_text(dum1, 5);
160- g_free (dum1);
161- }
162- if (gmenu_tree_entry_get_comment (entry))
163- {
164- dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_comment (entry));
165+ if (g_app_info_get_display_name (app_info))
166+ {
167+ dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_display_name (app_info));
168+ indexer->index_text(dum1, 5);
169+ g_free (dum1);
170+ }
171+ if (g_app_info_get_name (app_info))
172+ {
173+ dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_name (app_info));
174+ indexer->index_text(dum1, 5);
175+ g_free (dum1);
176+ }
177+ if (g_app_info_get_description (app_info))
178+ {
179+ dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_description (app_info));
180 indexer->index_text (dum1, 0);
181 g_free (dum1);
182 }
183@@ -232,18 +247,18 @@
184 doc.add_term ("ATapplication");
185
186 /* Index application names */
187- dum1 = (gchar *) gmenu_tree_entry_get_display_name (entry); // const
188+ dum1 = (gchar *) g_app_info_get_display_name (app_info);
189 dum2 = g_strconcat ("AA", dum1, NULL);
190 doc.add_term (dum2);
191 g_free (dum2);
192
193- dum1 = (gchar *) gmenu_tree_entry_get_name (entry); // const
194+ dum1 = (gchar *) g_app_info_get_name (app_info);
195 dum2 = g_strconcat ("AA", dum1, NULL);
196 doc.add_term (dum2);
197 g_free (dum2);
198
199 /* Index executable name, change - in _ for exec */
200- dum1 = g_strdup (gmenu_tree_entry_get_exec (entry)); // alloc
201+ dum1 = g_strdup (g_app_info_get_commandline (app_info)); // alloc
202 if (dum1)
203 {
204 dum2 = strstr (dum1, " "); // const
205@@ -268,8 +283,9 @@
206 case GMENU_TREE_ITEM_ALIAS:
207 break;
208 default:
209- g_warning ("Unexpected GMenuTreeItemType %u", gmenu_tree_item_get_type (item));
210- return;
211+ g_warning ("Unexpected GMenuTreeItemType %u", item_type);
212+ break;
213+ }
214 }
215
216 // Add the document to the database.
217@@ -292,8 +308,7 @@
218
219 /* Index the menu recursively */
220 Xapian::TermGenerator *indexer = new Xapian::TermGenerator ();
221- index_menu_item (db, indexer,
222- GMENU_TREE_ITEM (gmenu_tree_get_root_directory (menu)));
223+ index_menu_item (db, indexer, gmenu_tree_get_root_directory (menu));
224 delete indexer;
225 db->flush ();
226
227@@ -336,7 +351,7 @@
228 }
229
230 init_searcher (searcher);
231-
232+
233 return searcher;
234 }
235
236@@ -672,7 +687,7 @@
237 g_warning ("List should have even list of arguments");
238 return NULL;
239 }
240-
241+
242 const string pkgname = ((char *)iter->data);
243 Xapian::Query query1 ("AA" + appname);
244 Xapian::Query query2 ("AP" + pkgname);
245
246=== modified file 'tests/unit/Makefile.am'
247--- tests/unit/Makefile.am 2012-10-12 09:56:12 +0000
248+++ tests/unit/Makefile.am 2012-10-22 15:00:28 +0000
249@@ -93,7 +93,7 @@
250 nodist_test_software_center_details_SOURCES = $(test_software_center_details_VALASOURCES:.vala=.c)
251
252 unity-package-search.o : $(top_srcdir)/src/unity-package-search.cc $(top_srcdir)/src/unity-package-search.h
253- $(AM_V_GEN)$(CXX) -g $(UNITY_PACKAGE_SEARCH_LIBS) -DGMENU_I_KNOW_THIS_IS_UNSTABLE `pkg-config --cflags --libs glib-2.0 libgnome-menu unity gee-1.0` -c $(top_srcdir)/src/unity-package-search.cc
254+ $(AM_V_GEN)$(CXX) -g $(UNITY_PACKAGE_SEARCH_LIBS) -DGMENU_I_KNOW_THIS_IS_UNSTABLE `pkg-config --cflags --libs glib-2.0 libgnome-menu-3.0 unity gee-1.0` -c $(top_srcdir)/src/unity-package-search.cc
255
256 CLEANFILES = *.stamp \
257 $(test_software_center_data_cache_VALASOURCES:.vala=.c) \
258
259=== modified file 'vapi/unity-package-search.deps'
260--- vapi/unity-package-search.deps 2010-09-02 10:48:11 +0000
261+++ vapi/unity-package-search.deps 2012-10-22 15:00:28 +0000
262@@ -1,3 +1,2 @@
263 glib-2.0
264-libgnome-menu
265-
266+libgnome-menu-3.0

Subscribers

People subscribed via source and target branches