diff options
Diffstat (limited to 'libgnomecanvas')
-rw-r--r-- | libgnomecanvas/gailcanvas.c | 28 | ||||
-rw-r--r-- | libgnomecanvas/gailcanvasitem.c | 12 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-pixbuf.c | 7 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-rect.c | 7 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-rich-text.c | 70 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-text.c | 40 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-util.c | 8 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas-widget.c | 32 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas.c | 141 |
9 files changed, 84 insertions, 261 deletions
diff --git a/libgnomecanvas/gailcanvas.c b/libgnomecanvas/gailcanvas.c index 47501c7d1c..5ca87a6cbe 100644 --- a/libgnomecanvas/gailcanvas.c +++ b/libgnomecanvas/gailcanvas.c @@ -176,26 +176,24 @@ static void gail_canvas_real_initialize (AtkObject *obj, gpointer data) { - GnomeCanvas *canvas; - GtkAdjustment *adj; + GnomeCanvas *canvas; + GtkAdjustment *adj; - parent_atk_object_class->initialize (obj, data); + parent_atk_object_class->initialize (obj, data); - canvas = GNOME_CANVAS (data); + canvas = GNOME_CANVAS (data); - adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); - g_signal_connect (adj, - "value_changed", - G_CALLBACK (adjustment_changed), - canvas); + adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + g_signal_connect ( + adj, "value_changed", + G_CALLBACK (adjustment_changed), canvas); - adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); - g_signal_connect (adj, - "value_changed", - G_CALLBACK (adjustment_changed), - canvas); + adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); + g_signal_connect ( + adj, "value_changed", + G_CALLBACK (adjustment_changed), canvas); - obj->role = ATK_ROLE_LAYERED_PANE; + obj->role = ATK_ROLE_LAYERED_PANE; } static gint diff --git a/libgnomecanvas/gailcanvasitem.c b/libgnomecanvas/gailcanvasitem.c index ce98ee0b40..ab4f6a4dda 100644 --- a/libgnomecanvas/gailcanvasitem.c +++ b/libgnomecanvas/gailcanvasitem.c @@ -246,12 +246,12 @@ gail_canvas_item_add_focus_handler (AtkComponent *component, (gpointer) handler, NULL); if (!ret) { - return g_signal_connect_closure_by_id (component, - signal_id, 0, - g_cclosure_new ( - G_CALLBACK (handler), NULL, - (GClosureNotify) NULL), - FALSE); + return g_signal_connect_closure_by_id ( + component, signal_id, 0, + g_cclosure_new ( + G_CALLBACK (handler), NULL, + (GClosureNotify) NULL), + FALSE); } else { diff --git a/libgnomecanvas/gnome-canvas-pixbuf.c b/libgnomecanvas/gnome-canvas-pixbuf.c index b9ece1f504..a3f30600de 100644 --- a/libgnomecanvas/gnome-canvas-pixbuf.c +++ b/libgnomecanvas/gnome-canvas-pixbuf.c @@ -30,6 +30,10 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "gnome-canvas-pixbuf.h" +#define GNOME_CANVAS_PIXBUF_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), GNOME_TYPE_CANVAS_PIXBUF, GnomeCanvasPixbufPrivate)) + /* Private part of the GnomeCanvasPixbuf structure */ struct _GnomeCanvasPixbufPrivate { /* Our gdk-pixbuf */ @@ -100,8 +104,7 @@ gnome_canvas_pixbuf_class_init (GnomeCanvasPixbufClass *class) static void gnome_canvas_pixbuf_init (GnomeCanvasPixbuf *gcp) { - gcp->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - gcp, GNOME_TYPE_CANVAS_PIXBUF, GnomeCanvasPixbufPrivate); + gcp->priv = GNOME_CANVAS_PIXBUF_GET_PRIVATE (gcp); } /* Dispose handler for the pixbuf canvas item */ diff --git a/libgnomecanvas/gnome-canvas-rect.c b/libgnomecanvas/gnome-canvas-rect.c index 35453506b5..487b7e23ae 100644 --- a/libgnomecanvas/gnome-canvas-rect.c +++ b/libgnomecanvas/gnome-canvas-rect.c @@ -32,6 +32,10 @@ #include "gnome-canvas-rect.h" +#define GNOME_CANVAS_RECT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRectPrivate)) + struct _GnomeCanvasRectPrivate { cairo_path_t *path; /* Our bezier path representation */ @@ -704,8 +708,7 @@ gnome_canvas_rect_class_init (GnomeCanvasRectClass *class) static void gnome_canvas_rect_init (GnomeCanvasRect *rect) { - rect->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - rect, GNOME_TYPE_CANVAS_RECT, GnomeCanvasRectPrivate); + rect->priv = GNOME_CANVAS_RECT_GET_PRIVATE (rect); rect->priv->scale = 1.0; diff --git a/libgnomecanvas/gnome-canvas-rich-text.c b/libgnomecanvas/gnome-canvas-rich-text.c index 7cb39b28fd..a632c6989d 100644 --- a/libgnomecanvas/gnome-canvas-rich-text.c +++ b/libgnomecanvas/gnome-canvas-rich-text.c @@ -38,6 +38,10 @@ #include "gnome-canvas-rich-text.h" #include "gnome-canvas-i18n.h" +#define GNOME_CANVAS_RICH_TEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), GNOME_TYPE_CANVAS_RICH_TEXT, GnomeCanvasRichTextPrivate)) + struct _GnomeCanvasRichTextPrivate { GtkTextLayout *layout; GtkTextBuffer *buffer; @@ -109,11 +113,8 @@ enum { LAST_SIGNAL }; -static GnomeCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = { 0 }; -static void gnome_canvas_rich_text_class_init (GnomeCanvasRichTextClass *klass); -static void gnome_canvas_rich_text_init (GnomeCanvasRichText *text); static void gnome_canvas_rich_text_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void gnome_canvas_rich_text_get_property (GObject *object, guint property_id, @@ -151,58 +152,21 @@ static gint blink_cb (gpointer data); #define CURSOR_ON_TIME 800 #define CURSOR_OFF_TIME 400 -GType -gnome_canvas_rich_text_get_type (void) -{ - static GType rich_text_type; - - if (!rich_text_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasRichTextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_rich_text_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvasRichText), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_rich_text_init, - NULL /* value_table */ - }; - - rich_text_type = g_type_register_static ( - GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasRichText", - &object_info, 0); - } - - return rich_text_type; -} - -static void -gnome_canvas_rich_text_finalize (GObject *object) -{ - GnomeCanvasRichText *text; - - text = GNOME_CANVAS_RICH_TEXT (object); - - g_free (text->_priv); - text->_priv = NULL; - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} +G_DEFINE_TYPE ( + GnomeCanvasRichText, + gnome_canvas_rich_text, + GNOME_TYPE_CANVAS_ITEM) static void -gnome_canvas_rich_text_class_init (GnomeCanvasRichTextClass *klass) +gnome_canvas_rich_text_class_init (GnomeCanvasRichTextClass *class) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class); - parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (class, sizeof (GnomeCanvasRichTextPrivate)); gobject_class->set_property = gnome_canvas_rich_text_set_property; gobject_class->get_property = gnome_canvas_rich_text_get_property; - gobject_class->finalize = gnome_canvas_rich_text_finalize; g_object_class_install_property ( gobject_class, @@ -389,7 +353,7 @@ gnome_canvas_rich_text_class_init (GnomeCanvasRichTextClass *klass) static void gnome_canvas_rich_text_init (GnomeCanvasRichText *text) { - text->_priv = g_new0 (GnomeCanvasRichTextPrivate, 1); + text->_priv = GNOME_CANVAS_RICH_TEXT_GET_PRIVATE (text); /* Try to set some sane defaults */ text->_priv->cursor_visible = TRUE; @@ -650,7 +614,7 @@ gnome_canvas_rich_text_realize (GnomeCanvasItem *item) { GnomeCanvasRichText *text = GNOME_CANVAS_RICH_TEXT (item); - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->realize)(item); + (* GNOME_CANVAS_ITEM_CLASS (gnome_canvas_rich_text_parent_class)->realize)(item); gnome_canvas_rich_text_ensure_layout (text); } /* gnome_canvas_rich_text_realize */ @@ -662,7 +626,7 @@ gnome_canvas_rich_text_unrealize (GnomeCanvasItem *item) gnome_canvas_rich_text_destroy_layout (text); - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize)(item); + (* GNOME_CANVAS_ITEM_CLASS (gnome_canvas_rich_text_parent_class)->unrealize)(item); } /* gnome_canvas_rich_text_unrealize */ static void @@ -2009,8 +1973,8 @@ gnome_canvas_rich_text_update (GnomeCanvasItem *item, gdouble x1, y1, x2, y2; GtkTextIter start; - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update)( - item, matrix, flags); + (* GNOME_CANVAS_ITEM_CLASS (gnome_canvas_rich_text_parent_class)-> + update)(item, matrix, flags); get_bounds (text, &x1, &y1, &x2, &y2); diff --git a/libgnomecanvas/gnome-canvas-text.c b/libgnomecanvas/gnome-canvas-text.c index d14effacca..1558640d8d 100644 --- a/libgnomecanvas/gnome-canvas-text.c +++ b/libgnomecanvas/gnome-canvas-text.c @@ -94,8 +94,6 @@ enum { PROP_TEXT_HEIGHT }; -static void gnome_canvas_text_class_init (GnomeCanvasTextClass *class); -static void gnome_canvas_text_init (GnomeCanvasText *text); static void gnome_canvas_text_dispose (GnomeCanvasItem *object); static void gnome_canvas_text_set_property (GObject *object, guint param_id, @@ -133,40 +131,10 @@ static void add_attr (PangoAttrList *attr_list, static GnomeCanvasItemClass *parent_class; -/** - * gnome_canvas_text_get_type: - * @void: - * - * Registers the &GnomeCanvasText class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GnomeCanvasText class. - **/ -GType -gnome_canvas_text_get_type (void) -{ - static GType text_type; - - if (!text_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasTextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_text_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvasText), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_text_init, - NULL /* value_table */ - }; - - text_type = g_type_register_static (GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasText", - &object_info, 0); - } - - return text_type; -} +G_DEFINE_TYPE ( + GnomeCanvasText, + gnome_canvas_text, + GNOME_TYPE_CANVAS_ITEM) /* Class initialization function for the text item */ static void diff --git a/libgnomecanvas/gnome-canvas-util.c b/libgnomecanvas/gnome-canvas-util.c index 00e76daae9..ac5250ca13 100644 --- a/libgnomecanvas/gnome-canvas-util.c +++ b/libgnomecanvas/gnome-canvas-util.c @@ -80,12 +80,16 @@ gnome_canvas_update_bbox (GnomeCanvasItem *item, gint x2, gint y2) { - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); + gnome_canvas_request_redraw ( + item->canvas, item->x1, item->y1, item->x2, item->y2); + item->x1 = x1; item->y1 = y1; item->x2 = x2; item->y2 = y2; - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); + + gnome_canvas_request_redraw ( + item->canvas, item->x1, item->y1, item->x2, item->y2); } /** diff --git a/libgnomecanvas/gnome-canvas-widget.c b/libgnomecanvas/gnome-canvas-widget.c index ef516eb5b2..82077af291 100644 --- a/libgnomecanvas/gnome-canvas-widget.c +++ b/libgnomecanvas/gnome-canvas-widget.c @@ -49,8 +49,6 @@ enum { PROP_SIZE_PIXELS }; -static void gnome_canvas_widget_class_init (GnomeCanvasWidgetClass *class); -static void gnome_canvas_widget_init (GnomeCanvasWidget *witem); static void gnome_canvas_widget_dispose (GnomeCanvasItem *object); static void gnome_canvas_widget_get_property (GObject *object, guint param_id, @@ -84,32 +82,10 @@ static void gnome_canvas_widget_draw (GnomeCanvasItem *item, static GnomeCanvasItemClass *parent_class; -GType -gnome_canvas_widget_get_type (void) -{ - static GType widget_type; - - if (!widget_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasWidgetClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_widget_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvasWidget), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_widget_init, - NULL /* value_table */ - }; - - widget_type = g_type_register_static ( - GNOME_TYPE_CANVAS_ITEM, - "GnomeCanvasWidget", &object_info, 0); - } - - return widget_type; -} +G_DEFINE_TYPE ( + GnomeCanvasWidget, + gnome_canvas_widget, + GNOME_TYPE_CANVAS_ITEM) static void gnome_canvas_widget_class_init (GnomeCanvasWidgetClass *class) diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index 176c990561..1b4019b7b4 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -127,48 +127,16 @@ enum { ITEM_LAST_SIGNAL }; -static void gnome_canvas_item_class_init (GnomeCanvasItemClass *class); -static void gnome_canvas_item_init (GnomeCanvasItem *item); static gint emit_event (GnomeCanvas *canvas, GdkEvent *event); static guint item_signals[ITEM_LAST_SIGNAL]; static GObjectClass *item_parent_class; -/** - * gnome_canvas_item_get_type: - * - * Registers the &GnomeCanvasItem class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GnomeCanvasItem class. - **/ -GType -gnome_canvas_item_get_type (void) -{ - static GType canvas_item_type; - - if (!canvas_item_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasItemClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_item_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvasItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_item_init, - NULL /* value_table */ - }; - - canvas_item_type = g_type_register_static ( - G_TYPE_INITIALLY_UNOWNED, - "GnomeCanvasItem", &object_info, 0); - } - - return canvas_item_type; -} +G_DEFINE_TYPE ( + GnomeCanvasItem, + gnome_canvas_item, + G_TYPE_INITIALLY_UNOWNED) /* Object initialization function for GnomeCanvasItem */ static void @@ -1153,7 +1121,8 @@ gnome_canvas_item_get_bounds (GnomeCanvasItem *item, /* Get the item's bounds in its coordinate system */ if (GNOME_CANVAS_ITEM_GET_CLASS (item)->bounds) - (* GNOME_CANVAS_ITEM_GET_CLASS (item)->bounds) (item, &tx1, &ty1, &tx2, &ty2); + GNOME_CANVAS_ITEM_GET_CLASS (item)->bounds ( + item, &tx1, &ty1, &tx2, &ty2); /* Make the bounds relative to the item's parent coordinate system */ gnome_canvas_matrix_transform_rect (&item->matrix, &tx1, &ty1, &tx2, &ty2); @@ -1206,8 +1175,6 @@ enum { GROUP_PROP_Y }; -static void gnome_canvas_group_class_init (GnomeCanvasGroupClass *class); -static void gnome_canvas_group_init (GnomeCanvasGroup *group); static void gnome_canvas_group_set_property (GObject *object, guint property_id, const GValue *value, @@ -1239,40 +1206,10 @@ static void gnome_canvas_group_bounds (GnomeCanvasItem *item, static GnomeCanvasItemClass *group_parent_class; -/** - * gnome_canvas_group_get_type: - * - * Registers the &GnomeCanvasGroup class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GnomeCanvasGroup class. - **/ -GType -gnome_canvas_group_get_type (void) -{ - static GType canvas_group_type; - - if (!canvas_group_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasGroupClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_group_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvasGroup), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_group_init, - NULL /* value_table */ - }; - - canvas_group_type = g_type_register_static ( - GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasGroup", - &object_info, 0); - } - - return canvas_group_type; -} +G_DEFINE_TYPE ( + GnomeCanvasGroup, + gnome_canvas_group, + GNOME_TYPE_CANVAS_ITEM) /* Class initialization function for GnomeCanvasGroupClass */ static void @@ -1717,8 +1654,6 @@ enum { LAST_SIGNAL }; -static void gnome_canvas_class_init (GnomeCanvasClass *class); -static void gnome_canvas_init (GnomeCanvas *canvas); static void gnome_canvas_dispose (GObject *object); static void gnome_canvas_map (GtkWidget *widget); static void gnome_canvas_unmap (GtkWidget *widget); @@ -1757,6 +1692,11 @@ enum { PROP_FOCUSED_ITEM, }; +G_DEFINE_TYPE ( + GnomeCanvas, + gnome_canvas, + GTK_TYPE_LAYOUT) + static void gnome_canvas_paint_rect (GnomeCanvas *canvas, cairo_t *cr, @@ -1822,40 +1762,6 @@ gnome_canvas_paint_rect (GnomeCanvas *canvas, } } -/** - * gnome_canvas_get_type: - * - * Registers the &GnomeCanvas class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &GnomeCanvas class. - **/ -GType -gnome_canvas_get_type (void) -{ - static GType canvas_type; - - if (!canvas_type) { - const GTypeInfo object_info = { - sizeof (GnomeCanvasClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gnome_canvas_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (GnomeCanvas), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_canvas_init, - NULL /* value_table */ - }; - - canvas_type = g_type_register_static (GTK_TYPE_LAYOUT, "GnomeCanvas", - &object_info, 0); - } - - return canvas_type; -} - static void gnome_canvas_get_property (GObject *object, guint property_id, @@ -1890,15 +1796,15 @@ gnome_canvas_set_property (GObject *object, /* Class initialization function for GnomeCanvasClass */ static void -gnome_canvas_class_init (GnomeCanvasClass *klass) +gnome_canvas_class_init (GnomeCanvasClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; - object_class = (GObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; + object_class = (GObjectClass *) class; + widget_class = (GtkWidgetClass *) class; - canvas_parent_class = g_type_class_peek_parent (klass); + 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; @@ -1920,8 +1826,8 @@ gnome_canvas_class_init (GnomeCanvasClass *klass) widget_class->focus_in_event = gnome_canvas_focus_in; widget_class->focus_out_event = gnome_canvas_focus_out; - klass->draw_background = gnome_canvas_draw_background; - klass->request_update = gnome_canvas_request_update_real; + class->draw_background = gnome_canvas_draw_background; + class->request_update = gnome_canvas_request_update_real; g_object_class_install_property (object_class, PROP_FOCUSED_ITEM, g_param_spec_object ("focused_item", NULL, NULL, @@ -2264,7 +2170,8 @@ gnome_canvas_size_allocate (GtkWidget *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 (canvas_parent_class)->size_allocate ( + widget, allocation); scrollable = GTK_SCROLLABLE (widget); hadjustment = gtk_scrollable_get_hadjustment (scrollable); @@ -2993,7 +2900,7 @@ gnome_canvas_set_scroll_region (GnomeCanvas *canvas, canvas->need_repick = TRUE; #if 0 /* todo: should be requesting update */ - (* GNOME_CANVAS_ITEM_CLASS (canvas->root->object.klass)->update) ( + (* GNOME_CANVAS_ITEM_CLASS (canvas->root->object.class)->update) ( canvas->root, NULL, NULL, 0); #endif } |