/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GsApp *app; const gchar *EMPTY[] = { "", NULL }; /* nothing to do here */ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH) == 0) return TRUE; for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (gs_app_get_menu_path (app) == NULL) { if (!gs_plugin_refine_app (plugin, app)) { /* don't keep searching for this */ gs_app_set_menu_path (app, (gchar **) EMPTY); } } } return TRUE; }
/* adds the menu-path for applications */ gboolean gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { const gchar *strv[] = { "", NULL, NULL }; const GsDesktopData *msdata; gboolean found = FALSE; guint i, j, k; /* nothing to do here */ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH) == 0) return TRUE; if (gs_app_get_menu_path (app) != NULL) return TRUE; /* find a top level category the app has */ msdata = gs_desktop_get_data (); for (i = 0; !found && msdata[i].id != NULL; i++) { const GsDesktopData *data = &msdata[i]; for (j = 0; !found && data->mapping[j].id != NULL; j++) { const GsDesktopMap *map = &data->mapping[j]; if (g_strcmp0 (map->id, "all") == 0) continue; if (g_strcmp0 (map->id, "featured") == 0) continue; for (k = 0; !found && map->fdo_cats[k] != NULL; k++) { const gchar *tmp = msdata[i].mapping[j].fdo_cats[k]; if (_gs_app_has_desktop_group (app, tmp)) { strv[0] = msdata[i].name; strv[1] = msdata[i].mapping[j].name; found = TRUE; break; } } } } /* always set something to avoid keep searching for this */ gs_app_set_menu_path (app, (gchar **) strv); return TRUE; }