Example #1
0
static void
list_header_func (GtkListBoxRow *row,
		  GtkListBoxRow *before,
		  gpointer user_data)
{
	GtkStyleContext *context;
	GtkWidget *header;

	/* first entry */
	gtk_list_box_row_set_header (row, NULL);
	if (before == NULL)
		return;

	/* desktop -> addons */
	if (!is_addon_id_kind (gs_app_row_get_app (GS_APP_ROW (before))) &&
	    is_addon_id_kind (gs_app_row_get_app (GS_APP_ROW (row)))) {
		/* TRANSLATORS: This is the header dividing the normal
		 * applications and the addons */
		header = gtk_label_new (_("Add-ons"));
		g_object_set (header,
			      "xalign", 0.0,
			      NULL);
		context = gtk_widget_get_style_context (header);
		gtk_style_context_add_class (context, "header-label");
	} else {
		header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	}
	gtk_list_box_row_set_header (row, header);
}
Example #2
0
static void
list_header_func (GtkListBoxRow *row,
		  GtkListBoxRow *before,
		  gpointer user_data)
{
	GsApp *app = gs_app_row_get_app (GS_APP_ROW (row));
	GsUpdateListSection before_section = GS_UPDATE_LIST_SECTION_LAST;
	GsUpdateListSection section;
	GsUpdateList *update_list = GS_UPDATE_LIST (user_data);
	GtkWidget *header;

	/* first entry */
	gtk_list_box_row_set_header (row, NULL);
	if (before != NULL) {
		GsApp *before_app = gs_app_row_get_app (GS_APP_ROW (before));
		before_section = gs_update_list_get_app_section (before_app);
	}

	/* section changed or forced to have headers */
	section = gs_update_list_get_app_section (app);
	if (gs_update_list_has_headers (update_list) &&
	    before_section != section) {
		header = gs_update_list_get_section_header (update_list, section);
	} else {
		header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	}
	gtk_list_box_row_set_header (row, header);
}
Example #3
0
static gint
list_sort_func (GtkListBoxRow *a,
		GtkListBoxRow *b,
		gpointer user_data)
{
	GsApp *a1 = gs_app_row_get_app (GS_APP_ROW (a));
	GsApp *a2 = gs_app_row_get_app (GS_APP_ROW (b));
	g_autofree gchar *key1 = get_app_sort_key (a1);
	g_autofree gchar *key2 = get_app_sort_key (a2);

	/* compare the keys according to the algorithm above */
	return g_strcmp0 (key1, key2);
}
Example #4
0
/**
 * gs_update_list_button_clicked_cb:
 **/
static void
gs_update_list_button_clicked_cb (GsAppRow *app_row,
				  GsUpdateList *update_list)
{
	GsApp *app = gs_app_row_get_app (app_row);
	g_signal_emit (update_list, signals[SIGNAL_BUTTON_CLICKED], 0, app);
}
Example #5
0
GList *
gs_update_list_get_apps (GsUpdateList *update_list)
{
	GList *apps = NULL;
	GList *l;
	g_autoptr(GList) children = NULL;

	children = gtk_container_get_children (GTK_CONTAINER (update_list));
	for (l = children; l != NULL; l = l->next) {
		GsAppRow *app_row = GS_APP_ROW (l->data);
		apps = g_list_prepend (apps, gs_app_row_get_app (app_row));
	}
	return apps;
}
Example #6
0
static void
gs_update_list_emit_clicked_for_section (GsUpdateList *update_list,
					 GsUpdateListSection section)
{
	g_autoptr(GList) children = NULL;
	children = gtk_container_get_children (GTK_CONTAINER (update_list));
	for (GList *l = children; l != NULL; l = l->next) {
		GsAppRow *app_row = GS_APP_ROW (l->data);
		GsApp *app = gs_app_row_get_app (app_row);
		if (gs_update_list_get_app_section (app) != section)
			continue;
		g_signal_emit (update_list, signals[SIGNAL_BUTTON_CLICKED], 0, app);
	}
}