[glade] Added GladeLayoutEditor



commit 9df38fc6d9b32f60bafc56c04ba63fdfdec7feb7
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat May 18 22:14:41 2013 +0900

    Added GladeLayoutEditor
    
    A very basic editor which embeds the GladeScrollableEditor

 plugins/gtk+/Makefile.am                       |    3 +
 plugins/gtk+/glade-gtk-fixed-layout.c          |   14 ++++
 plugins/gtk+/glade-gtk-resources.gresource.xml |    1 +
 plugins/gtk+/glade-layout-editor.c             |   76 ++++++++++++++++++++++++
 plugins/gtk+/glade-layout-editor.h             |   68 +++++++++++++++++++++
 plugins/gtk+/glade-layout-editor.ui            |   38 ++++++++++++
 plugins/gtk+/gtk+.xml.in                       |   13 ++++
 po/POTFILES.in                                 |    2 +
 8 files changed, 215 insertions(+), 0 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 96018e9..358e0b1 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 4fc7d7c..22ce1ad 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 b782897..b2380fe 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 0000000..509d64f
--- /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 0000000..c49a919
--- /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 0000000..a49a54d
--- /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 51e754d..4b1a603 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 bcb522e..fd58324 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


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