Commit 89f70a7e authored by Tristan Van Berkom's avatar Tristan Van Berkom

Revamping of the glade-editor, wrenched out the GladeEditorProperty code


	* src/glade-editor.[ch], src/glade-editor-property.[ch], src/Makefile.am:
	  Revamping of the glade-editor, wrenched out the GladeEditorProperty code
	  from glade-editor.[ch] and created glade-editor-property.[ch], lots of
	  code cleanup all around and now GladeEditorProperty is a GtkWidget with
	  a smooth encapsulation, transperent derivitives for different pspec types
	  and can now be used standalone inside custom editors.

	* src/glade-property.[ch]: clarified recursion protection with "syncing" var.

	* src/glade-property-class.c: Now consults glade_editor_property_supported instead
	  of the old glade_editor_editable_property.
parent ba2237e7
2005-10-08 Tristan Van Berkom <tvb@gnome.org>
* src/glade-editor.[ch], src/glade-editor-property.[ch], src/Makefile.am:
Revamping of the glade-editor, wrenched out the GladeEditorProperty code
from glade-editor.[ch] and created glade-editor-property.[ch], lots of
code cleanup all around and now GladeEditorProperty is a GtkWidget with
a smooth encapsulation, transperent derivitives for different pspec types
and can now be used standalone inside custom editors.
* src/glade-property.[ch]: clarified recursion protection with "syncing" var.
* src/glade-property-class.c: Now consults glade_editor_property_supported instead
of the old glade_editor_editable_property.
2005-10-06 Tristan Van Berkom <tvb@gnome.org>
* src/glade-app.c, src/glade-editor.c:
......
......@@ -46,6 +46,7 @@ libgladeui_1_la_SOURCES = \
glade-popup.c \
glade-widget.c \
glade-catalog.c \
glade-editor-property.c \
glade-editor.c \
glade-utils.c \
glade-signal.c \
......@@ -76,6 +77,7 @@ libgladeuiinclude_HEADERS = \
glade-parameter.h \
glade-placeholder.h \
glade-editor.h \
glade-editor-property.h \
glade-signal-editor.h \
glade-palette.h \
glade-cursor.h \
......
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_EDITOR_PROPERTY_H__
#define __GLADE_EDITOR_PROPERTY_H__
#define GLADE_TYPE_EDITOR_PROPERTY (glade_editor_property_get_type())
#define GLADE_EDITOR_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EDITOR_PROPERTY, GladeEditorProperty))
#define GLADE_EDITOR_PROPERTY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EDITOR_PROPERTY, GladeEditorPropertyClass))
#define GLADE_IS_EDITOR_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EDITOR_PROPERTY))
#define GLADE_IS_EDITOR_PROPERTY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EDITOR_PROPERTY))
#define GLADE_EDITOR_PROPERTY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EDITOR_PROPERTY, GladeEditorPropertyClass))
typedef struct _GladeEditorProperty GladeEditorProperty;
typedef struct _GladeEditorPropertyClass GladeEditorPropertyClass;
struct _GladeEditorProperty {
GtkHBox parent_instance;
GladePropertyClass *class; /* The property class this GladeEditorProperty was created for
*/
GladeProperty *property; /* The currently loaded property
*/
GtkWidget *item_label; /* Name of property (need a handle to set visual insensitive state)
*/
GtkWidget *eventbox; /* Eventbox on item_label.
*/
GtkWidget *input; /* Input part of property (need to set sensitivity seperately)
*/
GtkWidget *check; /* Check button for optional properties.
*/
gulong tooltip_id; /* signal connection id for tooltip changes */
gulong sensitive_id; /* signal connection id for sensitivity changes */
gulong changed_id; /* signal connection id for value changes */
gulong enabled_id; /* signal connection id for enable/disable changes */
gboolean loading; /* True during glade_editor_property_load calls, this
* is used to avoid feedback from input widgets.
*/
gboolean use_command; /* Whether we should use the glade command interface
* or skip directly to GladeProperty interface.
* (used for query dialogs).
*/
};
struct _GladeEditorPropertyClass {
GtkHBoxClass parent_class;
void (* load) (GladeEditorProperty *, GladeProperty *);
/* private */
GtkWidget *(* create_input) (GladeEditorProperty *);
};
LIBGLADEUI_API GType glade_editor_property_get_type (void);
LIBGLADEUI_API GladeEditorProperty *glade_editor_property_new (GladePropertyClass *class,
gboolean use_command);
LIBGLADEUI_API void glade_editor_property_load (GladeEditorProperty *eprop,
GladeProperty *property);
LIBGLADEUI_API void glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
GladeWidget *widget);
LIBGLADEUI_API gboolean glade_editor_property_supported (GParamSpec *pspec);
#endif // __GLADE_EDITOR_PROPERTY_H__
This diff is collapsed.
......@@ -16,13 +16,10 @@ G_BEGIN_DECLS
#define GLADE_EDITOR_TABLE(t) ((GladeEditorTable *)t)
#define GLADE_IS_EDITOR_TABLE(t) (t != NULL)
#define GLADE_EDITOR_PROPERTY(p) ((GladeEditorProperty *)p)
#define GLADE_IS_EDITOR_PROPERTY(p) (p != NULL)
typedef struct _GladeEditor GladeEditor;
typedef struct _GladeEditorClass GladeEditorClass;
typedef struct _GladeEditorTable GladeEditorTable;
typedef struct _GladeEditorProperty GladeEditorProperty;
typedef enum _GladeEditorTableType GladeEditorTableType;
enum _GladeEditorTableType
......@@ -43,10 +40,11 @@ struct _GladeEditor
GtkWidget *notebook; /* The notebook widget */
GladeWidget *loaded_widget; /* A handy pointer to the GladeWidget
* that is loaded in the editor. NULL
* if no widgets are selected
*/
GladeWidget *loaded_widget; /* A handy pointer to the GladeWidget
* that is loaded in the editor. NULL
* if no widgets are selected
*/
GladeWidgetClass *loaded_class; /* A pointer to the loaded
* GladeWidgetClass. Note that we can
* have a class loaded without a
......@@ -61,32 +59,38 @@ struct _GladeEditor
* when we switch from widgets of the
* same class
*/
GtkWidget *vbox_widget; /* The editor has (at this moment) four tabs
* this are pointers to the vboxes inside
* each tab. The vboxes are wrapped into a
* scrolled window.
* The vbox_widget is deparented and parented
* with GladeWidgetClass->table_widget
* when a widget is selecteed.
*/
GtkWidget *vbox_packing; /* We might not need this pointer. Not yet
* implemeted
*/
GtkWidget *vbox_common; /* We might not need this pointer. Not yet
* implemented
*/
GtkWidget *vbox_signals; /* Widget from the GladeSignalEditor is placed
* here
*/
GladeSignalEditor *signal_editor;
GList * widget_tables; /* A list of GladeEditorTable. We have a table
/* The editor has (at this moment) four tabs; these are pointers to the
* vboxes inside each tab. The vboxes are wrapped into a scrolled window.
* The vbox_* widgets are deparented and parented with
* ((GladeEditorTable *)etable)->table_widget when a widget is selected and
* the correct editor table is found. The exception is `vbox_signals' which
* always contains the same signal editor widget which simply reloads when
* loading a widget.
*/
GtkWidget *vbox_widget;
GtkWidget *vbox_packing;
GtkWidget *vbox_common;
GtkWidget *vbox_signals;
GladeSignalEditor *signal_editor; /* The signal editor packed into vbox_signals
*/
GList *widget_tables; /* A list of GladeEditorTable. We have a table
* (gtktable) for each GladeWidgetClass, if
* we don't have one yet, we create it when
* we are asked to load a widget of a particular
* GladeWidgetClass
*/
GladeEditorTable *packing_etable; /* The currently loaded editor table in
* the packing page.
*/
GList *packing_eprops; /* Current list of packing GladeEditorProperties
*/
gboolean loading; /* Use when loading a GladeWidget into the editor
* we set this flag so that we can ignore the
* "changed" signal of the name entry text since
......@@ -97,6 +101,8 @@ struct _GladeEditor
GtkWidget *launch_button; /* Button used to launch custom editors implemented
* through the plugin backend.
*/
};
struct _GladeEditorClass
......@@ -150,71 +156,18 @@ struct _GladeEditorTable
GladeEditorTableType type; /* Is this table to be used in the common tab, ?
* the general tab, a packing tab or the query popup ?
*/
gint rows;
};
/* For every GladePropertyClass we have a GladeEditorProperty that is
* basically an input (GtkWidget) for that GladePropertyClass.
*/
struct _GladeEditorProperty
{
GladePropertyClass *class; /* The class this property
* corresponds to.
*/
GladeProperty *property; /* The loaded GladeProperty
*/
GtkWidget *input; /* The widget that modifies this property, the widget
* can be a GtkSpinButton, a GtkEntry, GtkMenu, etc.
* depending on the property type.
* [see glade-property.h and glade-property-class.h]
*/
#if 0
/* Hmmm, should this be removed from GladeProperty and used here ? */
gboolean loading; /* We set this flag when we are loading a new GladeProperty
* into this GladeEditorProperty. This flag is used so that
* when we receive a "changed" signal we know that nothing has
* really changed, we just loaded a new glade widget
*/
#endif
GList *children; /* Used for class->type = OBJECT. Where a sigle entry corresponds
* to a number of inputs
*/
gboolean from_query_dialog; /* If this input is part of a query dialog
* this is TRUE.
*/
gulong tooltip_id; /* signal connection id for tooltip changes */
GladeProperty *tooltip_prop; /* the last object this was connected to */
GladeProperty *signal_prop; /* the last object these signals were connected to */
gulong sensitive_id; /* signal connection id for sensitivity changes */
gulong changed_id; /* signal connection id for value changes */
gulong enabled_id; /* signal connection id for enable/disable changes */
GtkWidget *eventbox; /* Keep a hold of this for tooltips */
GtkWidget *item_label; /* control visual label state manually */
GtkWidget *text_entry; /* Keep a hold of either the entry or textview. */
gint rows;
};
LIBGLADEUI_API GType glade_editor_get_type (void);
LIBGLADEUI_API GladeEditor *glade_editor_new (void);
LIBGLADEUI_API GType glade_editor_get_type (void);
LIBGLADEUI_API GladeEditor *glade_editor_new (void);
LIBGLADEUI_API void glade_editor_load_widget (GladeEditor *editor,
GladeWidget *widget);
LIBGLADEUI_API void glade_editor_refresh (GladeEditor *editor);
LIBGLADEUI_API void glade_editor_update_widget_name (GladeEditor *editor);
LIBGLADEUI_API gboolean glade_editor_query_dialog (GladeEditor *editor,
GladeWidget *widget);
LIBGLADEUI_API gboolean glade_editor_editable_property (GParamSpec *pspec);
G_END_DECLS
......
......@@ -35,7 +35,7 @@
#include "glade-parameter.h"
#include "glade-property.h"
#include "glade-property-class.h"
#include "glade-editor.h"
#include "glade-editor-property.h"
#include "glade-debug.h"
/**
......@@ -588,7 +588,7 @@ glade_property_class_new_from_spec (GParamSpec *spec)
/* Register only editable properties.
*/
if (!glade_editor_editable_property (property_class->pspec))
if (!glade_editor_property_supported (property_class->pspec))
goto lblError;
property_class->id = g_strdup (spec->name);
......@@ -647,15 +647,15 @@ gchar *
glade_property_class_get_displayable_value(GladePropertyClass *class, gint value)
{
gint i, len;
GArray *disp_val=class->displayable_values;
GArray *disp_val = class->displayable_values;
if (disp_val == NULL) return NULL;
len=disp_val->len;
len = disp_val->len;
for (i = 0; i < len; i++)
if (g_array_index(disp_val, GEnumValue, i).value == value)
return g_array_index(disp_val, GEnumValue, i).value_name;
if (g_array_index (disp_val, GEnumValue, i).value == value)
return g_array_index (disp_val, GEnumValue, i).value_name;
return NULL;
}
......@@ -674,8 +674,8 @@ gpc_get_displayable_values_from_node (GladeXmlNode *node, GEnumValue *values, gi
GArray *array;
GladeXmlNode *child;
child = glade_xml_search_child (node, GLADE_TAG_VALUE);
if (child == NULL) return NULL;
if ((child = glade_xml_search_child (node, GLADE_TAG_VALUE)) == NULL)
return NULL;
array = g_array_new (FALSE, TRUE, sizeof(GEnumValue));
......
......@@ -195,10 +195,10 @@ glade_property_sync_impl (GladeProperty *property)
{
if (property->enabled == FALSE ||
property->class->ignore ||
property->loading)
property->syncing)
return;
property->loading = TRUE;
property->syncing = TRUE;
if (property->class->set_function)
/* if there is a custom set_property, use it */
......@@ -251,7 +251,7 @@ glade_property_sync_impl (GladeProperty *property)
else
glade_property_set_property (property, property->value);
property->loading = FALSE;
property->syncing = FALSE;
}
static gboolean
......@@ -472,7 +472,7 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
g_param_spec_boolean
("sensitive", _("Sensitive"),
_("This gives backends control to set property sensitivity"),
TRUE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
TRUE, G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_I18N_COMMENT,
......
......@@ -56,7 +56,9 @@ struct _GladeProperty
/* A GladeProperty of type object has a child */
GladeWidget *child;
#endif
gboolean loading;
gboolean syncing; /* Avoid recursion while synchronizing object with value.
*/
};
......
......@@ -335,9 +335,9 @@ glade_widget_class_create_icon (GladeWidgetClass *class)
}
static void
glade_widget_class_update_properties_from_node (GladeXmlNode *node,
GladeWidgetClass *widget_class,
GList **properties)
glade_widget_class_update_properties_from_node (GladeXmlNode *node,
GladeWidgetClass *widget_class,
GList **properties)
{
GladeXmlNode *child;
......@@ -977,15 +977,6 @@ glade_widget_class_load_library (const gchar *library_name)
return module;
}
static gboolean
glade_widget_class_direct_children (GtkWidget *ancestor, GtkWidget *widget, const char *property_id)
{
if (ancestor != NULL && widget->parent == ancestor)
return TRUE;
return FALSE;
}
GladeWidgetClass *
glade_widget_class_new (GladeXmlNode *class_node, const gchar *library)
{
......@@ -1119,7 +1110,8 @@ glade_widget_class_get_type (GladeWidgetClass *widget)
* class.
*/
GladePropertyClass *
glade_widget_class_get_property_class (GladeWidgetClass *class, const gchar *name)
glade_widget_class_get_property_class (GladeWidgetClass *class,
const gchar *name)
{
GList *list, *l;
GladePropertyClass *pclass;
......
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