summaryrefslogtreecommitdiffstats
path: root/src/text-context.cpp
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2013-01-26 16:18:08 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2013-01-26 16:18:08 +0000
commit55b2e59196c6e980bdb3f03379de6707dd91082b (patch)
tree8502ac20fa9c4bd4ffa4aee6da3f52a0e906c199 /src/text-context.cpp
parentfix crash (diff)
downloadinkscape-55b2e59196c6e980bdb3f03379de6707dd91082b.tar.gz
inkscape-55b2e59196c6e980bdb3f03379de6707dd91082b.zip
More GObject boilerplate reduction
(bzr r12064)
Diffstat (limited to 'src/text-context.cpp')
-rw-r--r--src/text-context.cpp41
1 files changed, 9 insertions, 32 deletions
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
}