[gnome-builder] create-project: sort templates by priority
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] create-project: sort templates by priority
- Date: Sun, 21 Jan 2018 00:21:04 +0000 (UTC)
commit b79fd37b938342d61ac2c1acf4766faf75f22960
Author: Christian Hergert <chergert redhat com>
Date: Sat Jan 20 16:17:55 2018 -0800
create-project: sort templates by priority
.../create-project/gbp-create-project-widget.c | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/src/plugins/create-project/gbp-create-project-widget.c
b/src/plugins/create-project/gbp-create-project-widget.c
index 620f7f364..d7fff8d57 100644
--- a/src/plugins/create-project/gbp-create-project-widget.c
+++ b/src/plugins/create-project/gbp-create-project-widget.c
@@ -260,6 +260,25 @@ gbp_create_project_widget_template_selected (GbpCreateProjectWidget *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_IS_READY]);
}
+static gint
+project_template_sort_func (GtkFlowBoxChild *child1,
+ GtkFlowBoxChild *child2,
+ gpointer user_data)
+{
+ GbpCreateProjectTemplateIcon *icon1;
+ GbpCreateProjectTemplateIcon *icon2;
+ IdeProjectTemplate *tmpl1;
+ IdeProjectTemplate *tmpl2;
+
+ icon1 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (child1)));
+ icon2 = GBP_CREATE_PROJECT_TEMPLATE_ICON (gtk_bin_get_child (GTK_BIN (child2)));
+
+ tmpl1 = gbp_create_project_template_icon_get_template (icon1);
+ tmpl2 = gbp_create_project_template_icon_get_template (icon2);
+
+ return ide_project_template_compare (tmpl1, tmpl2);
+}
+
static void
gbp_create_project_widget_add_template_buttons (GbpCreateProjectWidget *self,
GList *project_templates)
@@ -288,6 +307,8 @@ gbp_create_project_widget_add_template_buttons (GbpCreateProjectWidget *self,
gtk_flow_box_insert (self->project_template_chooser, GTK_WIDGET (template_container), -1);
}
+ gtk_flow_box_invalidate_sort (self->project_template_chooser);
+
gbp_create_project_widget_refilter (self);
}
@@ -477,6 +498,10 @@ gbp_create_project_widget_init (GbpCreateProjectWidget *self)
G_CALLBACK (gbp_create_project_widget_template_selected),
self,
G_CONNECT_SWAPPED);
+
+ gtk_flow_box_set_sort_func (self->project_template_chooser,
+ project_template_sort_func,
+ NULL, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]