[gtk+] widget-factory: Add a listbox example



commit b86f54b54a446d826952c7f36a32ba472d9c9ab1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 12 21:45:30 2014 -0700

    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 19380a3..21ff514 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -221,6 +221,22 @@ startup (GApplication *app)
 }
 
 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)
 {
   GtkBuilder *builder;
@@ -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 f33e45f..08aa246 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -16,11 +16,11 @@
       </item>
     </section>
   </menu>
-  <menu id='gear_menu'>
+  <menu id="gear_menu">
     <section>
       <item>
-        <attribute name='label' translatable='yes'>Dark Theme</attribute>
-        <attribute name='action'>win.dark</attribute>
+        <attribute name="label" translatable="yes">Dark Theme</attribute>
+        <attribute name="action">win.dark</attribute>
       </item>
     </section>
   </menu>
@@ -1924,6 +1924,88 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
                         <property name="top-attach">2</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkFrame">
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkListBox" id="listbox">
+                            <property name="visible">True</property>
+                            <property name="selection-mode">none</property>
+                            <child>
+                              <object class="GtkBox" id="listboxrow1">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 1</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSwitch">
+                                    <property name="visible">True</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="listboxrow2">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 2</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkScale">
+                                    <property name="orientation">horizontal</property>
+                                    <property name="visible">True</property>
+                                    <property name="margin">6</property>
+                                    <property name="draw-value">False</property>
+                                    <property name="width-request">150</property>
+                                    <property name="adjustment">adjustment1</property>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkBox" id="listboxrow3">
+                                <property name="visible">True</property>
+                                <property name="orientation">horizontal</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="label">Row 3</property>
+                                    <property name="halign">start</property>
+                                    <property name="margin">6</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">3</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
               </object>
@@ -1937,4 +2019,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
       </object>
     </child>
   </object>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <widgets>
+      <widget name="listboxrow1"/>
+      <widget name="listboxrow2"/>
+      <widget name="listboxrow3"/>
+    </widgets>
+  </object>
 </interface>


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