From 4cff9f1b30d110eba814d9adc0689fa073c79157 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 31 Dec 2012 12:20:39 +0000 Subject: Replace C-style pointer casts in event contexts (bzr r12001) --- src/text-context.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/text-context.cpp') diff --git a/src/text-context.cpp b/src/text-context.cpp index d4b53f6a4..90715b805 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -104,10 +104,10 @@ GType sp_text_context_get_type() static void sp_text_context_class_init(SPTextContextClass *klass) { - GObjectClass *object_class=(GObjectClass *)klass; - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; + GObjectClass *object_class=G_OBJECT_CLASS(klass); + SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_text_context_dispose; @@ -236,8 +236,8 @@ static void sp_text_context_setup(SPEventContext *ec) } } - if (((SPEventContextClass *) parent_class)->setup) - ((SPEventContextClass *) parent_class)->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); ec->shape_editor = new ShapeEditor(ec->desktop); @@ -455,8 +455,8 @@ static gint sp_text_context_item_handler(SPEventContext *event_context, SPItem * } if (!ret) { - if (((SPEventContextClass *) parent_class)->item_handler) - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) + ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler(event_context, item, event); } return ret; @@ -1324,8 +1324,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } // if nobody consumed it so far - if (((SPEventContextClass *) parent_class)->root_handler) { // and there's a handler in parent context, - return ((SPEventContextClass *) parent_class)->root_handler(event_context, event); // send event to parent + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { // and there's a handler in parent context, + return (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); // send event to parent } else { return FALSE; // return "I did nothing" value so that global shortcuts can be activated } @@ -1428,7 +1428,7 @@ SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec) SPObject const *obj = sp_te_object_at_position(tc->text, tc->text_sel_end); if (obj) - return take_style_from_item((SPItem *) obj); + return take_style_from_item(SP_ITEM(obj)); return NULL; } -- cgit v1.2.3 From 55b2e59196c6e980bdb3f03379de6707dd91082b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 16:18:08 +0000 Subject: More GObject boilerplate reduction (bzr r12064) --- src/text-context.cpp | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'src/text-context.cpp') diff --git a/src/text-context.cpp b/src/text-context.cpp index 90715b805..1ee21e732 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -57,8 +57,6 @@ using Inkscape::ControlManager; using Inkscape::DocumentUndo; -static void sp_text_context_class_init(SPTextContextClass *klass); -static void sp_text_context_init(SPTextContext *text_context); static void sp_text_context_dispose(GObject *obj); static void sp_text_context_setup(SPEventContext *ec); @@ -81,34 +79,13 @@ static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, SPTextContext static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, SPTextContext *tc); static void sptc_commit(GtkIMContext *imc, gchar *string, SPTextContext *tc); -static SPEventContextClass *parent_class; - -GType sp_text_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTextContextClass), - NULL, NULL, - (GClassInitFunc) sp_text_context_class_init, - NULL, NULL, - sizeof(SPTextContext), - 4, - (GInstanceInitFunc) sp_text_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPTextContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPTextContext, sp_text_context, SP_TYPE_EVENT_CONTEXT); static void sp_text_context_class_init(SPTextContextClass *klass) { GObjectClass *object_class=G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_text_context_dispose; event_context_class->setup = sp_text_context_setup; @@ -173,8 +150,8 @@ static void sp_text_context_dispose(GObject *obj) tc->text_sel_end.~iterator(); tc->text_sel_start.~iterator(); tc->text_selection_quads.~vector(); - if (G_OBJECT_CLASS(parent_class)->dispose) { - G_OBJECT_CLASS(parent_class)->dispose(obj); + if (G_OBJECT_CLASS(sp_text_context_parent_class)->dispose) { + G_OBJECT_CLASS(sp_text_context_parent_class)->dispose(obj); } if (tc->grabbed) { sp_canvas_item_ungrab(tc->grabbed, GDK_CURRENT_TIME); @@ -236,8 +213,8 @@ static void sp_text_context_setup(SPEventContext *ec) } } - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->setup(ec); ec->shape_editor = new ShapeEditor(ec->desktop); @@ -455,8 +432,8 @@ static gint sp_text_context_item_handler(SPEventContext *event_context, SPItem * } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler(event_context, item, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->item_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->item_handler(event_context, item, event); } return ret; @@ -1324,8 +1301,8 @@ static gint sp_text_context_root_handler(SPEventContext *const event_context, Gd } // if nobody consumed it so far - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { // and there's a handler in parent context, - return (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); // send event to parent + if ((SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->root_handler) { // and there's a handler in parent context, + return (SP_EVENT_CONTEXT_CLASS(sp_text_context_parent_class))->root_handler(event_context, event); // send event to parent } else { return FALSE; // return "I did nothing" value so that global shortcuts can be activated } -- cgit v1.2.3