Codebase list cinnamon-menus / 055bd2e
Revert 44ee2de737e53b and go back to loading .desktop files *as* GDesktopAppInfo - this is the only way g_desktop_app_info_get_filename() will work properly. Michael Webster 7 years ago
2 changed file(s) with 38 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
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;
315 DesktopEntryResultCode rescode = DESKTOP_ENTRY_LOAD_SUCCESS;
326316
327317 key_file = g_key_file_new ();
328318
353343 else
354344 menu_verbose ("Failed to load \"%s\"\n", entry->path);
355345 }
346
347 return rescode;
356348 }
357349 else
358350 g_assert_not_reached ();
359351
360 return rescode;
352 return DESKTOP_ENTRY_LOAD_FAIL_OTHER;
361353 }
362354
363355 DesktopEntry *
351351 entry_basename = desktop_entry_get_basename (tmp->data);
352352 if (strcmp (entry_basename, basename) == 0)
353353 {
354 if (desktop_entry_reload (tmp->data) == NULL)
354 if (!desktop_entry_reload (tmp->data))
355355 {
356356 dir->entries = g_slist_delete_link (dir->entries, tmp);
357357 }
652652 if (handled)
653653 {
654654 /* CHANGED events don't change the set of desktop entries, unless it's the mimeinfo.cache file changing */
655 if ((event == MENU_MONITOR_EVENT_CREATED || event == MENU_MONITOR_EVENT_DELETED))
655 if (retry_changes || (event == MENU_MONITOR_EVENT_CREATED || event == MENU_MONITOR_EVENT_DELETED))
656656 {
657657 _entry_directory_list_empty_desktop_cache ();
658658 }