[gtk+] widget-factory: More variety in listbox content
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget-factory: More variety in listbox content
- Date: Wed, 3 Sep 2014 02:26:44 +0000 (UTC)
commit 2b643a6fd1c3a117d2f3c99c78df8757f0e7d8cc
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 2 22:25:29 2014 -0400
widget-factory: More variety in listbox content
Add rows with buttons and checkboxes to the listbox example
on page 2, and make the switch in row 1 toggle selection mode,
to test various cases of widgets in 'selected context'.
demos/widget-factory/widget-factory.c | 20 +++++++
demos/widget-factory/widget-factory.ui | 93 ++++++++++++++++++++++++++++++-
2 files changed, 110 insertions(+), 3 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 0ecc3d1..072d3c5 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -776,6 +776,19 @@ close_selection_dialog (GtkWidget *dialog, gint response, GtkWidget *tv)
}
static void
+toggle_selection_mode (GtkSwitch *sw,
+ GParamSpec *pspec,
+ GtkListBox *listbox)
+{
+ if (gtk_switch_get_active (sw))
+ gtk_list_box_set_selection_mode (listbox, GTK_SELECTION_SINGLE);
+ else
+ gtk_list_box_set_selection_mode (listbox, GTK_SELECTION_NONE);
+
+ gtk_list_box_set_activate_on_single_click (listbox, !gtk_switch_get_active (sw));
+}
+
+static void
activate (GApplication *app)
{
GtkBuilder *builder;
@@ -851,6 +864,9 @@ activate (GApplication *app)
gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_header, NULL, NULL);
g_signal_connect (widget, "row-activated", G_CALLBACK (row_activated), NULL);
+ widget2 = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow1switch");
+ g_signal_connect (widget2, "notify::active", G_CALLBACK (toggle_selection_mode), widget);
+
widget = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow3");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow3image");
g_object_set_data (G_OBJECT (widget), "image", widget2);
@@ -859,6 +875,10 @@ activate (GApplication *app)
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "info_dialog");
g_object_set_data (G_OBJECT (widget), "dialog", widget2);
+ widget = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow5button");
+ widget2 = (GtkWidget *)gtk_builder_get_object (builder, "action_dialog");
+ g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_window_present), widget2);
+
widget = (GtkWidget *)gtk_builder_get_object (builder, "toolbar");
g_object_set_data (G_OBJECT (window), "toolbar", widget);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 4c3b306..8fbcb54 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -2186,8 +2186,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
</object>
</child>
<child>
- <object class="GtkFrame">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
+ <property name="shadow-type">in</property>
+ <property name="hscrollbar-policy">never</property>
+ <property name="vscrollbar-policy">automatic</property>
+ <property name="min-content-height">200</property>
<child>
<object class="GtkListBox" id="listbox">
<property name="visible">True</property>
@@ -2197,6 +2201,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
<object class="GtkListBoxRow" id="listboxrow1">
<property name="visible">True</property>
<property name="activatable">False</property>
+ <property name="selectable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@@ -2214,9 +2219,9 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
</packing>
</child>
<child>
- <object class="GtkSwitch">
+ <object class="GtkSwitch" id="listboxrow1switch">
<property name="visible">True</property>
- <property name="active">True</property>
+ <property name="active">False</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin-top">6</property>
@@ -2344,6 +2349,86 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
</child>
</object>
</child>
+ <child>
+ <object class="GtkListBoxRow" id="listboxrow5">
+ <property name="visible">True</property>
+ <property name="activatable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Row 5</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="margin">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="listboxrow5button">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-size">1</property>
+ <property
name="icon-name">appointment-soon-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow" id="listboxrow6">
+ <property name="visible">True</property>
+ <property name="activatable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Row 6</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="margin">6</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -3383,6 +3468,8 @@ bad things might happen.</property>
<widget name="listboxrow2"/>
<widget name="listboxrow3"/>
<widget name="listboxrow4"/>
+ <widget name="listboxrow5"/>
+ <widget name="listboxrow6"/>
</widgets>
</object>
<object class="GtkSizeGroup">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]