Package list cinnamon-menus / 75c7079
Merge tag 'upstream/3.0.2' Upstream version 3.0.2 Margarita Manterola 5 years ago
3 changed file(s) with 42 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
00 AC_PREREQ(2.62)
11
2 AC_INIT([cinnamon-menus], [3.0.1])
2 AC_INIT([cinnamon-menus], [3.0.2])
33 AC_CONFIG_SRCDIR(libmenu/gmenu-tree.h)
44
55 AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
265265 static DesktopEntryResultCode
266266 desktop_entry_load (DesktopEntry *entry)
267267 {
268 DesktopEntryResultCode rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER;
269
270268 if (strstr (entry->path, "/menu-xdg/"))
271 return rescode;
272
269 return DESKTOP_ENTRY_LOAD_FAIL_OTHER;
273270 if (entry->type == DESKTOP_ENTRY_DESKTOP)
274271 {
275272 GKeyFile *key_file = NULL;
276273 DesktopEntryDesktop *entry_desktop = (DesktopEntryDesktop*)entry;
274 const char *categories_str;
275
276 entry_desktop->appinfo = g_desktop_app_info_new_from_filename (entry->path);
277 if (!entry_desktop->appinfo ||
278 !g_app_info_get_name (G_APP_INFO (entry_desktop->appinfo)) ||
279 !g_app_info_get_executable (G_APP_INFO (entry_desktop->appinfo)))
280 {
281 menu_verbose ("Failed to load \"%s\"\n", entry->path);
282 return DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
283 }
284
285 categories_str = g_desktop_app_info_get_categories (entry_desktop->appinfo);
286 if (categories_str)
287 {
288 char **categories;
289 int i;
290
291 categories = g_strsplit (categories_str, ";", -1);
292 entry_desktop->categories = g_new0 (GQuark, g_strv_length (categories) + 1);
293
294 for (i = 0; categories[i]; i++)
295 entry_desktop->categories[i] = g_quark_from_string (categories[i]);
296
297 g_strfreev (categories);
298 }
277299
278300 key_file = g_key_file_new ();
279301
280 if (g_key_file_load_from_file (key_file, entry->path, 0, NULL))
281 {
282 entry_desktop->appinfo = g_desktop_app_info_new_from_keyfile (key_file);
283
284 if (!entry_desktop->appinfo ||
285 !g_app_info_get_name (G_APP_INFO (entry_desktop->appinfo)) ||
286 !g_app_info_get_executable (G_APP_INFO (entry_desktop->appinfo)))
287 {
288 menu_verbose ("Failed to load appinfo for \"%s\"\n", entry->path);
289 rescode = DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
290 }
291 else
292 {
293 const char *categories_str;
294 categories_str = g_desktop_app_info_get_categories (entry_desktop->appinfo);
295
296 if (categories_str)
297 {
298 char **categories;
299 int i;
300
301 categories = g_strsplit (categories_str, ";", -1);
302 entry_desktop->categories = g_new0 (GQuark, g_strv_length (categories) + 1);
303
304 for (i = 0; categories[i]; i++)
305 entry_desktop->categories[i] = g_quark_from_string (categories[i]);
306
307 g_strfreev (categories);
308 }
309
310 entry_desktop->showin = key_file_get_show_in (key_file);
311
312 rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
313 }
314 }
302 if (!g_key_file_load_from_file (key_file, entry->path, 0, NULL))
303 entry_desktop->showin = TRUE;
315304 else
316 {
317 menu_verbose ("Failed to read contents of \"%s\"\n", entry->path);
318 rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER;
319 }
305 entry_desktop->showin = key_file_get_show_in (key_file);
306
320307 g_key_file_free (key_file);
308
309 return DESKTOP_ENTRY_LOAD_SUCCESS;
321310 }
322311 else if (entry->type == DESKTOP_ENTRY_DIRECTORY)
323312 {
324313 GKeyFile *key_file = NULL;
325314 GError *error = NULL;
326 rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
315 DesktopEntryResultCode rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
327316
328317 key_file = g_key_file_new ();
329318
354343 else
355344 menu_verbose ("Failed to load \"%s\"\n", entry->path);
356345 }
346
347 return rescode;
357348 }
358349 else
359350 g_assert_not_reached ();
360351
361 return rescode;
362 }
363
364 static gboolean
365 code_failed (DesktopEntryResultCode code)
366 {
367 return code == DESKTOP_ENTRY_LOAD_FAIL_OTHER ||
368 code == DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
352 return DESKTOP_ENTRY_LOAD_FAIL_OTHER;
369353 }
370354
371355 DesktopEntry *
404388 code = desktop_entry_load (retval);
405389 *res_code = code;
406390
407 if (code_failed (code))
391 if (code < DESKTOP_ENTRY_LOAD_SUCCESS)
408392 {
409393 desktop_entry_unref (retval);
410394 return NULL;
446430 else
447431 g_assert_not_reached ();
448432
449 if (code_failed (desktop_entry_load (entry)))
433 if (desktop_entry_load (entry) < DESKTOP_ENTRY_LOAD_SUCCESS)
450434 {
451435 desktop_entry_unref (entry);
452436 return NULL;
3232
3333 typedef enum
3434 {
35 DESKTOP_ENTRY_LOAD_SUCCESS = 0,
36 DESKTOP_ENTRY_LOAD_FAIL_OTHER,
37 DESKTOP_ENTRY_LOAD_FAIL_APPINFO
35 DESKTOP_ENTRY_LOAD_FAIL_OTHER = 0,
36 DESKTOP_ENTRY_LOAD_FAIL_APPINFO,
37 DESKTOP_ENTRY_LOAD_SUCCESS
3838 } DesktopEntryResultCode;
3939
4040 typedef struct DesktopEntry DesktopEntry;