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
=== modified file 'configure.ac'
--- configure.ac 2012-10-10 09:22:14 +0000
+++ configure.ac 2012-10-22 15:00:28 +0000
@@ -15,7 +15,7 @@
15# Init the other things we depend on15# Init the other things we depend on
16#############################################16#############################################
17AM_MAINTAINER_MODE17AM_MAINTAINER_MODE
18AM_PROG_VALAC([0.16.0])18AM_PROG_VALAC([0.18.0])
19AS_IF([test -z "$VALAC"], [AC_MSG_ERROR(["No valac compiler found."])])19AS_IF([test -z "$VALAC"], [AC_MSG_ERROR(["No valac compiler found."])])
20AC_PROG_CC20AC_PROG_CC
21AC_PROG_CXX21AC_PROG_CXX
@@ -65,7 +65,7 @@
65 dee-1.0 >= 0.5.1665 dee-1.0 >= 0.5.16
66 zeitgeist-1.0 >= 0.3.866 zeitgeist-1.0 >= 0.3.8
67 unity >= 6.7.067 unity >= 6.7.0
68 libgnome-menu)68 libgnome-menu-3.0 >= 3.6.0)
6969
70AC_SUBST(LENS_DAEMON_CFLAGS)70AC_SUBST(LENS_DAEMON_CFLAGS)
71AC_SUBST(LENS_DAEMON_LIBS)71AC_SUBST(LENS_DAEMON_LIBS)
7272
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-10-15 08:16:11 +0000
+++ src/Makefile.am 2012-10-22 15:00:28 +0000
@@ -35,7 +35,7 @@
35 --pkg zeitgeist-1.0 \35 --pkg zeitgeist-1.0 \
36 --pkg unity \36 --pkg unity \
37 --pkg gee-1.0 \37 --pkg gee-1.0 \
38 --pkg libgnome-menu \38 --pkg libgnome-menu-3.0 \
39 --pkg unity-package-search \39 --pkg unity-package-search \
40 --pkg unity-ratings-db \40 --pkg unity-ratings-db \
41 --target-glib=2.26 \41 --target-glib=2.26 \
@@ -72,7 +72,7 @@
72 $(NULL)72 $(NULL)
7373
74unity-package-search.o : $(srcdir)/unity-package-search.cc $(srcdir)/unity-package-search.h74unity-package-search.o : $(srcdir)/unity-package-search.cc $(srcdir)/unity-package-search.h
75 $(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.cc75 $(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
7676
77unity-ratings-db.o : $(srcdir)/unity-ratings-db.c $(srcdir)/unity-ratings-db.h77unity-ratings-db.o : $(srcdir)/unity-ratings-db.c $(srcdir)/unity-ratings-db.h
78 $(AM_V_CC)$(CC) -g $(unity_ratings_db_libs) `pkg-config --cflags --libs glib-2.0` -c $(srcdir)/unity-ratings-db.c78 $(AM_V_CC)$(CC) -g $(unity_ratings_db_libs) `pkg-config --cflags --libs glib-2.0` -c $(srcdir)/unity-ratings-db.c
7979
=== modified file 'src/daemon.vala'
--- src/daemon.vala 2012-10-16 10:33:26 +0000
+++ src/daemon.vala 2012-10-22 15:00:28 +0000
@@ -354,10 +354,19 @@
354 * the Installed and Availabale categorys. If a NoDisplay app is installed,354 * the Installed and Availabale categorys. If a NoDisplay app is installed,
355 * eg. Evince, it wont otherwise be in the menu index, only in the355 * eg. Evince, it wont otherwise be in the menu index, only in the
356 * S-C index - thus show up in the Available category */356 * S-C index - thus show up in the Available category */
357 app_menu = GMenu.Tree.lookup ("unity-lens-applications.menu",357 app_menu = new GMenu.Tree ("unity-lens-applications.menu",
358 GMenu.TreeFlags.INCLUDE_NODISPLAY);358 GMenu.TreeFlags.INCLUDE_NODISPLAY);
359359
360 app_menu.add_monitor ((menu) => {360 try
361 {
362 app_menu.load_sync (); //FIXME: libgnome-menu doesn't provide async method (yet?)
363 }
364 catch (GLib.Error e)
365 {
366 warning ("Failed to load menu entries: %s", e.message);
367 }
368
369 app_menu.changed.connect (() => {
361 /* Reschedule the timeout if we already have one. The menu tree triggers370 /* Reschedule the timeout if we already have one. The menu tree triggers
362 * many change events during app installation. This way we wait the full371 * many change events during app installation. This way we wait the full
363 * delay *after* the last change event has triggered */372 * delay *after* the last change event has triggered */
364373
=== modified file 'src/unity-package-search.cc'
--- src/unity-package-search.cc 2012-10-09 15:26:49 +0000
+++ src/unity-package-search.cc 2012-10-22 15:00:28 +0000
@@ -137,11 +137,14 @@
137static void137static void
138index_menu_item (Xapian::WritableDatabase *db,138index_menu_item (Xapian::WritableDatabase *db,
139 Xapian::TermGenerator *indexer,139 Xapian::TermGenerator *indexer,
140 GMenuTreeItem *item)140 GMenuTreeDirectory *item)
141{141{
142 Xapian::Document doc;
143 GSList *iter;
144 GMenuTreeEntry *entry;142 GMenuTreeEntry *entry;
143 GMenuTreeDirectory *dir;
144 GMenuTreeIter *iter;
145 GDesktopAppInfo *info;
146 GAppInfo *app_info;
147 GMenuTreeItemType item_type;
145 UnityAppInfoManager *appman;148 UnityAppInfoManager *appman;
146 gchar **cats, **keywords;149 gchar **cats, **keywords;
147 gchar *dum1, *dum2, *dum3;150 gchar *dum1, *dum2, *dum3;
@@ -151,47 +154,59 @@
151 g_return_if_fail (indexer != NULL);154 g_return_if_fail (indexer != NULL);
152 g_return_if_fail (item != NULL);155 g_return_if_fail (item != NULL);
153156
154 switch (gmenu_tree_item_get_type (item))157 iter = gmenu_tree_directory_iter (item);
158 while ((item_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID)
155 {159 {
156 case GMENU_TREE_ITEM_INVALID:160 Xapian::Document doc;
157 return;161
162 switch (item_type)
163 {
158 case GMENU_TREE_ITEM_DIRECTORY:164 case GMENU_TREE_ITEM_DIRECTORY:
159 /* Recurse into directory */165 /* Recurse into directory */
160 iter = gmenu_tree_directory_get_contents (GMENU_TREE_DIRECTORY (item));166 dir = gmenu_tree_iter_get_directory (iter);
161 for (; iter != NULL; iter = iter->next)167 index_menu_item (db, indexer, dir);
162 {
163 index_menu_item (db, indexer, GMENU_TREE_ITEM (iter->data));
164 }
165 break;168 break;
166 case GMENU_TREE_ITEM_ENTRY:169 case GMENU_TREE_ITEM_ENTRY:
167 /* Add this entry to the index */170 /* Add this entry to the index */
168 entry = GMENU_TREE_ENTRY (item);171 entry = gmenu_tree_iter_get_entry (iter);
172 info = gmenu_tree_entry_get_app_info (entry);
173 app_info = G_APP_INFO (info);
169174
170 /* Store relevant values */175 /* Store relevant values */
171 if (gmenu_tree_entry_get_display_name (entry))176 if (g_app_info_get_display_name (app_info))
172 doc.add_value (XAPIAN_VALUE_APPNAME, gmenu_tree_entry_get_display_name (entry));177 doc.add_value (XAPIAN_VALUE_APPNAME, g_app_info_get_display_name (app_info));
173 if (gmenu_tree_entry_get_icon (entry))178
174 doc.add_value (XAPIAN_VALUE_ICON, gmenu_tree_entry_get_icon (entry));179 if (g_app_info_get_icon (app_info))
180 {
181 gchar *icon_str = g_icon_to_string (g_app_info_get_icon (app_info));
182 if (icon_str != NULL)
183 {
184 doc.add_value (XAPIAN_VALUE_ICON, icon_str);
185 g_free (icon_str);
186 }
187 }
175 if (gmenu_tree_entry_get_desktop_file_id (entry))188 if (gmenu_tree_entry_get_desktop_file_id (entry))
189 {
176 doc.add_value (XAPIAN_VALUE_DESKTOP_FILE, gmenu_tree_entry_get_desktop_file_id (entry));190 doc.add_value (XAPIAN_VALUE_DESKTOP_FILE, gmenu_tree_entry_get_desktop_file_id (entry));
177 191 }
192
178 /* Index full text data */193 /* Index full text data */
179 indexer->set_document(doc);194 indexer->set_document(doc);
180 if (gmenu_tree_entry_get_display_name (entry))195 if (g_app_info_get_display_name (app_info))
181 {196 {
182 dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_display_name (entry));197 dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_display_name (app_info));
183 indexer->index_text(dum1, 5);198 indexer->index_text(dum1, 5);
184 g_free (dum1);199 g_free (dum1);
185 }200 }
186 if (gmenu_tree_entry_get_name (entry))201 if (g_app_info_get_name (app_info))
187 {202 {
188 dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_name (entry));203 dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_name (app_info));
189 indexer->index_text(dum1, 5);204 indexer->index_text(dum1, 5);
190 g_free (dum1);205 g_free (dum1);
191 }206 }
192 if (gmenu_tree_entry_get_comment (entry))207 if (g_app_info_get_description (app_info))
193 {208 {
194 dum1 = unity_applications_lens_utils_preprocess_string (gmenu_tree_entry_get_comment (entry));209 dum1 = unity_applications_lens_utils_preprocess_string (g_app_info_get_description (app_info));
195 indexer->index_text (dum1, 0);210 indexer->index_text (dum1, 0);
196 g_free (dum1);211 g_free (dum1);
197 }212 }
@@ -232,18 +247,18 @@
232 doc.add_term ("ATapplication");247 doc.add_term ("ATapplication");
233248
234 /* Index application names */249 /* Index application names */
235 dum1 = (gchar *) gmenu_tree_entry_get_display_name (entry); // const250 dum1 = (gchar *) g_app_info_get_display_name (app_info);
236 dum2 = g_strconcat ("AA", dum1, NULL);251 dum2 = g_strconcat ("AA", dum1, NULL);
237 doc.add_term (dum2);252 doc.add_term (dum2);
238 g_free (dum2);253 g_free (dum2);
239254
240 dum1 = (gchar *) gmenu_tree_entry_get_name (entry); // const255 dum1 = (gchar *) g_app_info_get_name (app_info);
241 dum2 = g_strconcat ("AA", dum1, NULL);256 dum2 = g_strconcat ("AA", dum1, NULL);
242 doc.add_term (dum2);257 doc.add_term (dum2);
243 g_free (dum2);258 g_free (dum2);
244259
245 /* Index executable name, change - in _ for exec */260 /* Index executable name, change - in _ for exec */
246 dum1 = g_strdup (gmenu_tree_entry_get_exec (entry)); // alloc261 dum1 = g_strdup (g_app_info_get_commandline (app_info)); // alloc
247 if (dum1)262 if (dum1)
248 {263 {
249 dum2 = strstr (dum1, " "); // const264 dum2 = strstr (dum1, " "); // const
@@ -268,8 +283,9 @@
268 case GMENU_TREE_ITEM_ALIAS:283 case GMENU_TREE_ITEM_ALIAS:
269 break;284 break;
270 default:285 default:
271 g_warning ("Unexpected GMenuTreeItemType %u", gmenu_tree_item_get_type (item));286 g_warning ("Unexpected GMenuTreeItemType %u", item_type);
272 return;287 break;
288 }
273 }289 }
274290
275 // Add the document to the database.291 // Add the document to the database.
@@ -292,8 +308,7 @@
292308
293 /* Index the menu recursively */309 /* Index the menu recursively */
294 Xapian::TermGenerator *indexer = new Xapian::TermGenerator ();310 Xapian::TermGenerator *indexer = new Xapian::TermGenerator ();
295 index_menu_item (db, indexer,311 index_menu_item (db, indexer, gmenu_tree_get_root_directory (menu));
296 GMENU_TREE_ITEM (gmenu_tree_get_root_directory (menu)));
297 delete indexer;312 delete indexer;
298 db->flush ();313 db->flush ();
299314
@@ -336,7 +351,7 @@
336 }351 }
337352
338 init_searcher (searcher);353 init_searcher (searcher);
339 354
340 return searcher;355 return searcher;
341}356}
342357
@@ -672,7 +687,7 @@
672 g_warning ("List should have even list of arguments");687 g_warning ("List should have even list of arguments");
673 return NULL;688 return NULL;
674 }689 }
675 690
676 const string pkgname = ((char *)iter->data);691 const string pkgname = ((char *)iter->data);
677 Xapian::Query query1 ("AA" + appname);692 Xapian::Query query1 ("AA" + appname);
678 Xapian::Query query2 ("AP" + pkgname);693 Xapian::Query query2 ("AP" + pkgname);
679694
=== modified file 'tests/unit/Makefile.am'
--- tests/unit/Makefile.am 2012-10-12 09:56:12 +0000
+++ tests/unit/Makefile.am 2012-10-22 15:00:28 +0000
@@ -93,7 +93,7 @@
93nodist_test_software_center_details_SOURCES = $(test_software_center_details_VALASOURCES:.vala=.c)93nodist_test_software_center_details_SOURCES = $(test_software_center_details_VALASOURCES:.vala=.c)
9494
95unity-package-search.o : $(top_srcdir)/src/unity-package-search.cc $(top_srcdir)/src/unity-package-search.h95unity-package-search.o : $(top_srcdir)/src/unity-package-search.cc $(top_srcdir)/src/unity-package-search.h
96 $(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.cc96 $(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
9797
98CLEANFILES = *.stamp \98CLEANFILES = *.stamp \
99 $(test_software_center_data_cache_VALASOURCES:.vala=.c) \99 $(test_software_center_data_cache_VALASOURCES:.vala=.c) \
100100
=== modified file 'vapi/unity-package-search.deps'
--- vapi/unity-package-search.deps 2010-09-02 10:48:11 +0000
+++ vapi/unity-package-search.deps 2012-10-22 15:00:28 +0000
@@ -1,3 +1,2 @@
1glib-2.01glib-2.0
2libgnome-menu2libgnome-menu-3.0
3

Subscribers

People subscribed via source and target branches