widget-factory: More popover examples

Add an example for text input in a popover. This leads to nested
popovers with touch selection, and does not currently work.
This commit is contained in:
Matthias Clasen 2015-06-13 13:45:57 -04:00
parent 94fc9f5211
commit 2af2189347
2 changed files with 98 additions and 1 deletions

View File

@ -1217,6 +1217,15 @@ populate_popup (GtkTextView *tv,
add_item (tv, popup, "<u>Underline</u>", "underline", all_underline);
}
static void
open_popover_text_changed (GtkEntry *entry, GParamSpec *pspec, GtkWidget *button)
{
const gchar *text;
text = gtk_entry_get_text (entry);
gtk_widget_set_sensitive (button, strlen (text) > 0);
}
static void
activate (GApplication *app)
{
@ -1424,6 +1433,13 @@ activate (GApplication *app)
g_signal_connect (widget, "populate-popup",
G_CALLBACK (populate_popup), NULL);
widget = (GtkWidget *)gtk_builder_get_object (builder, "open_popover");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "open_popover_entry");
widget3 = (GtkWidget *)gtk_builder_get_object (builder, "open_popover_button");
gtk_popover_set_default_widget (GTK_POPOVER (widget), widget3);
g_signal_connect (widget2, "notify::text", G_CALLBACK (open_popover_text_changed), widget3);
g_signal_connect_swapped (widget3, "clicked", G_CALLBACK (gtk_widget_hide), widget);
gtk_widget_show_all (GTK_WIDGET (window));
g_object_unref (builder);

View File

@ -2893,9 +2893,10 @@ microphone-sensitivity-medium-symbolic</property>
<property name="halign">start</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton">
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="popover">open_popover</property>
<style>
<class name="text-button"/>
<class name="image-button"/>
@ -3884,6 +3885,86 @@ bad things might happen.</property>
<action-widget response="ok" default="true">select_selection_dialog</action-widget>
</action-widgets>
</object>
<object class="GtkPopover" id="open_popover">
<property name="visible">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="margin">10</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label">Title:</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="valign">start</property>
<property name="visible">True</property>
<property name="label">Description:</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="valign">start</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">70</property>
<child>
<object class="GtkTextView" id="open_popover_textview">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="open_popover_entry">
<property name="visible">True</property>
<property name="activates-default">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="open_popover_button">
<property name="halign">end</property>
<property name="visible">True</property>
<property name="label">_Open</property>
<property name="use-underline">True</property>
<property name="sensitive">False</property>
<property name="can-default">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkSizeGroup">
<property name="mode">vertical</property>
<widgets>