Exemplo n.º 1
0
static void
gs_cmd_show_results_categories (GPtrArray *list)
{
	GPtrArray *subcats;
	GsCategory *cat;
	GsCategory *parent;
	guint i;

	for (i = 0; i < list->len; i++) {
		g_autofree gchar *tmp = NULL;
		cat = GS_CATEGORY (g_ptr_array_index (list, i));
		parent = gs_category_get_parent (cat);
		if (parent != NULL){
			g_autofree gchar *id = NULL;
			id = g_strdup_printf ("%s/%s [%u]",
					      gs_category_get_id (parent),
					      gs_category_get_id (cat),
					      gs_category_get_size (cat));
			tmp = gs_cmd_pad_spaces (id, 32);
			g_print ("%s : %s\n",
				 tmp, gs_category_get_name (cat));
		} else {
			tmp = gs_cmd_pad_spaces (gs_category_get_id (cat), 32);
			g_print ("%s : %s\n",
				 tmp, gs_category_get_name (cat));
			subcats = gs_category_get_children (cat);
			gs_cmd_show_results_categories (subcats);
		}
	}
}
Exemplo n.º 2
0
/**
 * gs_cmd_show_results_categories:
 **/
static void
gs_cmd_show_results_categories (GList *list)
{
	GList *l;
	GList *subcats;
	GsCategory *cat;
	GsCategory *parent;

	for (l = list; l != NULL; l = l->next) {
		_cleanup_free_ gchar *tmp = NULL;
		cat = GS_CATEGORY (l->data);
		parent = gs_category_get_parent (cat);
		if (parent != NULL){
			_cleanup_free_ gchar *id = NULL;
			id = g_strdup_printf ("%s/%s",
					      gs_category_get_id (parent),
					      gs_category_get_id (cat));
			tmp = gs_cmd_pad_spaces (id, 32);
			g_print ("%s : %s\n",
				 tmp, gs_category_get_name (cat));
		} else {
			tmp = gs_cmd_pad_spaces (gs_category_get_id (cat), 32);
			g_print ("%s : %s\n",
				 tmp, gs_category_get_name (cat));
			subcats = gs_category_get_subcategories (cat);
			gs_cmd_show_results_categories (subcats);
		}
	}
}
Exemplo n.º 3
0
void
gs_shell_category_set_category (GsShellCategory *shell, GsCategory *category)
{
	GsShellCategoryPrivate *priv = shell->priv;
	GsCategory *sub;
	GsCategory *selected = NULL;
	GList *l;
	_cleanup_list_free_ GList *list = NULL;

	/* this means we've come from the app-view -> back */
	if (priv->category == category)
		return;

	/* save this */
	g_clear_object (&priv->category);
	priv->category = g_object_ref (category);

	/* select favourites by default */
	list = gs_category_get_subcategories (category);
	for (l = list; l != NULL; l = l->next) {
		sub = GS_CATEGORY (l->data);
		if (g_strcmp0 (gs_category_get_id (sub), "favourites") == 0) {
			selected = sub;
			break;
		}
	}

	/* okay, no favourites, so just select the first entry */
	if (selected == NULL && list != NULL)
		selected = GS_CATEGORY (list->data);

	/* find apps in this group */
	gs_shell_category_create_filter_list (shell, category, selected);
}
static void
gs_shell_category_populate_filtered (GsShellCategory *shell)
{
	GsShellCategoryPrivate *priv = shell->priv;
	GsCategory *parent;
	GtkWidget *tile;
	guint i;

	if (priv->cancellable != NULL) {
		g_cancellable_cancel (priv->cancellable);
		g_object_unref (priv->cancellable);
	}
	priv->cancellable = g_cancellable_new ();

	parent = gs_category_get_parent (priv->category);
	if (parent == NULL) {
		g_debug ("search using %s",
			 gs_category_get_id (priv->category));
	} else {
		g_debug ("search using %s/%s",
			 gs_category_get_id (parent),
			 gs_category_get_id (priv->category));
	}

	gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 1);
	gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 0);

	for (i = 0; i < MIN (30, gs_category_get_size (priv->category)); i++) {
		tile = gs_app_tile_new (NULL);
		gtk_grid_attach (GTK_GRID (priv->category_detail_grid), tile, (i % 2), i / 2, 1, 1);
	}

	gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col0_placeholder, 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col1_placeholder, 1, 0, 1, 1);

	gs_plugin_loader_get_category_apps_async (priv->plugin_loader,
						  priv->category,
						  GS_PLUGIN_REFINE_FLAGS_DEFAULT |
						  GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING,
						  priv->cancellable,
						  gs_shell_category_get_apps_cb,
						  shell);
}
Exemplo n.º 5
0
gboolean
gs_plugin_add_category_apps (GsPlugin *plugin,
			     GsCategory *category,
			     GsAppList *list,
			     GCancellable *cancellable,
			     GError **error)
{
	GsCategory *c;
	g_autoptr(GString) id = NULL;
	const gchar *sections = NULL;

	id = g_string_new ("");
	for (c = category; c != NULL; c = gs_category_get_parent (c)) {
		if (c != category)
			g_string_prepend (id, "/");
		g_string_prepend (id, gs_category_get_id (c));
	}

	if (strcmp (id->str, "games/featured") == 0)
		sections = "games";
	else if (strcmp (id->str, "audio-video/featured") == 0)
		sections = "music;video";
	else if (strcmp (id->str, "graphics/featured") == 0)
		sections = "graphics";
	else if (strcmp (id->str, "communication/featured") == 0)
		sections = "social-networking";
	else if (strcmp (id->str, "productivity/featured") == 0)
		sections = "productivity;finance";
	else if (strcmp (id->str, "developer-tools/featured") == 0)
		sections = "developers";
	else if (strcmp (id->str, "utilities/featured") == 0)
		sections = "utilities";

	if (sections != NULL) {
		g_auto(GStrv) tokens = NULL;
		int i;

		tokens = g_strsplit (sections, ";", -1);
		for (i = 0; tokens[i] != NULL; i++) {
			g_autoptr(GPtrArray) snaps = NULL;
			guint j;

			snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, tokens[i], NULL, cancellable, error);
			if (snaps == NULL)
				return FALSE;
			for (j = 0; j < snaps->len; j++) {
				g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, j));
				gs_app_list_add (list, app);
			}
		}
	}
	return TRUE;
}