From b86f54b54a446d826952c7f36a32ba472d9c9ab1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 12 Apr 2014 21:45:30 -0700 Subject: [PATCH] widget-factory: Add a listbox example --- demos/widget-factory/widget-factory.c | 19 +++++ demos/widget-factory/widget-factory.ui | 96 +++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 19380a3a87..21ff514268 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -220,6 +220,22 @@ startup (GApplication *app) g_object_unref (builder); } +static void +update_header (GtkListBoxRow *row, + GtkListBoxRow *before, + gpointer data) +{ + if (before != NULL && + gtk_list_box_row_get_header (row) == NULL) + { + GtkWidget *separator; + + separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); + gtk_widget_show (separator); + gtk_list_box_row_set_header (row, separator); + } +} + static void activate (GApplication *app) { @@ -255,6 +271,9 @@ activate (GApplication *app) adj = (GtkAdjustment *) gtk_builder_get_object (builder, "adjustment2"); g_signal_connect (adj, "value-changed", G_CALLBACK (spin_value_changed), widget); + widget = (GtkWidget *)gtk_builder_get_object (builder, "listbox"); + gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_header, NULL, NULL); + gtk_widget_show_all (GTK_WIDGET (window)); g_object_unref (builder); diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index f33e45fd86..08aa24653b 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -16,11 +16,11 @@ - +
- Dark Theme - win.dark + Dark Theme + win.dark
@@ -1924,6 +1924,88 @@ Suspendisse feugiat quam quis dolor accumsan cursus. 2 + + + True + + + True + none + + + True + horizontal + + + True + Row 1 + start + 6 + + + True + + + + + True + 6 + + + + + + + True + horizontal + + + True + Row 2 + start + 6 + + + True + + + + + horizontal + True + 6 + False + 150 + adjustment1 + + + + + + + True + horizontal + + + True + Row 3 + start + 6 + + + True + + + + + + + + + 0 + 3 + + @@ -1937,4 +2019,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus. + + vertical + + + + + +