[gtk+/wip/matthiasc/help-overlay] Beef up the shortcuts example more



commit 7993feccf510bebb7c5011dbf4b191bddd5190de
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 13 08:28:50 2015 -0400

    Beef up the shortcuts example more
    
    Add separate buttons for showing the full and filtered Clocks
    example, and make the buttons work more than once.

 demos/gtk-demo/shortcuts.ui      |   29 +++++++++++++++++++++--------
 demos/gtk-demo/shortcutswindow.c |   22 ++++++++++++++++++++--
 2 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/demos/gtk-demo/shortcuts.ui b/demos/gtk-demo/shortcuts.ui
index 6f64ff5..2ebef31 100644
--- a/demos/gtk-demo/shortcuts.ui
+++ b/demos/gtk-demo/shortcuts.ui
@@ -1,16 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.17 -->
-  <object class="GFileIcon" id="left-swipe-icon">
-    <property name="file">resource:///icons/gesture-two-finger-swipe-left.svg</property>
-  </object>
-  <object class="GFileIcon" id="right-swipe-icon">
-    <property name="file">resource:///icons/gesture-two-finger-swipe-right.svg</property>
-  </object>
+
   <object class="GtkWindow" id="window1">
     <child>
       <object class="GtkBox">
         <property name="visible">1</property>
+        <property name="orientation">vertical</property>
         <property name="margin">50</property>
         <property name="spacing">10</property>
         <child>
@@ -23,16 +19,32 @@
         <child>
           <object class="GtkButton">
             <property name="visible">1</property>
-            <property name="label">Clocks</property>
-            <signal name="clicked" handler="gtk_widget_show" swapped="1" object="clocks-shortcuts"/>
+            <property name="label">Clocks - all</property>
+            <signal name="clicked" handler="show_clock_shortcuts" swapped="1" object="clocks-shortcuts"/>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton">
+            <property name="visible">1</property>
+            <property name="label">Clocks - Stopwatch</property>
+            <signal name="clicked" handler="show_clock_shortcuts_stopwatch" swapped="1" 
object="clocks-shortcuts"/>
           </object>
         </child>
       </object>
     </child>
   </object>
+
+  <object class="GFileIcon" id="left-swipe-icon">
+    <property name="file">resource:///icons/gesture-two-finger-swipe-left.svg</property>
+  </object>
+  <object class="GFileIcon" id="right-swipe-icon">
+    <property name="file">resource:///icons/gesture-two-finger-swipe-right.svg</property>
+  </object>
+
   <object class="GtkShortcutsWindow" id="builder-shortcuts">
     <property name="transient-for">window1</property>
     <property name="modal">1</property>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete"/>
     <sections>
       <section name="editor">
         <property name="title" translatable="yes">Editor Shortcuts</property>
@@ -322,6 +334,7 @@
   <object class="GtkShortcutsWindow" id="clocks-shortcuts">
     <property name="transient-for">window1</property>
     <property name="modal">1</property>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete"/>
     <sections>
       <section name="shortcuts">
         <page>
diff --git a/demos/gtk-demo/shortcutswindow.c b/demos/gtk-demo/shortcutswindow.c
index 1186782..587eb65 100644
--- a/demos/gtk-demo/shortcutswindow.c
+++ b/demos/gtk-demo/shortcutswindow.c
@@ -1,11 +1,25 @@
 /* Shortcuts Window
  *
- * GtkShortcutsWindow is a window that provides a help overview
- * for shortcuts in an application.
+ * GtkShortcutsWindow is a window that provides a help overlay
+ * for shortcuts and gestures in an application.
  */
 
 #include <gtk/gtk.h>
 
+static void
+show_clock_shortcuts (GtkWidget *window)
+{
+  g_object_set (window, "view-name", NULL, NULL);
+  gtk_widget_show (window);
+}
+
+static void
+show_clock_shortcuts_stopwatch (GtkWidget *window)
+{
+  g_object_set (window, "view-name", "stopwatch", NULL);
+  gtk_widget_show (window);
+}
+
 GtkWidget *
 do_shortcutswindow (GtkWidget *do_widget)
 {
@@ -25,6 +39,10 @@ do_shortcutswindow (GtkWidget *do_widget)
       GtkBuilder *builder;
 
       builder = gtk_builder_new_from_resource ("/shortcuts/shortcuts.ui");
+      gtk_builder_add_callback_symbols (builder,
+                                        "show_clock_shortcuts", G_CALLBACK (show_clock_shortcuts),
+                                        "show_clock_shortcuts_stopwatch", G_CALLBACK 
(show_clock_shortcuts_stopwatch),
+                                        NULL);
       gtk_builder_connect_signals (builder, NULL);
       window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
       gtk_window_set_screen (GTK_WINDOW (window),


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