[glade] Added GladeViewportEditor



commit 5c978697e60f191564fcb914bf0b75c68f92862e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat May 18 22:21:40 2013 +0900

    Added GladeViewportEditor
    
    Another very basic editor embedding GladeScrollableEditor

 plugins/gtk+/Makefile.am                       |    4 +
 plugins/gtk+/glade-gtk-resources.gresource.xml |    1 +
 plugins/gtk+/glade-gtk-viewport.c              |   40 ++++++++++++
 plugins/gtk+/glade-viewport-editor.c           |   76 ++++++++++++++++++++++++
 plugins/gtk+/glade-viewport-editor.h           |   68 +++++++++++++++++++++
 plugins/gtk+/glade-viewport-editor.ui          |   38 ++++++++++++
 plugins/gtk+/gtk+.xml.in                       |   17 +++++-
 po/POTFILES.in                                 |    3 +
 8 files changed, 245 insertions(+), 2 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 358e0b1..abc177b 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -108,6 +108,7 @@ libgladegtk_la_SOURCES =            \
        glade-gtk-tool-palette.c        \
        glade-gtk-toolbar.c             \
        glade-gtk-tree-view.c           \
+       glade-gtk-viewport.c            \
        glade-gtk-widget.c              \
        glade-gtk-window.c              \
        glade-icon-factory-editor.c     \
@@ -139,6 +140,7 @@ libgladegtk_la_SOURCES =            \
        glade-tool-item-group-editor.c  \
        glade-tool-palette-editor.c     \
        glade-treeview-editor.c         \
+       glade-viewport-editor.c         \
        glade-widget-editor.c           \
        glade-window-editor.c
 
@@ -210,6 +212,7 @@ noinst_HEADERS =                    \
        glade-tool-item-group-editor.h  \
        glade-tool-palette-editor.h     \
        glade-treeview-editor.h         \
+       glade-viewport-editor.h         \
        glade-widget-editor.h           \
        glade-window-editor.h
 
@@ -275,6 +278,7 @@ UI_FILES =                          \
        glade-text-view-editor.ui       \
        glade-tool-button-editor.ui     \
        glade-tool-palette-editor.ui    \
+       glade-viewport-editor.ui        \
        glade-widget-editor.ui          \
        glade-window-editor.ui
 
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index b2380fe..9611615 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -41,6 +41,7 @@
     <file compressed="true" preprocess="xml-stripblanks">glade-text-view-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-tool-palette-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-tool-button-editor.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">glade-viewport-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-widget-editor.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">glade-window-editor.ui</file>
   </gresource>
diff --git a/plugins/gtk+/glade-gtk-viewport.c b/plugins/gtk+/glade-gtk-viewport.c
new file mode 100644
index 0000000..40b555f
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-viewport.c
@@ -0,0 +1,40 @@
+/*
+ * glade-gtk-viewport.c - GladeWidgetAdaptor for GtkViewport
+ *
+ * Copyright (C) 2013 Tristan Van Berkom
+ *
+ * Authors:
+ *      Tristan Van Berkom <tristan van berkom gmail 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>
+
+#include "glade-viewport-editor.h"
+
+GladeEditable *
+glade_gtk_viewport_create_editable (GladeWidgetAdaptor * adaptor,
+                                   GladeEditorPageType type)
+{
+  if (type == GLADE_PAGE_GENERAL)
+    {
+      return (GladeEditable *)glade_viewport_editor_new ();
+    }
+
+  return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+}
diff --git a/plugins/gtk+/glade-viewport-editor.c b/plugins/gtk+/glade-viewport-editor.c
new file mode 100644
index 0000000..f4cc65d
--- /dev/null
+++ b/plugins/gtk+/glade-viewport-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-viewport-editor.h"
+
+/* GtkWidgetClass */
+static void glade_viewport_editor_grab_focus    (GtkWidget          *widget);
+
+struct _GladeViewportEditorPrivate
+{
+  GtkWidget *embed;
+};
+
+G_DEFINE_TYPE (GladeViewportEditor, glade_viewport_editor, GLADE_TYPE_EDITOR_SKELETON)
+
+static void
+glade_viewport_editor_class_init (GladeViewportEditorClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  widget_class->grab_focus = glade_viewport_editor_grab_focus;
+
+  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-viewport-editor.ui");
+  gtk_widget_class_bind_child (widget_class, GladeViewportEditorPrivate, embed);
+
+  g_type_class_add_private (object_class, sizeof (GladeViewportEditorPrivate));  
+}
+
+static void
+glade_viewport_editor_init (GladeViewportEditor * self)
+{
+  self->priv = 
+    G_TYPE_INSTANCE_GET_PRIVATE (self,
+                                GLADE_TYPE_VIEWPORT_EDITOR,
+                                GladeViewportEditorPrivate);
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+glade_viewport_editor_grab_focus (GtkWidget * widget)
+{
+  GladeViewportEditor        *viewport_editor = GLADE_VIEWPORT_EDITOR (widget);
+  GladeViewportEditorPrivate *priv = viewport_editor->priv;
+
+  gtk_widget_grab_focus (priv->embed);
+}
+
+GtkWidget *
+glade_viewport_editor_new (void)
+{
+  return g_object_new (GLADE_TYPE_VIEWPORT_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-viewport-editor.h b/plugins/gtk+/glade-viewport-editor.h
new file mode 100644
index 0000000..77ba590
--- /dev/null
+++ b/plugins/gtk+/glade-viewport-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_VIEWPORT_EDITOR_H_
+#define _GLADE_VIEWPORT_EDITOR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_VIEWPORT_EDITOR                 (glade_viewport_editor_get_type ())
+#define GLADE_VIEWPORT_EDITOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GLADE_TYPE_VIEWPORT_EDITOR, GladeViewportEditor))
+#define GLADE_VIEWPORT_EDITOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), 
GLADE_TYPE_VIEWPORT_EDITOR, GladeViewportEditorClass))
+#define GLADE_IS_VIEWPORT_EDITOR(obj)      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_VIEWPORT_EDITOR))
+#define GLADE_IS_VIEWPORT_EDITOR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GLADE_TYPE_VIEWPORT_EDITOR))
+#define GLADE_VIEWPORT_EDITOR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GLADE_TYPE_VIEWPORT_EDITOR, GladeViewportEditorClass))
+
+typedef struct _GladeViewportEditor        GladeViewportEditor;
+typedef struct _GladeViewportEditorClass   GladeViewportEditorClass;
+typedef struct _GladeViewportEditorPrivate GladeViewportEditorPrivate;
+
+typedef enum {
+  GLADE_VIEWPORT_MODE_ATTRIBUTES = 0, /* default */
+  GLADE_VIEWPORT_MODE_MARKUP,
+  GLADE_VIEWPORT_MODE_PATTERN
+} GladeViewportContentMode;
+
+typedef enum {
+  GLADE_VIEWPORT_WRAP_FREE = 0, /* default */
+  GLADE_VIEWPORT_SINGLE_LINE,
+  GLADE_VIEWPORT_WRAP_MODE
+} GladeViewportWrapMode;
+
+struct _GladeViewportEditor
+{
+  GladeEditorSkeleton parent;
+
+  GladeViewportEditorPrivate *priv;
+};
+
+struct _GladeViewportEditorClass
+{
+  GladeEditorSkeletonClass parent;
+};
+
+GType            glade_viewport_editor_get_type (void) G_GNUC_CONST;
+GtkWidget       *glade_viewport_editor_new      (void);
+
+G_END_DECLS
+
+#endif  /* _GLADE_VIEWPORT_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-viewport-editor.ui b/plugins/gtk+/glade-viewport-editor.ui
new file mode 100644
index 0000000..ea9f2b5
--- /dev/null
+++ b/plugins/gtk+/glade-viewport-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="GladeViewportEditor" 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 4b1a603..c21ee61 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2279,8 +2279,21 @@ range of values</_tooltip>
       </properties>
     </glade-widget-class>
     
-    <glade-widget-class name="GtkViewport" generic-name="viewport" _title="Viewport"/>
-    
+    <glade-widget-class name="GtkViewport" generic-name="viewport" _title="Viewport">
+      <create-editable-function>glade_gtk_viewport_create_editable</create-editable-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="GtkScrolledWindow" generic-name="scrolledwindow" _title="Scrolled Window">
       <create-editable-function>glade_gtk_scrolled_window_create_editable</create-editable-function>
       <set-property-function>glade_gtk_scrolled_window_set_property</set-property-function>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fd58324..a748f9e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -137,6 +137,7 @@ plugins/gtk+/glade-gtk-tool-item-group.c
 plugins/gtk+/glade-gtk-tool-palette.c
 plugins/gtk+/glade-gtk-toolbar.c
 plugins/gtk+/glade-gtk-tree-view.c
+plugins/gtk+/glade-gtk-viewport.c
 plugins/gtk+/glade-gtk-widget.c
 plugins/gtk+/glade-gtk-window.c
 plugins/gtk+/glade-icon-factory-editor.c
@@ -167,6 +168,7 @@ plugins/gtk+/glade-text-view-editor.c
 plugins/gtk+/glade-tool-button-editor.c
 plugins/gtk+/glade-tool-item-group-editor.c
 plugins/gtk+/glade-treeview-editor.c
+plugins/gtk+/glade-viewport-editor.c
 plugins/gtk+/glade-widget-editor.c
 plugins/gtk+/glade-window-editor.c
 plugins/gtk+/gtkunixprint.xml.in
@@ -210,5 +212,6 @@ plugins/gtk+/gtk+.xml.in
 [type: gettext/glade]plugins/gtk+/glade-text-view-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-tool-button-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-tool-palette-editor.ui
+[type: gettext/glade]plugins/gtk+/glade-viewport-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-widget-editor.ui
 [type: gettext/glade]plugins/gtk+/glade-window-editor.ui


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