widget-factory: Add a listbox example

This commit is contained in:
Matthias Clasen 2014-04-12 21:45:30 -07:00
parent 4e64708b3d
commit b86f54b54a
2 changed files with 112 additions and 3 deletions

View File

@ -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);

View File

@ -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>