[glade/stack] Support GtkStack and GtkStackSwitcher



commit 16266ae9451c629e230fe6c398b420426394d656
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 13 16:29:22 2014 -0400

    Support GtkStack and GtkStackSwitcher
    
    These widgets are in GTK+ since 3.12, time that glade starts
    supporting them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738480

 plugins/gtk+/Makefile.am                           |    2 +
 plugins/gtk+/glade-gtk-stack-switcher.c            |   34 +++++++++
 plugins/gtk+/glade-gtk-stack.c                     |   77 ++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in                           |   42 +++++++++++-
 plugins/gtk+/icons/16x16/Makefile.am               |    2 +
 plugins/gtk+/icons/16x16/widget-gtk-stack.png      |  Bin 0 -> 181 bytes
 .../gtk+/icons/16x16/widget-gtk-stackswitcher.png  |  Bin 0 -> 226 bytes
 plugins/gtk+/icons/22x22/Makefile.am               |    2 +
 plugins/gtk+/icons/22x22/widget-gtk-stack.png      |  Bin 0 -> 188 bytes
 .../gtk+/icons/22x22/widget-gtk-stackswitcher.png  |  Bin 0 -> 255 bytes
 10 files changed, 158 insertions(+), 1 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 6f17c31..9f347e7 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -103,6 +103,8 @@ libgladegtk_la_SOURCES =            \
        glade-gtk-scrolled-window.c     \
        glade-gtk-size-group.c          \
        glade-gtk-spin-button.c         \
+       glade-gtk-stack.c               \
+       glade-gtk-stack-switcher.c      \
        glade-gtk-switch.c              \
        glade-gtk-table.c               \
        glade-gtk-text-buffer.c         \
