[gtk+] widget-factory: More popover examples



commit 2af218934715632b67ac8559efe9e58c53b654f9
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 13 13:45:57 2015 -0400

    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.

 demos/widget-factory/widget-factory.c  |   16 ++++++
 demos/widget-factory/widget-factory.ui |   83 +++++++++++++++++++++++++++++++-
 2 files changed, 98 insertions(+), 1 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 2541ccd..9f93a29 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1218,6 +1218,15 @@ populate_popup (GtkTextView *tv,
 }
 
 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)
 {
   GtkBuilder *builder;
@@ -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);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index c9f6b44..31a110b 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]