[glade] Added GladeRecentActionEditor
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Added GladeRecentActionEditor
- Date: Sun, 5 May 2013 12:36:44 +0000 (UTC)
commit 4724aa138f1ad471e3756298c3393aa5ea7f9755
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sun May 5 21:28:51 2013 +0900
Added GladeRecentActionEditor
This derives the GladeActionEditor and embeds a GladeRecentChooserEditor.
GladeRecentChooserEditor now conditionally shows some properties
based on whether its a GtkRecentAction or not (i.e. "select-multiple"
and "show-numbers").
plugins/gtk+/Makefile.am | 3 +
plugins/gtk+/glade-gtk-action.c | 8 +++-
plugins/gtk+/glade-gtk-resources.gresource.xml | 1 +
plugins/gtk+/glade-recent-action-editor.c | 48 ++++++++++++++++++++
plugins/gtk+/glade-recent-action-editor.h | 57 ++++++++++++++++++++++++
plugins/gtk+/glade-recent-action-editor.ui | 32 +++++++++++++
plugins/gtk+/glade-recent-chooser-editor.c | 54 ++++++++++++++++++++++-
plugins/gtk+/glade-recent-chooser-editor.ui | 16 +++++++
plugins/gtk+/gtk+.xml.in | 13 +++++-
po/POTFILES.in | 2 +
10 files changed, 231 insertions(+), 3 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index ce9101e..fbdcab6 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -104,6 +104,7 @@ libgladegtk_la_SOURCES = \
glade-label-editor.c \
glade-message-dialog-editor.c \
glade-model-data.c \
+ glade-recent-action-editor.c \
glade-recent-chooser-dialog-editor.c \
glade-recent-chooser-editor.c \
glade-recent-chooser-widget-editor.c \
@@ -155,6 +156,7 @@ noinst_HEADERS = \
glade-label-editor.h \
glade-message-dialog-editor.h \
glade-model-data.h \
+ glade-recent-action-editor.h \
glade-recent-chooser-dialog-editor.h \
glade-recent-chooser-editor.h \
glade-recent-chooser-widget-editor.h \
@@ -204,6 +206,7 @@ UI_FILES = \
glade-image-editor.ui \
glade-label-editor.ui \
glade-message-dialog-editor.ui \
+ glade-recent-action-editor.ui \
glade-recent-chooser-dialog-editor.ui \
glade-recent-chooser-editor.ui \
glade-recent-chooser-widget-editor.ui \
diff --git a/plugins/gtk+/glade-gtk-action.c b/plugins/gtk+/glade-gtk-action.c
index 0da6e59..49c4f83 100644
--- a/plugins/gtk+/glade-gtk-action.c
+++ b/plugins/gtk+/glade-gtk-action.c
@@ -27,6 +27,7 @@
#include "glade-gtk.h"
#include "glade-action-editor.h"
+#include "glade-recent-action-editor.h"
void
glade_gtk_action_post_create (GladeWidgetAdaptor * adaptor,
@@ -53,7 +54,12 @@ glade_gtk_action_create_editable (GladeWidgetAdaptor * adaptor,
if (type == GLADE_PAGE_GENERAL)
{
- editable = (GladeEditable *) glade_action_editor_new ();
+ GType action_type = glade_widget_adaptor_get_object_type (adaptor);
+
+ if (g_type_is_a (action_type, GTK_TYPE_RECENT_ACTION))
+ editable = (GladeEditable *) glade_recent_action_editor_new ();
+ else
+ editable = (GladeEditable *) glade_action_editor_new ();
}
else
editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml
index d9b2869..3800cbe 100644
--- a/plugins/gtk+/glade-gtk-resources.gresource.xml
+++ b/plugins/gtk+/glade-gtk-resources.gresource.xml
@@ -17,6 +17,7 @@
<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-message-dialog-editor.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">glade-recent-action-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-recent-chooser-dialog-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-recent-chooser-editor.ui</file>
<file compressed="true" preprocess="xml-stripblanks">glade-recent-chooser-widget-editor.ui</file>
diff --git a/plugins/gtk+/glade-recent-action-editor.c b/plugins/gtk+/glade-recent-action-editor.c
new file mode 100644
index 0000000..06570c6
--- /dev/null
+++ b/plugins/gtk+/glade-recent-action-editor.c
@@ -0,0 +1,48 @@
+/*
+ * 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-recent-action-editor.h"
+
+G_DEFINE_TYPE (GladeRecentActionEditor, glade_recent_action_editor, GLADE_TYPE_ACTION_EDITOR)
+
+static void
+glade_recent_action_editor_class_init (GladeRecentActionEditorClass * klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gladegtk/glade-recent-action-editor.ui");
+}
+
+static void
+glade_recent_action_editor_init (GladeRecentActionEditor * self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+GtkWidget *
+glade_recent_action_editor_new (void)
+{
+ return g_object_new (GLADE_TYPE_RECENT_ACTION_EDITOR, NULL);
+}
diff --git a/plugins/gtk+/glade-recent-action-editor.h b/plugins/gtk+/glade-recent-action-editor.h
new file mode 100644
index 0000000..aaac115
--- /dev/null
+++ b/plugins/gtk+/glade-recent-action-editor.h
@@ -0,0 +1,57 @@
+/*
+ * 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_RECENT_ACTION_EDITOR_H_
+#define _GLADE_RECENT_ACTION_EDITOR_H_
+
+#include <gtk/gtk.h>
+#include "glade-action-editor.h"
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_RECENT_ACTION_EDITOR (glade_recent_action_editor_get_type ())
+#define GLADE_RECENT_ACTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GLADE_TYPE_RECENT_ACTION_EDITOR, GladeRecentActionEditor))
+#define GLADE_RECENT_ACTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GLADE_TYPE_RECENT_ACTION_EDITOR, GladeRecentActionEditorClass))
+#define GLADE_IS_RECENT_ACTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GLADE_TYPE_RECENT_ACTION_EDITOR))
+#define GLADE_IS_RECENT_ACTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GLADE_TYPE_RECENT_ACTION_EDITOR))
+#define GLADE_RECENT_ACTION_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GLADE_TYPE_RECENT_ACTION_EDITOR, GladeRecentActionEditorClass))
+
+typedef struct _GladeRecentActionEditor GladeRecentActionEditor;
+typedef struct _GladeRecentActionEditorClass GladeRecentActionEditorClass;
+typedef struct _GladeRecentActionEditorPrivate GladeRecentActionEditorPrivate;
+
+struct _GladeRecentActionEditor
+{
+ GladeActionEditor parent;
+
+ GladeRecentActionEditorPrivate *priv;
+};
+
+struct _GladeRecentActionEditorClass
+{
+ GladeActionEditorClass parent;
+};
+
+GType glade_recent_action_editor_get_type (void) G_GNUC_CONST;
+GtkWidget *glade_recent_action_editor_new (void);
+
+G_END_DECLS
+
+#endif /* _GLADE_RECENT_ACTION_EDITOR_H_ */
diff --git a/plugins/gtk+/glade-recent-action-editor.ui b/plugins/gtk+/glade-recent-action-editor.ui
new file mode 100644
index 0000000..e9366ba
--- /dev/null
+++ b/plugins/gtk+/glade-recent-action-editor.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="glade">
+ <!-- interface-requires glade-gtk-plugin 0.0 -->
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="GladeRecentActionEditor" parent="GladeActionEditor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child internal-child="extension_port">
+ <object class="GtkBox" id="extension_port">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GladeRecentChooserEditor" id="recentchoosereditor">
+ <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">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child-editors>
+ <editor id="recentchoosereditor"/>
+ </child-editors>
+ </template>
+</interface>
diff --git a/plugins/gtk+/glade-recent-chooser-editor.c b/plugins/gtk+/glade-recent-chooser-editor.c
index 009e59a..9ecf0ce 100644
--- a/plugins/gtk+/glade-recent-chooser-editor.c
+++ b/plugins/gtk+/glade-recent-chooser-editor.c
@@ -25,22 +25,74 @@
#include "glade-recent-chooser-editor.h"
-G_DEFINE_TYPE (GladeRecentChooserEditor, glade_recent_chooser_editor, GLADE_TYPE_EDITOR_SKELETON)
+static void glade_recent_chooser_editor_editable_init (GladeEditableIface * iface);
+
+struct _GladeRecentChooserEditorPrivate {
+ GtkWidget *select_multiple_editor;
+ GtkWidget *show_numbers_editor;
+};
+
+static GladeEditableIface *parent_editable_iface;
+
+G_DEFINE_TYPE_WITH_CODE (GladeRecentChooserEditor, glade_recent_chooser_editor, GLADE_TYPE_EDITOR_SKELETON,
+ G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
+ glade_recent_chooser_editor_editable_init));
static void
glade_recent_chooser_editor_class_init (GladeRecentChooserEditorClass * klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gladegtk/glade-recent-chooser-editor.ui");
+
+ gtk_widget_class_bind_child (widget_class, GladeRecentChooserEditorPrivate, select_multiple_editor);
+ gtk_widget_class_bind_child (widget_class, GladeRecentChooserEditorPrivate, show_numbers_editor);
+
+ g_type_class_add_private (object_class, sizeof (GladeRecentChooserEditorPrivate));
}
static void
glade_recent_chooser_editor_init (GladeRecentChooserEditor * self)
{
+ self->priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GLADE_TYPE_RECENT_CHOOSER_EDITOR,
+ GladeRecentChooserEditorPrivate);
+
gtk_widget_init_template (GTK_WIDGET (self));
}
+static void
+glade_recent_chooser_editor_load (GladeEditable *editable,
+ GladeWidget *gwidget)
+{
+ GladeRecentChooserEditor *recent_editor = GLADE_RECENT_CHOOSER_EDITOR (editable);
+ GladeRecentChooserEditorPrivate *priv = recent_editor->priv;
+
+ /* Chain up to default implementation */
+ parent_editable_iface->load (editable, gwidget);
+
+ if (gwidget)
+ {
+ GObject *object = glade_widget_get_object (gwidget);
+ gboolean is_recent_action = GTK_IS_RECENT_ACTION (object);
+
+ /* Update subclass specific editor visibility */
+ gtk_widget_set_visible (priv->select_multiple_editor, !is_recent_action);
+ gtk_widget_set_visible (priv->show_numbers_editor, is_recent_action);
+ }
+}
+
+static void
+glade_recent_chooser_editor_editable_init (GladeEditableIface * iface)
+{
+ parent_editable_iface = g_type_interface_peek_parent (iface);
+
+ iface->load = glade_recent_chooser_editor_load;
+}
+
+
GtkWidget *
glade_recent_chooser_editor_new (void)
{
diff --git a/plugins/gtk+/glade-recent-chooser-editor.ui b/plugins/gtk+/glade-recent-chooser-editor.ui
index da96656..b32dd44 100644
--- a/plugins/gtk+/glade-recent-chooser-editor.ui
+++ b/plugins/gtk+/glade-recent-chooser-editor.ui
@@ -237,6 +237,21 @@
</packing>
</child>
<child>
+ <object class="GladePropertyShell" id="show_numbers_editor">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="property_name">show-numbers</property>
+ <property name="editor_type">GladeEpropCheck</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">6</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
@@ -276,6 +291,7 @@
<editor id="show_not_found_editor"/>
<editor id="select_multiple_editor"/>
<editor id="local_only_editor"/>
+ <editor id="show_numbers_editor"/>
</child-editors>
</template>
</interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index a36cdad..e90592e 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2528,7 +2528,18 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkRecentAction" generic-name="recentaction" _title="Recent Action"
since="2.12">
<properties>
- <property id="select-multiple" disabled="True"/>
+ <!-- Claim the GladeRecentChooserEditor properties -->
+ <property id="recent-manager" custom-layout="True"/>
+ <property id="filter" custom-layout="True"/>
+ <property id="limit" custom-layout="True"/>
+ <property id="sort-type" custom-layout="True"/>
+ <property id="show-private" custom-layout="True"/>
+ <property id="show-tips" custom-layout="True"/>
+ <property id="show-icons" custom-layout="True"/>
+ <property id="show-not-found" custom-layout="True"/>
+ <property id="local-only" custom-layout="True"/>
+ <property id="select-multiple" custom-layout="True"/>
+ <property id="show-numbers" custom-layout="True"/>
</properties>
</glade-widget-class>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6e5f74a..70903e6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -133,6 +133,7 @@ plugins/gtk+/glade-image-item-editor.c
plugins/gtk+/glade-label-editor.c
plugins/gtk+/glade-message-dialog-editor.c
plugins/gtk+/glade-model-data.c
+plugins/gtk+/glade-recent-action-editor.c
plugins/gtk+/glade-recent-chooser-dialog-editor.c
plugins/gtk+/glade-recent-chooser-editor.c
plugins/gtk+/glade-recent-chooser-widget-editor.c
@@ -160,6 +161,7 @@ plugins/gtk+/gtk+.xml.in
[type: gettext/glade]plugins/gtk+/glade-image-editor.ui
[type: gettext/glade]plugins/gtk+/glade-label-editor.ui
[type: gettext/glade]plugins/gtk+/glade-message-dialog-editor.ui
+[type: gettext/glade]plugins/gtk+/glade-recent-action-editor.ui
[type: gettext/glade]plugins/gtk+/glade-recent-chooser-dialog-editor.ui
[type: gettext/glade]plugins/gtk+/glade-recent-chooser-editor.ui
[type: gettext/glade]plugins/gtk+/glade-recent-chooser-widget-editor.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]