diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-05-18 22:14:41 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-05-18 22:14:41 +0900 |
commit | 9df38fc6d9b32f60bafc56c04ba63fdfdec7feb7 (patch) | |
tree | 211d77f76e2c600c301870f9fd754cb9684716ef | |
parent | 6edfe3ba81dfbc60192b039c76d4fefe4f23e6cb (diff) | |
download | glade-9df38fc6d9b32f60bafc56c04ba63fdfdec7feb7.tar.gz |
Added GladeLayoutEditor
A very basic editor which embeds the GladeScrollableEditor
-rw-r--r-- | plugins/gtk+/Makefile.am | 3 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-fixed-layout.c | 14 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-resources.gresource.xml | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-layout-editor.c | 76 | ||||
-rw-r--r-- | plugins/gtk+/glade-layout-editor.h | 68 | ||||
-rw-r--r-- | plugins/gtk+/glade-layout-editor.ui | 38 | ||||
-rw-r--r-- | plugins/gtk+/gtk+.xml.in | 13 | ||||
-rw-r--r-- | po/POTFILES.in | 2 |
8 files changed, 215 insertions, 0 deletions
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am index 96018e90..358e0b1d 100644 --- a/plugins/gtk+/Makefile.am +++ b/plugins/gtk+/Makefile.am @@ -115,6 +115,7 @@ libgladegtk_la_SOURCES = \ glade-image-editor.c \ glade-image-item-editor.c \ glade-label-editor.c \ + glade-layout-editor.c \ glade-level-bar-editor.c \ glade-message-dialog-editor.c \ glade-model-data.c \ @@ -185,6 +186,7 @@ noinst_HEADERS = \ glade-image-editor.h \ glade-image-item-editor.h \ glade-label-editor.h \ + glade-layout-editor.h \ glade-level-bar-editor.h \ glade-message-dialog-editor.h \ glade-model-data.h \ @@ -254,6 +256,7 @@ UI_FILES = \ glade-grid-editor.ui \ glade-image-editor.ui \ glade-label-editor.ui \ + glade-layout-editor.ui \ glade-level-bar-editor.ui \ glade-message-dialog-editor.ui \ glade-notebook-editor.ui \ diff --git a/plugins/gtk+/glade-gtk-fixed-layout.c b/plugins/gtk+/glade-gtk-fixed-layout.c index 4fc7d7c2..22ce1ad9 100644 --- a/plugins/gtk+/glade-gtk-fixed-layout.c +++ b/plugins/gtk+/glade-gtk-fixed-layout.c @@ -25,6 +25,20 @@ #include <glib/gi18n-lib.h> #include <gladeui/glade.h> +#include "glade-layout-editor.h" + +GladeEditable * +glade_gtk_layout_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + { + return (GladeEditable *)glade_layout_editor_new (); + } + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + static void glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget) { diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml index b7828972..b2380fe2 100644 --- a/plugins/gtk+/glade-gtk-resources.gresource.xml +++ b/plugins/gtk+/glade-gtk-resources.gresource.xml @@ -22,6 +22,7 @@ <file compressed="true" preprocess="xml-stripblanks">glade-grid-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-image-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-label-editor.ui</file> + <file compressed="true" preprocess="xml-stripblanks">glade-layout-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-level-bar-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-message-dialog-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-progress-bar-editor.ui</file> diff --git a/plugins/gtk+/glade-layout-editor.c b/plugins/gtk+/glade-layout-editor.c new file mode 100644 index 00000000..509d64f6 --- /dev/null +++ b/plugins/gtk+/glade-layout-editor.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 Tristan Van Berkom. + * + * 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: + * Tristan Van Berkom <tvb@gnome.org> + */ + +#include <config.h> +#include <gladeui/glade.h> +#include <glib/gi18n-lib.h> + +#include "glade-layout-editor.h" + +/* GtkWidgetClass */ +static void glade_layout_editor_grab_focus (GtkWidget *widget); + +struct _GladeLayoutEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE (GladeLayoutEditor, glade_layout_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_layout_editor_class_init (GladeLayoutEditorClass * klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_layout_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-layout-editor.ui"); + gtk_widget_class_bind_child (widget_class, GladeLayoutEditorPrivate, embed); + + g_type_class_add_private (object_class, sizeof (GladeLayoutEditorPrivate)); +} + +static void +glade_layout_editor_init (GladeLayoutEditor * self) +{ + self->priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, + GLADE_TYPE_LAYOUT_EDITOR, + GladeLayoutEditorPrivate); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_layout_editor_grab_focus (GtkWidget * widget) +{ + GladeLayoutEditor *layout_editor = GLADE_LAYOUT_EDITOR (widget); + GladeLayoutEditorPrivate *priv = layout_editor->priv; + + gtk_widget_grab_focus (priv->embed); +} + +GtkWidget * +glade_layout_editor_new (void) +{ + return g_object_new (GLADE_TYPE_LAYOUT_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-layout-editor.h b/plugins/gtk+/glade-layout-editor.h new file mode 100644 index 00000000..c49a919b --- /dev/null +++ b/plugins/gtk+/glade-layout-editor.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2013 Tristan Van Berkom. + * + * 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: + * Tristan Van Berkom <tvb@gnome.org> + */ +#ifndef _GLADE_LAYOUT_EDITOR_H_ +#define _GLADE_LAYOUT_EDITOR_H_ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GLADE_TYPE_LAYOUT_EDITOR (glade_layout_editor_get_type ()) +#define GLADE_LAYOUT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_LAYOUT_EDITOR, GladeLayoutEditor)) +#define GLADE_LAYOUT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_LAYOUT_EDITOR, GladeLayoutEditorClass)) +#define GLADE_IS_LAYOUT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_LAYOUT_EDITOR)) +#define GLADE_IS_LAYOUT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_LAYOUT_EDITOR)) +#define GLADE_LAYOUT_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_LAYOUT_EDITOR, GladeLayoutEditorClass)) + +typedef struct _GladeLayoutEditor GladeLayoutEditor; +typedef struct _GladeLayoutEditorClass GladeLayoutEditorClass; +typedef struct _GladeLayoutEditorPrivate GladeLayoutEditorPrivate; + +typedef enum { + GLADE_LAYOUT_MODE_ATTRIBUTES = 0, /* default */ + GLADE_LAYOUT_MODE_MARKUP, + GLADE_LAYOUT_MODE_PATTERN +} GladeLayoutContentMode; + +typedef enum { + GLADE_LAYOUT_WRAP_FREE = 0, /* default */ + GLADE_LAYOUT_SINGLE_LINE, + GLADE_LAYOUT_WRAP_MODE +} GladeLayoutWrapMode; + +struct _GladeLayoutEditor +{ + GladeEditorSkeleton parent; + + GladeLayoutEditorPrivate *priv; +}; + +struct _GladeLayoutEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_layout_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_layout_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_LAYOUT_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-layout-editor.ui b/plugins/gtk+/glade-layout-editor.ui new file mode 100644 index 00000000..a49a54d7 --- /dev/null +++ b/plugins/gtk+/glade-layout-editor.ui @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface domain="glade"> + <!-- interface-requires glade-gtk-plugin 0.0 --> + <!-- interface-requires gladeui 0.0 --> + <template class="GladeLayoutEditor" parent="GladeEditorSkeleton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GladeEditorTable" id="embed"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GladeScrollableEditor" id="scrollable_editor"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child-editors> + <editor id="embed"/> + <editor id="scrollable_editor"/> + </child-editors> + </template> +</interface> diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index 51e754d9..4b1a6035 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -2202,10 +2202,23 @@ range of values</_tooltip> </glade-widget-class> <glade-widget-class name="GtkLayout" generic-name="layout" _title="Layout" use-placeholders="False"> + <create-editable-function>glade_gtk_layout_create_editable</create-editable-function> <create-widget-function>glade_gtk_create_fixed_widget</create-widget-function> <post-create-function>glade_gtk_fixed_layout_post_create</post-create-function> <add-child-function>glade_gtk_fixed_layout_add_child</add-child-function> <remove-child-function>glade_gtk_fixed_layout_remove_child</remove-child-function> + + <properties> + <!-- Scrollable attributes --> + <property id="hadjustment" custom-layout="True"/> + <property id="vadjustment" custom-layout="True"/> + <property id="hscroll-policy" custom-layout="True"> + <_tooltip>Whether to start scrolling at less than minimum or natural width</_tooltip> + </property> + <property id="vscroll-policy" custom-layout="True"> + <_tooltip>Whether to start scrolling at less than minimum or natural height</_tooltip> + </property> + </properties> </glade-widget-class> <glade-widget-class name="GtkFixed" generic-name="fixed" _title="Fixed" use-placeholders="False"> diff --git a/po/POTFILES.in b/po/POTFILES.in index bcb522ee..fd583246 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -144,6 +144,7 @@ plugins/gtk+/glade-icon-sources.c plugins/gtk+/glade-image-editor.c plugins/gtk+/glade-image-item-editor.c plugins/gtk+/glade-label-editor.c +plugins/gtk+/glade-layout-editor.c plugins/gtk+/glade-level-bar-editor.c plugins/gtk+/glade-message-dialog-editor.c plugins/gtk+/glade-model-data.c @@ -190,6 +191,7 @@ plugins/gtk+/gtk+.xml.in [type: gettext/glade]plugins/gtk+/glade-grid-editor.ui [type: gettext/glade]plugins/gtk+/glade-image-editor.ui [type: gettext/glade]plugins/gtk+/glade-label-editor.ui +[type: gettext/glade]plugins/gtk+/glade-layout-editor.ui [type: gettext/glade]plugins/gtk+/glade-level-bar-editor.ui [type: gettext/glade]plugins/gtk+/glade-message-dialog-editor.ui [type: gettext/glade]plugins/gtk+/glade-notebook-editor.ui |