From f78a224e9629ac7b304306c0eb51e8fdf1f1728f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Jul 2014 06:31:45 -0400 Subject: [PATCH] widget-factory: More treeview examples The new treeview on page 3 sports expanders, grid and tree lines, alternating row colors, etc. --- demos/widget-factory/widget-factory.c | 104 ++++++++++ demos/widget-factory/widget-factory.ui | 260 ++++++++++++++++++++----- 2 files changed, 316 insertions(+), 48 deletions(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 07e1ce9d18..29bfc0c36b 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -310,6 +310,106 @@ page_changed_cb (GtkWidget *stack, GParamSpec *pspec, gpointer data) } } +static void +populate_model (GtkTreeStore *store) +{ + GtkTreeIter iter, parent0, parent1, parent2, parent3; + + gtk_tree_store_append (store, &iter, NULL); + gtk_tree_store_set (store, &iter, + 0, "Charlemagne", + 1, "742", + 2, "814", + -1); + parent0 = iter; + gtk_tree_store_append (store, &iter, &parent0); + gtk_tree_store_set (store, &iter, + 0, "Pepin the Short", + 1, "714", + 2, "768", + -1); + parent1 = iter; + gtk_tree_store_append (store, &iter, &parent1); + gtk_tree_store_set (store, &iter, + 0, "Charles Martel", + 1, "688", + 2, "741", + -1); + parent2 = iter; + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Pepin of Herstal", + 1, "635", + 2, "714", + -1); + parent3 = iter; + gtk_tree_store_append (store, &iter, &parent3); + gtk_tree_store_set (store, &iter, + 0, "Ansegisel", + 1, "602 or 610", + 2, "murdered before 679", + -1); + gtk_tree_store_append (store, &iter, &parent3); + gtk_tree_store_set (store, &iter, + 0, "Begga", + 1, "615", + 2, "693", + -1); + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Alpaida", + -1); + gtk_tree_store_append (store, &iter, &parent1); + gtk_tree_store_set (store, &iter, + 0, "Rotrude", + -1); + parent2 = iter; + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Liévin de Trèves", + -1); + parent3 = iter; + gtk_tree_store_append (store, &iter, &parent3); + gtk_tree_store_set (store, &iter, + 0, "Guérin", + -1); + gtk_tree_store_append (store, &iter, &parent3); + gtk_tree_store_set (store, &iter, + 0, "Gunza", + -1); + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Willigarde de Bavière", + -1); + gtk_tree_store_append (store, &iter, &parent0); + gtk_tree_store_set (store, &iter, + 0, "Bertrada of Laon", + 1, "710", + 2, "783", + -1); + parent1 = iter; + gtk_tree_store_append (store, &iter, &parent1); + gtk_tree_store_set (store, &iter, + 0, "Caribert of Laon", + 2, "before 762", + -1); + parent2 = iter; + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Unknown", + -1); + gtk_tree_store_append (store, &iter, &parent2); + gtk_tree_store_set (store, &iter, + 0, "Bertrada of Prüm", + 1, "ca. 670", + 2, "after 721", + -1); + gtk_tree_store_append (store, &iter, &parent1); + gtk_tree_store_set (store, &iter, + 0, "Gisele of Aquitaine", + -1); +} + static void activate (GApplication *app) { @@ -394,6 +494,10 @@ activate (GApplication *app) widget = (GtkWidget *)gtk_builder_get_object (builder, "preference_dialog_button"); g_signal_connect (widget, "clicked", G_CALLBACK (show_dialog), dialog); + widget = (GtkWidget *)gtk_builder_get_object (builder, "charletree"); + populate_model ((GtkTreeStore *)gtk_tree_view_get_model (GTK_TREE_VIEW (widget))); + gtk_tree_view_expand_all (GTK_TREE_VIEW (widget)); + 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 3cca886ede..ecb390f17d 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -158,54 +158,151 @@ Suspendisse feugiat quam quis dolor accumsan cursus. Uyghur - + + + - audio-headphones-symbolic - audio-speakers-symbolic - audio-input-microphone-symbolic - bookmark-new-symbolic - call-start-symbolic - call-stop-symbolic - camera-photo-symbolic - camera-video-symbolic - camera-web-symbolic - document-new-symbolic - document-open-recent-symbolic - document-open-symbolic - drive-harddisk-symbolic - drive-multidisk-symbolic - drive-optical-symbolic - edit-clear-all-symbolic - edit-copy-symbolic - edit-cut-symbolic - edit-delete-symbolic - find-location-symbolic - format-indent-less-symbolic - format-indent-more-symbolic - format-justify-left-symbolic - format-justify-center-symbolic - format-justify-right-symbolic - network-wired-symbolic - network-wireless-symbolic - phone-symbolic - insert-image-symbolic - insert-link-symbolic - insert-object-symbolic - view-continuous-symbolic - view-dual-symbolic - view-fullscreen-symbolic - view-grid-symbolic - view-list-symbolic - view-paged-symbolic - weather-clear-night-symbolic - weather-few-clouds-night-symbolic - weather-fog-symbolic - weather-overcast-symbolic - weather-severe-alert-symbolic - weather-showers-symbolic - weather-snow-symbolic + + audio-headphones-symbolic + + + audio-speakers-symbolic + + + audio-input-microphone-symbolic + + + bookmark-new-symbolic + + + call-start-symbolic + + + call-stop-symbolic + + + camera-photo-symbolic + + + camera-video-symbolic + + + camera-web-symbolic + + + document-new-symbolic + + + document-open-recent-symbolic + + + document-open-symbolic + + + drive-harddisk-symbolic + + + drive-multidisk-symbolic + + + drive-optical-symbolic + + + edit-clear-all-symbolic + + + edit-copy-symbolic + + + edit-cut-symbolic + + + edit-delete-symbolic + + + find-location-symbolic + + + format-indent-less-symbolic + + + format-indent-more-symbolic + + + format-justify-left-symbolic + + + format-justify-center-symbolic + + + format-justify-right-symbolic + + + network-wired-symbolic + + + network-wireless-symbolic + + + phone-symbolic + + + insert-image-symbolic + + + insert-link-symbolic + + + insert-object-symbolic + + + view-continuous-symbolic + + + view-dual-symbolic + + + view-fullscreen-symbolic + + + view-grid-symbolic + + + view-list-symbolic + + + view-paged-symbolic + + + weather-clear-night-symbolic + + + weather-few-clouds-night-symbolic + + + weather-fog-symbolic + + + weather-overcast-symbolic + + + weather-severe-alert-symbolic + + + weather-showers-symbolic + + + weather-snow-symbolic + + + + + + + + False GTK+ Widget Factory @@ -2718,10 +2815,77 @@ Suspendisse feugiat quam quis dolor accumsan cursus. - + True - True - True + vertical + + + True + never + always + 300 + start + in + 10 + + + True + vertical + True + True + charlemodel + + + multiple + + + + + True + Name + + + + 0 + + + + + + + True + Birth + + + + 1 + + + + + + + True + Death + + + + 2 + + + + + + + + + + + True + True + True + + page3