From 4e97ffeb6ca4a4b1a4848864d8ab6033f71a0f17 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 19 Nov 2014 07:53:42 +0100 Subject: Add an editor for GtkPopover --- plugins/gtk+/Makefile.am | 3 + plugins/gtk+/glade-gtk-popover.c | 13 ++ plugins/gtk+/glade-gtk-resources.gresource.xml | 1 + plugins/gtk+/glade-popover-editor.c | 69 +++++++++++ plugins/gtk+/glade-popover-editor.h | 57 +++++++++ plugins/gtk+/glade-popover-editor.ui | 165 +++++++++++++++++++++++++ plugins/gtk+/gtk+.xml.in | 6 +- 7 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 plugins/gtk+/glade-popover-editor.c create mode 100644 plugins/gtk+/glade-popover-editor.h create mode 100644 plugins/gtk+/glade-popover-editor.ui diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am index 8e15d891..7e502c15 100644 --- a/plugins/gtk+/Makefile.am +++ b/plugins/gtk+/Makefile.am @@ -135,6 +135,7 @@ libgladegtk_la_SOURCES = \ glade-misc-editor.c \ glade-model-data.c \ glade-notebook-editor.c \ + glade-popover-editor.c \ glade-progress-bar-editor.c \ glade-real-tree-view-editor.c \ glade-recent-action-editor.c \ @@ -214,6 +215,7 @@ noinst_HEADERS = \ glade-misc-editor.h \ glade-model-data.h \ glade-notebook-editor.h \ + glade-popover-editor.h \ glade-progress-bar-editor.h \ glade-real-tree-view-editor.h \ glade-recent-action-editor.h \ @@ -291,6 +293,7 @@ UI_FILES = \ glade-message-dialog-editor.ui \ glade-misc-editor.ui \ glade-notebook-editor.ui \ + glade-popover-editor.ui \ glade-progress-bar-editor.ui \ glade-real-tree-view-editor.ui \ glade-recent-action-editor.ui \ diff --git a/plugins/gtk+/glade-gtk-popover.c b/plugins/gtk+/glade-gtk-popover.c index 2d80bada..b60e6ff0 100644 --- a/plugins/gtk+/glade-gtk-popover.c +++ b/plugins/gtk+/glade-gtk-popover.c @@ -25,6 +25,8 @@ #include #include +#include "glade-popover-editor.h" + GObject * glade_gtk_popover_constructor (GType type, guint n_construct_properties, @@ -43,3 +45,14 @@ glade_gtk_popover_constructor (GType type, return ret_obj; } + +GladeEditable * +glade_gtk_popover_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_popover_editor_new (); + else + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml index e9e5d020..f3a9ec69 100644 --- a/plugins/gtk+/glade-gtk-resources.gresource.xml +++ b/plugins/gtk+/glade-gtk-resources.gresource.xml @@ -31,6 +31,7 @@ glade-misc-editor.ui glade-progress-bar-editor.ui glade-notebook-editor.ui + glade-popover-editor.ui glade-real-tree-view-editor.ui glade-recent-action-editor.ui glade-recent-chooser-dialog-editor.ui diff --git a/plugins/gtk+/glade-popover-editor.c b/plugins/gtk+/glade-popover-editor.c new file mode 100644 index 00000000..84210943 --- /dev/null +++ b/plugins/gtk+/glade-popover-editor.c @@ -0,0 +1,69 @@ +/* + * 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 + +#include "glade-popover-editor.h" + +static void glade_popover_editor_grab_focus (GtkWidget * widget); + +struct _GladePopoverEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladePopoverEditor, glade_popover_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_popover_editor_class_init (GladePopoverEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_popover_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-popover-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladePopoverEditor, embed); +} + +static void +glade_popover_editor_init (GladePopoverEditor * self) +{ + self->priv = glade_popover_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_popover_editor_grab_focus (GtkWidget * widget) +{ + GladePopoverEditor *editor = GLADE_POPOVER_EDITOR (widget); + + gtk_widget_grab_focus (editor->priv->embed); +} + +GtkWidget * +glade_popover_editor_new (void) +{ + return g_object_new (GLADE_TYPE_POPOVER_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-popover-editor.h b/plugins/gtk+/glade-popover-editor.h new file mode 100644 index 00000000..eeb35a63 --- /dev/null +++ b/plugins/gtk+/glade-popover-editor.h @@ -0,0 +1,57 @@ +/* + * 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_POPOVER_EDITOR_H_ +#define _GLADE_POPOVER_EDITOR_H_ + +#include +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_POPOVER_EDITOR (glade_popover_editor_get_type ()) +#define GLADE_POPOVER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_POPOVER_EDITOR, GladePopoverEditor)) +#define GLADE_POPOVER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_POPOVER_EDITOR, GladePopoverEditorClass)) +#define GLADE_IS_POPOVER_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_POPOVER_EDITOR)) +#define GLADE_IS_POPOVER_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_POPOVER_EDITOR)) +#define GLADE_POPOVER_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_POPOVER_EDITOR, GladePopoverEditorClass)) + +typedef struct _GladePopoverEditor GladePopoverEditor; +typedef struct _GladePopoverEditorClass GladePopoverEditorClass; +typedef struct _GladePopoverEditorPrivate GladePopoverEditorPrivate; + +struct _GladePopoverEditor +{ + GladeEditorSkeleton parent; + + GladePopoverEditorPrivate *priv; +}; + +struct _GladePopoverEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_popover_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_popover_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_POPOVER_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-popover-editor.ui b/plugins/gtk+/glade-popover-editor.ui new file mode 100644 index 00000000..69219f3a --- /dev/null +++ b/plugins/gtk+/glade-popover-editor.ui @@ -0,0 +1,165 @@ + + + + + + + diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index 5935a727..c4c507b6 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -3376,9 +3376,11 @@ glade_gtk_popover_constructor + glade_gtk_popover_create_editable - - + + + -- cgit v1.2.1