From a47ec7a4e60fbaf1eeee99a3772d611a278730c8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 2 Nov 2014 20:36:52 -0500 Subject: [PATCH] Add editors for GtkStack and GtkStackSwitcher --- plugins/gtk+/Makefile.am | 6 + .../gtk+/glade-gtk-resources.gresource.xml | 2 + plugins/gtk+/glade-gtk-stack-switcher.c | 6 + plugins/gtk+/glade-gtk-stack.c | 12 + plugins/gtk+/glade-stack-editor.c | 68 ++++++ plugins/gtk+/glade-stack-editor.h | 56 +++++ plugins/gtk+/glade-stack-editor.ui | 218 ++++++++++++++++++ plugins/gtk+/glade-stack-switcher-editor.c | 68 ++++++ plugins/gtk+/glade-stack-switcher-editor.h | 56 +++++ plugins/gtk+/glade-stack-switcher-editor.ui | 140 +++++++++++ plugins/gtk+/gtk+.xml.in | 34 ++- 11 files changed, 664 insertions(+), 2 deletions(-) create mode 100644 plugins/gtk+/glade-stack-editor.c create mode 100644 plugins/gtk+/glade-stack-editor.h create mode 100644 plugins/gtk+/glade-stack-editor.ui create mode 100644 plugins/gtk+/glade-stack-switcher-editor.c create mode 100644 plugins/gtk+/glade-stack-switcher-editor.h create mode 100644 plugins/gtk+/glade-stack-switcher-editor.ui diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am index 4e69a8b0..4fff22b2 100644 --- a/plugins/gtk+/Makefile.am +++ b/plugins/gtk+/Makefile.am @@ -147,6 +147,8 @@ libgladegtk_la_SOURCES = \ glade-scrollbar-editor.c \ glade-scrolled-window-editor.c \ glade-spin-button-editor.c \ + glade-stack-editor.c \ + glade-stack-switcher-editor.c \ glade-store-editor.c \ glade-string-list.c \ glade-text-view-editor.c \ @@ -224,6 +226,8 @@ noinst_HEADERS = \ glade-scrollbar-editor.h \ glade-scrolled-window-editor.h \ glade-spin-button-editor.h \ + glade-stack-editor.h \ + glade-stack-switcher-editor.h \ glade-store-editor.h \ glade-string-list.h \ glade-text-view-editor.h \ @@ -299,6 +303,8 @@ UI_FILES = \ glade-scrollbar-editor.ui \ glade-scrolled-window-editor.ui \ glade-spin-button-editor.ui \ + glade-stack-editor.ui \ + glade-stack-switcher-editor.ui \ glade-text-view-editor.ui \ glade-tool-button-editor.ui \ glade-tool-palette-editor.ui \ diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml index 4052b025..e9e5d020 100644 --- a/plugins/gtk+/glade-gtk-resources.gresource.xml +++ b/plugins/gtk+/glade-gtk-resources.gresource.xml @@ -43,6 +43,8 @@ glade-scrollbar-editor.ui glade-scrolled-window-editor.ui glade-spin-button-editor.ui + glade-stack-editor.ui + glade-stack-switcher-editor.ui glade-text-view-editor.ui glade-tool-palette-editor.ui glade-tool-button-editor.ui diff --git a/plugins/gtk+/glade-gtk-stack-switcher.c b/plugins/gtk+/glade-gtk-stack-switcher.c index dbe27d86..c375ac7d 100644 --- a/plugins/gtk+/glade-gtk-stack-switcher.c +++ b/plugins/gtk+/glade-gtk-stack-switcher.c @@ -25,10 +25,16 @@ #include #include +#include "glade-stack-switcher-editor.h" + + GladeEditable * glade_gtk_stack_switcher_create_editable (GladeWidgetAdaptor * adaptor, GladeEditorPageType type) { + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_stack_switcher_editor_new (); + 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 index 7d8c3672..96ad6f90 100644 --- a/plugins/gtk+/glade-gtk-stack.c +++ b/plugins/gtk+/glade-gtk-stack.c @@ -24,6 +24,8 @@ #include #include +#include "glade-stack-editor.h" + void glade_gtk_stack_post_create (GladeWidgetAdaptor *adaptor, GObject *container, @@ -75,3 +77,13 @@ glade_gtk_stack_child_action_activate (GladeWidgetAdaptor * adaptor, action_path); } +GladeEditable * +glade_gtk_stack_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_stack_editor_new (); + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + diff --git a/plugins/gtk+/glade-stack-editor.c b/plugins/gtk+/glade-stack-editor.c new file mode 100644 index 00000000..d949d764 --- /dev/null +++ b/plugins/gtk+/glade-stack-editor.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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. + * + * Authors: + * Matthias Clasen + */ + +#include +#include +#include + +#include "glade-stack-editor.h" + +static void glade_stack_editor_grab_focus (GtkWidget * widget); + +struct _GladeStackEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladeStackEditor, glade_stack_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_stack_editor_class_init (GladeStackEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_stack_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-stack-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladeStackEditor, embed); +} + +static void +glade_stack_editor_init (GladeStackEditor * self) +{ + self->priv = glade_stack_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_stack_editor_grab_focus (GtkWidget * widget) +{ + GladeStackEditor *stack_editor = GLADE_STACK_EDITOR (widget); + + gtk_widget_grab_focus (stack_editor->priv->embed); +} + +GtkWidget * +glade_stack_editor_new (void) +{ + return g_object_new (GLADE_TYPE_STACK_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-stack-editor.h b/plugins/gtk+/glade-stack-editor.h new file mode 100644 index 00000000..29ba18dd --- /dev/null +++ b/plugins/gtk+/glade-stack-editor.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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. + * + * Authors: + * Matthias Clasen + */ +#ifndef _GLADE_STACK_EDITOR_H_ +#define _GLADE_STACK_EDITOR_H_ + +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_STACK_EDITOR (glade_stack_editor_get_type ()) +#define GLADE_STACK_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_STACK_EDITOR, GladeStackEditor)) +#define GLADE_STACK_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_STACK_EDITOR, GladeStackEditorClass)) +#define GLADE_IS_STACK_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_STACK_EDITOR)) +#define GLADE_IS_STACK_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_STACK_EDITOR)) +#define GLADE_STACK_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_STACK_EDITOR, GladeStackEditorClass)) + +typedef struct _GladeStackEditor GladeStackEditor; +typedef struct _GladeStackEditorClass GladeStackEditorClass; +typedef struct _GladeStackEditorPrivate GladeStackEditorPrivate; + +struct _GladeStackEditor +{ + GladeEditorSkeleton parent; + + GladeStackEditorPrivate *priv; +}; + +struct _GladeStackEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_stack_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_stack_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_STACK_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-stack-editor.ui b/plugins/gtk+/glade-stack-editor.ui new file mode 100644 index 00000000..59c6ab95 --- /dev/null +++ b/plugins/gtk+/glade-stack-editor.ui @@ -0,0 +1,218 @@ + + + + + + + diff --git a/plugins/gtk+/glade-stack-switcher-editor.c b/plugins/gtk+/glade-stack-switcher-editor.c new file mode 100644 index 00000000..d02e849e --- /dev/null +++ b/plugins/gtk+/glade-stack-switcher-editor.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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. + * + * Authors: + * Matthias Clasen + */ + +#include +#include +#include + +#include "glade-stack-switcher-editor.h" + +static void glade_stack_switcher_editor_grab_focus (GtkWidget * widget); + +struct _GladeStackSwitcherEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladeStackSwitcherEditor, glade_stack_switcher_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_stack_switcher_editor_class_init (GladeStackSwitcherEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_stack_switcher_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-stack-switcher-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladeStackSwitcherEditor, embed); +} + +static void +glade_stack_switcher_editor_init (GladeStackSwitcherEditor * self) +{ + self->priv = glade_stack_switcher_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_stack_switcher_editor_grab_focus (GtkWidget * widget) +{ + GladeStackSwitcherEditor *editor = GLADE_STACK_SWITCHER_EDITOR (widget); + + gtk_widget_grab_focus (editor->priv->embed); +} + +GtkWidget * +glade_stack_switcher_editor_new (void) +{ + return g_object_new (GLADE_TYPE_STACK_SWITCHER_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-stack-switcher-editor.h b/plugins/gtk+/glade-stack-switcher-editor.h new file mode 100644 index 00000000..343e37c6 --- /dev/null +++ b/plugins/gtk+/glade-stack-switcher-editor.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * 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. + * + * Authors: + * Matthias Clasen + */ +#ifndef _GLADE_STACK_SWITCHER_EDITOR_H_ +#define _GLADE_STACK_SWITCHER_EDITOR_H_ + +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_STACK_SWITCHER_EDITOR (glade_stack_switcher_editor_get_type ()) +#define GLADE_STACK_SWITCHER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_STACK_SWITCHER_EDITOR, GladeStackSwitcherEditor)) +#define GLADE_STACK_SWITCHER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_STACK_SWITCHER_EDITOR, GladeStackSwitcherEditorClass)) +#define GLADE_IS_STACK_SWITCHER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_STACK_SWITCHER_EDITOR)) +#define GLADE_IS_STACK_SWITCHER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_STACK_SWITCHER_EDITOR)) +#define GLADE_STACK_SWITCHER_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_STACK_SWITCHER_EDITOR, GladeStackSwitcherEditorClass)) + +typedef struct _GladeStackSwitcherEditor GladeStackSwitcherEditor; +typedef struct _GladeStackSwitcherEditorClass GladeStackSwitcherEditorClass; +typedef struct _GladeStackSwitcherEditorPrivate GladeStackSwitcherEditorPrivate; + +struct _GladeStackSwitcherEditor +{ + GladeEditorSkeleton parent; + + GladeStackSwitcherEditorPrivate *priv; +}; + +struct _GladeStackSwitcherEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_stack_switcher_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_stack_switcher_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_STACK_SWITCHER_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-stack-switcher-editor.ui b/plugins/gtk+/glade-stack-switcher-editor.ui new file mode 100644 index 00000000..3d40d10b --- /dev/null +++ b/plugins/gtk+/glade-stack-switcher-editor.ui @@ -0,0 +1,140 @@ + + + + + + + diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index b8e9df5e..a74487bb 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -2456,6 +2456,7 @@ + glade_gtk_stack_create_editable glade_gtk_stack_post_create glade_gtk_stack_child_action_activate @@ -2464,12 +2465,41 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + glade_gtk_stack_switcher_create_editable