aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-10-14 00:22:54 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 01:49:59 +0800
commit629353acc37e3056972dc30009f5efdde4e54ef5 (patch)
tree82bc089f7576dc2626c741d7f31feeac8b7a045f
parentba8393138d737c3abcc460152b6f1e471412219d (diff)
downloadgsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar.gz
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar.bz2
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar.lz
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar.xz
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.tar.zst
gsoc2013-evolution-629353acc37e3056972dc30009f5efdde4e54ef5.zip
gnome-canvas: Get rid of GnomeCanvasRE object
No more ellipses, no more need for 2 classes.
-rw-r--r--libgnomecanvas/gnome-canvas-rect-ellipse.c190
-rw-r--r--libgnomecanvas/gnome-canvas-rect-ellipse.h41
2 files changed, 71 insertions, 160 deletions
diff --git a/libgnomecanvas/gnome-canvas-rect-ellipse.c b/libgnomecanvas/gnome-canvas-rect-ellipse.c
index f3377899f8..b82a94e865 100644
--- a/libgnomecanvas/gnome-canvas-rect-ellipse.c
+++ b/libgnomecanvas/gnome-canvas-rect-ellipse.c
@@ -55,58 +55,29 @@ enum {
PROP_Y2
};
-static void gnome_canvas_re_class_init (GnomeCanvasREClass *class);
-static void gnome_canvas_re_init (GnomeCanvasRE *re);
-static void gnome_canvas_re_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gnome_canvas_re_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gnome_canvas_rect_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags);
-
-static GnomeCanvasItemClass *re_parent_class;
-
-GType
-gnome_canvas_re_get_type (void)
-{
- static GType re_type;
-
- if (!re_type) {
- const GTypeInfo object_info = {
- sizeof (GnomeCanvasREClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gnome_canvas_re_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GnomeCanvasRE),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gnome_canvas_re_init,
- NULL /* value_table */
- };
-
- re_type = g_type_register_static (GNOME_TYPE_CANVAS_SHAPE, "GnomeCanvasRE",
- &object_info, 0);
- }
+static void gnome_canvas_rect_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gnome_canvas_rect_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
- return re_type;
-}
+static void gnome_canvas_rect_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags);
+
+G_DEFINE_TYPE(GnomeCanvasRect, gnome_canvas_rect, GNOME_TYPE_CANVAS_SHAPE)
static void
-gnome_canvas_re_class_init (GnomeCanvasREClass *class)
+gnome_canvas_rect_class_init (GnomeCanvasRectClass *class)
{
GObjectClass *gobject_class;
+ GnomeCanvasItemClass *item_class;
gobject_class = (GObjectClass *) class;
- re_parent_class = g_type_class_peek_parent (class);
-
- gobject_class->set_property = gnome_canvas_re_set_property;
- gobject_class->get_property = gnome_canvas_re_get_property;
+ gobject_class->set_property = gnome_canvas_rect_set_property;
+ gobject_class->get_property = gnome_canvas_rect_get_property;
g_object_class_install_property
(gobject_class,
@@ -132,55 +103,59 @@ gnome_canvas_re_class_init (GnomeCanvasREClass *class)
g_param_spec_double ("y2", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
+
+ item_class = (GnomeCanvasItemClass *) class;
+
+ item_class->update = gnome_canvas_rect_update;
}
static void
-gnome_canvas_re_init (GnomeCanvasRE *re)
+gnome_canvas_rect_init (GnomeCanvasRect *rect)
{
- re->x1 = 0.0;
- re->y1 = 0.0;
- re->x2 = 0.0;
- re->y2 = 0.0;
- re->path_dirty = 0;
+ rect->x1 = 0.0;
+ rect->y1 = 0.0;
+ rect->x2 = 0.0;
+ rect->y2 = 0.0;
+ rect->path_dirty = 0;
}
static void
-gnome_canvas_re_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
+gnome_canvas_rect_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GnomeCanvasItem *item;
- GnomeCanvasRE *re;
+ GnomeCanvasRect *rect;
g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_RE (object));
+ g_return_if_fail (GNOME_IS_CANVAS_RECT (object));
item = GNOME_CANVAS_ITEM (object);
- re = GNOME_CANVAS_RE (object);
+ rect = GNOME_CANVAS_RECT (object);
switch (param_id) {
case PROP_X1:
- re->x1 = g_value_get_double (value);
- re->path_dirty = 1;
+ rect->x1 = g_value_get_double (value);
+ rect->path_dirty = 1;
gnome_canvas_item_request_update (item);
break;
case PROP_Y1:
- re->y1 = g_value_get_double (value);
- re->path_dirty = 1;
+ rect->y1 = g_value_get_double (value);
+ rect->path_dirty = 1;
gnome_canvas_item_request_update (item);
break;
case PROP_X2:
- re->x2 = g_value_get_double (value);
- re->path_dirty = 1;
+ rect->x2 = g_value_get_double (value);
+ rect->path_dirty = 1;
gnome_canvas_item_request_update (item);
break;
case PROP_Y2:
- re->y2 = g_value_get_double (value);
- re->path_dirty = 1;
+ rect->y2 = g_value_get_double (value);
+ rect->path_dirty = 1;
gnome_canvas_item_request_update (item);
break;
@@ -191,33 +166,33 @@ gnome_canvas_re_set_property (GObject *object,
}
static void
-gnome_canvas_re_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
+gnome_canvas_rect_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GnomeCanvasRE *re;
+ GnomeCanvasRect *rect;
g_return_if_fail (object != NULL);
- g_return_if_fail (GNOME_IS_CANVAS_RE (object));
+ g_return_if_fail (GNOME_IS_CANVAS_RECT (object));
- re = GNOME_CANVAS_RE (object);
+ rect = GNOME_CANVAS_RECT (object);
switch (param_id) {
case PROP_X1:
- g_value_set_double (value, re->x1);
+ g_value_set_double (value, rect->x1);
break;
case PROP_Y1:
- g_value_set_double (value, re->y1);
+ g_value_set_double (value, rect->y1);
break;
case PROP_X2:
- g_value_set_double (value, re->x2);
+ g_value_set_double (value, rect->x2);
break;
case PROP_Y2:
- g_value_set_double (value, re->y2);
+ g_value_set_double (value, rect->y2);
break;
default:
@@ -226,67 +201,28 @@ gnome_canvas_re_get_property (GObject *object,
}
}
-/* Rectangle item */
-static void gnome_canvas_rect_class_init (GnomeCanvasRectClass *class);
-
-GType
-gnome_canvas_rect_get_type (void)
-{
- static GType rect_type;
-
- if (!rect_type) {
- const GTypeInfo object_info = {
- sizeof (GnomeCanvasRectClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gnome_canvas_rect_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GnomeCanvasRect),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
- NULL /* value_table */
- };
-
- rect_type = g_type_register_static (GNOME_TYPE_CANVAS_RE, "GnomeCanvasRect",
- &object_info, 0);
- }
-
- return rect_type;
-}
-
-static void
-gnome_canvas_rect_class_init (GnomeCanvasRectClass *class)
-{
- GnomeCanvasItemClass *item_class;
-
- item_class = (GnomeCanvasItemClass *) class;
-
- item_class->update = gnome_canvas_rect_update;
-}
-
static void
gnome_canvas_rect_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gint flags)
-{ GnomeCanvasRE *re;
-
+{
+ GnomeCanvasRect *rect;
GnomeCanvasPathDef *path_def;
- re = GNOME_CANVAS_RE (item);
+ rect = GNOME_CANVAS_RECT (item);
- if (re->path_dirty) {
+ if (rect->path_dirty) {
path_def = gnome_canvas_path_def_new ();
- gnome_canvas_path_def_moveto (path_def, re->x1, re->y1);
- gnome_canvas_path_def_lineto (path_def, re->x2, re->y1);
- gnome_canvas_path_def_lineto (path_def, re->x2, re->y2);
- gnome_canvas_path_def_lineto (path_def, re->x1, re->y2);
- gnome_canvas_path_def_lineto (path_def, re->x1, re->y1);
+ gnome_canvas_path_def_moveto (path_def, rect->x1, rect->y1);
+ gnome_canvas_path_def_lineto (path_def, rect->x2, rect->y1);
+ gnome_canvas_path_def_lineto (path_def, rect->x2, rect->y2);
+ gnome_canvas_path_def_lineto (path_def, rect->x1, rect->y2);
+ gnome_canvas_path_def_lineto (path_def, rect->x1, rect->y1);
gnome_canvas_path_def_closepath_current (path_def);
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (item), path_def);
gnome_canvas_path_def_unref (path_def);
- re->path_dirty = 0;
+ rect->path_dirty = 0;
}
- if (re_parent_class->update)
- (* re_parent_class->update) (item, affine, clip_path, flags);
+ if (GNOME_CANVAS_ITEM_CLASS (gnome_canvas_rect_parent_class)->update)
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_rect_parent_class)->update (item, affine, clip_path, flags);
}
diff --git a/libgnomecanvas/gnome-canvas-rect-ellipse.h b/libgnomecanvas/gnome-canvas-rect-ellipse.h
index c02097617b..1a161ee3e3 100644
--- a/libgnomecanvas/gnome-canvas-rect-ellipse.h
+++ b/libgnomecanvas/gnome-canvas-rect-ellipse.h
@@ -42,8 +42,8 @@
G_BEGIN_DECLS
-/* Base class for rectangle and ellipse item types. These are defined by their top-left and
- * bottom-right corners. Rectangles and ellipses share the following arguments:
+/* Rectangle item. These are defined by their top-left and bottom-right corners.
+ * Rectangles have the following arguments:
*
* name type read/write description
* ------------------------------------------------------------------------------------------
@@ -63,35 +63,6 @@ G_BEGIN_DECLS
* will be scaled when the canvas zoom factor is changed.
*/
-#define GNOME_TYPE_CANVAS_RE (gnome_canvas_re_get_type ())
-#define GNOME_CANVAS_RE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_RE, GnomeCanvasRE))
-#define GNOME_CANVAS_RE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_RE, GnomeCanvasREClass))
-#define GNOME_IS_CANVAS_RE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_RE))
-#define GNOME_IS_CANVAS_RE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_RE))
-#define GNOME_CANVAS_RE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_RE, GnomeCanvasREClass))
-
-typedef struct _GnomeCanvasRE GnomeCanvasRE;
-typedef struct _GnomeCanvasREClass GnomeCanvasREClass;
-
-struct _GnomeCanvasRE {
- GnomeCanvasShape item;
-
- gdouble x1, y1, x2, y2; /* Corners of item */
-
- guint path_dirty : 1;
-};
-
-struct _GnomeCanvasREClass {
- GnomeCanvasShapeClass parent_class;
-};
-
-/* Standard Gtk function */
-GType gnome_canvas_re_get_type (void) G_GNUC_CONST;
-
-/* Rectangle item. No configurable or queryable arguments are available (use those in
- * GnomeCanvasRE).
- */
-
#define GNOME_TYPE_CANVAS_RECT (gnome_canvas_rect_get_type ())
#define GNOME_CANVAS_RECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRect))
#define GNOME_CANVAS_RECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRectClass))
@@ -103,11 +74,15 @@ typedef struct _GnomeCanvasRect GnomeCanvasRect;
typedef struct _GnomeCanvasRectClass GnomeCanvasRectClass;
struct _GnomeCanvasRect {
- GnomeCanvasRE re;
+ GnomeCanvasShape parent;
+
+ gdouble x1, y1, x2, y2; /* Corners of item */
+
+ guint path_dirty : 1;
};
struct _GnomeCanvasRectClass {
- GnomeCanvasREClass parent_class;
+ GnomeCanvasShapeClass parent_class;
};
/* Standard Gtk function */