mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
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:
parent
b4282be76b
commit
2b643a6fd1
@ -775,6 +775,19 @@ close_selection_dialog (GtkWidget *dialog, gint response, GtkWidget *tv)
|
|||||||
my_text_view_set_background ((MyTextView *)tv, filename);
|
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
|
static void
|
||||||
activate (GApplication *app)
|
activate (GApplication *app)
|
||||||
{
|
{
|
||||||
@ -851,6 +864,9 @@ activate (GApplication *app)
|
|||||||
gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_header, NULL, NULL);
|
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);
|
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");
|
widget = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow3");
|
||||||
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow3image");
|
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "listboxrow3image");
|
||||||
g_object_set_data (G_OBJECT (widget), "image", widget2);
|
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");
|
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "info_dialog");
|
||||||
g_object_set_data (G_OBJECT (widget), "dialog", widget2);
|
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");
|
widget = (GtkWidget *)gtk_builder_get_object (builder, "toolbar");
|
||||||
g_object_set_data (G_OBJECT (window), "toolbar", widget);
|
g_object_set_data (G_OBJECT (window), "toolbar", widget);
|
||||||
|
|
||||||
|
@ -2186,8 +2186,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<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>
|
<child>
|
||||||
<object class="GtkListBox" id="listbox">
|
<object class="GtkListBox" id="listbox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -2197,6 +2201,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
|||||||
<object class="GtkListBoxRow" id="listboxrow1">
|
<object class="GtkListBoxRow" id="listboxrow1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="activatable">False</property>
|
<property name="activatable">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -2214,9 +2219,9 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSwitch">
|
<object class="GtkSwitch" id="listboxrow1switch">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="active">True</property>
|
<property name="active">False</property>
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="margin-top">6</property>
|
<property name="margin-top">6</property>
|
||||||
@ -2344,6 +2349,86 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -3383,6 +3468,8 @@ bad things might happen.</property>
|
|||||||
<widget name="listboxrow2"/>
|
<widget name="listboxrow2"/>
|
||||||
<widget name="listboxrow3"/>
|
<widget name="listboxrow3"/>
|
||||||
<widget name="listboxrow4"/>
|
<widget name="listboxrow4"/>
|
||||||
|
<widget name="listboxrow5"/>
|
||||||
|
<widget name="listboxrow6"/>
|
||||||
</widgets>
|
</widgets>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkSizeGroup">
|
<object class="GtkSizeGroup">
|
||||||
|
Loading…
Reference in New Issue
Block a user