From 1615436543169f305d1df4d830ed8f5ec5dc75ed Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 19:33:04 +0000 Subject: More GObject boilerplate reduction (bzr r12065) --- src/pencil-context.cpp | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'src/pencil-context.cpp') diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 19a040b24..090a43a25 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -45,9 +45,6 @@ #include "display/curve.h" #include "livarot/Path.h" - -static void sp_pencil_context_class_init(SPPencilContextClass *klass); -static void sp_pencil_context_init(SPPencilContext *pc); static void sp_pencil_context_setup(SPEventContext *ec); static void sp_pencil_context_dispose(GObject *object); @@ -66,34 +63,12 @@ static void fit_and_split(SPPencilContext *pc); static void interpolate(SPPencilContext *pc); static void sketch_interpolate(SPPencilContext *pc); -static SPDrawContextClass *pencil_parent_class; static Geom::Point pencil_drag_origin_w(0, 0); static bool pencil_within_tolerance = false; static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } -/** - * Register SPPencilContext class with Gdk and return its type number. - */ -GType -sp_pencil_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPencilContextClass), - NULL, NULL, - (GClassInitFunc) sp_pencil_context_class_init, - NULL, NULL, - sizeof(SPPencilContext), - 4, - (GInstanceInitFunc) sp_pencil_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPencilContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPencilContext, sp_pencil_context, SP_TYPE_DRAW_CONTEXT); /** * Initialize SPPencilContext vtable. @@ -107,8 +82,6 @@ sp_pencil_context_class_init(SPPencilContextClass *klass) object_class = (GObjectClass *) klass; event_context_class = (SPEventContextClass *) klass; - pencil_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_pencil_context_dispose; event_context_class->setup = sp_pencil_context_setup; @@ -147,8 +120,8 @@ sp_pencil_context_setup(SPEventContext *ec) ec->enableSelectionCue(); } - if (((SPEventContextClass *) pencil_parent_class)->setup) { - ((SPEventContextClass *) pencil_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_pencil_context_parent_class)->setup) { + ((SPEventContextClass *) sp_pencil_context_parent_class)->setup(ec); } SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec); @@ -160,7 +133,7 @@ sp_pencil_context_setup(SPEventContext *ec) static void sp_pencil_context_dispose(GObject *object) { - G_OBJECT_CLASS(pencil_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_pencil_context_parent_class)->dispose(object); } /** Snaps new node relative to the previous node. */ @@ -218,7 +191,7 @@ sp_pencil_context_root_handler(SPEventContext *const ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = ((SPEventContextClass *) pencil_parent_class)->root_handler; + = ((SPEventContextClass *) sp_pencil_context_parent_class)->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } -- cgit v1.2.3