[glade] Added GladeBoxEditor
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Added GladeBoxEditor
- Date: Thu, 9 May 2013 12:53:23 +0000 (UTC)
commit 76f5cbc0504c787eca2434345395531cadcfec7a
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu May 9 21:16:27 2013 +0900
Added GladeBoxEditor
gladeui/glade-editor-table.c | 10 +-
plugins/gtk+/Makefile.am | 3 +
plugins/gtk+/glade-box-editor.c | 75 +++++++++
plugins/gtk+/glade-box-editor.h | 56 +++++++
plugins/gtk+/glade-box-editor.ui | 211 ++++++++++++++++++++++++
plugins/gtk+/glade-gtk-box.c | 10 +
plugins/gtk+/glade-gtk-resources.gresource.xml | 1 +
plugins/gtk+/gtk+.xml.in | 9 +-
po/POTFILES.in | 2 +
9 files changed, 370 insertions(+), 7 deletions(-)
---
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index 021c5bd..a5af49b 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -481,11 +481,13 @@ get_sorted_properties (GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
GladePropertyClass *klass = l->data;
/* Collect properties in our domain, query dialogs are allowed editor
- * invisible properties, allow adaptors to filter out properties from
- * the GladeEditorTable using the "custom-layout" attribute.
+ * invisible (or custom-layout) properties, allow adaptors to filter
+ * out properties from the GladeEditorTable using the "custom-layout" attribute.
*/
- if (!glade_property_class_custom_layout (klass) && GLADE_PROPERTY_CLASS_IS_TYPE (klass, type)
- && (glade_property_class_is_visible (klass) || type == GLADE_PAGE_QUERY))
+ if (GLADE_PROPERTY_CLASS_IS_TYPE (klass, type) &&
+ (type == GLADE_PAGE_QUERY ||
+ (!glade_property_class_custom_layout (klass) &&
+ glade_property_class_is_visible (klass))))
{
list = g_list_prepend (list, klass);
}
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 534fce9..4280e8a 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -28,6 +28,7 @@ libgladegtk_la_SOURCES = \
glade-action-editor.c \
glade-activatable-editor.c \
glade-attributes.c \
+ glade-box-editor.c \
glade-button-editor.c \
glade-cell-renderer-editor.c \
glade-column-types.c \
@@ -126,6 +127,7 @@ noinst_HEADERS = \
glade-action-editor.h \
glade-activatable-editor.h \
glade-attributes.h \
+ glade-box-editor.h \
glade-button-editor.h \
glade-cell-renderer-editor.h \
glade-column-types.h \
@@ -195,6 +197,7 @@ UI_FILES = \
glade-about-dialog-editor.ui \
glade-action-editor.ui \
glade-activatable-editor.ui \
+ glade-box-editor.ui \
glade-button-editor.ui \
glade-entry-editor.ui \
glade-file-chooser-button-editor.ui \
diff --git a/plugins/gtk+/glade-box-editor.c b/plugins/gtk+/glade-box-editor.c
new file mode 100644
index 0000000..9d1a832
--- /dev/null
+++ b/plugins/gtk+/glade-box-editor.c
@@ -0,0 +1,75 @@
+/*
+ * 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 <gdk/gdkkeysyms.h>
+
+#include "glade-box-editor.h"
+
+static void glade_box_editor_grab_focus (GtkWidget * widget);
+
+struct _GladeBoxEditorPrivate
+{
+ GtkWidget *embed;
+};
+
+G_DEFINE_TYPE (GladeBoxEditor, glade_box_editor, GLADE_TYPE_EDITOR_SKELETON)
+
+static void
+glade_box_editor_class_init (GladeBoxEditorClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->grab_focus = glade_box_editor_grab_focus;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-box-editor.ui");
+ gtk_widget_class_bind_child (widget_class, GladeBoxEditorPrivate, embed);
+
+ g_type_class_add_private (object_class, sizeof (GladeBoxEditorPrivate));
+}
+
+static void
+glade_box_editor_init (GladeBoxEditor * self)
+{
+ self->priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GLADE_TYPE_BOX_EDITOR,
+ GladeBoxEditorPrivate);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+static void
+glade_box_editor_grab_focus (GtkWidget * widget)
+{
+ GladeBoxEditor *box_editor = GLADE_BOX_EDITOR (widget);
+
+ gtk_widget_grab_focus (box_editor->priv->embed);
+}
+
+GtkWidget *
+glade_box_editor_new (void)
+{
+ return g_object_new (GLADE_TYPE_BOX_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-box-editor.h b/plugins/gtk+/glade-box-editor.h
new file mode 100644
index 0000000..69549e5
--- /dev/null
+++ b/plugins/gtk+/glade-box-editor.h
@@ -0,0 +1,56 @@
+/*
+ * 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_BOX_EDITOR_H_
+#define _GLADE_BOX_EDITOR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_BOX_EDITOR (glade_box_editor_get_type ())
+#define GLADE_BOX_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_BOX_EDITOR,
GladeBoxEditor))
+#define GLADE_BOX_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_BOX_EDITOR,
GladeBoxEditorClass))
+#define GLADE_IS_BOX_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_BOX_EDITOR))
+#define GLADE_IS_BOX_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_BOX_EDITOR))
+#define GLADE_BOX_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_BOX_EDITOR,
GladeBoxEditorClass))
+
+typedef struct _GladeBoxEditor GladeBoxEditor;
+typedef struct _GladeBoxEditorClass GladeBoxEditorClass;
+typedef struct _GladeBoxEditorPrivate GladeBoxEditorPrivate;
+
+struct _GladeBoxEditor
+{
+ GladeEditorSkeleton parent;
+
+ GladeBoxEditorPrivate *priv;
+};
+
+struct _GladeBoxEditorClass
+{
+ GladeEditorSkeletonClass parent;
+};
+
+GType glade_box_editor_get_type (void) G_GNUC_CONST;
+GtkWidget *glade_box_editor_new (void);
+
+G_END_DECLS
+
+#endif /* _GLADE_BOX_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-box-editor.ui b/plugins/gtk+/glade-box-editor.ui
new file mode 100644
index 0000000..7d2dbdd
--- /dev/null
+++ b/plugins/gtk+/glade-box-editor.ui
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="glade">
+ <!-- interface-requires gladeui 0.0 -->
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GladeBoxEditor" parent="GladeEditorSkeleton">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GladeEditorTable" id="embed">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">6</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">Box Attributes</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">6</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyLabel" id="orientation_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">orientation</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyShell" id="orientation_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">orientation</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyLabel" id="baseline_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">baseline-position</property>
+ <property name="custom_text" translatable="yes">Baseline:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyShell" id="baseline_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">baseline-position</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyLabel" id="spacing_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">spacing</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyShell" id="spacing_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">spacing</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyLabel" id="size_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">size</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyShell" id="size_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">size</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GladePropertyShell" id="homogeneous_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">homogeneous</property>
+ <property name="editor_type">GladeEpropCheck</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child-editors>
+ <editor id="embed"/>
+ <editor id="orientation_label"/>
+ <editor id="orientation_editor"/>
+ <editor id="baseline_label"/>
+ <editor id="baseline_editor"/>
+ <editor id="spacing_label"/>
+ <editor id="spacing_editor"/>
+ <editor id="size_label"/>
+ <editor id="size_editor"/>
+ <editor id="homogeneous_editor"/>
+ </child-editors>
+ </template>
+</interface>
diff --git a/plugins/gtk+/glade-gtk-box.c b/plugins/gtk+/glade-gtk-box.c
index 1f13282..36d67e1 100644
--- a/plugins/gtk+/glade-gtk-box.c
+++ b/plugins/gtk+/glade-gtk-box.c
@@ -28,6 +28,7 @@
#include "glade-fixed.h"
#include "glade-gtk-notebook.h"
+#include "glade-box-editor.h"
#include "glade-gtk.h"
static gboolean glade_gtk_box_configure_child (GladeFixed * fixed,
@@ -45,6 +46,15 @@ static gboolean glade_gtk_box_configure_end (GladeFixed * fixed,
GtkWidget * box);
+GladeEditable *
+glade_gtk_box_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
+{
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_box_editor_new ();
+
+ return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+}
void
glade_gtk_box_post_create (GladeWidgetAdaptor * adaptor,
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index fff48bd..ad11fb7 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -4,6 +4,7 @@
<file compressed="true" preprocess="xml-stripblanks">glade-about-dialog-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-action-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-activatable-editor.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">glade-box-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-button-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-entry-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-file-chooser-button-editor.ui</file>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 61e4f9a..67c8c50 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -340,6 +340,7 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkBox" generic-name="box" _title="Box">
<create-widget-function>glade_gtk_create_fixed_widget</create-widget-function>
+ <create-editable-function>glade_gtk_box_create_editable</create-editable-function>
<post-create-function>glade_gtk_box_post_create</post-create-function>
<get-children-function>glade_gtk_box_get_children</get-children-function>
<set-property-function>glade_gtk_box_set_property</set-property-function>
@@ -358,15 +359,17 @@ embedded in another object</_tooltip>
</packing-actions>
<properties>
- <property id="orientation" default="GTK_ORIENTATION_VERTICAL"/>
- <property id="size" _name="Number of items" query="True" default="3" save="False">
+ <property id="orientation" default="GTK_ORIENTATION_VERTICAL" custom-layout="True"/>
+ <property id="homogeneous" custom-layout="True"/>
+ <property id="spacing" custom-layout="True"/>
+ <property id="size" _name="Number of items" query="True" default="3" save="False"
custom-layout="True">
<parameter-spec>
<type>GParamInt</type>
<min>1</min>
</parameter-spec>
<_tooltip>The number of items in the box</_tooltip>
</property>
- <property id="baseline-position" since="3.10">
+ <property id="baseline-position" since="3.10" custom-layout="True">
<displayable-values>
<value id="GTK_BASELINE_POSITION_TOP" _name="Top"/>
<value id="GTK_BASELINE_POSITION_CENTER" _name="Center"/>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7269873..f1e9bbc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,6 +57,7 @@ plugins/gtk+/glade-accels.c
plugins/gtk+/glade-action-editor.c
plugins/gtk+/glade-activatable-editor.c
plugins/gtk+/glade-attributes.c
+plugins/gtk+/glade-box-editor.c
plugins/gtk+/glade-button-editor.c
plugins/gtk+/glade-cell-renderer-editor.c
plugins/gtk+/glade-column-types.c
@@ -150,6 +151,7 @@ plugins/gtk+/gtk+.xml.in
[type: gettext/glade]plugins/gtk+/glade-about-dialog-editor.ui
[type: gettext/glade]plugins/gtk+/glade-action-editor.ui
[type: gettext/glade]plugins/gtk+/glade-activatable-editor.ui
+[type: gettext/glade]plugins/gtk+/glade-box-editor.ui
[type: gettext/glade]plugins/gtk+/glade-button-editor.ui
[type: gettext/glade]plugins/gtk+/glade-entry-editor.ui
[type: gettext/glade]plugins/gtk+/glade-file-chooser-button-editor.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]