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'.
This commit is contained in:
Matthias Clasen 2014-09-02 22:25:29 -04:00
parent b4282be76b
commit 2b643a6fd1
2 changed files with 110 additions and 3 deletions

View File

@ -775,6 +775,19 @@ close_selection_dialog (GtkWidget *dialog, gint response, GtkWidget *tv)
my_text_view_set_background ((MyTextView *)tv, filename);
}
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)
{
@ -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);

View File

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