[cairo-commit] goocanvas/src Makefile.am, 1.11, 1.12 goocanvas.h,
1.3, 1.4 goocanvasgroup.c, 1.14, 1.15 goocanvasitem.c, 1.11,
1.12 goocanvasitemmodel.c, 1.1, 1.2 goocanvasitemmodel.h, 1.1,
1.2 goocanvastable.c, NONE, 1.1 goocanvastable.h, NONE,
1.1 goocanvasutils.c, 1.7, 1.8
Damon Chaplin
commit at pdx.freedesktop.org
Sat Dec 9 04:03:10 PST 2006
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv11699
Modified Files:
Makefile.am goocanvas.h goocanvasgroup.c goocanvasitem.c
goocanvasitemmodel.c goocanvasitemmodel.h goocanvasutils.c
Added Files:
goocanvastable.c goocanvastable.h
Log Message:
2006-12-09 Damon Chaplin <damon at gnome.org>
* docs/Makefile.am (SCANGOBJ_OPTIONS): added --query-child-properties
argument to document child properties (needs cvs gtk-doc).
* src/goocanvasutils.c (goo_canvas_query_child_properties): new
function to allow documentation of child properties with gtk-doc.
* src/goocanvasitemmodel.c:
* src/goocanvasitem.c: added support for child properties of item
models.
* src/goocanvastable.c: beginnings of a new table item to layout child
items. Doesn't do much yet.
* src/goocanvasitem.c (goo_canvas_item_animate): clarified docs.
* src/goocanvasgroup.c: use goo_canvas_item_add/move/remove_child()
rather than goo_canvas_group_add/move_remove_child() so subclasses can
reuse group's code. Also fix some docs & variable names.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/src/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am 29 Nov 2006 18:40:53 -0000 1.11
+++ Makefile.am 9 Dec 2006 12:03:05 -0000 1.12
@@ -26,6 +26,7 @@
goocanvaspath.h \
goocanvasrect.h \
goocanvasstyle.h \
+ goocanvastable.h \
goocanvastext.h \
goocanvasutils.h \
goocanvaswidget.h \
@@ -47,6 +48,7 @@
goocanvasprivate.h \
goocanvasrect.c \
goocanvasstyle.c \
+ goocanvastable.c \
goocanvastext.c \
goocanvasutils.c \
goocanvaswidget.c \
Index: goocanvas.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvas.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goocanvas.h 29 Nov 2006 18:40:53 -0000 1.3
+++ goocanvas.h 9 Dec 2006 12:03:05 -0000 1.4
@@ -15,6 +15,7 @@
#include <goocanvaspath.h>
#include <goocanvaspolyline.h>
#include <goocanvasrect.h>
+#include <goocanvastable.h>
#include <goocanvastext.h>
#include <goocanvaswidget.h>
Index: goocanvasgroup.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroup.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- goocanvasgroup.c 29 Nov 2006 18:40:53 -0000 1.14
+++ goocanvasgroup.c 9 Dec 2006 12:03:05 -0000 1.15
@@ -260,7 +260,7 @@
child_model = goo_canvas_item_model_get_child ((GooCanvasItemModel*) model,
position);
child = goo_canvas_create_item (simple->canvas, child_model);
- goo_canvas_group_add_child (item, child, position);
+ goo_canvas_item_add_child (item, child, position);
g_object_unref (child);
}
@@ -271,7 +271,7 @@
gint new_position,
GooCanvasGroup *group)
{
- goo_canvas_group_move_child ((GooCanvasItem*) group, old_position,
+ goo_canvas_item_move_child ((GooCanvasItem*) group, old_position,
new_position);
}
@@ -281,7 +281,7 @@
gint child_num,
GooCanvasGroup *group)
{
- goo_canvas_group_remove_child ((GooCanvasItem*) group, child_num);
+ goo_canvas_item_remove_child ((GooCanvasItem*) group, child_num);
}
@@ -507,7 +507,7 @@
/**
* SECTION:goocanvasgroupmodel
- * @Title: GooCanvasGroupModelModel
+ * @Title: GooCanvasGroupModel
* @Short_Description: model for a group of items.
*
* #GooCanvasGroupModel represents a group of items. Groups can be nested to any
@@ -568,27 +568,27 @@
goo_canvas_group_model_new (GooCanvasItemModel *parent,
...)
{
- GooCanvasItemModel *item;
+ GooCanvasItemModel *model;
GooCanvasGroupModel *gmodel;
va_list var_args;
const char *first_property;
- item = g_object_new (GOO_TYPE_CANVAS_GROUP_MODEL, NULL);
- gmodel = (GooCanvasGroupModel*) item;
+ model = g_object_new (GOO_TYPE_CANVAS_GROUP_MODEL, NULL);
+ gmodel = (GooCanvasGroupModel*) model;
va_start (var_args, parent);
first_property = va_arg (var_args, char*);
if (first_property)
- g_object_set_valist (G_OBJECT (item), first_property, var_args);
+ g_object_set_valist (G_OBJECT (model), first_property, var_args);
va_end (var_args);
if (parent)
{
- goo_canvas_item_model_add_child (parent, item, -1);
- g_object_unref (item);
+ goo_canvas_item_model_add_child (parent, model, -1);
+ g_object_unref (model);
}
- return item;
+ return model;
}
Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- goocanvasitem.c 29 Nov 2006 18:40:53 -0000 1.11
+++ goocanvasitem.c 9 Dec 2006 12:03:05 -0000 1.12
@@ -1327,21 +1327,22 @@
-
+/*
+ * Child Properties.
+ */
void
-goo_canvas_item_get_child_properties_valist (GooCanvasItem *item,
- GooCanvasItem *child,
- va_list var_args)
+_goo_canvas_item_get_child_properties_internal (GObject *object,
+ GObject *child,
+ va_list var_args,
+ GParamSpecPool *property_pool,
+ GObjectNotifyContext *notify_context,
+ gboolean is_model)
{
- g_return_if_fail (GOO_IS_CANVAS_ITEM (item));
- g_return_if_fail (GOO_IS_CANVAS_ITEM (child));
-
- g_object_ref (item);
+ g_object_ref (object);
g_object_ref (child);
for (;;)
{
- GooCanvasItemIface *iface;
GObjectClass *class;
GValue value = { 0, };
GParamSpec *pspec;
@@ -1351,24 +1352,43 @@
if (!name)
break;
- pspec = g_param_spec_pool_lookup (_goo_canvas_item_child_property_pool,
- name, G_OBJECT_TYPE (item), TRUE);
+ pspec = g_param_spec_pool_lookup (property_pool, name,
+ G_OBJECT_TYPE (object), TRUE);
if (!pspec)
{
- g_warning ("%s: canvas item class `%s' has no child property named `%s'",
- G_STRLOC, G_OBJECT_TYPE_NAME (item), name);
+ g_warning ("%s: class `%s' has no child property named `%s'",
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
break;
}
if (!(pspec->flags & G_PARAM_READABLE))
{
- g_warning ("%s: child property `%s' of canvas item class `%s' is not readable",
- G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (item));
+ g_warning ("%s: child property `%s' of class `%s' is not readable",
+ G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
break;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
class = g_type_class_peek (pspec->owner_type);
- iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM);
- iface->get_child_property (item, child, pspec->param_id, &value, pspec);
+
+ if (is_model)
+ {
+ GooCanvasItemModelIface *iface;
+
+ iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM_MODEL);
+ iface->get_child_property ((GooCanvasItemModel*) object,
+ (GooCanvasItemModel*) child,
+ pspec->param_id, &value, pspec);
+ }
+ else
+ {
+ GooCanvasItemIface *iface;
+
+ iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM);
+ iface->get_child_property ((GooCanvasItem*) object,
+ (GooCanvasItem*) child,
+ pspec->param_id, &value, pspec);
+ }
+
G_VALUE_LCOPY (&value, var_args, 0, &error);
if (error)
{
@@ -1381,19 +1401,18 @@
}
g_object_unref (child);
- g_object_unref (item);
+ g_object_unref (object);
}
static inline void
-canvas_item_set_child_property (GooCanvasItem *item,
- GooCanvasItem *child,
+canvas_item_set_child_property (GObject *object,
+ GObject *child,
GParamSpec *pspec,
const GValue *value,
- GObjectNotifyQueue *nqueue)
+ GObjectNotifyQueue *nqueue,
+ gboolean is_model)
{
- GooCanvasItemIface *iface;
- GObjectClass *class;
GValue tmp_value = { 0, };
/* provide a copy to work from, convert (if necessary) and validate */
@@ -1416,10 +1435,27 @@
}
else
{
- class = g_type_class_peek (pspec->owner_type);
- iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM);
- iface->set_child_property (item, child, pspec->param_id, &tmp_value,
- pspec);
+ GObjectClass *class = g_type_class_peek (pspec->owner_type);
+
+ if (is_model)
+ {
+ GooCanvasItemModelIface *iface;
+
+ iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM_MODEL);
+ iface->set_child_property ((GooCanvasItemModel*) object,
+ (GooCanvasItemModel*) child,
+ pspec->param_id, &tmp_value, pspec);
+ }
+ else
+ {
+ GooCanvasItemIface *iface;
+
+ iface = g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM);
+ iface->set_child_property ((GooCanvasItem*) object,
+ (GooCanvasItem*) child,
+ pspec->param_id, &tmp_value, pspec);
+ }
+
g_object_notify_queue_add (G_OBJECT (child), nqueue, pspec);
}
g_value_unset (&tmp_value);
@@ -1427,19 +1463,19 @@
void
-goo_canvas_item_set_child_properties_valist (GooCanvasItem *item,
- GooCanvasItem *child,
- va_list var_args)
+_goo_canvas_item_set_child_properties_internal (GObject *object,
+ GObject *child,
+ va_list var_args,
+ GParamSpecPool *property_pool,
+ GObjectNotifyContext *notify_context,
+ gboolean is_model)
{
GObjectNotifyQueue *nqueue;
- g_return_if_fail (GOO_IS_CANVAS_ITEM (item));
- g_return_if_fail (GOO_IS_CANVAS_ITEM (child));
-
- g_object_ref (item);
+ g_object_ref (object);
g_object_ref (child);
- nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _goo_canvas_item_child_property_notify_context);
+ nqueue = g_object_notify_queue_freeze (child, notify_context);
for (;;)
{
@@ -1451,18 +1487,18 @@
if (!name)
break;
- pspec = g_param_spec_pool_lookup (_goo_canvas_item_child_property_pool,
- name, G_OBJECT_TYPE (item), TRUE);
+ pspec = g_param_spec_pool_lookup (property_pool, name,
+ G_OBJECT_TYPE (object), TRUE);
if (!pspec)
{
- g_warning ("%s: canvas item class `%s' has no child property named `%s'",
- G_STRLOC, G_OBJECT_TYPE_NAME (item), name);
+ g_warning ("%s: class `%s' has no child property named `%s'",
+ G_STRLOC, G_OBJECT_TYPE_NAME (object), name);
break;
}
if (!(pspec->flags & G_PARAM_WRITABLE))
{
- g_warning ("%s: child property `%s' of canvas item class `%s' is not writable",
- G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (item));
+ g_warning ("%s: child property `%s' of class `%s' is not writable",
+ G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object));
break;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
@@ -1477,17 +1513,42 @@
*/
break;
}
- canvas_item_set_child_property (item, child, pspec, &value, nqueue);
+ canvas_item_set_child_property (object, child, pspec, &value, nqueue,
+ is_model);
g_value_unset (&value);
}
g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
- g_object_unref (item);
+ g_object_unref (object);
g_object_unref (child);
}
void
+goo_canvas_item_get_child_properties_valist (GooCanvasItem *item,
+ GooCanvasItem *child,
+ va_list var_args)
+{
+ g_return_if_fail (GOO_IS_CANVAS_ITEM (item));
+ g_return_if_fail (GOO_IS_CANVAS_ITEM (child));
+
+ _goo_canvas_item_get_child_properties_internal ((GObject*) item, (GObject*) child, var_args, _goo_canvas_item_child_property_pool, _goo_canvas_item_child_property_notify_context, FALSE);
+}
+
+
+void
+goo_canvas_item_set_child_properties_valist (GooCanvasItem *item,
+ GooCanvasItem *child,
+ va_list var_args)
+{
+ g_return_if_fail (GOO_IS_CANVAS_ITEM (item));
+ g_return_if_fail (GOO_IS_CANVAS_ITEM (child));
+
+ _goo_canvas_item_set_child_properties_internal ((GObject*) item, (GObject*) child, var_args, _goo_canvas_item_child_property_pool, _goo_canvas_item_child_property_notify_context, FALSE);
+}
+
+
+void
goo_canvas_item_get_child_properties (GooCanvasItem *item,
GooCanvasItem *child,
...)
Index: goocanvasitemmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- goocanvasitemmodel.c 29 Nov 2006 18:27:06 -0000 1.1
+++ goocanvasitemmodel.c 9 Dec 2006 12:03:05 -0000 1.2
@@ -16,6 +16,8 @@
#include <config.h>
#include <math.h>
#include <glib/gi18n-lib.h>
+#include <gobject/gobjectnotifyqueue.c>
+#include <gobject/gvaluecollector.h>
#include <gtk/gtk.h>
#include "goocanvasprivate.h"
#include <goocanvasenumtypes.h>
@@ -24,6 +26,8 @@
#include "goocanvasmarshal.h"
+static GParamSpecPool *_goo_canvas_item_model_child_property_pool = NULL;
+static GObjectNotifyContext *_goo_canvas_item_model_child_property_notify_context = NULL;
static const char *animation_key = "GooCanvasItemModelAnimation";
enum {
@@ -32,6 +36,8 @@
CHILD_REMOVED,
CHANGED,
+ CHILD_NOTIFY,
+
LAST_SIGNAL
};
@@ -68,14 +74,34 @@
static void
+child_property_notify_dispatcher (GObject *object,
+ guint n_pspecs,
+ GParamSpec **pspecs)
+{
+ guint i;
+
+ for (i = 0; i < n_pspecs; i++)
+ g_signal_emit (object, item_model_signals[CHILD_NOTIFY],
+ g_quark_from_string (pspecs[i]->name), pspecs[i]);
+}
+
+
+static void
goo_canvas_item_model_base_init (gpointer g_iface)
{
+ static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
static gboolean initialized = FALSE;
if (!initialized)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
+ _goo_canvas_item_model_child_property_pool = g_param_spec_pool_new (TRUE);
+
+ cpn_context.quark_notify_queue = g_quark_from_static_string ("GooCanvasItemModel-child-property-notify-queue");
+ cpn_context.dispatcher = child_property_notify_dispatcher;
+ _goo_canvas_item_model_child_property_notify_context = &cpn_context;
+
/**
* GooCanvasItemModel::child-added
* @model: the item that received the signal.
@@ -146,6 +172,24 @@
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
+ /**
+ * GooCanvasItemModel::child-notify
+ * @item: the item model that received the signal.
+ * @pspec: the #GParamSpec of the changed child property.
+ *
+ * The ::child-notify signal is emitted for each child property that has
+ * changed on an object. The signal's detail holds the property name.
+ */
+ item_model_signals[CHILD_NOTIFY] =
+ g_signal_new ("child_notify",
+ iface_type,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (GooCanvasItemModelIface, child_notify),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__PARAM,
+ G_TYPE_NONE, 1,
+ G_TYPE_PARAM);
+
g_object_interface_install_property (g_iface,
g_param_spec_object ("parent",
@@ -853,3 +897,143 @@
/* This will result in a call to goo_canvas_item_model_free_animation(). */
g_object_set_data (G_OBJECT (model), animation_key, NULL);
}
+
+
+
+/*
+ * Child Properties.
+ */
+extern void _goo_canvas_item_get_child_properties_internal (GObject *object, GObject *child, va_list var_args, GParamSpecPool *property_pool, GObjectNotifyContext *notify_context, gboolean is_model);
+
+extern void _goo_canvas_item_set_child_properties_internal (GObject *object, GObject *child, va_list var_args, GParamSpecPool *property_pool, GObjectNotifyContext *notify_context, gboolean is_model);
+
+
+void
+goo_canvas_item_model_get_child_properties_valist (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ va_list var_args)
+{
+ g_return_if_fail (GOO_IS_CANVAS_ITEM_MODEL (model));
+ g_return_if_fail (GOO_IS_CANVAS_ITEM_MODEL (child));
+
+ _goo_canvas_item_get_child_properties_internal ((GObject*) model, (GObject*) child, var_args, _goo_canvas_item_model_child_property_pool, _goo_canvas_item_model_child_property_notify_context, TRUE);
+}
+
+
+void
+goo_canvas_item_model_set_child_properties_valist (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ va_list var_args)
+{
+ g_return_if_fail (GOO_IS_CANVAS_ITEM_MODEL (model));
+ g_return_if_fail (GOO_IS_CANVAS_ITEM_MODEL (child));
+
+ _goo_canvas_item_set_child_properties_internal ((GObject*) model, (GObject*) child, var_args, _goo_canvas_item_model_child_property_pool, _goo_canvas_item_model_child_property_notify_context, TRUE);
+}
+
+
+void
+goo_canvas_item_model_get_child_properties (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ ...)
+{
+ va_list var_args;
+
+ va_start (var_args, child);
+ goo_canvas_item_model_get_child_properties_valist (model, child, var_args);
+ va_end (var_args);
+}
+
+
+void
+goo_canvas_item_model_set_child_properties (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ ...)
+{
+ va_list var_args;
+
+ va_start (var_args, child);
+ goo_canvas_item_model_set_child_properties_valist (model, child, var_args);
+ va_end (var_args);
+}
+
+
+
+/**
+ * goo_canvas_item_model_class_install_child_property:
+ * @mclass: a #GObjectClass
+ * @property_id: the id for the property
+ * @pspec: the #GParamSpec for the property
+ *
+ * Installs a child property on a canvas item class.
+ **/
+void
+goo_canvas_item_model_class_install_child_property (GObjectClass *mclass,
+ guint property_id,
+ GParamSpec *pspec)
+{
+ g_return_if_fail (G_IS_OBJECT_CLASS (mclass));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+ g_return_if_fail (property_id > 0);
+
+ if (g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool,
+ pspec->name, G_OBJECT_CLASS_TYPE (mclass),
+ FALSE))
+ {
+ g_warning (G_STRLOC ": class `%s' already contains a child property named `%s'",
+ G_OBJECT_CLASS_NAME (mclass), pspec->name);
+ return;
+ }
+ g_param_spec_ref (pspec);
+ g_param_spec_sink (pspec);
+ pspec->param_id = property_id;
+ g_param_spec_pool_insert (_goo_canvas_item_model_child_property_pool, pspec,
+ G_OBJECT_CLASS_TYPE (mclass));
+}
+
+/**
+ * goo_canvas_item_model_class_find_child_property:
+ * @mclass: a #GObjectClass
+ * @property_name: the name of the child property to find
+ * @returns: the #GParamSpec of the child property or %NULL if @class has no
+ * child property with that name.
+ *
+ * Finds a child property of a canvas item class by name.
+ */
+GParamSpec*
+goo_canvas_item_model_class_find_child_property (GObjectClass *mclass,
+ const gchar *property_name)
+{
+ g_return_val_if_fail (G_IS_OBJECT_CLASS (mclass), NULL);
+ g_return_val_if_fail (property_name != NULL, NULL);
+
+ return g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool,
+ property_name, G_OBJECT_CLASS_TYPE (mclass),
+ TRUE);
+}
+
+/**
+ * goo_canvas_item_model_class_list_child_properties:
+ * @mclass: a #GObjectClass
+ * @n_properties: location to return the number of child properties found
+ * @returns: a newly allocated array of #GParamSpec*. The array must be
+ * freed with g_free().
+ *
+ * Returns all child properties of a canvas item class.
+ */
+GParamSpec**
+goo_canvas_item_model_class_list_child_properties (GObjectClass *mclass,
+ guint *n_properties)
+{
+ GParamSpec **pspecs;
+ guint n;
+
+ g_return_val_if_fail (G_IS_OBJECT_CLASS (mclass), NULL);
+
+ pspecs = g_param_spec_pool_list (_goo_canvas_item_model_child_property_pool,
+ G_OBJECT_CLASS_TYPE (mclass), &n);
+ if (n_properties)
+ *n_properties = n;
+
+ return pspecs;
+}
Index: goocanvasitemmodel.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- goocanvasitemmodel.h 29 Nov 2006 18:27:06 -0000 1.1
+++ goocanvasitemmodel.h 9 Dec 2006 12:03:05 -0000 1.2
@@ -97,6 +97,8 @@
gint child_num);
void (* changed) (GooCanvasItemModel *model,
gboolean recompute_bounds);
+ void (* child_notify) (GooCanvasItemModel *model,
+ GParamSpec *pspec);
};
@@ -120,26 +122,19 @@
gint goo_canvas_item_model_find_child (GooCanvasItemModel *model,
GooCanvasItemModel *child);
-void goo_canvas_item_model_child_get (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- ...) G_GNUC_NULL_TERMINATED;
-void goo_canvas_item_model_child_set (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- ...) G_GNUC_NULL_TERMINATED;
-void goo_canvas_item_model_child_get_valist (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- va_list var_args);
-void goo_canvas_item_model_child_set_valist (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- va_list var_args);
-void goo_canvas_item_model_child_get_property (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- const gchar *property,
- GValue *value);
-void goo_canvas_item_model_child_set_property (GooCanvasItemModel *model,
- GooCanvasItemModel *child,
- const gchar *property,
- const GValue *value);
+void goo_canvas_item_model_get_child_properties (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ ...) G_GNUC_NULL_TERMINATED;
+void goo_canvas_item_model_set_child_properties (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ ...) G_GNUC_NULL_TERMINATED;
+void goo_canvas_item_model_get_child_properties_valist (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ va_list var_args);
+void goo_canvas_item_model_set_child_properties_valist (GooCanvasItemModel *model,
+ GooCanvasItemModel *child,
+ va_list var_args);
+
/*
* Model functions - these are safe to call on all models.
@@ -192,6 +187,19 @@
void goo_canvas_item_model_stop_animation (GooCanvasItemModel *model);
+/*
+ * Functions to support child properties when implementing new canvas items.
+ */
+void goo_canvas_item_model_class_install_child_property (GObjectClass *mclass,
+ guint property_id,
+ GParamSpec *pspec);
+GParamSpec* goo_canvas_item_model_class_find_child_property (GObjectClass *mclass,
+ const gchar *property_name);
+GParamSpec** goo_canvas_item_model_class_list_child_properties (GObjectClass *mclass,
+ guint *n_properties);
+
+
+
G_END_DECLS
#endif /* __GOO_CANVAS_ITEM_MODEL_H__ */
--- NEW FILE: goocanvastable.c ---
/*
* GooCanvas. Copyright (C) 2005-6 Damon Chaplin.
* Released under the GNU LGPL license. See COPYING for details.
*
* goocanvastable.c - table item.
*/
#include <config.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "goocanvastable.h"
enum
{
PROP_0,
PROP_ROW_SPACING,
PROP_COLUMN_SPACING,
PROP_HOMOGENEOUS_ROWS,
[...1245 lines suppressed...]
/* Note that we set the canvas before the model, since we may need the
canvas to create any child items. */
goo_canvas_item_set_canvas (item, canvas);
goo_canvas_item_set_model (item, model);
return item;
}
static void
item_model_interface_init (GooCanvasItemModelIface *iface)
{
iface->add_child = goo_canvas_table_model_add_child;
iface->move_child = goo_canvas_table_model_move_child;
iface->remove_child = goo_canvas_table_model_remove_child;
iface->get_child_property = goo_canvas_table_model_get_child_property;
iface->set_child_property = goo_canvas_table_model_set_child_property;
iface->create_item = goo_canvas_table_model_create_item;
}
--- NEW FILE: goocanvastable.h ---
/*
* GooCanvas. Copyright (C) 2005-6 Damon Chaplin.
* Released under the GNU LGPL license. See COPYING for details.
*
* goocanvastable.h - table item.
*/
#ifndef __GOO_CANVAS_TABLE_H__
#define __GOO_CANVAS_TABLE_H__
#include <gtk/gtk.h>
#include "goocanvasgroup.h"
G_BEGIN_DECLS
typedef struct _GooCanvasTableDimension GooCanvasTableDimension;
struct _GooCanvasTableDimension
{
gint size;
gdouble default_spacing;
/* These are specific spacings for particular rows or columns. A negative
value indicates that the default should be used. */
gdouble *spacings;
guint homogeneous : 1;
};
/* This is the data used by both model and view classes. */
typedef struct _GooCanvasTableData GooCanvasTableData;
typedef struct _GooCanvasTableLayoutData GooCanvasTableLayoutData;
struct _GooCanvasTableData
{
GooCanvasTableDimension rows;
GooCanvasTableDimension columns;
gdouble border_width;
/* An array of GooCanvasTableChild. */
GArray *children;
GooCanvasTableLayoutData *layout_data;
};
#define GOO_TYPE_CANVAS_TABLE (goo_canvas_table_get_type ())
#define GOO_CANVAS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_CANVAS_TABLE, GooCanvasTable))
#define GOO_CANVAS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_CANVAS_TABLE, GooCanvasTableClass))
#define GOO_IS_CANVAS_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_CANVAS_TABLE))
#define GOO_IS_CANVAS_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_CANVAS_TABLE))
#define GOO_CANVAS_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GOO_TYPE_CANVAS_TABLE, GooCanvasTableClass))
typedef struct _GooCanvasTable GooCanvasTable;
typedef struct _GooCanvasTableClass GooCanvasTableClass;
struct _GooCanvasTable
{
GooCanvasGroup parent;
GooCanvasTableData *table_data;
};
struct _GooCanvasTableClass
{
GooCanvasGroupClass parent_class;
};
GType goo_canvas_table_get_type (void) G_GNUC_CONST;
GooCanvasItem* goo_canvas_table_new (GooCanvasItem *parent,
...);
#define GOO_TYPE_CANVAS_TABLE_MODEL (goo_canvas_table_model_get_type ())
#define GOO_CANVAS_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_CANVAS_TABLE_MODEL, GooCanvasTableModel))
#define GOO_CANVAS_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_CANVAS_TABLE_MODEL, GooCanvasTableModelClass))
#define GOO_IS_CANVAS_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_CANVAS_TABLE_MODEL))
#define GOO_IS_CANVAS_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_CANVAS_TABLE_MODEL))
#define GOO_CANVAS_TABLE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GOO_TYPE_CANVAS_TABLE_MODEL, GooCanvasTableModelClass))
typedef struct _GooCanvasTableModel GooCanvasTableModel;
typedef struct _GooCanvasTableModelClass GooCanvasTableModelClass;
struct _GooCanvasTableModel
{
GooCanvasGroupModel parent_object;
GooCanvasTableData table_data;
};
struct _GooCanvasTableModelClass
{
GooCanvasGroupModelClass parent_class;
};
GType goo_canvas_table_model_get_type (void) G_GNUC_CONST;
GooCanvasItemModel* goo_canvas_table_model_new (GooCanvasItemModel *parent,
...);
G_END_DECLS
#endif /* __GOO_CANVAS_TABLE_H__ */
Index: goocanvasutils.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasutils.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvasutils.c 12 Oct 2006 12:53:47 -0000 1.7
+++ goocanvasutils.c 9 Dec 2006 12:03:05 -0000 1.8
@@ -14,7 +14,8 @@
*/
#include <config.h>
#include <gtk/gtk.h>
-#include "goocanvasutils.h"
+#include "goocanvas.h"
+
/* Glib doesn't provide a g_ptr_array_index() so we need our own one. */
void
@@ -443,3 +444,21 @@
return type_cairo_matrix;
}
+
+
+/* This is a semi-private function to help gtk-doc find child properties. */
+GParamSpec**
+goo_canvas_query_child_properties (gpointer class,
+ guint *n_properties)
+{
+ if (g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM))
+ return goo_canvas_item_class_list_child_properties (class,
+ n_properties);
+
+ if (g_type_interface_peek (class, GOO_TYPE_CANVAS_ITEM_MODEL))
+ return goo_canvas_item_model_class_list_child_properties (class,
+ n_properties);
+
+ return NULL;
+}
+
More information about the cairo-commit
mailing list