diff --git a/plugins/gtk+/glade-gtk-stack-switcher.c b/plugins/gtk+/glade-gtk-stack-switcher.c
new file mode 100644
index 0000000..dbe27d8
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-stack-switcher.c
@@ -0,0 +1,34 @@
+/*
+ * glade-gtk-swack-switcher.c - GladeWidgetAdaptor for GtkStackSwitcher
+ *
+ * Copyright (C) 2014 Red Hat, Inc
+ *
+ * Authors:
+ *      Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+GladeEditable *
+glade_gtk_stack_switcher_create_editable (GladeWidgetAdaptor * adaptor,
+                                          GladeEditorPageType type)
+{
+  return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+}
+
diff --git a/plugins/gtk+/glade-gtk-stack.c b/plugins/gtk+/glade-gtk-stack.c
new file mode 100644
index 0000000..7d8c367
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-stack.c
@@ -0,0 +1,77 @@
+/*
+ * glade-gtk-stack.c - GladeWidgetAdaptor for GtkStack
+ *
+ * Copyright (C) 2014 Red Hat, Inc
+ *
+ * Authors:
+ *      Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+void
+glade_gtk_stack_post_create (GladeWidgetAdaptor *adaptor,
+                             GObject            *container,
+                             GladeCreateReason   reason)
+{
+  if (reason == GLADE_CREATE_USER)
+    {
+      gtk_stack_add_named (GTK_STACK (container),
+                           glade_placeholder_new (),
+                           "page0");
+    }
+}
+
+void
+glade_gtk_stack_child_action_activate (GladeWidgetAdaptor * adaptor,
+                                       GObject * container,
+                                       GObject * object,
+                                       const gchar * action_path)
+{
+  if (!strcmp (action_path, "insert_page_after") ||
+      !strcmp (action_path, "insert_page_before"))
+    {
+      gint position;
+      gchar *name;
+      GtkWidget *new_widget;
+
+      gtk_container_child_get (GTK_CONTAINER (container), GTK_WIDGET (object),
+                               "position", &position, NULL);
+
+      if (!strcmp (action_path, "insert_page_after"))
+        position++;
+
+      name = g_strdup_printf ("page%d", position);
+      new_widget = glade_placeholder_new ();
+
+      gtk_stack_add_named (GTK_STACK (container), new_widget, name);
+      gtk_stack_set_visible_child (GTK_STACK (container), new_widget);
+
+      g_free (name);
+    }
+  else if (strcmp (action_path, "remove_page") == 0)
+    {
+      gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (object)); 
+    }
+  else
+    GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
+                                                               container,
+                                                               object,
+                                                               action_path);
+}
+
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index bf5b006..67bead8 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2368,6 +2368,33 @@
         </packing-properties>
       </glade-widget-class>
       
+      <glade-widget-class name="GtkStack" generic-name="stack" _title="Stack" since="3.10">
+        <post-create-function>glade_gtk_stack_post_create</post-create-function>
+        
<child-action-activate-function>glade_gtk_stack_child_action_activate</child-action-activate-function>
+        <packing-actions>
+          <action id="insert_page_before" _name="Insert Page Before" stock="list-add"/>
+          <action id="insert_page_after" _name="Insert Page After" stock="list-add"/>
+          <action id="remove_page" _name="Remove Page"  stock="list-remove"/>
+        </packing-actions>
+        <properties>
+          <property id="visible-child" save="False"/>
+          <property id="visible-child-name" save="False"/>
+        </properties>
+      </glade-widget-class>
+
+      <glade-widget-class name="GtkStackSwitcher" generic-name="stackswitcher" _title="Stack Switcher" 
since="3.10">
+
+        <properties>
+          <property id="orientation" default="GTK_ORIENTATION_HORIZONTAL"/>
+          <!-- Disable GtkBox stuff -->
+          <property id="size" disabled="True" default="0"/>
+          <property id="homogeneous" disabled="True"/>
+          <property id="spacing" disabled="True"/>
+          <property id="baseline-position" disabled="True"/>
+        </properties>
+
+      </glade-widget-class>
+
       <glade-widget-class name="GtkRevealer" generic-name="revealer" _title="Revealer" since="3.10">
         <post-create-function>glade_gtk_revealer_post_create</post-create-function>
         <properties>
@@ -3064,7 +3091,18 @@
       </glade-widget-class>
       
       <glade-widget-class name="GtkColorChooserWidget" generic-name="colorchooserwidget"
-                       _title="Color Chooser Widget" icon-name="widget-gtk-colorselection" since="3.4"/>
+                       _title="Color Chooser Widget" icon-name="widget-gtk-colorselection" since="3.4">
+        <properties>
+          <!-- Disable GtkBox stuff -->
+          <property id="size" disabled="True"/>
+          <property id="homogeneous" disabled="True"/>
+          <property id="orientation" disabled="True"/>
+          <property id="spacing" disabled="True"/>
+          <property id="baseline-position" disabled="True"/>
+        </properties>
+      
+      </glade-widget-class>
+
       <glade-widget-class name="GtkColorChooserDialog" generic-name="colorchooserdialog"
                        _title="Color Chooser Dialog" icon-name="widget-gtk-colorselectiondialog" 
since="3.4"/>
       <glade-widget-class name="GtkFontChooserWidget" generic-name="fontchooserwidget"
@@ -5141,6 +5179,7 @@
       <glade-widget-class-ref name="GtkScrolledWindow"/>
       <glade-widget-class-ref name="GtkAlignment"/>
       <glade-widget-class-ref name="GtkRevealer" />
+      <glade-widget-class-ref name="GtkStack" />
     </glade-widget-group>
     
     <glade-widget-group name="gtk-control-display" _title="Control and Display">
@@ -5194,6 +5233,7 @@
       <glade-widget-class-ref name="GtkDrawingArea"/>
       
       <glade-widget-class-ref name="GtkInfoBar"/>
+      <glade-widget-class-ref name="GtkStackSwitcher" />
     </glade-widget-group>
     
     <glade-widget-group name="gtk-composite" _title="Composite Widgets">
diff --git a/plugins/gtk+/icons/16x16/Makefile.am b/plugins/gtk+/icons/16x16/Makefile.am
index baaeba7..680844b 100644
--- a/plugins/gtk+/icons/16x16/Makefile.am
+++ b/plugins/gtk+/icons/16x16/Makefile.am
@@ -99,6 +99,8 @@ icons_DATA = \
        widget-gtk-sizegroup.png \
        widget-gtk-spinbutton.png \
        widget-gtk-spinner.png \
+       widget-gtk-stack.png \
+       widget-gtk-stackswitcher.png \
        widget-gtk-statusbar.png \
        widget-gtk-statusicon.png \
        widget-gtk-table.png \
diff --git a/plugins/gtk+/icons/16x16/widget-gtk-stack.png b/plugins/gtk+/icons/16x16/widget-gtk-stack.png
new file mode 100644
index 0000000..7c31847
Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-stack.png differ
diff --git a/plugins/gtk+/icons/16x16/widget-gtk-stackswitcher.png 
b/plugins/gtk+/icons/16x16/widget-gtk-stackswitcher.png
new file mode 100644
index 0000000..1e3f23d
Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-stackswitcher.png differ
diff --git a/plugins/gtk+/icons/22x22/Makefile.am b/plugins/gtk+/icons/22x22/Makefile.am
index ff45e33..acb0e7c 100644
--- a/plugins/gtk+/icons/22x22/Makefile.am
+++ b/plugins/gtk+/icons/22x22/Makefile.am
@@ -99,6 +99,8 @@ icons_DATA = \
        widget-gtk-sizegroup.png \
        widget-gtk-spinbutton.png \
        widget-gtk-spinner.png \
+       widget-gtk-stack.png \
+       widget-gtk-stackswitcher.png \
        widget-gtk-statusbar.png \
        widget-gtk-statusicon.png \
        widget-gtk-table.png \
diff --git a/plugins/gtk+/icons/22x22/widget-gtk-stack.png b/plugins/gtk+/icons/22x22/widget-gtk-stack.png
new file mode 100644
index 0000000..3ce48b5
Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-stack.png differ
diff --git a/plugins/gtk+/icons/22x22/widget-gtk-stackswitcher.png 
b/plugins/gtk+/icons/22x22/widget-gtk-stackswitcher.png
new file mode 100644
index 0000000..fc21309
Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-stackswitcher.png differ


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