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.º 2
0
/**
 * gs_shell_category_get_apps_cb:
 **/
static void
gs_shell_category_get_apps_cb (GObject *source_object,
			       GAsyncResult *res,
			       gpointer user_data)
{
	gint i = 0;
	GList *l;
	GList *list;
	GsApp *app;
	GtkWidget *tile;
	GsShellCategory *shell = GS_SHELL_CATEGORY (user_data);
	GsShellCategoryPrivate *priv = shell->priv;
	GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
	_cleanup_error_free_ GError *error = NULL;

	list = gs_plugin_loader_get_category_apps_finish (plugin_loader,
							  res,
							  &error);
	if (list == NULL) {
		if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
			g_warning ("failed to get apps for category apps: %s", error->message);
		goto out;
	}
	gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 1);
	gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 0);

	for (l = list, i = 0; l != NULL; l = l->next, i++) {
		app = GS_APP (l->data);
		tile = gs_app_tile_new (app);
		g_signal_connect (tile, "clicked",
				  G_CALLBACK (app_tile_clicked), shell);
		gtk_grid_attach (GTK_GRID (priv->category_detail_grid), tile, (i % 2), i / 2, 1, 1);
	}

	if (i == 1)
		gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col1_placeholder, 1, 0, 1, 1);

out:
	gs_plugin_list_free (list);

}