[gtk+] widget-factory: More treeview examples



commit f78a224e9629ac7b304306c0eb51e8fdf1f1728f
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 10 06:31:45 2014 -0400

    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 07e1ce9..29bfc0c 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -311,6 +311,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)
 {
   GtkBuilder *builder;
@@ -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 3cca886..ecb390f 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. </property>
  Uyghur</property>
   </object>
   <object class="GtkListStore" id="iconsmodel">
-    <columns><column type="gchararray"/></columns>
+    <columns>
+      <column type="gchararray"/>
+    </columns>
     <data>
-      <row><col id="0">audio-headphones-symbolic</col></row>
-      <row><col id="0">audio-speakers-symbolic</col></row>
-      <row><col id="0">audio-input-microphone-symbolic</col></row>
-      <row><col id="0">bookmark-new-symbolic</col></row>
-      <row><col id="0">call-start-symbolic</col></row>
-      <row><col id="0">call-stop-symbolic</col></row>
-      <row><col id="0">camera-photo-symbolic</col></row>
-      <row><col id="0">camera-video-symbolic</col></row>
-      <row><col id="0">camera-web-symbolic</col></row>
-      <row><col id="0">document-new-symbolic</col></row>
-      <row><col id="0">document-open-recent-symbolic</col></row>
-      <row><col id="0">document-open-symbolic</col></row>
-      <row><col id="0">drive-harddisk-symbolic</col></row>
-      <row><col id="0">drive-multidisk-symbolic</col></row>
-      <row><col id="0">drive-optical-symbolic</col></row>
-      <row><col id="0">edit-clear-all-symbolic</col></row>
-      <row><col id="0">edit-copy-symbolic</col></row>
-      <row><col id="0">edit-cut-symbolic</col></row>
-      <row><col id="0">edit-delete-symbolic</col></row>
-      <row><col id="0">find-location-symbolic</col></row>
-      <row><col id="0">format-indent-less-symbolic</col></row>
-      <row><col id="0">format-indent-more-symbolic</col></row>
-      <row><col id="0">format-justify-left-symbolic</col></row>
-      <row><col id="0">format-justify-center-symbolic</col></row>
-      <row><col id="0">format-justify-right-symbolic</col></row>
-      <row><col id="0">network-wired-symbolic</col></row>
-      <row><col id="0">network-wireless-symbolic</col></row>
-      <row><col id="0">phone-symbolic</col></row>
-      <row><col id="0">insert-image-symbolic</col></row>
-      <row><col id="0">insert-link-symbolic</col></row>
-      <row><col id="0">insert-object-symbolic</col></row>
-      <row><col id="0">view-continuous-symbolic</col></row>
-      <row><col id="0">view-dual-symbolic</col></row>
-      <row><col id="0">view-fullscreen-symbolic</col></row>
-      <row><col id="0">view-grid-symbolic</col></row>
-      <row><col id="0">view-list-symbolic</col></row>
-      <row><col id="0">view-paged-symbolic</col></row>
-      <row><col id="0">weather-clear-night-symbolic</col></row>
-      <row><col id="0">weather-few-clouds-night-symbolic</col></row>
-      <row><col id="0">weather-fog-symbolic</col></row>
-      <row><col id="0">weather-overcast-symbolic</col></row>
-      <row><col id="0">weather-severe-alert-symbolic</col></row>
-      <row><col id="0">weather-showers-symbolic</col></row>
-      <row><col id="0">weather-snow-symbolic</col></row>
+      <row>
+        <col id="0">audio-headphones-symbolic</col>
+      </row>
+      <row>
+        <col id="0">audio-speakers-symbolic</col>
+      </row>
+      <row>
+        <col id="0">audio-input-microphone-symbolic</col>
+      </row>
+      <row>
+        <col id="0">bookmark-new-symbolic</col>
+      </row>
+      <row>
+        <col id="0">call-start-symbolic</col>
+      </row>
+      <row>
+        <col id="0">call-stop-symbolic</col>
+      </row>
+      <row>
+        <col id="0">camera-photo-symbolic</col>
+      </row>
+      <row>
+        <col id="0">camera-video-symbolic</col>
+      </row>
+      <row>
+        <col id="0">camera-web-symbolic</col>
+      </row>
+      <row>
+        <col id="0">document-new-symbolic</col>
+      </row>
+      <row>
+        <col id="0">document-open-recent-symbolic</col>
+      </row>
+      <row>
+        <col id="0">document-open-symbolic</col>
+      </row>
+      <row>
+        <col id="0">drive-harddisk-symbolic</col>
+      </row>
+      <row>
+        <col id="0">drive-multidisk-symbolic</col>
+      </row>
+      <row>
+        <col id="0">drive-optical-symbolic</col>
+      </row>
+      <row>
+        <col id="0">edit-clear-all-symbolic</col>
+      </row>
+      <row>
+        <col id="0">edit-copy-symbolic</col>
+      </row>
+      <row>
+        <col id="0">edit-cut-symbolic</col>
+      </row>
+      <row>
+        <col id="0">edit-delete-symbolic</col>
+      </row>
+      <row>
+        <col id="0">find-location-symbolic</col>
+      </row>
+      <row>
+        <col id="0">format-indent-less-symbolic</col>
+      </row>
+      <row>
+        <col id="0">format-indent-more-symbolic</col>
+      </row>
+      <row>
+        <col id="0">format-justify-left-symbolic</col>
+      </row>
+      <row>
+        <col id="0">format-justify-center-symbolic</col>
+      </row>
+      <row>
+        <col id="0">format-justify-right-symbolic</col>
+      </row>
+      <row>
+        <col id="0">network-wired-symbolic</col>
+      </row>
+      <row>
+        <col id="0">network-wireless-symbolic</col>
+      </row>
+      <row>
+        <col id="0">phone-symbolic</col>
+      </row>
+      <row>
+        <col id="0">insert-image-symbolic</col>
+      </row>
+      <row>
+        <col id="0">insert-link-symbolic</col>
+      </row>
+      <row>
+        <col id="0">insert-object-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-continuous-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-dual-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-fullscreen-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-grid-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-list-symbolic</col>
+      </row>
+      <row>
+        <col id="0">view-paged-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-clear-night-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-few-clouds-night-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-fog-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-overcast-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-severe-alert-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-showers-symbolic</col>
+      </row>
+      <row>
+        <col id="0">weather-snow-symbolic</col>
+      </row>
     </data>
   </object>
+  <object class="GtkTreeStore" id="charlemodel">
+    <columns>
+      <column type="gchararray"/>
+      <column type="gchararray"/>
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkApplicationWindow" id="window">
     <property name="can_focus">False</property>
     <property name="title">GTK+ Widget Factory</property>
@@ -2718,10 +2815,77 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
               </packing>
             </child>
             <child>
-              <object class="GtkSpinner">
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="active">True</property>
-                <property name="expand">True</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkScrolledWindow">
+                    <property name="visible">True</property>
+                    <property name="hscrollbar-policy">never</property>
+                    <property name="vscrollbar-policy">always</property>
+                    <property name="height-request">300</property>
+                    <property name="halign">start</property>
+                    <property name="shadow-type">in</property>
+                    <property name="margin">10</property>
+                    <child>
+                      <object class="GtkTreeView" id="charletree">
+                        <property name="visible">True</property>
+                        <property name="enable-grid-lines">vertical</property>
+                        <property name="enable-tree-lines">True</property>
+                        <property name="rubber-banding">True</property>
+                        <property name="model">charlemodel</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection">
+                            <property name="mode">multiple</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn">
+                            <property name="visible">True</property>
+                            <property name="title" translatable="yes">Name</property>
+                            <child>
+                              <object class="GtkCellRendererText"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn">
+                            <property name="visible">True</property>
+                            <property name="title" translatable="yes">Birth</property>
+                            <child>
+                              <object class="GtkCellRendererText"/>
+                              <attributes>
+                                <attribute name="text">1</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn">
+                            <property name="visible">True</property>
+                            <property name="title" translatable="yes">Death</property>
+                            <child>
+                              <object class="GtkCellRendererText"/>
+                              <attributes>
+                                <attribute name="text">2</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkSpinner">
+                    <property name="visible">True</property>
+                    <property name="active">True</property>
+                    <property name="expand">True</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="name">page3</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]