static gboolean filter_category (GsApp *app, gpointer user_data) { const gchar *category = (const gchar *) user_data; return !gs_app_has_category (app, category); }
/** * gs_plugin_refine_app_category: */ static void gs_plugin_refine_app_category (GsPlugin *plugin, GsApp *app, const MenuSpecData *cat) { const gchar *menu_path[] = { NULL, NULL, NULL }; const MenuSpecData *msdata; gboolean ret = FALSE; gchar *tmp; guint i; /* find a sub-level category the app has */ msdata = menu_spec_get_data (); for (i = 0; msdata[i].path != NULL; i++) { tmp = g_strstr_len (msdata[i].path, -1, "::"); if (tmp == NULL) continue; if (!g_str_has_prefix (msdata[i].path, cat->path)) continue; ret = gs_app_has_category (app, tmp + 2); if (ret) { g_autofree gchar *msgctxt = NULL; msgctxt = g_strdup_printf ("Menu subcategory of %s", cat->text); menu_path[1] = g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msdata[i].text); break; } } /* the top-level category always exists */ menu_path[0] = gettext (cat->text); gs_app_set_menu_path (app, (gchar **) menu_path); }
static gboolean _gs_app_has_desktop_group (GsApp *app, const gchar *desktop_group) { guint i; g_auto(GStrv) split = g_strsplit (desktop_group, "::", -1); for (i = 0; split[i] != NULL; i++) { if (!gs_app_has_category (app, split[i])) return FALSE; } return TRUE; }
/** * gs_plugin_refine_app: */ static gboolean gs_plugin_refine_app (GsPlugin *plugin, GsApp *app) { const MenuSpecData *msdata; gboolean ret = FALSE; gchar *tmp; guint i; /* find a top level category the app has */ msdata = menu_spec_get_data (); for (i = 0; msdata[i].path != NULL; i++) { tmp = g_strstr_len (msdata[i].path, -1, "::"); if (tmp != NULL) continue; ret = gs_app_has_category (app, msdata[i].path); if (ret) { gs_plugin_refine_app_category (plugin, app, &msdata[i]); break; } } return ret; }