Commit 70c1fae2 authored by Adrien Plazas's avatar Adrien Plazas Committed by Guido Gunther
Browse files

examples: Add the Lists page

This page presents GtkListBox related widgets like HdyRow and its
descendants.
parent 83ee5ec4
Pipeline #2636 passed with stage
in 2 minutes and 56 seconds
......@@ -19,6 +19,9 @@ struct _ExampleWindow
HdySearchBar *search_bar;
GtkEntry *search_entry;
GtkListBox *column_listbox;
GtkListBox *lists_listbox;
HdyComboRow *combo_row;
HdyComboRow *enum_combo_row;
HdyHeaderGroup *header_group;
GtkAdjustment *adj_arrows_count;
GtkAdjustment *adj_arrows_duration;
......@@ -281,6 +284,9 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, search_bar);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, search_entry);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, column_listbox);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, lists_listbox);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, combo_row);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, enum_combo_row);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, header_group);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, adj_arrows_count);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, adj_arrows_duration);
......@@ -300,12 +306,68 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_callback_full (widget_class, "adj_arrows_duration_value_changed_cb", G_CALLBACK(adj_arrows_duration_value_changed_cb));
}
static gchar *
combo_get_name (gpointer item,
gpointer user_data)
{
return g_strdup (gtk_label_get_text (GTK_LABEL (item)));
}
static void
lists_page_init (ExampleWindow *self)
{
GListStore *list_store;
gtk_list_box_set_header_func (self->lists_listbox, hdy_list_box_separator_header, NULL, NULL);
list_store = g_list_store_new (GTK_TYPE_LABEL);
g_list_store_insert (list_store, 0,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Foo",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
g_list_store_insert (list_store, 1,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Bar",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
g_list_store_insert (list_store, 2,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Baz",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
hdy_combo_row_bind_name_model (self->combo_row, G_LIST_MODEL (list_store), combo_get_name, NULL, NULL);
hdy_combo_row_set_for_enum (self->enum_combo_row, GTK_TYPE_LICENSE, hdy_enum_value_row_name, NULL, NULL);
}
static void
example_window_init (ExampleWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_header_func (self->column_listbox, hdy_list_box_separator_header, NULL, NULL);
lists_page_init (self);
hdy_leaflet_set_visible_child_name (self->content_box, "content");
update_header_bar (self);
}
......@@ -653,6 +653,212 @@
<property name="title">Column</property>
</packing>
</child>
<child>
<object class="HdyColumn">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="margin-bottom">32</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">32</property>
<property name="expand">True</property>
<property name="maximum-width" bind-source="column_width_adjustment" bind-property="value" bind-flags="sync-create"/>
<property name="linear-growth-width" bind-source="column_linear_width_adjustment" bind-property="value" bind-flags="sync-create"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="expand">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-bottom">32</property>
<property name="expand">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="pixel_size">128</property>
<property name="icon_name">format-justify-fill-symbolic</property>
<property name="icon-size">0</property>
<property name="margin-bottom">18</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="opacity">0.5</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Lists</property>
<property name="halign">center</property>
<property name="xalign">0</property>
<property name="margin-bottom">12</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="opacity">0.5</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Rows and helpers for &lt;i&gt;GtkListBox&lt;/i&gt;.</property>
<property name="justify">center</property>
<property name="use_markup">true</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="label" translatable="yes">Lists</property>
<property name="justify">left</property>
<property name="halign">start</property>
<property name="margin-bottom">12</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="margin-bottom">32</property>
<child>
<object class="GtkListBox" id="lists_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="expand">True</property>
<property name="selection-mode">none</property>
<child>
<object class="HdyActionRow">
<property name="icon_name" translatable="yes">preferences-other-symbolic</property>
<property name="subtitle" translatable="yes">They also have a subtitle and an icon</property>
<property name="title" translatable="yes">Rows have a title</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="title" translatable="yes">Rows can have action widgets</property>
<property name="visible">True</property>
<child type="action">
<object class="GtkButton">
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Frobnicate</property>
<property name="valign">center</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="HdyActionRow">
<property name="title" translatable="yes">Rows can have prefix widgets</property>
<property name="visible">True</property>
<child type="prefix">
<object class="GtkRadioButton">
<property name="can_focus">True</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="HdyComboRow" id="combo_row">
<property name="title" translatable="yes">Combo row</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="HdyComboRow" id="enum_combo_row">
<property name="subtitle" translatable="yes">This combo row was created from an enumeration</property>
<property name="title" translatable="yes">Enumeration combo row</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="HdyExpanderRow" id="expander_row">
<property name="title" translatable="yes">Expander row</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Hello, world!</property>
<property name="margin">12</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="HdyExpanderRow" id="enable_expander_row">
<property name="show_enable_switch">True</property>
<property name="title" translatable="yes">Toggleable expander row</property>
<property name="visible">True</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Hello, world!</property>
<property name="margin">12</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">lists</property>
<property name="title">Lists</property>
</packing>
</child>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment