aboutsummaryrefslogtreecommitdiffstats
path: root/libgnomecanvas
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-06-24 19:31:28 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-06-25 08:31:42 +0800
commitf960fd2dff5358f0e13eba7041d35855bf48c22e (patch)
tree92859c8ba093fa15a3bd7b888332d6e61a704a51 /libgnomecanvas
parent88db20f3e9ff38296c031671de963ae665fd8143 (diff)
downloadgsoc2013-evolution-f960fd2dff5358f0e13eba7041d35855bf48c22e.tar.gz
gsoc2013-evolution-f960fd2dff5358f0e13eba7041d35855bf48c22e.tar.zst
gsoc2013-evolution-f960fd2dff5358f0e13eba7041d35855bf48c22e.zip
Reduce usage of g_type_class_peek_parent().
G_DEFINE_TYPE macros define a static "parent_class" variable.
Diffstat (limited to 'libgnomecanvas')
-rw-r--r--libgnomecanvas/gailcanvasitem.c8
-rw-r--r--libgnomecanvas/gnome-canvas-text.c12
-rw-r--r--libgnomecanvas/gnome-canvas-widget.c12
-rw-r--r--libgnomecanvas/gnome-canvas.c80
4 files changed, 47 insertions, 65 deletions
diff --git a/libgnomecanvas/gailcanvasitem.c b/libgnomecanvas/gailcanvasitem.c
index ab4f6a4dda..53e0e4666c 100644
--- a/libgnomecanvas/gailcanvasitem.c
+++ b/libgnomecanvas/gailcanvasitem.c
@@ -53,8 +53,6 @@ static void get_item_extents (GnomeCanvasItem *
static gboolean is_item_in_window (GnomeCanvasItem *item,
const GdkRectangle *extents);
-static AtkGObjectAccessibleClass *parent_class = NULL;
-
G_DEFINE_TYPE_WITH_CODE (GailCanvasItem,
gail_canvas_item,
ATK_TYPE_GOBJECT_ACCESSIBLE,
@@ -85,7 +83,7 @@ static void
gail_canvas_item_initialize (AtkObject *obj,
gpointer data)
{
- ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
+ ATK_OBJECT_CLASS (gail_canvas_item_parent_class)->initialize (obj, data);
g_object_set_data (G_OBJECT (obj), "atk-component-layer",
GINT_TO_POINTER (ATK_LAYER_MDI));
@@ -96,8 +94,6 @@ gail_canvas_item_class_init (GailCanvasItemClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
class->get_parent = gail_canvas_item_get_parent;
class->get_index_in_parent = gail_canvas_item_get_index_in_parent;
class->ref_state_set = gail_canvas_item_ref_state_set;
@@ -185,7 +181,7 @@ gail_canvas_item_ref_state_set (AtkObject *obj)
g_return_val_if_fail (GAIL_IS_CANVAS_ITEM (obj), NULL);
atk_gobj = ATK_GOBJECT_ACCESSIBLE (obj);
- state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ state_set = ATK_OBJECT_CLASS (gail_canvas_item_parent_class)->ref_state_set (obj);
g_obj = atk_gobject_accessible_get_object (atk_gobj);
if (g_obj == NULL)
diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c
index 5a7e9c8136..6720ad42eb 100644
--- a/libgnomecanvas/gnome-canvas-text.c
+++ b/libgnomecanvas/gnome-canvas-text.c
@@ -129,8 +129,6 @@ static void gnome_canvas_text_apply_attributes (GnomeCanvasText *textitem);
static void add_attr (PangoAttrList *attr_list,
PangoAttribute *attr);
-static GnomeCanvasItemClass *parent_class;
-
G_DEFINE_TYPE (
GnomeCanvasText,
gnome_canvas_text,
@@ -146,8 +144,6 @@ gnome_canvas_text_class_init (GnomeCanvasTextClass *class)
gobject_class = (GObjectClass *) class;
item_class = (GnomeCanvasItemClass *) class;
- parent_class = g_type_class_peek_parent (class);
-
gobject_class->set_property = gnome_canvas_text_set_property;
gobject_class->get_property = gnome_canvas_text_get_property;
@@ -512,8 +508,8 @@ gnome_canvas_text_dispose (GnomeCanvasItem *object)
text->attr_list = NULL;
}
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->dispose)
- GNOME_CANVAS_ITEM_CLASS (parent_class)->dispose (object);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_text_parent_class)->
+ dispose (object);
}
static void
@@ -1169,8 +1165,8 @@ gnome_canvas_text_update (GnomeCanvasItem *item,
text = GNOME_CANVAS_TEXT (item);
- if (parent_class->update)
- (* parent_class->update) (item, matrix, flags);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_text_parent_class)->
+ update (item, matrix, flags);
get_bounds (text, &x1, &y1, &x2, &y2);
diff --git a/libgnomecanvas/gnome-canvas-widget.c b/libgnomecanvas/gnome-canvas-widget.c
index 84ffa80fe2..7632bb0ddf 100644
--- a/libgnomecanvas/gnome-canvas-widget.c
+++ b/libgnomecanvas/gnome-canvas-widget.c
@@ -80,8 +80,6 @@ static void gnome_canvas_widget_draw (GnomeCanvasItem *item,
gint width,
gint height);
-static GnomeCanvasItemClass *parent_class;
-
G_DEFINE_TYPE (
GnomeCanvasWidget,
gnome_canvas_widget,
@@ -96,8 +94,6 @@ gnome_canvas_widget_class_init (GnomeCanvasWidgetClass *class)
gobject_class = (GObjectClass *) class;
item_class = (GnomeCanvasItemClass *) class;
- parent_class = g_type_class_peek_parent (class);
-
gobject_class->set_property = gnome_canvas_widget_set_property;
gobject_class->get_property = gnome_canvas_widget_get_property;
@@ -185,8 +181,8 @@ gnome_canvas_widget_dispose (GnomeCanvasItem *object)
witem->widget = NULL;
}
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->dispose)
- GNOME_CANVAS_ITEM_CLASS (parent_class)->dispose (object);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_widget_parent_class)->
+ dispose (object);
}
static void
@@ -365,8 +361,8 @@ gnome_canvas_widget_update (GnomeCanvasItem *item,
witem = GNOME_CANVAS_WIDGET (item);
- if (parent_class->update)
- (* parent_class->update) (item, matrix, flags);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_widget_parent_class)->
+ update (item, matrix, flags);
if (witem->widget) {
witem->cwidth = (gint) (witem->width + 0.5);
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index ba49c09caf..8911e610eb 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -131,8 +131,6 @@ static gint emit_event (GnomeCanvas *canvas, GdkEvent *ev
static guint item_signals[ITEM_LAST_SIGNAL];
-static GObjectClass *item_parent_class;
-
G_DEFINE_TYPE (
GnomeCanvasItem,
gnome_canvas_item,
@@ -336,12 +334,24 @@ gnome_canvas_item_dispose (GObject *object)
if (GNOME_CANVAS_ITEM_GET_CLASS (item)->dispose)
GNOME_CANVAS_ITEM_GET_CLASS (item)->dispose (item);
- G_OBJECT_CLASS (item_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gnome_canvas_item_parent_class)->dispose (object);
/* items should remove any reference to item->canvas after the
* first ::dispose */
item->canvas = NULL;
}
+/* Update handler for canvas items */
+static void
+gnome_canvas_item_update (GnomeCanvasItem *item,
+ const cairo_matrix_t *matrix,
+ gint flags)
+{
+ item->flags &= ~GNOME_CANVAS_ITEM_NEED_UPDATE;
+ item->flags &= ~GNOME_CANVAS_ITEM_NEED_AFFINE;
+ item->flags &= ~GNOME_CANVAS_ITEM_NEED_CLIP;
+ item->flags &= ~GNOME_CANVAS_ITEM_NEED_VIS;
+}
+
/* Realize handler for canvas items */
static void
gnome_canvas_item_realize (GnomeCanvasItem *item)
@@ -372,16 +382,11 @@ gnome_canvas_item_unmap (GnomeCanvasItem *item)
item->flags &= ~GNOME_CANVAS_ITEM_MAPPED;
}
-/* Update handler for canvas items */
+/* Dispose handler for canvas items */
static void
-gnome_canvas_item_update (GnomeCanvasItem *item,
- const cairo_matrix_t *matrix,
- gint flags)
+gnome_canvas_item_dispose_item (GnomeCanvasItem *item)
{
- item->flags &= ~GNOME_CANVAS_ITEM_NEED_UPDATE;
- item->flags &= ~GNOME_CANVAS_ITEM_NEED_AFFINE;
- item->flags &= ~GNOME_CANVAS_ITEM_NEED_CLIP;
- item->flags &= ~GNOME_CANVAS_ITEM_NEED_VIS;
+ /* Placeholder so subclasses can safely chain up. */
}
/*
@@ -1204,8 +1209,6 @@ static void gnome_canvas_group_bounds (GnomeCanvasItem *item,
gdouble *x1, gdouble *y1,
gdouble *x2, gdouble *y2);
-static GnomeCanvasItemClass *group_parent_class;
-
G_DEFINE_TYPE (
GnomeCanvasGroup,
gnome_canvas_group,
@@ -1221,8 +1224,6 @@ gnome_canvas_group_class_init (GnomeCanvasGroupClass *class)
object_class = (GObjectClass *) class;
item_class = (GnomeCanvasItemClass *) class;
- group_parent_class = g_type_class_peek_parent (class);
-
object_class->set_property = gnome_canvas_group_set_property;
object_class->get_property = gnome_canvas_group_get_property;
@@ -1329,8 +1330,8 @@ gnome_canvas_group_dispose (GnomeCanvasItem *object)
g_object_run_dispose (G_OBJECT (group->item_list->data));
}
- if (GNOME_CANVAS_ITEM_CLASS (group_parent_class)->dispose)
- GNOME_CANVAS_ITEM_CLASS (group_parent_class)->dispose (object);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->
+ dispose (object);
}
/* Update handler for canvas groups */
@@ -1346,7 +1347,8 @@ gnome_canvas_group_update (GnomeCanvasItem *item,
group = GNOME_CANVAS_GROUP (item);
- (* group_parent_class->update) (item, i2c, flags);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->
+ update (item, i2c, flags);
x1 = G_MAXDOUBLE;
y1 = G_MAXDOUBLE;
@@ -1390,7 +1392,8 @@ gnome_canvas_group_realize (GnomeCanvasItem *item)
(* GNOME_CANVAS_ITEM_GET_CLASS (i)->realize) (i);
}
- (* group_parent_class->realize) (item);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->
+ realize (item);
}
/* Unrealize handler for canvas groups */
@@ -1410,7 +1413,8 @@ gnome_canvas_group_unrealize (GnomeCanvasItem *item)
(* GNOME_CANVAS_ITEM_GET_CLASS (i)->unrealize) (i);
}
- (* group_parent_class->unrealize) (item);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->
+ unrealize (item);
}
/* Map handler for canvas groups */
@@ -1430,7 +1434,7 @@ gnome_canvas_group_map (GnomeCanvasItem *item)
(* GNOME_CANVAS_ITEM_GET_CLASS (i)->map) (i);
}
- (* group_parent_class->map) (item);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->map (item);
}
/* Unmap handler for canvas groups */
@@ -1450,7 +1454,7 @@ gnome_canvas_group_unmap (GnomeCanvasItem *item)
(* GNOME_CANVAS_ITEM_GET_CLASS (i)->unmap) (i);
}
- (* group_parent_class->unmap) (item);
+ GNOME_CANVAS_ITEM_CLASS (gnome_canvas_group_parent_class)->unmap (item);
}
/* Draw handler for canvas groups */
@@ -1683,8 +1687,6 @@ static void gnome_canvas_draw_background (GnomeCanvas *canvas,
gint width,
gint height);
-static GtkLayoutClass *canvas_parent_class;
-
static guint canvas_signals[LAST_SIGNAL];
enum {
@@ -1804,8 +1806,6 @@ gnome_canvas_class_init (GnomeCanvasClass *class)
object_class = (GObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
- canvas_parent_class = g_type_class_peek_parent (class);
-
object_class->set_property = gnome_canvas_set_property;
object_class->get_property = gnome_canvas_get_property;
object_class->dispose = gnome_canvas_dispose;
@@ -1941,7 +1941,7 @@ gnome_canvas_dispose (GObject *object)
shutdown_transients (canvas);
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (canvas_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gnome_canvas_parent_class)->dispose (object);
}
/**
@@ -1967,8 +1967,7 @@ gnome_canvas_map (GtkWidget *widget)
/* Normal widget mapping stuff */
- if (GTK_WIDGET_CLASS (canvas_parent_class)->map)
- (* GTK_WIDGET_CLASS (canvas_parent_class)->map) (widget);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->map (widget);
canvas = GNOME_CANVAS (widget);
@@ -2000,8 +1999,7 @@ gnome_canvas_unmap (GtkWidget *widget)
/* Normal widget unmapping stuff */
- if (GTK_WIDGET_CLASS (canvas_parent_class)->unmap)
- (* GTK_WIDGET_CLASS (canvas_parent_class)->unmap) (widget);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->unmap (widget);
}
/* Realize handler for the canvas */
@@ -2016,8 +2014,7 @@ gnome_canvas_realize (GtkWidget *widget)
/* Normal widget realization stuff */
- if (GTK_WIDGET_CLASS (canvas_parent_class)->realize)
- (* GTK_WIDGET_CLASS (canvas_parent_class)->realize) (widget);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->realize (widget);
canvas = GNOME_CANVAS (widget);
@@ -2058,8 +2055,7 @@ gnome_canvas_unrealize (GtkWidget *widget)
(* GNOME_CANVAS_ITEM_GET_CLASS (canvas->root)->unrealize) (canvas->root);
- if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->unrealize (widget);
}
/* Handles scrolling of the canvas. Adjusts the scrolling and zooming offset to
@@ -2170,9 +2166,8 @@ gnome_canvas_size_allocate (GtkWidget *widget,
g_return_if_fail (GNOME_IS_CANVAS (widget));
g_return_if_fail (allocation != NULL);
- if (GTK_WIDGET_CLASS (canvas_parent_class)->size_allocate)
- GTK_WIDGET_CLASS (canvas_parent_class)->size_allocate (
- widget, allocation);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->
+ size_allocate (widget, allocation);
scrollable = GTK_SCROLLABLE (widget);
hadjustment = gtk_scrollable_get_hadjustment (scrollable);
@@ -2245,7 +2240,7 @@ gnome_canvas_draw (GtkWidget *widget,
cairo_restore (cr);
/* And call expose on parent container class */
- GTK_WIDGET_CLASS (canvas_parent_class)->draw (widget, cr);
+ GTK_WIDGET_CLASS (gnome_canvas_parent_class)->draw (widget, cr);
return FALSE;
}
@@ -2649,7 +2644,7 @@ gnome_canvas_key (GtkWidget *widget,
if (!emit_event (canvas, (GdkEvent *) event)) {
GtkWidgetClass *widget_class;
- widget_class = GTK_WIDGET_CLASS (canvas_parent_class);
+ widget_class = GTK_WIDGET_CLASS (gnome_canvas_parent_class);
if (event->type == GDK_KEY_PRESS) {
if (widget_class->key_press_event)
@@ -3311,8 +3306,6 @@ gnome_canvas_item_class_init (GnomeCanvasItemClass *class)
gobject_class = (GObjectClass *) class;
- item_parent_class = g_type_class_peek_parent (class);
-
gobject_class->set_property = gnome_canvas_item_set_property;
gobject_class->get_property = gnome_canvas_item_get_property;
@@ -3334,9 +3327,10 @@ gnome_canvas_item_class_init (GnomeCanvasItemClass *class)
gobject_class->dispose = gnome_canvas_item_dispose;
+ class->update = gnome_canvas_item_update;
class->realize = gnome_canvas_item_realize;
class->unrealize = gnome_canvas_item_unrealize;
class->map = gnome_canvas_item_map;
class->unmap = gnome_canvas_item_unmap;
- class->update = gnome_canvas_item_update;
+ class->dispose = gnome_canvas_item_dispose_item;
}