Commit e13581f6 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Removed the new GladePropertyEditor iface

Now just use GladeEditable everywhere (for property labels, editors and shells).
parent 8748db65
......@@ -103,7 +103,6 @@ libgladeui_2_la_SOURCES = \
glade-project.c \
glade-property.c \
glade-property-class.c \
glade-property-editor.c \
glade-property-label.c \
glade-property-shell.c \
glade-signal.c \
......@@ -158,7 +157,6 @@ libgladeuiinclude_HEADERS = \
glade-project.h \
glade-property.h \
glade-property-class.h \
glade-property-editor.h \
glade-property-label.h \
glade-property-shell.h \
glade-signal.h \
......
......@@ -33,30 +33,8 @@
#include "glade-project.h"
#include "glade-widget.h"
#include "glade-editable.h"
#include "glade-property-editor.h"
static void glade_editable_property_editor_init (GladePropertyEditorInterface *iface);
G_DEFINE_INTERFACE_WITH_CODE (GladeEditable, glade_editable, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_PROPERTY_EDITOR,
glade_editable_property_editor_init));
/*******************************************************************************
* GladePropertyEditorInterface *
*******************************************************************************/
static void
glade_editable_property_editor_load (GladePropertyEditor *editor,
GladeWidget *widget)
{
glade_editable_load (GLADE_EDITABLE (editor), widget);
}
static void
glade_editable_property_editor_init (GladePropertyEditorInterface *iface)
{
iface->load = glade_editable_property_editor_load;
}
G_DEFINE_INTERFACE (GladeEditable, glade_editable, GTK_TYPE_WIDGET);
static GQuark glade_editable_project_quark = 0;
static GQuark glade_editable_widget_quark = 0;
......
......@@ -40,7 +40,7 @@
#include "glade.h"
#include "glade-widget.h"
#include "glade-property-editor.h"
#include "glade-editable.h"
#include "glade-editor-property.h"
#include "glade-property-label.h"
#include "glade-property.h"
......@@ -106,26 +106,40 @@ struct _GladeEditorPropertyPrivate
guint disable_check : 1; /* Whether to explicitly disable the optional check button */
};
static void glade_editor_property_property_editor_init (GladePropertyEditorInterface *iface);
static void glade_editor_property_editable_init (GladeEditableIface *iface);
static GladeEditableIface *parent_editable_iface;
G_DEFINE_TYPE_WITH_CODE (GladeEditorProperty, glade_editor_property, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_PROPERTY_EDITOR,
glade_editor_property_property_editor_init));
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_editor_property_editable_init));
/*******************************************************************************
* GladePropertyEditorInterface *
* GladeEditableIface *
*******************************************************************************/
static void
glade_editor_property_property_editor_load (GladePropertyEditor *editor,
glade_editor_property_editable_load (GladeEditable *editable,
GladeWidget *widget)
{
glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (editor), widget);
/* Chain up to default implementation */
parent_editable_iface->load (editable, widget);
glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (editable), widget);
}
static void
glade_editor_property_set_show_name (GladeEditable * editable, gboolean show_name)
{
}
static void
glade_editor_property_property_editor_init (GladePropertyEditorInterface *iface)
glade_editor_property_editable_init (GladeEditableIface * iface)
{
iface->load = glade_editor_property_property_editor_load;
parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE);
iface->load = glade_editor_property_editable_load;
iface->set_show_name = glade_editor_property_set_show_name;
}
/*******************************************************************************
......
......@@ -107,9 +107,9 @@ glade_editor_skeleton_load (GladeEditable *editable,
for (l = priv->editors; l; l = l->next)
{
GladePropertyEditor *editor = l->data;
GladeEditable *editor = l->data;
glade_property_editor_load (editor, widget);
glade_editable_load (editor, widget);
}
}
......@@ -122,10 +122,9 @@ glade_editor_skeleton_set_show_name (GladeEditable * editable, gboolean show_nam
for (l = priv->editors; l; l = l->next)
{
GladePropertyEditor *editor = l->data;
GladeEditable *editor = l->data;
if (GLADE_IS_EDITABLE (editor))
glade_editable_set_show_name (GLADE_EDITABLE (editor), show_name);
glade_editable_set_show_name (editor, show_name);
}
}
......@@ -229,12 +228,12 @@ glade_editor_skeleton_custom_finished (GtkBuildable *buildable,
object = gtk_builder_get_object (builder, id);
if (!GLADE_IS_PROPERTY_EDITOR (object))
g_warning ("Object '%s' is not a property editor\n",
if (!GLADE_EDITABLE (object))
g_warning ("Object '%s' is not a GladeEditable\n",
object ? G_OBJECT_TYPE_NAME (object) : "(null)");
else
glade_editor_skeleton_add_editor (GLADE_EDITOR_SKELETON (buildable),
GLADE_PROPERTY_EDITOR (object));
GLADE_EDITABLE (object));
}
g_slist_free_full (editor_data->editors, g_free);
......@@ -260,12 +259,12 @@ glade_editor_skeleton_new (void)
void
glade_editor_skeleton_add_editor (GladeEditorSkeleton *skeleton,
GladePropertyEditor *editor)
GladeEditable *editor)
{
GladeEditorSkeletonPrivate *priv;
g_return_if_fail (GLADE_IS_EDITOR_SKELETON (skeleton));
g_return_if_fail (GLADE_IS_PROPERTY_EDITOR (editor));
g_return_if_fail (GLADE_IS_EDITABLE (editor));
priv = skeleton->priv;
......
......@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
#include <gladeui/glade-xml-utils.h>
#include <gladeui/glade-property-editor.h>
#include <gladeui/glade-editable.h>
G_BEGIN_DECLS
......@@ -55,7 +55,7 @@ GType glade_editor_skeleton_get_type (void) G_GNUC_CONST;
GtkWidget *glade_editor_skeleton_new (void);
void glade_editor_skeleton_add_editor (GladeEditorSkeleton *skeleton,
GladePropertyEditor *editor);
GladeEditable *editor);
G_END_DECLS
......
/*
* glade-property-editor.c
*
* Copyright (C) 2013 Tristan Van Berkom.
*
* Authors:
* Tristan Van Berkom <tvb@gnome.org>
*
* 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.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n-lib.h>
#include <string.h>
#include <stdlib.h>
#include "glade-widget.h"
#include "glade-property-editor.h"
G_DEFINE_INTERFACE (GladePropertyEditor, glade_property_editor, GTK_TYPE_WIDGET);
static void
glade_property_editor_default_init (GladePropertyEditorInterface *iface)
{
}
/**
* glade_property_editor_load:
* @editor: A #GladePropertyEditor
* @widget: the #GladeWidget to load
*
* Loads @editor from @widget
*/
void
glade_property_editor_load (GladePropertyEditor *editor,
GladeWidget *widget)
{
GladePropertyEditorInterface *iface;
g_return_if_fail (GLADE_IS_PROPERTY_EDITOR (editor));
g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
iface = GLADE_PROPERTY_EDITOR_GET_IFACE (editor);
if (iface->load)
iface->load (editor, widget);
else
g_critical ("No GladePropertyEditor::load_by_widget() support on type %s",
G_OBJECT_TYPE_NAME (editor));
}
#ifndef __GLADE_PROPERTY_EDITOR_H__
#define __GLADE_PROPERTY_EDITOR_H__
#include <glib.h>
#include <glib-object.h>
#include <gladeui/glade-xml-utils.h>
G_BEGIN_DECLS
#define GLADE_TYPE_PROPERTY_EDITOR (glade_property_editor_get_type ())
#define GLADE_PROPERTY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PROPERTY_EDITOR, GladePropertyEditor))
#define GLADE_PROPERTY_EDITOR_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GLADE_TYPE_PROPERTY_EDITOR, GladePropertyEditorInterface))
#define GLADE_IS_PROPERTY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROPERTY_EDITOR))
#define GLADE_PROPERTY_EDITOR_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GLADE_TYPE_PROPERTY_EDITOR, GladePropertyEditorInterface))
typedef struct _GladePropertyEditor GladePropertyEditor;
typedef struct _GladePropertyEditorIface GladePropertyEditorInterface;
struct _GladePropertyEditorIface
{
GTypeInterface g_iface;
/* virtual table */
void (* load) (GladePropertyEditor *editor,
GladeWidget *widget);
};
GType glade_property_editor_get_type (void) G_GNUC_CONST;
void glade_property_editor_load (GladePropertyEditor *editor,
GladeWidget *widget);
G_END_DECLS
#endif /* __GLADE_PROPERTY_EDITOR_H__ */
......@@ -28,7 +28,7 @@
#include "glade.h"
#include "glade-widget.h"
#include "glade-popup.h"
#include "glade-property-editor.h"
#include "glade-editable.h"
#include "glade-property-label.h"
/* GObjectClass */
......@@ -47,8 +47,8 @@ static void glade_property_label_get_real_property (GObject *object
static gint glade_property_label_button_press (GtkWidget *widget,
GdkEventButton *event);
/* GladePropertyEditorInterface */
static void glade_property_label_property_editor_init (GladePropertyEditorInterface *iface);
/* GladeEditableIface */
static void glade_property_label_editable_init (GladeEditableIface *iface);
struct _GladePropertyLabelPrivate
{
......@@ -79,9 +79,11 @@ enum {
PROP_CUSTOM_TOOLTIP,
};
static GladeEditableIface *parent_editable_iface;
G_DEFINE_TYPE_WITH_CODE (GladePropertyLabel, glade_property_label, GTK_TYPE_EVENT_BOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_PROPERTY_EDITOR,
glade_property_label_property_editor_init));
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_property_label_editable_init));
static void
glade_property_label_init (GladePropertyLabel *label)
......@@ -236,16 +238,19 @@ glade_property_label_get_real_property (GObject *object,
}
/*******************************************************************************
* GladePropertyEditorInterface *
* GladeEditableIface *
*******************************************************************************/
static void
glade_property_label_property_editor_load (GladePropertyEditor *editor,
glade_property_label_load (GladeEditable *editable,
GladeWidget *widget)
{
GladePropertyLabel *label = GLADE_PROPERTY_LABEL (editor);
GladePropertyLabel *label = GLADE_PROPERTY_LABEL (editable);
GladePropertyLabelPrivate *priv;
GladeProperty *property;
/* Chain up to default implementation */
parent_editable_iface->load (editable, widget);
g_return_if_fail (label->priv->property_name != NULL);
priv = label->priv;
......@@ -264,9 +269,17 @@ glade_property_label_property_editor_load (GladePropertyEditor *editor,
}
static void
glade_property_label_property_editor_init (GladePropertyEditorInterface *iface)
glade_property_label_set_show_name (GladeEditable * editable, gboolean show_name)
{
iface->load = glade_property_label_property_editor_load;
}
static void
glade_property_label_editable_init (GladeEditableIface * iface)
{
parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE);
iface->load = glade_property_label_load;
iface->set_show_name = glade_property_label_set_show_name;
}
/***********************************************************
......
......@@ -28,7 +28,7 @@
#include "glade.h"
#include "glade-widget.h"
#include "glade-popup.h"
#include "glade-property-editor.h"
#include "glade-editable.h"
#include "glade-property-shell.h"
/* GObjectClass */
......@@ -42,8 +42,8 @@ static void glade_property_shell_get_real_property (GObject *object
GValue *value,
GParamSpec *pspec);
/* GladePropertyEditorInterface */
static void glade_property_shell_property_editor_init (GladePropertyEditorInterface *iface);
/* GladeEditableIface */
static void glade_property_shell_editable_init (GladeEditableIface *iface);
struct _GladePropertyShellPrivate
{
......@@ -64,9 +64,11 @@ enum {
PROP_USE_COMMAND,
};
static GladeEditableIface *parent_editable_iface;
G_DEFINE_TYPE_WITH_CODE (GladePropertyShell, glade_property_shell, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_PROPERTY_EDITOR,
glade_property_shell_property_editor_init));
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_property_shell_editable_init));
static void
glade_property_shell_init (GladePropertyShell *shell)
......@@ -175,15 +177,18 @@ glade_property_shell_get_real_property (GObject *object,
}
/*******************************************************************************
* GladePropertyEditorInterface *
* GladeEditableIface *
*******************************************************************************/
static void
glade_property_shell_property_editor_load (GladePropertyEditor *editor,
glade_property_shell_load (GladeEditable *editable,
GladeWidget *widget)
{
GladePropertyShell *shell = GLADE_PROPERTY_SHELL (editor);
GladePropertyShell *shell = GLADE_PROPERTY_SHELL (editable);
GladePropertyShellPrivate *priv;
/* Chain up to default implementation */
parent_editable_iface->load (editable, widget);
g_return_if_fail (shell->priv->property_name != NULL);
priv = shell->priv;
......@@ -212,16 +217,24 @@ glade_property_shell_property_editor_load (GladePropertyEditor *editor,
/* If we have an editor for the right adaptor, load it */
if (priv->property_editor)
glade_property_editor_load (GLADE_PROPERTY_EDITOR (priv->property_editor), widget);
glade_editable_load (GLADE_EDITABLE (priv->property_editor), widget);
}
else if (priv->property_editor)
glade_property_editor_load (GLADE_PROPERTY_EDITOR (priv->property_editor), NULL);
glade_editable_load (GLADE_EDITABLE (priv->property_editor), NULL);
}
static void
glade_property_shell_property_editor_init (GladePropertyEditorInterface *iface)
glade_property_shell_set_show_name (GladeEditable * editable, gboolean show_name)
{
iface->load = glade_property_shell_property_editor_load;
}
static void
glade_property_shell_editable_init (GladeEditableIface * iface)
{
parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE);
iface->load = glade_property_shell_load;
iface->set_show_name = glade_property_shell_set_show_name;
}
/***********************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment