[glade] Support GtkStack and GtkStackSwitcher
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Support GtkStack and GtkStackSwitcher
- Date: Fri, 21 Nov 2014 05:58:12 +0000 (UTC)
commit f4dc9a24dd8b6d91ddafc99269846da98fac9e69
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 | 31 ++++++++-
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, 147 insertions(+), 1 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index fbff8bc..4e69a8b 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -104,6 +104,8 @@ libgladegtk_la_SOURCES = \
glade-gtk-searchbar.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 4b5a426..b8e9df5 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2399,7 +2399,7 @@
<property id="tab-label" disabled="True"/>
</packing-properties>
</glade-widget-class>
-
+
<glade-widget-class name="GtkHeaderBar" generic-name="headerbar" _title="HeaderBar" since="3.10">
<post-create-function>glade_gtk_header_bar_post_create</post-create-function>
<add-child-function>glade_gtk_header_bar_add_child</add-child-function>
@@ -2454,6 +2454,33 @@
<action id="add_slot" _name="Add Slot" stock="gtk-add"/>
</actions>
</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>
@@ -5243,6 +5270,7 @@
<glade-widget-class-ref name="GtkRevealer" />
<glade-widget-class-ref name="GtkSearchBar" />
<glade-widget-class-ref name="GtkHeaderBar" />
+ <glade-widget-class-ref name="GtkStack" />
</glade-widget-group>
<glade-widget-group name="gtk-control-display" _title="Control and Display">
@@ -5296,6 +5324,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 7ea1da1..6685b39 100644
--- a/plugins/gtk+/icons/16x16/Makefile.am
+++ b/plugins/gtk+/icons/16x16/Makefile.am
@@ -101,6 +101,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 411d6cd..dfca02a 100644
--- a/plugins/gtk+/icons/22x22/Makefile.am
+++ b/plugins/gtk+/icons/22x22/Makefile.am
@@ -101,6 +101,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]