Commit a41f5a12 authored by Paolo Borelli's avatar Paolo Borelli

Turn GladeProperty in a simple struct instead of being a GObject.

parent 51957117
2003-1109 Paolo Borelli <pborelli@katamail.com>
* src/glade-property.[ch]: turn GladeProperty into a simple struct
instead of a GObject.
* src/glade-editor.c: fixup for the above change.
2003-11-08 Joaquin Cuenca Abela <e98cuenc@yahoo.com>
* glade-placeholder.c: Unref the placeholder_pixmap in the finalize
......
......@@ -1372,7 +1372,8 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
/* Remove the old properties */
container = GTK_CONTAINER (editor->vbox_packing);
list = gtk_container_get_children (container);
for (; list; list = list->next) {
for (; list; list = list->next)
{
GtkWidget *widget = list->data;
g_return_if_fail (GTK_IS_WIDGET (widget));
gtk_container_remove (container, widget);
......@@ -1400,7 +1401,8 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
table->common = FALSE;
table->packing = TRUE;
for (list = parent->class->child_properties; list; list = list->next) {
for (list = parent->class->child_properties; list; list = list->next)
{
property_class = list->data;
g_assert (property_class->packing == TRUE);
editor_property = glade_editor_table_append_item (table, property_class);
......@@ -1415,26 +1417,6 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
old = table;
}
static void
glade_editor_property_changed_cb (GladeProperty *property,
GladeEditorProperty *editor_property)
{
g_return_if_fail (property == editor_property->property);
glade_editor_property_load (editor_property, property->widget);
}
static void
glade_editor_property_connect_signals (GladeEditorProperty *editor_property,
GladeWidget *widget)
{
GladeProperty *property = editor_property->property;
g_signal_connect (G_OBJECT (property), "changed",
G_CALLBACK (glade_editor_property_changed_cb),
editor_property);
}
/**
* glade_editor_load_widget:
* @editor:
......@@ -1465,7 +1447,8 @@ glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget)
glade_signal_editor_load_widget (editor->signal_editor, widget);
/* we are just clearing, we are done */
if (widget == NULL) {
if (widget == NULL)
{
editor->loaded_widget = NULL;
return;
}
......@@ -1476,19 +1459,16 @@ glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget)
table = glade_editor_get_table_from_class (editor, class, FALSE);
gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name);
for (list = table->properties; list; list = list->next) {
for (list = table->properties; list; list = list->next)
{
property = list->data;
glade_editor_property_load (property, widget);
if (property->class->type == GLADE_PROPERTY_TYPE_OBJECT)
continue;
glade_editor_property_connect_signals (property, widget);
}
/* Load each GladeEditorProperty for the common tab */
table = glade_editor_get_table_from_class (editor, class, TRUE);
for (list = table->properties; list; list = list->next) {
for (list = table->properties; list; list = list->next)
{
property = list->data;
glade_editor_property_load (property, widget);
}
......
......@@ -32,73 +32,6 @@
#include "glade-widget-class.h"
#include "glade-debug.h"
static void glade_property_object_class_init (GladePropertyObjectClass *class);
static void glade_property_init (GladeProperty *property);
enum
{
CHANGED,
LAST_SIGNAL
};
static guint glade_property_signals[LAST_SIGNAL] = {0};
static GtkObjectClass *parent_class = NULL;
GType
glade_property_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo info =
{
sizeof (GladePropertyObjectClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) glade_property_object_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (GladeProperty),
0,
(GInstanceInitFunc) glade_property_init
};
type = g_type_register_static (G_TYPE_OBJECT, "GladeProperty", &info, 0);
}
return type;
}
static void
glade_property_object_class_init (GladePropertyObjectClass *class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
glade_property_signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GladePropertyObjectClass, changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
class->changed = NULL;
}
static void
glade_property_init (GladeProperty *property)
{
property->class = NULL;
property->value = g_new0 (GValue, 1);
property->enabled = TRUE;
// property->child = NULL;
}
GladeProperty *
glade_property_new (GladePropertyClass *class, GladeWidget *widget)
......@@ -108,11 +41,14 @@ glade_property_new (GladePropertyClass *class, GladeWidget *widget)
g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (class), NULL);
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
property = g_object_new (GLADE_TYPE_PROPERTY, NULL);
property = g_new0 (GladeProperty, 1);
property->class = class;
property->widget = widget;
property->value = g_new0 (GValue, 1);
property->enabled = TRUE;
#if 0
property->child = NULL;
if (class->type == GLADE_PROPERTY_TYPE_OBJECT) {
property->child = glade_widget_new_from_class (class->child,
widget->project,
......@@ -156,11 +92,22 @@ glade_property_new (GladePropertyClass *class, GladeWidget *widget)
return property;
}
static void
glade_property_emit_changed (GladeProperty *property)
void
glade_property_free (GladeProperty *property)
{
g_signal_emit (G_OBJECT (property), glade_property_signals [CHANGED], 0);
property->class = NULL;
property->widget = NULL;
if (property->value)
g_free (property->value);
property->value = NULL;
#if 0
if (property->child)
g_warning ("Implmenet free property->child\n");
#endif
g_free (property);
}
/**
......@@ -220,8 +167,6 @@ glade_property_set (GladeProperty *property, const GValue *value)
g_value_copy (value, property->value);
property->loading = FALSE;
glade_property_emit_changed (property);
}
GladeXmlNode *
......@@ -233,7 +178,6 @@ glade_property_write (GladeXmlContext *context, GladeProperty *property)
if (!property->enabled)
return NULL;
/* create a new node <property ...> */
node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
if (!node)
return NULL;
......@@ -266,24 +210,6 @@ glade_property_write (GladeXmlContext *context, GladeProperty *property)
glade_xml_set_content (node, tmp);
g_free (tmp);
/* return the created node */
return node;
}
void
glade_property_free (GladeProperty *property)
{
property->class = NULL;
property->widget = NULL;
if (property->value)
g_free (property->value);
property->value = NULL;
#if 0
if (property->child)
g_warning ("Implmenet free property->child\n");
#endif
g_free (property);
}
......@@ -5,12 +5,9 @@
G_BEGIN_DECLS
#define GLADE_TYPE_PROPERTY (glade_property_get_type ())
#define GLADE_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PROPERTY, GladeProperty))
#define GLADE_PROPERTY_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PROPERTY, GladePropertyObjectClass))
#define GLADE_IS_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PROPERTY))
#define GLADE_PROPERTY(p) ((GladeProperty *)p)
#define GLADE_IS_PROPERTY(p) (p != NULL)
typedef struct _GladePropertyObjectClass GladePropertyObjectClass;
/* A GladeProperty is an instance of a GladePropertyClass.
* There will be one GladePropertyClass for "GtkLabel->label" but one
......@@ -18,8 +15,6 @@ typedef struct _GladePropertyObjectClass GladePropertyObjectClass;
*/
struct _GladeProperty
{
GObject object;
GladePropertyClass *class; /* A pointer to the GladeProperty that this
* setting specifies
*/
......@@ -44,14 +39,6 @@ struct _GladeProperty
gboolean loading;
};
struct _GladePropertyObjectClass
{
GtkObjectClass parent_class;
void (*changed) (GladeProperty *property, const gchar *value);
};
GType glade_property_get_type (void);
GladeProperty *glade_property_new (GladePropertyClass *class, GladeWidget *widget);
......@@ -59,7 +46,6 @@ void glade_property_free (GladeProperty *property);
void glade_property_set (GladeProperty *property, const GValue *value);
/* XML i/o */
GladeXmlNode *glade_property_write (GladeXmlContext *context, GladeProperty *property);
......
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