diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-02-06 08:19:53 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx.marker.es> | 2013-02-06 08:19:53 +0000 |
| commit | 549a79b5367ffd259a23fbd18e93199d1c0149b7 (patch) | |
| tree | 9c4ce4a0217afa63b59f32d02a60b848f43a9520 /src | |
| parent | Merge from branch (diff) | |
| parent | Supress Pango error message. (diff) | |
| download | inkscape-549a79b5367ffd259a23fbd18e93199d1c0149b7.tar.gz inkscape-549a79b5367ffd259a23fbd18e93199d1c0149b7.zip | |
Merge from branch
(bzr r11950.1.19)
Diffstat (limited to 'src')
205 files changed, 2699 insertions, 9000 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 46c655f9c..65baec21b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,6 +48,7 @@ all_libs = \ $(INKBOARD_LIBS) \ $(LIBWPG_LIBS) \ $(LIBVISIO_LIBS) \ + $(LIBCDR_LIBS) \ $(DBUS_LIBS) \ $(GDL_LIBS) \ $(IMAGEMAGICK_LIBS) @@ -72,6 +73,7 @@ INCLUDES = \ $(INKBOARD_CFLAGS) \ $(LIBWPG_CFLAGS) \ $(LIBVISIO_CFLAGS) \ + $(LIBCDR_CFLAGS) \ $(DBUS_CFLAGS) \ $(GDL_CFLAGS) \ $(XFT_CFLAGS) \ diff --git a/src/arc-context.cpp b/src/arc-context.cpp index c35e0041f..b5bdf58ef 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -49,8 +49,6 @@ using Inkscape::DocumentUndo; -static void sp_arc_context_class_init(SPArcContextClass *klass); -static void sp_arc_context_init(SPArcContext *arc_context); static void sp_arc_context_dispose(GObject *object); static void sp_arc_context_setup(SPEventContext *ec); @@ -62,35 +60,13 @@ static void sp_arc_drag(SPArcContext *ec, Geom::Point pt, guint state); static void sp_arc_finish(SPArcContext *ec); static void sp_arc_cancel(SPArcContext *ec); -static SPEventContextClass *parent_class; - -GType sp_arc_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPArcContextClass), - NULL, NULL, - (GClassInitFunc) sp_arc_context_class_init, - NULL, NULL, - sizeof(SPArcContext), - 4, - (GInstanceInitFunc) sp_arc_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPArcContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPArcContext, sp_arc_context, SP_TYPE_EVENT_CONTEXT); static void sp_arc_context_class_init(SPArcContextClass *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_arc_context_dispose; event_context_class->setup = sp_arc_context_setup; @@ -127,8 +103,8 @@ static void sp_arc_context_finish(SPEventContext *ec) sp_arc_finish(ac); ac->sel_changed_connection.disconnect(); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->finish(ec); } } @@ -152,7 +128,7 @@ static void sp_arc_context_dispose(GObject *object) delete ac->_message_context; - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_arc_context_parent_class)->dispose(object); } /** @@ -174,8 +150,8 @@ static void sp_arc_context_setup(SPEventContext *ec) SPArcContext *ac = SP_ARC_CONTEXT(ec); Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -219,8 +195,8 @@ static gint sp_arc_context_item_handler(SPEventContext *event_context, SPItem *i break; } - 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_arc_context_parent_class))->item_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler(event_context, item, event); } return ret; @@ -401,8 +377,8 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 38327b413..0527dad4e 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -209,9 +209,9 @@ void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags) { } // Find parent value for same property (property) - gchar const * property_p = NULL; gchar const * value_p = NULL; if( css_parent != NULL ) { + gchar const * property_p = NULL; for ( List<AttributeRecord const> iter_p = css_parent->attributeList() ; iter_p ; ++iter_p ) { property_p = g_quark_to_string(iter_p->key); diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index a58059e89..1af5ed29f 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -53,8 +53,6 @@ using Inkscape::DocumentUndo; -static void sp_box3d_context_class_init(Box3DContextClass *klass); -static void sp_box3d_context_init(Box3DContext *box3d_context); static void sp_box3d_context_dispose(GObject *object); static void sp_box3d_context_setup(SPEventContext *ec); @@ -66,34 +64,13 @@ static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem static void sp_box3d_drag(Box3DContext &bc, guint state); static void sp_box3d_finish(Box3DContext *bc); -static SPEventContextClass *parent_class; - -GType sp_box3d_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(Box3DContextClass), - NULL, NULL, - (GClassInitFunc) sp_box3d_context_class_init, - NULL, NULL, - sizeof(Box3DContext), - 4, - (GInstanceInitFunc) sp_box3d_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "Box3DContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(Box3DContext, sp_box3d_context, SP_TYPE_EVENT_CONTEXT); static void sp_box3d_context_class_init(Box3DContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_box3d_context_dispose; event_context_class->setup = sp_box3d_context_setup; @@ -135,8 +112,8 @@ static void sp_box3d_context_finish(SPEventContext *ec) bc->sel_changed_connection.disconnect(); // sp_repr_remove_listener_by_data(cc->active_shape_repr, cc); - if (((SPEventContextClass *) parent_class)->finish) { - ((SPEventContextClass *) parent_class)->finish(ec); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->finish) { + ((SPEventContextClass *) sp_box3d_context_parent_class)->finish(ec); } } @@ -166,7 +143,7 @@ static void sp_box3d_context_dispose(GObject *object) delete bc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_box3d_context_parent_class)->dispose(object); } /** @@ -211,8 +188,8 @@ static void sp_box3d_context_setup(SPEventContext *ec) { Box3DContext *bc = SP_BOX3D_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->setup) { + ((SPEventContextClass *) sp_box3d_context_parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -259,8 +236,8 @@ static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem break; } - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler) { + ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -572,8 +549,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 42268ec83..fc18207b0 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -26,9 +26,6 @@ struct SPPathClass; -static void box3d_side_class_init (Box3DSideClass *klass); -static void box3d_side_init (Box3DSide *side); - static void box3d_side_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *box3d_side_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void box3d_side_set (SPObject *object, unsigned int key, const gchar *value); @@ -38,34 +35,12 @@ static void box3d_side_set_shape (SPShape *shape); static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); -static SPShapeClass *parent_class; - -GType -box3d_side_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (Box3DSideClass), - NULL, NULL, - (GClassInitFunc) box3d_side_class_init, - NULL, NULL, - sizeof (Box3DSide), - 16, - (GInstanceInitFunc) box3d_side_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_SHAPE, "Box3DSide", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(Box3DSide, box3d_side, SP_TYPE_SHAPE); static void box3d_side_class_init(Box3DSideClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); SPShapeClass *shape_class = reinterpret_cast<SPShapeClass *>(klass); - parent_class = SP_SHAPE_CLASS(g_type_class_ref (SP_TYPE_SHAPE)); sp_object_class->build = box3d_side_build; sp_object_class->write = box3d_side_write; @@ -85,8 +60,8 @@ box3d_side_init (Box3DSide * side) static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if ((SP_OBJECT_CLASS(parent_class))->build) { - (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(box3d_side_parent_class))->build) { + (SP_OBJECT_CLASS(box3d_side_parent_class))->build(object, document, repr); } object->readAttr( "inkscape:box3dsidetype" ); @@ -119,8 +94,8 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: repr->setAttribute("d", d); g_free (d); - if ((SP_OBJECT_CLASS(parent_class))->write) - (SP_OBJECT_CLASS(parent_class))->write (object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(box3d_side_parent_class))->write) + (SP_OBJECT_CLASS(box3d_side_parent_class))->write (object, xml_doc, repr, flags); return repr; } @@ -153,8 +128,8 @@ box3d_side_set (SPObject *object, unsigned int key, const gchar *value) } break; default: - if ((SP_OBJECT_CLASS(parent_class))->set) - (SP_OBJECT_CLASS(parent_class))->set (object, key, value); + if ((SP_OBJECT_CLASS(box3d_side_parent_class))->set) + (SP_OBJECT_CLASS(box3d_side_parent_class))->set (object, key, value); break; } } @@ -172,8 +147,8 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) static_cast<SPShape *>(object)->setShape (); } - if ((SP_OBJECT_CLASS(parent_class))->update) - (SP_OBJECT_CLASS(parent_class))->update (object, ctx, flags); + if ((SP_OBJECT_CLASS(box3d_side_parent_class))->update) + (SP_OBJECT_CLASS(box3d_side_parent_class))->update (object, ctx, flags); } /* Create a new Box3DSide and append it to the parent box */ diff --git a/src/box3d.cpp b/src/box3d.cpp index 0cb139458..ed0f717d4 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -39,9 +39,6 @@ #include "desktop-handles.h" #include "macros.h" -static void box3d_class_init(SPBox3DClass *klass); -static void box3d_init(SPBox3D *box3d); - static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void box3d_release(SPObject *object); static void box3d_set(SPObject *object, unsigned int key, const gchar *value); @@ -54,41 +51,15 @@ static void box3d_convert_to_guides(SPItem *item); static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, SPBox3D *box); -static SPGroupClass *parent_class; - static gint counter = 0; -GType -box3d_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPBox3DClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) box3d_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPBox3D), - 16, /* n_preallocs */ - (GInstanceInitFunc) box3d_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GROUP, "SPBox3D", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPBox3D, box3d, SP_TYPE_GROUP); static void box3d_class_init(SPBox3DClass *klass) { SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); SPItemClass *item_class = SP_ITEM_CLASS(klass); - parent_class = SP_GROUP_CLASS(g_type_class_ref(SP_TYPE_GROUP)); - sp_object_class->build = box3d_build; sp_object_class->release = box3d_release; sp_object_class->set = box3d_set; @@ -109,8 +80,8 @@ box3d_init(SPBox3D *box) static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if ((SP_OBJECT_CLASS(parent_class))->build) { - (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(box3d_parent_class))->build) { + (SP_OBJECT_CLASS(box3d_parent_class))->build(object, document, repr); } SPBox3D *box = SP_BOX3D (object); @@ -172,8 +143,8 @@ box3d_release(SPObject *object) */ } - if ((SP_OBJECT_CLASS(parent_class))->release) - (SP_OBJECT_CLASS(parent_class))->release(object); + if ((SP_OBJECT_CLASS(box3d_parent_class))->release) + (SP_OBJECT_CLASS(box3d_parent_class))->release(object); } static void @@ -224,8 +195,8 @@ box3d_set(SPObject *object, unsigned int key, const gchar *value) } break; default: - if ((SP_OBJECT_CLASS(parent_class))->set) { - (SP_OBJECT_CLASS(parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(box3d_parent_class))->set) { + (SP_OBJECT_CLASS(box3d_parent_class))->set(object, key, value); } break; } @@ -259,8 +230,8 @@ box3d_update(SPObject *object, SPCtx *ctx, guint flags) } // Invoke parent method - if ((SP_OBJECT_CLASS(parent_class))->update) - (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(box3d_parent_class))->update) + (SP_OBJECT_CLASS(box3d_parent_class))->update(object, ctx, flags); } @@ -306,8 +277,8 @@ static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Docume box->save_corner7 = box->orig_corner7; } - if ((SP_OBJECT_CLASS(parent_class))->write) { - (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(box3d_parent_class))->write) { + (SP_OBJECT_CLASS(box3d_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/common-context.cpp b/src/common-context.cpp index 9d5dbb048..ff99b5c0b 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -19,8 +19,6 @@ #define DRAG_MAX 1.0 -static void sp_common_context_class_init(SPCommonContextClass *klass); -static void sp_common_context_init(SPCommonContext *erc); static void sp_common_context_dispose(GObject *object); static void sp_common_context_setup(SPEventContext *ec); @@ -28,38 +26,13 @@ static void sp_common_context_set(SPEventContext *ec, Inkscape::Preferences::Ent static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEvent *event); - -static SPEventContextClass *common_parent_class = 0; - -GType sp_common_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCommonContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_common_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPCommonContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_common_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPCommonContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} - +G_DEFINE_TYPE(SPCommonContext, sp_common_context, SP_TYPE_EVENT_CONTEXT); static void sp_common_context_class_init(SPCommonContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - common_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_common_context_dispose; event_context_class->setup = sp_common_context_setup; @@ -144,14 +117,14 @@ static void sp_common_context_dispose(GObject *object) ctx->_message_context = 0; } - G_OBJECT_CLASS(common_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_common_context_parent_class)->dispose(object); } static void sp_common_context_setup(SPEventContext *ec) { - if ( common_parent_class->setup ) { - common_parent_class->setup(ec); + if ( SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->setup ) { + SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->setup(ec); } } @@ -199,8 +172,8 @@ static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEve if ( !ret ) { - if ( common_parent_class->root_handler ) { - ret = common_parent_class->root_handler(event_context, event); + if ( SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->root_handler ) { + ret = SP_EVENT_CONTEXT_CLASS(sp_common_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 24a7203ac..9631eecb1 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -109,8 +109,6 @@ using Inkscape::DocumentUndo; -static void sp_connector_context_class_init(SPConnectorContextClass *klass); -static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); static void sp_connector_context_setup(SPEventContext *ec); @@ -156,8 +154,6 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ -static SPEventContextClass *parent_class; - static Inkscape::XML::NodeEventVector shape_repr_events = { NULL, /* child_added */ @@ -175,26 +171,7 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; - -GType -sp_connector_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPConnectorContextClass), - NULL, NULL, - (GClassInitFunc) sp_connector_context_class_init, - NULL, NULL, - sizeof(SPConnectorContext), - 4, - (GInstanceInitFunc) sp_connector_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPConnectorContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); static void sp_connector_context_class_init(SPConnectorContextClass *klass) @@ -202,8 +179,6 @@ sp_connector_context_class_init(SPConnectorContextClass *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_connector_context_dispose; event_context_class->setup = sp_connector_context_setup; @@ -283,7 +258,7 @@ sp_connector_context_dispose(GObject *object) } g_assert( cc->newConnRef == NULL ); - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); } @@ -293,8 +268,8 @@ sp_connector_context_setup(SPEventContext *ec) SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); } cc->selection = sp_desktop_selection(dt); @@ -358,8 +333,8 @@ sp_connector_context_finish(SPEventContext *ec) spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); } if (cc->selection) { @@ -560,7 +535,7 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler; + = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 1cfe018ce..9942e3a13 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -196,7 +196,6 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge sp_guideline_set_position(SP_GUIDELINE(guide), event_dt); desktop->set_coordinate_status(event_dt); - desktop->setPosition(event_dt); } break; case GDK_BUTTON_RELEASE: @@ -395,7 +394,6 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } moved = true; desktop->set_coordinate_status(motion_dt); - desktop->setPosition(motion_dt); ret = TRUE; } @@ -483,7 +481,6 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } moved = false; desktop->set_coordinate_status(event_dt); - desktop->setPosition (event_dt); } drag_type = SP_DRAG_NONE; sp_canvas_item_ungrab(item, event->button.time); diff --git a/src/desktop.cpp b/src/desktop.cpp index ea23ebb9c..c7a763ae1 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1539,12 +1539,6 @@ void SPDesktop::toggleSnapGlobal() // Callback implementations. The virtual ones are connected by the view. void -SPDesktop::onPositionSet (double x, double y) -{ - _widget->viewSetPosition (Geom::Point(x,y)); -} - -void SPDesktop::onResized (double /*x*/, double /*y*/) { // Nothing called here diff --git a/src/desktop.h b/src/desktop.h index 529199692..93cf3201c 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -431,7 +431,6 @@ private: sigc::connection _commit_connection; sigc::connection _modified_connection; - virtual void onPositionSet (double, double); virtual void onResized (double, double); virtual void onRedrawRequested(); virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message); diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 692e31837..8eeee0277 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -27,6 +27,17 @@ #include "style.h" #include "helper/geom-curves.h" +namespace { + +/** + * Key for cairo_surface_t to keep track of current color interpolation value + * Only the address of the structure is used, it is never initialized. See: + * http://www.cairographics.org/manual/cairo-Types.html#cairo-user-data-key-t + */ +cairo_user_data_key_t ci_key; + +} // namespace + namespace Inkscape { CairoGroup::CairoGroup(cairo_t *_ct) : ct(_ct), pushed(false) {} @@ -586,11 +597,11 @@ void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, a = CLAMP(a, 0.0, 1.0); } -void srgb_to_linear( guint32* c, guint32 a ) { +static guint32 srgb_to_linear( const guint32 c, const guint32 a ) { - *c = unpremul_alpha( *c, a ); + const guint32 c1 = unpremul_alpha( c, a ); - double cc = *c/255.0; + double cc = c1/255.0; if( cc < 0.04045 ) { cc /= 12.92; @@ -599,16 +610,16 @@ void srgb_to_linear( guint32* c, guint32 a ) { } cc *= 255.0; - *c = (int)cc; + const guint32 c2 = (int)cc; - *c = premul_alpha( *c, a ); + return premul_alpha( c2, a ); } -void linear_to_srgb( guint32* c, guint32 a ) { +static guint32 linear_to_srgb( const guint32 c, const guint32 a ) { - *c = unpremul_alpha( *c, a ); + const guint32 c1 = unpremul_alpha( c, a ); - double cc = *c/255.0; + double cc = c1/255.0; if( cc < 0.0031308 ) { cc *= 12.92; @@ -617,9 +628,9 @@ void linear_to_srgb( guint32* c, guint32 a ) { } cc *= 255.0; - *c = (int)cc; + const guint32 c2 = (int)cc; - *c = premul_alpha( *c, a ); + return premul_alpha( c2, a ); } int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) @@ -636,9 +647,9 @@ int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) guint32 px = *reinterpret_cast<guint32*>(data + 4*x); EXTRACT_ARGB32(px, a,r,g,b) ; // Unneeded semi-colon for indenting if( a != 0 ) { - srgb_to_linear( &r, a ); - srgb_to_linear( &g, a ); - srgb_to_linear( &b, a ); + r = srgb_to_linear( r, a ); + g = srgb_to_linear( g, a ); + b = srgb_to_linear( b, a ); } ASSEMBLE_ARGB32(px2, a,r,g,b); *reinterpret_cast<guint32*>(data + 4*x) = px2; @@ -661,9 +672,9 @@ int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface) guint32 px = *reinterpret_cast<guint32*>(data + 4*x); EXTRACT_ARGB32(px, a,r,g,b) ; // Unneeded semi-colon for indenting if( a != 0 ) { - linear_to_srgb( &r, a ); - linear_to_srgb( &g, a ); - linear_to_srgb( &b, a ); + r = linear_to_srgb( r, a ); + g = linear_to_srgb( g, a ); + b = linear_to_srgb( b, a ); } ASSEMBLE_ARGB32(px2, a,r,g,b); *reinterpret_cast<guint32*>(data + 4*x) = px2; diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index e88c6d4e8..2596cd969 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -82,15 +82,6 @@ public: } // namespace Inkscape -/** - * Key for cairo_surface_t to keep track of current color interpolation value - * Only the address of the structure is used, it is never initialized. See: - * http://www.cairographics.org/manual/cairo-Types.html#cairo-user-data-key-t - */ -// TODO fixme check this usage. A static here in a header file is probably not doing what was intended: -static cairo_user_data_key_t ci_key; - - SPColorInterpolation get_cairo_surface_ci(cairo_surface_t *surface); void set_cairo_surface_ci(cairo_surface_t *surface, SPColorInterpolation cif); void copy_cairo_surface_ci(cairo_surface_t *in, cairo_surface_t *out); @@ -117,6 +108,7 @@ guint32 ink_cairo_surface_average_color(cairo_surface_t *surface); void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a); void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a); +double srgb_to_linear( const double c ); int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface); int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface); @@ -136,13 +128,13 @@ G_GNUC_CONST guint32 argb32_from_rgba(guint32 in); G_GNUC_CONST inline guint32 -premul_alpha(guint32 color, guint32 alpha) +premul_alpha(const guint32 color, const guint32 alpha) { - guint32 temp = alpha * color + 128; + const guint32 temp = alpha * color + 128; return (temp + (temp >> 8)) >> 8; } G_GNUC_CONST inline guint32 -unpremul_alpha(guint32 color, guint32 alpha) +unpremul_alpha(const guint32 color, const guint32 alpha) { // NOTE: you must check for alpha != 0 yourself. return (255 * color + alpha/2) / alpha; @@ -162,6 +154,15 @@ void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); #define ASSEMBLE_ARGB32(px,a,r,g,b) \ guint32 px = (a << 24) | (r << 16) | (g << 8) | b; +inline double srgb_to_linear( const double c ) { + if( c < 0.04045 ) { + return c / 12.92; + } else { + return pow( (c+0.055)/1.055, 2.4 ); + } +} + + namespace Inkscape { namespace Display diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 1e6e44d6f..80664d822 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -550,10 +550,12 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // for overlapping clip children. To fix this we use the SOURCE operator // instead of the default OVER. ict.setOperator(CAIRO_OPERATOR_SOURCE); + ict.paint(); if (_clip) { + ict.pushGroup(); _clip->clip(ict, *carea); // fixme: carea or area? - } else { - // if there is no clipping path, fill the entire surface with alpha = opacity. + ict.popGroupToSource(); + ict.setOperator(CAIRO_OPERATOR_IN); ict.paint(); } ict.setOperator(CAIRO_OPERATOR_OVER); // reset back to default diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index faf56a4ca..c6724e3ba 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -21,6 +21,8 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" +#include "svg/svg-icc-color.h" +#include "svg/svg-color.h" namespace Inkscape { namespace Filters { @@ -126,12 +128,37 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + double r = SP_RGBA32_R_F(lighting_color); + double g = SP_RGBA32_G_F(lighting_color); + double b = SP_RGBA32_B_F(lighting_color); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + + if (icc) { + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + } +#endif + // Only alpha channel of input is used, no need to check input color_interpolation_filter value. SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Lighting color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } set_cairo_surface_ci(out, ci_fp ); + guint32 color = SP_RGBA32_F_COMPOSE( r, g, b, 1.0 ); Geom::Rect slot_area = slot.get_slot_area(); Geom::Point p = slot_area.min(); @@ -142,15 +169,15 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) switch (light_type) { case DISTANT_LIGHT: ink_cairo_surface_synthesize(out, - DiffuseDistantLight(input, light.distant, lighting_color, scale, diffuseConstant)); + DiffuseDistantLight(input, light.distant, color, scale, diffuseConstant)); break; case POINT_LIGHT: ink_cairo_surface_synthesize(out, - DiffusePointLight(input, light.point, lighting_color, trans, scale, diffuseConstant, x0, y0)); + DiffusePointLight(input, light.point, color, trans, scale, diffuseConstant, x0, y0)); break; case SPOT_LIGHT: ink_cairo_surface_synthesize(out, - DiffuseSpotLight(input, light.spot, lighting_color, trans, scale, diffuseConstant, x0, y0)); + DiffuseSpotLight(input, light.spot, color, trans, scale, diffuseConstant, x0, y0)); break; default: { cairo_t *ct = cairo_create(out); @@ -165,6 +192,10 @@ void FilterDiffuseLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } +void FilterDiffuseLighting::set_icc(SVGICCColor *icc_color) { + icc = icc_color; +} + void FilterDiffuseLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 0da6cc218..315bf9f48 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -22,6 +22,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -32,6 +33,7 @@ public: static FilterPrimitive *create(); virtual ~FilterDiffuseLighting(); virtual void render_cairo(FilterSlot &slot); + virtual void set_icc(SVGICCColor *icc_color); virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); @@ -46,6 +48,7 @@ public: guint32 lighting_color; private: + SVGICCColor *icc; }; } /* namespace Filters */ diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 7117e0343..d1fe3e13f 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -45,8 +45,6 @@ void FilterFlood::render_cairo(FilterSlot &slot) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - // DOES THIS REALLY BELONG HERE? SHOULDN'T ICC BE APPLIED AFTER ALL COMPOSITING? - // What if color_interpolation_filter is set to linear RGB? if (icc) { guchar ru, gu, bu; icc_color_to_sRGB(icc, &ru, &gu, &bu); @@ -57,10 +55,21 @@ void FilterFlood::render_cairo(FilterSlot &slot) #endif cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); - // color_interpolation_filter is determined by CSS value (see spec. Turbulence). + + SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { - set_cairo_surface_ci(out, (SPColorInterpolation)_style->color_interpolation_filters.computed ); + ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Flood color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } + set_cairo_surface_ci(out, ci_fp ); // Get filter primitive area in user units Geom::Rect fp = filter_primitive_area( slot.get_units() ); diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 50f1b48c5..2ce02adee 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -21,6 +21,8 @@ #include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" +#include "svg/svg-icc-color.h" +#include "svg/svg-color.h" namespace Inkscape { namespace Filters { @@ -139,12 +141,37 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_t *input = slot.getcairo(_input); cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA); + double r = SP_RGBA32_R_F(lighting_color); + double g = SP_RGBA32_G_F(lighting_color); + double b = SP_RGBA32_B_F(lighting_color); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + + if (icc) { + guchar ru, gu, bu; + icc_color_to_sRGB(icc, &ru, &gu, &bu); + r = SP_COLOR_U_TO_F(ru); + g = SP_COLOR_U_TO_F(gu); + b = SP_COLOR_U_TO_F(bu); + } +#endif + // Only alpha channel of input is used, no need to check input color_interpolation_filter value. SPColorInterpolation ci_fp = SP_CSS_COLOR_INTERPOLATION_AUTO; if( _style ) { ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; + + // Lighting color is always defined in terms of sRGB, preconvert to linearRGB + // if color_interpolation_filters set to linearRGB (for efficiency assuming + // next filter primitive has same value of cif). + if( ci_fp == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) { + r = srgb_to_linear( r ); + g = srgb_to_linear( g ); + b = srgb_to_linear( b ); + } } set_cairo_surface_ci(out, ci_fp ); + guint32 color = SP_RGBA32_F_COMPOSE( r, g, b, 1.0 ); Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); Geom::Point p = slot.get_slot_area().min(); @@ -157,15 +184,15 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) switch (light_type) { case DISTANT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularDistantLight(input, light.distant, lighting_color, scale, ks, se)); + SpecularDistantLight(input, light.distant, color, scale, ks, se)); break; case POINT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularPointLight(input, light.point, lighting_color, trans, scale, ks, se, x0, y0)); + SpecularPointLight(input, light.point, color, trans, scale, ks, se, x0, y0)); break; case SPOT_LIGHT: ink_cairo_surface_synthesize(out, - SpecularSpotLight(input, light.spot, lighting_color, trans, scale, ks, se, x0, y0)); + SpecularSpotLight(input, light.spot, color, trans, scale, ks, se, x0, y0)); break; default: { cairo_t *ct = cairo_create(out); @@ -180,6 +207,10 @@ void FilterSpecularLighting::render_cairo(FilterSlot &slot) cairo_surface_destroy(out); } +void FilterSpecularLighting::set_icc(SVGICCColor *icc_color) { + icc = icc_color; +} + void FilterSpecularLighting::area_enlarge(Geom::IntRect &area, Geom::Affine const & /*trans*/) { // TODO: support kernelUnitLength diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 33ea17a87..4f8c2d112 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -20,6 +20,7 @@ class SPFeDistantLight; class SPFePointLight; class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -33,6 +34,7 @@ public: virtual ~FilterSpecularLighting(); virtual void render_cairo(FilterSlot &slot); + virtual void set_icc(SVGICCColor *icc_color); virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); @@ -48,6 +50,7 @@ public: guint32 lighting_color; private: + SVGICCColor *icc; }; } /* namespace Filters */ diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index eb51860ab..8b20ab2de 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -227,21 +227,6 @@ public: static int pickCurrentItem(SPCanvas *canvas, GdkEvent *event); /** - * Class initialization function for SPCanvasClass. - */ - static void classInit(SPCanvasClass *klass); - - /** - * Callback: object initialization for SPCanvas. - */ - static void init(SPCanvas *canvas); - - /** - * Destroy handler for SPCanvas. - */ - static void dispose(GObject *object); - - /** * The canvas widget's realize callback. */ static void realize(GtkWidget *widget); @@ -369,25 +354,11 @@ public: static void add_idle(SPCanvas *canvas); /** - * Convenience function to remove the idle handler of a canvas. - */ - static void remove_idle(SPCanvas *canvas); - - /** - * Removes the transient state of the canvas (idle handler, grabs). - */ - static void shutdown_transients(SPCanvas *canvas); - - /** * Update callback for canvas widget. */ static void requestCanvasUpdate(SPCanvas *canvas); - - static GtkWidgetClass *parentClass; }; -GtkWidgetClass *SPCanvasImpl::parentClass = 0; - GType SPCanvasItem::getType() { static GType object_type = 0; @@ -437,9 +408,9 @@ void sp_canvas_item_class_init(SPCanvasItemClass *klass) G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT); - gobject_class->dispose = sp_canvas_item_dispose; + gobject_class->dispose = sp_canvas_item_dispose; gobject_class->finalize = sp_canvas_item_finalize; - klass->destroy = sp_canvas_item_real_destroy; + klass->destroy = sp_canvas_item_real_destroy; object_signals[DESTROY] = g_signal_new ("destroy", @@ -1218,68 +1189,46 @@ void SPCanvasGroup::remove(SPCanvasItem *item) } } -/** - * Registers the SPCanvas class if necessary, and returns the type ID - * associated to it. - * - * @return The type ID of the SPCanvas class. - */ -GType SPCanvas::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCanvasClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)SPCanvasImpl::classInit, - 0, // class_finalize - 0, // class_data - sizeof(SPCanvas), - 0, // n_preallocs - (GInstanceInitFunc)SPCanvasImpl::init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_WIDGET, "SPCanvas", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +static void sp_canvas_dispose (GObject *object); +static void sp_canvas_shutdown_transients(SPCanvas *canvas); -void SPCanvasImpl::classInit(SPCanvasClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; +G_DEFINE_TYPE(SPCanvas, sp_canvas, GTK_TYPE_WIDGET); - parentClass = reinterpret_cast<GtkWidgetClass *>(g_type_class_peek_parent(klass)); +static void +sp_canvas_class_init(SPCanvasClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - object_class->dispose = SPCanvasImpl::dispose; + object_class->dispose = sp_canvas_dispose; - widget_class->realize = SPCanvasImpl::realize; - widget_class->unrealize = SPCanvasImpl::unrealize; + widget_class->realize = SPCanvasImpl::realize; + widget_class->unrealize = SPCanvasImpl::unrealize; #if GTK_CHECK_VERSION(3,0,0) - widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth; + widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth; widget_class->get_preferred_height = SPCanvasImpl::getPreferredHeight; - widget_class->draw = SPCanvasImpl::handleDraw; + widget_class->draw = SPCanvasImpl::handleDraw; #else - widget_class->size_request = SPCanvasImpl::sizeRequest; - widget_class->expose_event = SPCanvasImpl::handleExpose; + widget_class->size_request = SPCanvasImpl::sizeRequest; + widget_class->expose_event = SPCanvasImpl::handleExpose; #endif - widget_class->size_allocate = SPCanvasImpl::sizeAllocate; - widget_class->button_press_event = SPCanvasImpl::button; + widget_class->size_allocate = SPCanvasImpl::sizeAllocate; + widget_class->button_press_event = SPCanvasImpl::button; widget_class->button_release_event = SPCanvasImpl::button; - widget_class->motion_notify_event = SPCanvasImpl::handleMotion; - widget_class->scroll_event = SPCanvasImpl::handleScroll; - widget_class->key_press_event = SPCanvasImpl::handleKeyEvent; - widget_class->key_release_event = SPCanvasImpl::handleKeyEvent; - widget_class->enter_notify_event = SPCanvasImpl::handleCrossing; - widget_class->leave_notify_event = SPCanvasImpl::handleCrossing; - widget_class->focus_in_event = SPCanvasImpl::handleFocusIn; - widget_class->focus_out_event = SPCanvasImpl::handleFocusOut; + widget_class->motion_notify_event = SPCanvasImpl::handleMotion; + widget_class->scroll_event = SPCanvasImpl::handleScroll; + widget_class->key_press_event = SPCanvasImpl::handleKeyEvent; + widget_class->key_release_event = SPCanvasImpl::handleKeyEvent; + widget_class->enter_notify_event = SPCanvasImpl::handleCrossing; + widget_class->leave_notify_event = SPCanvasImpl::handleCrossing; + widget_class->focus_in_event = SPCanvasImpl::handleFocusIn; + widget_class->focus_out_event = SPCanvasImpl::handleFocusOut; } -void SPCanvasImpl::init(SPCanvas *canvas) +static void +sp_canvas_init(SPCanvas *canvas) { gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); @@ -1318,7 +1267,7 @@ void SPCanvasImpl::init(SPCanvas *canvas) canvas->is_scrolling = false; } -void SPCanvasImpl::remove_idle(SPCanvas *canvas) +static void sp_canvas_remove_idle(SPCanvas *canvas) { if (canvas->idle_id) { g_source_remove (canvas->idle_id); @@ -1326,7 +1275,8 @@ void SPCanvasImpl::remove_idle(SPCanvas *canvas) } } -void SPCanvasImpl::shutdown_transients(SPCanvas *canvas) +static void +sp_canvas_shutdown_transients(SPCanvas *canvas) { // We turn off the need_redraw flag, since if the canvas is mapped again // it will request a redraw anyways. We do not turn off the need_update @@ -1352,10 +1302,11 @@ void SPCanvasImpl::shutdown_transients(SPCanvas *canvas) #endif } - remove_idle(canvas); + sp_canvas_remove_idle(canvas); } -void SPCanvasImpl::dispose(GObject *object) +static void +sp_canvas_dispose(GObject *object) { SPCanvas *canvas = SP_CANVAS(object); @@ -1364,12 +1315,12 @@ void SPCanvasImpl::dispose(GObject *object) canvas->root = NULL; } - shutdown_transients(canvas); + sp_canvas_shutdown_transients(canvas); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) canvas->cms_key.~ustring(); #endif - if (G_OBJECT_CLASS(parentClass)->dispose) { - (* G_OBJECT_CLASS(parentClass)->dispose)(object); + if (G_OBJECT_CLASS(sp_canvas_parent_class)->dispose) { + (* G_OBJECT_CLASS(sp_canvas_parent_class)->dispose)(object); } } @@ -1388,7 +1339,7 @@ void trackLatency(GdkEvent const *event) GtkWidget *SPCanvas::createAA() { - SPCanvas *canvas = reinterpret_cast<SPCanvas *>(g_object_new(SPCanvas::getType(), NULL)); + SPCanvas *canvas = SP_CANVAS(g_object_new(SP_TYPE_CANVAS, NULL)); return GTK_WIDGET(canvas); } @@ -1456,10 +1407,10 @@ void SPCanvasImpl::unrealize(GtkWidget *widget) canvas->grabbed_item = NULL; canvas->focused_item = NULL; - shutdown_transients(canvas); + sp_canvas_shutdown_transients(canvas); - if (GTK_WIDGET_CLASS(parentClass)->unrealize) - (* GTK_WIDGET_CLASS(parentClass)->unrealize)(widget); + if (GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize) + (* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget); } diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index f0366a2e5..b570b739e 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS -#define SP_TYPE_CANVAS (SPCanvas::getType()) +#define SP_TYPE_CANVAS (sp_canvas_get_type()) #define SP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS, SPCanvas)) #define SP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS)) @@ -71,14 +71,14 @@ G_END_DECLS class SPCanvasImpl; +GType sp_canvas_get_type() G_GNUC_CONST; + /** * Port of GnomeCanvas for inkscape needs. */ struct SPCanvas { friend class SPCanvasImpl; - static GType getType(); - /** * Returns new canvas as widget. */ diff --git a/src/document.cpp b/src/document.cpp index 172037518..97b3bf584 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1435,10 +1435,12 @@ bool SPDocument::isSeeking() const { void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; - Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (SP_ACTIVE_DESKTOP) { + Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); + g_assert(parent != NULL); + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } diff --git a/src/dom/css.h b/src/dom/css.h index 2776b6d20..f270b99eb 100644 --- a/src/dom/css.h +++ b/src/dom/css.h @@ -269,8 +269,8 @@ public: * */ CSSRuleList(const CSSRuleList &other) + : rules (other.rules) { - rules = other.rules; } /** @@ -1012,9 +1012,10 @@ public: /** * */ - CSSFontFaceRule(const CSSFontFaceRule &other) : CSSRule(other) + CSSFontFaceRule(const CSSFontFaceRule &other) + : CSSRule(other), + style (other.style) { - style = other.style; } /** @@ -1433,9 +1434,10 @@ public: /** * */ - CSSValueList(const CSSValueList &other) : CSSValue(other) + CSSValueList(const CSSValueList &other) + : CSSValue(other), + items (other.items) { - items = other.items; } /** @@ -2014,8 +2016,8 @@ public: * */ ElementCSSInlineStyle(const ElementCSSInlineStyle &other) + : style (other.style) { - style = other.style; } /** diff --git a/src/dom/dom.h b/src/dom/dom.h index c12c02869..22fd09ebf 100644 --- a/src/dom/dom.h +++ b/src/dom/dom.h @@ -224,7 +224,8 @@ public: DOMException(const DOMString &reasonMsg) - { msg = reasonMsg; } + : msg (reasonMsg) + { } DOMException(short theCode) { @@ -318,8 +319,8 @@ public: * */ DOMStringList(const DOMStringList &other) + : strings (other.strings) { - strings = other.strings; } /** @@ -369,14 +370,14 @@ private: { public: NamePair(const DOMString &theNamespaceURI, const DOMString &theName) + : namespaceURI (theNamespaceURI), + name (theName) { - namespaceURI = theNamespaceURI; - name = theName; } NamePair(const NamePair &other) + : namespaceURI (other.namespaceURI), + name (other.name) { - namespaceURI = other.namespaceURI; - name = other.name; } NamePair &operator=(const NamePair &other) { @@ -463,8 +464,8 @@ public: * */ NameList(const NameList &other) + : namePairs (other.namePairs) { - namePairs = other.namePairs; } /** @@ -533,8 +534,8 @@ public: * */ DOMImplementationList(const DOMImplementationList &other) + : implementations (other.implementations) { - implementations = other.implementations; } /** @@ -1018,8 +1019,8 @@ public: * */ NodeList(const NodeList &other) + : nodes (other.nodes) { - nodes = other.nodes; } /** @@ -1087,10 +1088,10 @@ private: NamedNodeMapEntry(const DOMString &theNamespaceURI, const DOMString &theName, const NodePtr theNode) + : namespaceURI (theNamespaceURI), + name (theName), + node (theNode) { - namespaceURI = theNamespaceURI; - name = theName; - node = theNode; } NamedNodeMapEntry(const NamedNodeMapEntry &other) { @@ -1277,8 +1278,8 @@ public: * */ NamedNodeMap(const NamedNodeMap &other) + : entries (other.entries) { - entries = other.entries; } /** diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp index 9f25cb3be..3d9a29592 100644 --- a/src/dom/domimpl.cpp +++ b/src/dom/domimpl.cpp @@ -1701,7 +1701,6 @@ void ElementImpl::normalizeNamespaces() if (attrNode->getNodeType() != Node::ATTRIBUTE_NODE) continue; AttrImplPtr attr = reinterpret_cast<AttrImpl *>(attrNode.get()); - DOMString attrNS = attr->getNamespaceURI(); DOMString attrName = attr->getLocalName(); DOMString attrPrefix = attr->getPrefix(); DOMString attrValue = attr->getNodeValue(); @@ -1826,7 +1825,6 @@ void ElementImpl::normalizeNamespaces() AttrPtr attr = reinterpret_cast<Attr *>(attrNode.get()); DOMString attrNS = attr->getNamespaceURI(); DOMString attrPrefix = attr->getPrefix(); - DOMString attrValue = attr->getNodeValue(); if (attrNS == XMLNSNAME) continue; @@ -2360,12 +2358,15 @@ CDATASectionImpl::~CDATASectionImpl() DocumentTypeImpl::DocumentTypeImpl(const DOMString& theName, const DOMString& thePublicId, const DOMString& theSystemId) - : NodeImpl() + : NodeImpl(), + name(), //what with this variable? + publicId(thePublicId), + systemId(theSystemId), + entities(), + notations() { - nodeType = DOCUMENT_TYPE_NODE; - nodeName = theName; - publicId = thePublicId; - systemId = theSystemId; + nodeType = DOCUMENT_TYPE_NODE;//of class NodeImpl + nodeName = theName;//of class NodeImpl } /** @@ -3017,19 +3018,22 @@ NodePtr DocumentImpl::renameNode(const NodePtr node, DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, const DOMString &/*theNamespaceURI*/, const DOMString &theQualifiedName, - const DocumentTypePtr theDoctype) : NodeImpl() -{ - nodeType = DOCUMENT_NODE; - nodeName = "#document"; - parent = const_cast<DOMImplementation *>(domImpl); - //documentURI = stringCache(theNamespaceURI); - qualifiedName = theQualifiedName; + const DocumentTypePtr theDoctype) + : NodeImpl(), + namespaceIndex(0), + parent(const_cast<DOMImplementation *>(domImpl)), + qualifiedName(theQualifiedName), + xmlStandalone(false), + strictErrorChecking(false), + domConfig(NULL) +{ + nodeType = DOCUMENT_NODE;//of class NodeImpl + nodeName = "#document";//of class NodeImpl if (theDoctype.get()) //only assign if not null. doctype = theDoctype; else doctype = new DocumentTypeImpl("", "", ""); documentElement = new ElementImpl(this, "root"); - namespaceIndex = 0; } diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h index 5fe508076..df586f35e 100644 --- a/src/dom/domimpl.h +++ b/src/dom/domimpl.h @@ -526,11 +526,11 @@ protected: UserDataEntry(const DOMString &theKey, const DOMUserData *theData, const UserDataHandler *theHandler) + : next(NULL), + key(theKey), + data(const_cast<DOMUserData *>(theData)), + handler(const_cast<UserDataHandler *>(theHandler)) { - next = NULL; - key = theKey; - data = const_cast<DOMUserData *>(theData); - handler = const_cast<UserDataHandler *>(theHandler); } virtual ~UserDataEntry() @@ -1967,10 +1967,10 @@ protected: next = NULL; } NamedElementItem(const DOMString &nameArg, ElementPtr elemArg) + : next (NULL), + name (nameArg), + elem (elemArg) { - next = NULL; - name = nameArg; - elem = elemArg; } ~NamedElementItem() { diff --git a/src/dom/domptr.h b/src/dom/domptr.h index 5a1299867..aa9d4c208 100644 --- a/src/dom/domptr.h +++ b/src/dom/domptr.h @@ -153,7 +153,7 @@ public: template<class Y> Ptr &operator=(const Y * ref) { decrementRefCount(_ref); - _ref = (Y *) ref; + _ref = const_cast<Y *>(ref); incrementRefCount(_ref); return *this; } diff --git a/src/dom/events.h b/src/dom/events.h index 9f44fe591..59d83afcf 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -643,8 +643,8 @@ public: * */ EventTarget(const EventTarget &other) + : listeners (other.listeners) { - listeners = other.listeners; } /** @@ -704,7 +704,9 @@ public: /** * */ - DocumentEvent() {} + DocumentEvent() + : dispatchable(false) + {} /** * @@ -791,7 +793,10 @@ public: /** * */ - CustomEvent() {} + CustomEvent() + : propagationStopped(false), + immediatePropagationStopped(false) + {} /** * @@ -884,15 +889,19 @@ public: /** * */ - UIEvent() {} + UIEvent() + : view(), + detail(0) + {} /** * */ - UIEvent(const UIEvent &other) : Event(other) + UIEvent(const UIEvent &other) + : Event(other), + view(other.view), + detail(other.detail) { - view = other.view; - detail = other.detail; } /** @@ -1152,7 +1161,18 @@ public: /** * */ - MouseEvent() {} + MouseEvent() + : screenX(0), + screenY(0), + clientX(0), + clientY(0), + ctrlKey(false), + shiftKey(false), + altKey(false), + metaKey(false), + button(0), + relatedTarget(NULL) + {} /** * @@ -1322,7 +1342,14 @@ public: /** * */ - KeyboardEvent() {} + KeyboardEvent() + : keyIdentifier(), + keyLocation(0), + ctrlKey(false), + shiftKey(false), + altKey(false), + metaKey(false) + {} /** * @@ -1472,8 +1499,9 @@ public: * */ MutationEvent() + : relatedNodePtr (NULL), + attrChange(0) { - relatedNodePtr = NULL; } /** diff --git a/src/dom/io/domstream.h b/src/dom/io/domstream.h index b2e308653..1a93e73b2 100644 --- a/src/dom/io/domstream.h +++ b/src/dom/io/domstream.h @@ -51,7 +51,8 @@ class StreamException public: StreamException(const DOMString &theReason) throw() - { reason = theReason; } + : reason(theReason) + {} virtual ~StreamException() throw() { } char const *what() @@ -576,7 +577,13 @@ protected: Writer *destination; BasicWriter() - { destination = NULL; } + { + destination = NULL; + for(int k=0;k<2048;++k) + { + formatBuf[k]=0; + } + } //Used for printf() or other things that might //require formatting before sending down the stream diff --git a/src/dom/io/gzipstream.cpp b/src/dom/io/gzipstream.cpp index e1f9f9a60..2a2f8a5b5 100644 --- a/src/dom/io/gzipstream.cpp +++ b/src/dom/io/gzipstream.cpp @@ -188,7 +188,7 @@ void GzipOutputStream::close() */ void GzipOutputStream::flush() { - if (closed || buffer.size()<1) + if (closed || buffer.empty()) return; std::vector<unsigned char> compBuf; diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp index 94b0adeb7..d4da0d5ce 100644 --- a/src/dom/lsimpl.cpp +++ b/src/dom/lsimpl.cpp @@ -227,7 +227,7 @@ bool LSSerializerImpl::writeToURI(const NodePtr nodeArg, DOMString uri = uriArg; char *fileName = (char *) uri.c_str(); //temporary hack - FILE *f = fopen(fileName, "rb"); + FILE *f = fopen(fileName, "wb"); if (!f) return false; for (unsigned int i=0 ; i<outbuf.size() ; i++) diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp index 1e7a61e4e..cf460c964 100644 --- a/src/dom/odf/odfdocument.cpp +++ b/src/dom/odf/odfdocument.cpp @@ -44,18 +44,20 @@ namespace odf */ ImageData::ImageData(const std::string &fname, const std::vector<unsigned char> &buf) + : fileName (fname), + data (buf) + { - fileName = fname; - data = buf; } /** * */ ImageData::ImageData(const ImageData &other) + : fileName (other.fileName), + data (other.data) + { - fileName = other.fileName; - data = other.data; } /** @@ -120,10 +122,10 @@ OdfDocument::OdfDocument() : /** * */ -OdfDocument::OdfDocument(const OdfDocument &other) +OdfDocument::OdfDocument(const OdfDocument &other) : + content (other.content), + images (other.images) { - content = other.content; - images = other.images; } diff --git a/src/dom/smil.h b/src/dom/smil.h index 15bc361ac..14870a4e4 100644 --- a/src/dom/smil.h +++ b/src/dom/smil.h @@ -193,7 +193,12 @@ public: /** * */ - ElementLayout() {} + ElementLayout() : + title(), + backgroundColor(), + height(0), + width(0) + {} /** * @@ -274,8 +279,9 @@ public: /** * */ - SMILRegionInterface(const SMILRegionInterface &other) - { regionElement = other.regionElement; } + SMILRegionInterface(const SMILRegionInterface &other) : + regionElement (other.regionElement) + {} /** * @@ -542,9 +548,9 @@ public: /** * */ - TimeList(const TimeList &other) + TimeList(const TimeList &other) : + items (other.items) { - items = other.items; } /** @@ -1586,7 +1592,15 @@ public: /** * */ - ElementTest() + ElementTest() : + systemBitrate (0), + systemCaptions (false), + systemLanguage (), + systemRequired (false), + systemScreenSize (false), + systemScreenDepth (false), + systemOverdubOrSubtitle (), + systemAudioDesc (false) { } @@ -1629,8 +1643,6 @@ public: protected: - - long systemBitrate; bool systemCaptions; DOMString systemLanguage; diff --git a/src/dom/stylesheets.h b/src/dom/stylesheets.h index fc1bc9d88..2903b96d9 100644 --- a/src/dom/stylesheets.h +++ b/src/dom/stylesheets.h @@ -308,13 +308,14 @@ public: * */ StyleSheet() + : type(""), + disabled (false), + ownerNode (NULL), + parentStylesheet (NULL), + href (""), + title (""), + mediaList () { - type = ""; - disabled = false; - ownerNode = NULL; - parentStylesheet = NULL; - href = ""; - title = ""; } @@ -422,8 +423,8 @@ public: * */ StyleSheetList(const StyleSheetList &other) + : sheets (other.sheets) { - sheets = other.sheets; } /** @@ -489,8 +490,8 @@ public: * */ LinkStyle(const LinkStyle &other) + : sheet (other.sheet) { - sheet = other.sheet; } /** @@ -556,8 +557,8 @@ public: * */ DocumentStyle(const DocumentStyle &other) + : styleSheets (other.styleSheets) { - styleSheets = other.styleSheets; } /** diff --git a/src/dom/traversal.h b/src/dom/traversal.h index 13850f78e..302ac2b1f 100644 --- a/src/dom/traversal.h +++ b/src/dom/traversal.h @@ -295,11 +295,11 @@ public: /** * */ - NodeIterator(const NodeIterator &other) + NodeIterator(const NodeIterator &other) : + whatToShow (other.whatToShow), + filter (other.filter), + expandEntityReferences (other.expandEntityReferences) { - whatToShow = other.whatToShow; - filter = other.filter; - expandEntityReferences = other.expandEntityReferences; } /** @@ -499,12 +499,12 @@ public: /** * */ - TreeWalker(const TreeWalker &other) + TreeWalker(const TreeWalker &other) : + whatToShow (other.whatToShow), + filter (other.filter), + expandEntityReferences (other.expandEntityReferences), + currentNode (other.currentNode) { - whatToShow = other.whatToShow; - filter = other.filter; - expandEntityReferences = other.expandEntityReferences; - currentNode = other.currentNode; } /** diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index b30950f5a..742d52f09 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -81,8 +81,6 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass); -static void sp_dyna_draw_context_init(SPDynaDrawContext *ddc); static void sp_dyna_draw_context_dispose(GObject *object); static void sp_dyna_draw_context_setup(SPEventContext *ec); @@ -101,29 +99,7 @@ static Geom::Point sp_dyna_draw_get_npoint(SPDynaDrawContext const *ddc, Geom::P static Geom::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *ddc, Geom::Point n); static void draw_temporary_box(SPDynaDrawContext *dc); - -static SPEventContextClass *dd_parent_class = 0; - -GType sp_dyna_draw_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPDynaDrawContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_dyna_draw_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPDynaDrawContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_dyna_draw_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_COMMON_CONTEXT, "SPDynaDrawContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPDynaDrawContext, sp_dyna_draw_context, SP_TYPE_COMMON_CONTEXT); static void sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass) @@ -131,8 +107,6 @@ sp_dyna_draw_context_class_init(SPDynaDrawContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - dd_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_dyna_draw_context_dispose; event_context_class->setup = sp_dyna_draw_context_setup; @@ -182,7 +156,7 @@ sp_dyna_draw_context_dispose(GObject *object) } - G_OBJECT_CLASS(dd_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_dyna_draw_context_parent_class)->dispose(object); ddc->hatch_pointer_past.~list(); ddc->hatch_nearest_past.~list(); @@ -195,8 +169,8 @@ sp_dyna_draw_context_setup(SPEventContext *ec) { SPDynaDrawContext *ddc = SP_DYNA_DRAW_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(dd_parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(dd_parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->setup(ec); ddc->accumulated = new SPCurve(); ddc->currentcurve = new SPCurve(); @@ -262,8 +236,8 @@ sp_dyna_draw_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) ddc->keep_selected = val->getBool(); } else { //pass on up to parent class to handle common attributes. - if ( dd_parent_class->set ) { - dd_parent_class->set(ec, val); + if ( SP_COMMON_CONTEXT_CLASS(sp_dyna_draw_context_parent_class)->set ) { + SP_COMMON_CONTEXT_CLASS(sp_dyna_draw_context_parent_class)->set(ec, val); } } @@ -974,8 +948,8 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(dd_parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(dd_parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp index 8253818d2..5a827096f 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/ege-adjustment-action.cpp @@ -50,8 +50,6 @@ #include "ui/widget/gimpspinscale.h" -static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ); -static void ege_adjustment_action_init( EgeAdjustmentAction* action ); static void ege_adjustment_action_finalize( GObject* object ); static void ege_adjustment_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_adjustment_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -70,8 +68,6 @@ static void ege_adjustment_action_defocus( EgeAdjustmentAction* action ); static void egeAct_free_description( gpointer data, gpointer user_data ); static void egeAct_free_all_descriptions( EgeAdjustmentAction* action ); - -static GtkActionClass* gParentClass = 0; static EgeCreateAdjWidgetCB gFactoryCb = 0; static GQuark gDataName = 0; @@ -146,34 +142,11 @@ enum { BUMP_CUSTOM = 100 }; -GType ege_adjustment_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeAdjustmentActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_adjustment_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeAdjustmentAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_adjustment_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeAdjustmentAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} - +G_DEFINE_TYPE(EgeAdjustmentAction, ege_adjustment_action, GTK_TYPE_ACTION); static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass ) { if ( klass ) { - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass * objClass = G_OBJECT_CLASS( klass ); gDataName = g_quark_from_string("ege-adj-action"); @@ -308,8 +281,8 @@ static void ege_adjustment_action_finalize( GObject* object ) egeAct_free_all_descriptions( action ); - if ( G_OBJECT_CLASS(gParentClass)->finalize ) { - (*G_OBJECT_CLASS(gParentClass)->finalize)(object); + if ( G_OBJECT_CLASS(ege_adjustment_action_parent_class)->finalize ) { + (*G_OBJECT_CLASS(ege_adjustment_action_parent_class)->finalize)(object); } } @@ -772,7 +745,7 @@ static GtkWidget* create_menu_item( GtkAction* action ) gtk_widget_show_all( subby ); g_value_unset( &value ); } else { - item = gParentClass->create_menu_item( action ); + item = GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->create_menu_item( action ); } return item; @@ -910,7 +883,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) g_value_unset( &value ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->create_tool_item( action ); } return item; @@ -918,12 +891,12 @@ static GtkWidget* create_tool_item( GtkAction* action ) static void connect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->connect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->connect_proxy( action, proxy ); } static void disconnect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->disconnect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_adjustment_action_parent_class)->disconnect_proxy( action, proxy ); } void ege_adjustment_action_defocus( EgeAdjustmentAction* action ) diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index c0e095a98..2e1b8188f 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -90,11 +90,9 @@ enum { ADDED, REMOVED, MODIFIED, - LAST_SIGNAL}; - + LAST_SIGNAL +}; -static void ege_color_prof_tracker_class_init( EgeColorProfTrackerClass* klass ); -static void ege_color_prof_tracker_init( EgeColorProfTracker* tracker ); static void ege_color_prof_tracker_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_color_prof_tracker_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -114,7 +112,6 @@ void handle_property_change(GdkScreen* screen, const gchar* name); void add_x11_tracking_for_screen(GdkScreen* screen, ScreenTrack* screenTrack); #endif /* GDK_WINDOWING_X11 */ -static GObjectClass* gParentClass = 0; static guint signals[LAST_SIGNAL] = {0}; static GSList* tracked_screens = 0; @@ -140,33 +137,11 @@ static void clear_profile( GdkScreen* screen, guint monitor ); static void set_profile( GdkScreen* screen, guint monitor, const guint8* data, guint len ); static void track_screen( GdkScreen* screen, EgeColorProfTracker* tracker ); -GType ege_color_prof_tracker_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeColorProfTrackerClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_color_prof_tracker_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeColorProfTracker ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_color_prof_tracker_init, - NULL - }; - - myType = g_type_register_static( G_TYPE_OBJECT, "EgeColorProfTracker", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeColorProfTracker, ege_color_prof_tracker, G_TYPE_OBJECT); void ege_color_prof_tracker_class_init( EgeColorProfTrackerClass* klass ) { if ( klass ) { - gParentClass = G_OBJECT_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass* objClass = G_OBJECT_CLASS( klass ); objClass->get_property = ege_color_prof_tracker_get_property; diff --git a/src/ege-output-action.cpp b/src/ege-output-action.cpp index 1b356c55d..214bd4b29 100644 --- a/src/ege-output-action.cpp +++ b/src/ege-output-action.cpp @@ -46,8 +46,6 @@ #include "ege-output-action.h" -static void ege_output_action_class_init( EgeOutputActionClass* klass ); -static void ege_output_action_init( EgeOutputAction* action ); static void ege_output_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_output_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); static void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ); @@ -55,9 +53,6 @@ static void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data /* static GtkWidget* create_menu_item( GtkAction* action ); */ static GtkWidget* create_tool_item( GtkAction* action ); -static GtkActionClass* gParentClass = 0; - - struct _EgeOutputActionPrivate { gboolean useMarkup; @@ -69,34 +64,12 @@ enum { PROP_USE_MARKUP = 1, }; -GType ege_output_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeOutputActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_output_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeOutputAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_output_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeOutputAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeOutputAction, ege_output_action, GTK_TYPE_ACTION); void ege_output_action_class_init( EgeOutputActionClass* klass ) { if ( klass ) { GObjectClass* objClass = G_OBJECT_CLASS( klass ); - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); objClass->get_property = ege_output_action_get_property; objClass->set_property = ege_output_action_set_property; @@ -228,7 +201,7 @@ GtkWidget* create_tool_item( GtkAction* action ) g_value_unset( &value ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_output_action_parent_class)->create_tool_item( action ); } return item; diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp index a5d92e809..33cfd04f2 100644 --- a/src/ege-select-one-action.cpp +++ b/src/ege-select-one-action.cpp @@ -49,9 +49,6 @@ enum { CHANGED = 0, LAST_SIGNAL}; - -static void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ); -static void ege_select_one_action_init( EgeSelectOneAction* action ); static void ege_select_one_action_finalize( GObject* action ); static void ege_select_one_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ege_select_one_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -73,7 +70,6 @@ static void disconnect_proxy( GtkAction *action, GtkWidget *proxy ); static int scan_max_width( GtkTreeModel *model, gint labelColumn ); -static GtkActionClass* gParentClass = 0; static guint signals[LAST_SIGNAL] = {0}; static GQuark gDataName = 0; @@ -126,28 +122,7 @@ enum { PROP_SELECTION }; -GType ege_select_one_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( EgeSelectOneActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ege_select_one_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( EgeSelectOneAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ege_select_one_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "EgeSelectOneAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(EgeSelectOneAction, ege_select_one_action, GTK_TYPE_ACTION); GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){ return GTK_TREE_MODEL(action->private_data->model); @@ -155,7 +130,6 @@ GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){ void ege_select_one_action_class_init( EgeSelectOneActionClass* klass ) { if ( klass ) { - gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass* objClass = G_OBJECT_CLASS( klass ); gDataName = g_quark_from_string("ege-select1-action"); @@ -292,8 +266,8 @@ void ege_select_one_action_finalize( GObject* object ) g_free( action->private_data->appearance ); g_free( action->private_data->selection ); - if ( G_OBJECT_CLASS(gParentClass)->finalize ) { - (*G_OBJECT_CLASS(gParentClass)->finalize)(object); + if ( G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize ) { + (*G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize)(object); } } @@ -631,7 +605,7 @@ GtkWidget* create_menu_item( GtkAction* action ) g_free(sss); } else { - item = gParentClass->create_menu_item( action ); + item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_menu_item( action ); } return item; @@ -855,7 +829,7 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_widget_show_all( item ); } else { - item = gParentClass->create_tool_item( action ); + item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action ); } return item; @@ -864,12 +838,12 @@ GtkWidget* create_tool_item( GtkAction* action ) void connect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->connect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_select_one_action_parent_class)->connect_proxy( action, proxy ); } void disconnect_proxy( GtkAction *action, GtkWidget *proxy ) { - gParentClass->disconnect_proxy( action, proxy ); + GTK_ACTION_CLASS(ege_select_one_action_parent_class)->disconnect_proxy( action, proxy ); } diff --git a/src/event-context.cpp b/src/event-context.cpp index 71d4a5fb9..11b814aab 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -54,8 +54,6 @@ #include "sp-guide.h" #include "color.h" -static void sp_event_context_class_init(SPEventContextClass *klass); -static void sp_event_context_init(SPEventContext *event_context); static void sp_event_context_dispose(GObject *object); static void sp_event_context_private_setup(SPEventContext *ec); @@ -66,8 +64,6 @@ static gint sp_event_context_private_item_handler( static void set_event_location(SPDesktop * desktop, GdkEvent * event); -static GObjectClass *parent_class; - // globals for temporary switching to selector by space static bool selector_toggled = FALSE; static int switch_selector_to = 0; @@ -85,22 +81,7 @@ static guint32 scroll_event_time = 0; static gdouble scroll_multiply = 1; static guint scroll_keyval = 0; -/** - * Registers the SPEventContext class with Glib and returns its type number. - */ -GType sp_event_context_get_type(void) { - static GType type = 0; - if (!type) { - GTypeInfo info = { sizeof(SPEventContextClass), NULL, NULL, - (GClassInitFunc) sp_event_context_class_init, NULL, NULL, - sizeof(SPEventContext), 4, - (GInstanceInitFunc) sp_event_context_init, NULL, /* value_table */ - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPEventContext", &info, - (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPEventContext, sp_event_context, G_TYPE_OBJECT); /** * Callback to set up the SPEventContext vtable. @@ -108,8 +89,6 @@ GType sp_event_context_get_type(void) { static void sp_event_context_class_init(SPEventContextClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_event_context_dispose; klass->setup = sp_event_context_private_setup; @@ -166,7 +145,7 @@ static void sp_event_context_dispose(GObject *object) { delete ec->_delayed_snap_event; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_event_context_parent_class)->dispose(object); } /** @@ -733,6 +712,7 @@ static gint sp_event_context_private_root_handler( sp_toggle_selector(desktop); ret = TRUE; } + within_tolerance = false; break; case GDK_KEY_Q: case GDK_KEY_q: @@ -1103,7 +1083,7 @@ gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPIte } /** - * Emits 'position_set' signal on desktop and shows coordinates on status bar. + * Shows coordinates on status bar. */ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { if (event->type != GDK_MOTION_NOTIFY) { @@ -1112,7 +1092,6 @@ static void set_event_location(SPDesktop *desktop, GdkEvent *event) { Geom::Point const button_w(event->button.x, event->button.y); Geom::Point const button_dt(desktop->w2d(button_w)); - desktop->setPosition(button_dt); desktop->set_coordinate_status(button_dt); } diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index e1f04fa10..b5634f42f 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -63,17 +63,6 @@ set(extension_SRC script/InkscapeScript.cpp - # dxf2svg/aci2rgb.cpp - # dxf2svg/entities2elements.cpp - # dxf2svg/tables2svg_info.cpp - # dxf2svg/blocks.cpp - # dxf2svg/entities.cpp - # dxf2svg/tables.cpp - # dxf2svg/dxf2svg.cpp - # dxf2svg/read_dxf.cpp - # dxf2svg/test_dxf.cpp - - # ------ # Header db.h diff --git a/src/extension/dxf2svg/GPL.txt b/src/extension/dxf2svg/GPL.txt deleted file mode 100644 index 3912109b5..000000000 --- a/src/extension/dxf2svg/GPL.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/src/extension/dxf2svg/LGPL.txt b/src/extension/dxf2svg/LGPL.txt deleted file mode 100644 index 8add30ad5..000000000 --- a/src/extension/dxf2svg/LGPL.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/src/extension/dxf2svg/Makefile b/src/extension/dxf2svg/Makefile deleted file mode 100644 index d0f06daf0..000000000 --- a/src/extension/dxf2svg/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -objs = read_dxf.o entities.o entities2elements.o tables.o tables2svg_info.o blocks.o -flags = -O1 - -dxf2svg : dxf2svg.cpp $(objs) - g++ $(flags) -o dxf2svg dxf2svg.cpp $(objs) - -test : test_dxf.cpp $(objs) - g++ $(flags) -o test test_dxf.cpp $(objs) - -%.o : %.cpp %.h - g++ $(flags) -c $< - -clean : - rm dxf2svg $(objs) - -install: - echo ****User intervention required**** - echo - echo Copy dxf2svg executable and dxf2svg.inx to share/extension directory - echo Make sure file permissions are set correctly - diff --git a/src/extension/dxf2svg/README b/src/extension/dxf2svg/README deleted file mode 100644 index dbf98d2cc..000000000 --- a/src/extension/dxf2svg/README +++ /dev/null @@ -1,41 +0,0 @@ -26 Aug 05 - -To use: -I have only gotten this to work with Inkscape under linux (debian sarge). But the converter works from the commandline if you want to test it otherwise. - -1. Run make and copy dxf2svg to somewhere that is looked at by the PATH variable. Or add the current directory to your path -2. Copy the dxf_import.inx to ../Inkscape/share/extensions -3. Run Inkscape -4. Click on open or import and the dxf option should be there - -I have compiled and then succesfully converted dxf files to svg files with the following setups - -WinXP Pro, Cygwin, g++ 3.3.3 -Debian Sarge, AMD x86_64, g++ 4.0.2 -RedHat(?), x86(?), g++ 3.2.3 - -I have weakly tried and failed to compile using -Borland's free compiler bcc32 -MinGW - -What is supported: -polylines, lines, arc, circles, blocks, text, and a little linetypes - -currently not supported but I hope will be in the near future (probably after Sept 05) -layers, colors, trace, splines, dimentions - -If you don't have dxf files of your own, but would like to easily test some I would suggest a few places... - -www.newfocus.com -- look under optomechanics. There are a variety of mounts and such that are posted in dxf and pdf -www.thorlabs.com -- dido what I said about newfocus - -Free CAD programs: -Windows -- A free and not too bad CAD program for windows is CadStd Lite. It exports to dxf and has a variety of samples. -Windows/Linux -- QCad is ok. It has a lot of nice features but when I used it a year ago it would import dxf files but then you couldn't edit what was imported. It is free but with a time limit. My experience is that it can be a little annoying. Because of that and others comments I didn't use their libraries for dxf reading. - - -Matt Squires -squiresm@colorado.edu - -27 Aug 05, Fixed a fair number of bugs, and broken conversions. LWPOLYLINE works now, text rotation is ok but needs multiple transfomations to get it right, can read broken dxf files (w/o dxf EOF information) - diff --git a/src/extension/dxf2svg/aci2rgb.cpp b/src/extension/dxf2svg/aci2rgb.cpp deleted file mode 100644 index 57e488bfc..000000000 --- a/src/extension/dxf2svg/aci2rgb.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include <iostream> -#include <sstream> -#include <string> - - -char* RGB(double R, double G, double B); -char* RGB(double R, double G, double B){ - int r = int (R); - int g = int (G); - int b = int (B); - - char out[6]; - char *chr_ptr; - string output; - stringstream oss; - - if (r < 16 ){ - oss << 0; - } - oss << hex << r; - - if (g < 16 ){ - oss << 0; - } - oss << hex << g; - - if (b < 16 ){ - oss << 0; - } - oss << hex << b; - - output = oss.str(); - - for (int i = 0; i < 6; i++){ - out[i] = output[i]; - } - chr_ptr = &out; - return chr_ptr; -} - - -float aci_to_rgb(int aci); - -float aci_to_rgb(int aci) - { - aci = abs(aci); // hidden layers have negative color values - if (aci<10 || aci>249) // values of these ranges are special colors - { - switch (aci) - { - case 1: return RGB(255,0,0); // basic colors - case 2: return RGB(255,255,0); - case 3: return RGB(0,255,0); - case 4: return RGB(0,255,255); - case 5: return RGB(0,0,255); - case 6: return RGB(255,0,255); - case 7: return RGB(255,255,255); - case 8: return RGB(128,128,128); - case 9: return RGB(192,192,192); - case 250: return RGB(51,51,51); // grey shades - case 251: return RGB(91,91,91); - case 252: return RGB(132,132,132); - case 253: return RGB(173,173,173); - case 254: return RGB(214,214,214); - case 255: return RGB(255,255,255); - case 256: // "by layer" - // Here you should decide how to handle "by layer" logical color. - // Maybe it is a good idea to return a value like -1. - // The outer code will find what is the color of the layer which - // this entity belongs to. - return -1; - } - } - // for all the rest of ACI codes - float H,S,L, R,G,B; - int remainder = aci % 10; - H = 1.5f * (aci - remainder - 10); // hue in range 0-360 - S = ((aci % 2) ? 0.5f : 1.0f); // odd colors have 50% of saturation, even - 100% - // set lighteness, the last digit of aci code stands for this - if (reminder == 0 || reminder == 1) L = 1.0f; - if (reminder == 2 || reminder == 3) L = 0.8f; - if (reminder == 4 || reminder == 5) L = 0.6f; - if (reminder == 6 || reminder == 7) L = 0.5f; - if (reminder == 8 || reminder == 9) L = 0.3f; - // here we have H,S,L set already - // let's convert it to RGB, first without consideration of S and L - if (H<=120) - { - R = (120-H)/60; - G = H/60; - B = 0; - } - if (H>120 && H<=240) - { - R = 0; - G = (240-H)/60; - B = (H-120)/60; - } - if (H>240 && H<=360) - { - R = (H-240)/60; - G = 0; - B = (360-H)/60; - } - R = min(R, 1); - G = min(G, 1); - B = min(B, 1); - // influence of S and L - float max_value = max(R,max(G,B)); - R = (max_value-S*(max_value-R)) * L * 255; - G = (max_value-S*(max_value-G)) * L * 255; - B = (max_value-S*(max_value-B)) * L * 255; - return RGB(R,G,B); - }
\ No newline at end of file diff --git a/src/extension/dxf2svg/blocks.cpp b/src/extension/dxf2svg/blocks.cpp deleted file mode 100644 index 36f2b9e7e..000000000 --- a/src/extension/dxf2svg/blocks.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Read Blocks from file and convert to vectors of entities - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include"blocks.h" -#include<iostream> - -block::block(std::vector< std::vector< dxfpair > > sections) : entities( sections ){ - // Inherit most of the functionality of the entitites section - - basic_entity( sections[0] ); - block_info( sections[0] ); -} - -char* block::name(char* string){ - return( strcpy(string,block_name) ); -} - - -void block::block_info( std::vector< dxfpair > info){ - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: // Block name - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(block_name,string); - break; - } - } -} - - -blocks::blocks(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - char string[10000]; - std::vector< dxfpair > single_line; - std::vector< std::vector< dxfpair > > ents; - ents.clear(); - single_line.clear(); - - int n_loop = sections.size(); - n_loop--; - //for(int i = 0; i < (sections.size()-1); i++){ // It is odd but the last value seems to be bad so don't use it - // I am not really sure if I need the -1. I needed it once upon a time to make things work but I don't have time to test it well right now - // But sections.size() is an unsigned int so when you subtract 1 it becomes 4294967295 and tries to run the loop so work around that by making n_loop that is signed - for(int i = 0; i < n_loop; i++){ // It is odd but the last value seems to be bad so don't use it - sections[i][0].value_char(string); - ents.clear(); // First clear out the pline information - - - // Get everything from the start of the BLOCK designation to an ENDBLK value - if ( strncmp(string,"BLOCK",5) == 0 && (i < sections.size())){ - do{ - ents.push_back( sections[i] ); - sections[++i][0].value_char(string); - }while( strncmp(string,"ENDBLK",6) != 0 && (i < sections.size()-1) ); - blocks_blocks.push_back( block( ents ) ); - } - } -} - -block blocks::ret_block(char block_name[10000]){ - int string_len = 0; - char temp[10000]; - - for (int i = 0; i < blocks_blocks.size();i++){ - string_len = strlen(blocks_blocks[i].name(temp)); - if (strncmp(blocks_blocks[i].name(temp),block_name,string_len) == 0 ) return blocks_blocks[i]; - } - return blocks_blocks[0]; -} - - - diff --git a/src/extension/dxf2svg/blocks.h b/src/extension/dxf2svg/blocks.h deleted file mode 100644 index 27e0b8be1..000000000 --- a/src/extension/dxf2svg/blocks.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Read Blocks from file and convert to vectors of entities -Matt Squires -Google SOC 2005 -*/ - -#ifndef DXF_BLOCKS_H -#define DXF_BLOCKS_H - -#include"read_dxf.h" -#include"entities.h" -#include<vector> - - -class block : public entity, public entities{// : public entities, { - public: - block( std::vector< std::vector< dxfpair > > sections ); // Group all of the blocks as entities - char* name(char* string); - //void blocks_display(); - - - protected: - char block_name[10000]; - double rotation; - - private: - void block_info(std::vector< dxfpair > info); -}; - -class blocks{ - public: - blocks(std::vector< std::vector< dxfpair > > sections); - block ret_block(char block_name[10000]); - - protected: - std::vector< block > blocks_blocks; -}; - -#endif diff --git a/src/extension/dxf2svg/dxf2svg.cpp b/src/extension/dxf2svg/dxf2svg.cpp deleted file mode 100644 index 4884ed3fe..000000000 --- a/src/extension/dxf2svg/dxf2svg.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Build a SVG from an dxf, will support conversion to Inkscape types - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include<fstream> -#include<iostream> -#include"read_dxf.h" -#include"entities.h" -#include"blocks.h" -#include"entities2elements.h" - - -int main(int argc,char *argv[]){ - // Later include options for different conversions like converting as much as possible into paths - - if(argc > 1){ - double scaling = 90; // converstion from in to pt - - // Read the DXF file - std::vector< std::vector< dxfpair > > output, entities_info, tables_info, blocks_info; - //std::cout << "About to read file \n" << std::endl; - output = dxf_get_sections(argv[1]); - //std::cout << "Finished reading file \n" << std::endl; - - entities_info = separate_parts(output[4]); // Entities is the 5th part of the file. - entities ents(entities_info); // Sort entities into their respective parts - - tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file. - tables tbls(tables_info); // Sort the information in the tables - - blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file. - blocks blks(blocks_info); // Sort the information in the tables - - - - // Get the various file informations - /*std::vector< polyline > plines = ents.ret_plines(); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(); - std::vector< arc > arcs = ents.ret_arcs(); - std::vector< circle > circs = ents.ret_circles(); - std::vector< line > lns = ents.ret_lines(); - std::vector< text > txts = ents.ret_texts(); - std::vector< insert > ins = ents.ret_inserts(); - */ - - - std::vector< layer > layers = tbls.ret_layers(); - - char units[5] = "in"; - char tmp_char[100000]; - char layer_string[500]; - // int ink = 1; // Assume for now there is no inkscape stuff to add extra - - /*if (ink < 1){ - // Write a general svg header - std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n\t\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\"\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; - std::cout << "\tx=\"0.00000000\"\n\ty=\"0.00000000\"\n\twidth=\"744.09448\"\n\theight=\"-1052.3622\"" << std::endl; - } - else{*/ - std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl; - std::cout << "<!-- Created with dxf2svg -->" << std::endl; - std::cout << "<svg" << std::endl; - std::cout << "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"" << std::endl; - std::cout << "\txmlns:cc=\"http://web.resource.org/cc/\"" << std::endl; - std::cout << "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" << std::endl; - std::cout << "\txmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl; - std::cout << "\txmlns=\"http://www.w3.org/2000/svg\"" << std::endl; - std::cout << "\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl; - std::cout << "\txmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl; - std::cout << "\t>" << std::endl; - //} - - - // Now write SVG elements to file - if ( layers.size() < 1 ){ - write_all(0, ents, tbls, blks, scaling, units, tmp_char); - } - else{ - for (int i = 0; i < layers.size(); i++){ - std::cout << "\t<g\n\t\tinkscape:label=\"" << layers[i].name(layer_string) << "\"\n\t\tinkscape:groupmode=\"layer\"\n\t\tid=\"layer" << i+1 << "\">" << std::endl; - write_by_layer(0, ents, tbls, blks, scaling, units, layers[i].name(layer_string), tmp_char); - std::cout << "\t</g>" << std::endl; - } - } - - // Close SVG - std::cout << "</svg>"; - } - - return 0; -} diff --git a/src/extension/dxf2svg/dxf_input.inx b/src/extension/dxf2svg/dxf_input.inx deleted file mode 100644 index b96274ade..000000000 --- a/src/extension/dxf2svg/dxf_input.inx +++ /dev/null @@ -1,16 +0,0 @@ -<inkscape-extension> - <name>DXF Input</name> - <id>org.inkscape.input.dxf</id> - <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg</dependency> - <dependency type="extension">org.inkscape.input.svg</dependency> - <input> - <extension>.dxf</extension> - <mimetype>image/x-svgz</mimetype> - <filetypename>AutoCAD DXF (*.dxf)</filetypename> - <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip> - <output_extension>org.inkscape.output.svg</output_extension> - </input> - <script> - <command reldir="extensions">dxf2svg</command> - </script> -</inkscape-extension> diff --git a/src/extension/dxf2svg/dxf_input_windows.inx b/src/extension/dxf2svg/dxf_input_windows.inx deleted file mode 100644 index 7dbe6a11b..000000000 --- a/src/extension/dxf2svg/dxf_input_windows.inx +++ /dev/null @@ -1,17 +0,0 @@ -<inkscape-extension> - <name>DXF Input</name> - <id>org.inkscape.input.dxf</id> - <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at -http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg.exe</dependency> - <dependency type="extension">org.inkscape.input.svg</dependency> - <input> - <extension>.dxf</extension> - <mimetype>image/x-svgz</mimetype> - <filetypename>AutoCAD DXF (*.dxf)</filetypename> - <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip> - <output_extension>org.inkscape.output.svg</output_extension> - </input> - <script> - <command reldir="extensions">dxf2svg.exe</command> - </script> -</inkscape-extension> diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp deleted file mode 100644 index 4e2f83ee7..000000000 --- a/src/extension/dxf2svg/entities.cpp +++ /dev/null @@ -1,996 +0,0 @@ -/* - * Class for interpereting the entities found in a DXF file - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include"entities.h" -#include<iostream> -#include<math.h> - -int detmine_entity(char* value){ - // Common Elements as far as I am concerend - if ( strncmp(value,"POLYLINE",8) == 0 ) return 0; - if ( strncmp(value,"ARC",3) == 0 ) return 1; - if ( strncmp(value,"CIRCLE",6) == 0 ) return 2; - if ( strncmp(value,"LINE",4) == 0 ) return 3; - if ( strncmp(value,"SPLINE",6) == 0 ) return 4; - if ( strncmp(value,"XLINE",5) == 0 ) return 5; - if ( strncmp(value,"RAY",3) == 0 ) return 6; - if ( strncmp(value,"DIMENSION",9) == 0 ) return 7; - if ( strncmp(value,"ELLIPSE",7) == 0 ) return 8; - if ( strncmp(value,"INSERT",6) == 0 ) return 9; - if ( strncmp(value,"VERTEX",6) == 0 ) return 10; - if ( strncmp(value,"TEXT",4) == 0 ) return 11; - - // Less Common eletities as far as I am concerend - if ( strncmp(value,"3DSOLID",7) == 0 ) return 12; - if ( strncmp(value,"ACAD_PROXY_ENTITY",17) == 0 ) return 13; - if ( strncmp(value,"ARCALIGNEDTEXT",14) == 0 ) return 14; - if ( strncmp(value,"ATTDEF",6) == 0 ) return 15; - if ( strncmp(value,"ATTRIB",6) == 0 ) return 16; - if ( strncmp(value,"BODY",4) == 0 ) return 17; - if ( strncmp(value,"HATCH",5) == 0 ) return 18; - if ( strncmp(value,"IMAGE",5) == 0 ) return 19; - if ( strncmp(value,"LEADER",6) == 0 ) return 20; - if ( strncmp(value,"LWPOLYLINE",10) == 0 ) return 21; - if ( strncmp(value,"MLINE",5) == 0 ) return 22; - if ( strncmp(value,"MTEXT",5) == 0 ) return 23; - if ( strncmp(value,"OLEFRAME",8) == 0 ) return 24; - if ( strncmp(value,"POINT",5) == 0 ) return 25; - if ( strncmp(value,"REGION",6) == 0 ) return 26; - if ( strncmp(value,"RTEXT",5) == 0 ) return 27; - if ( strncmp(value,"SEQEND",6) == 0 ) return 28; - if ( strncmp(value,"SHAPE",5) == 0 ) return 29; - if ( strncmp(value,"SOLID",5) == 0 ) return 30; - if ( strncmp(value,"3DFACE",6) == 0 ) return 31; - if ( strncmp(value,"TOLERANCE",9) == 0 ) return 32; - if ( strncmp(value,"TRACE",5) == 0 ) return 33; - if ( strncmp(value,"VIEWPORT",8) == 0 ) return 34; - if ( strncmp(value,"WIPEOUT",7) == 0 ) return 35; - else return -1; -} - - -void entity::basic_entity( std::vector< dxfpair > info){ - // Extract all of the typical entity information (e.g. layer name, positions) - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 6: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(linetype,string); - break; - case 8: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(layer,string); - break; - case 10: - info[i].value_char(string); - x = atof(string); - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - break; - case 20: - info[i].value_char(string); - y = atof(string); - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } - break; - case 30: - info[i].value_char(string); - z = atof(string); - break; - } - } - -} - -void entity::entity_display(){ - std::cout << "\tlayer = " << layer << "\n\tlinetype = " << linetype << "\n\tx = " << x << "\ty = " << y << "\tz = " << z << std::flush; -} - -double entity::ret_x(){ - return x; -} - -double entity::ret_y(){ - return y; -} - -double entity::ret_z(){ - return z; -} - - -char* entity::ret_layer_name(char* string){ - return( strcpy(string,layer) ); -} - -char* entity::ret_ltype_name(char* string){ - return( strcpy(string,linetype) ); -} - -double entity::ret_min_x(){ - return min_x; -} - -double entity::ret_max_x(){ - return max_x; -} - -double entity::ret_min_y(){ - return min_y; -} - -double entity::ret_max_y(){ - return max_y; -} - -void entity::test_coord(double x, double y){ - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } -} - - -void entity::reset_extents(){ - min_x = -1e20; - max_x = 1e20; - min_y = -1e20; - max_y = 1e20; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// VERTEX -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -vertex::vertex( std::vector< dxfpair > info){ - // Get the vertex information - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 42: - info[i].value_char(string); - bulge = atof(string); - break; - } - } -} - -double vertex::ret_bulge(){ - return bulge; -} - -void vertex::display(){ - std::cout << "VERTEX\n"; - std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; -} - - - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// POLYLINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -// The polyline is handled a little differently compared to the other entities because a POLYLINE is built from a bunch of VERTEX entities -polyline::polyline( std::vector< std::vector< dxfpair > > sections ){ - buldge = 0; - pline_flag = 0; - reset_extents(); - // get the polyline information - basic_entity( sections[0] ); - points.clear(); - static char string[10000]; - for (int i = 0; i < sections[0].size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - sections[0][i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - sections[0][i].value_char(string); - start_width = atoi(string); - break; - case 41: - sections[0][i].value_char(string); - end_width = atoi(string); - break; - case 75: - sections[0][i].value_char(string); - curves_flag = atoi(string); - break; - } - } - curves_flag = 0; - - // Now add the VERTEX entities to the POLYLINE - for (int i = 1; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } -} - - -std::vector< vertex > polyline::ret_points(){ - return points; -} - -double polyline::bulge(int point){ - return points[point].ret_bulge(); -} - -double polyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; -} - -double polyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) - { - return 0; - } - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - if (dx > 0) - { - sb *= -1; // Correct for different point ordering and bulge direction - } - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -double polyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) - { - return 0; - } - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -bool polyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); -} - -void polyline::display(){ - std::cout << "POLYLINE\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LWPOLYLINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -// The lwpolyline is different than the polyline because there are no vertex entities. Use the same basic process as the polyline but parse it out differently -lwpolyline::lwpolyline( std::vector< dxfpair > section ){ - - // First break up the data into the same format that is used by the polyline entity - std::vector< std::vector< dxfpair > > sections; - std::vector< dxfpair > first; - std::vector< dxfpair > others; - - sections.clear(); - first.clear(); - others.clear(); - - int gc; // make a shorter name for group_code; - - int vertex_part; - int already_found = 0; - - for (int i = 0; i < section.size(); i++){ - gc = section[i].group_code; - // Encode bitwise information to keep track of what has been found - vertex_part = 0; - if (gc == 10 ) vertex_part += 1; - if (gc == 20 ) vertex_part += 2; - if (gc == 30 ) vertex_part += 4; - if (gc == 40 ) vertex_part += 8; - if (gc == 41 ) vertex_part += 16; - if (gc == 42 ) vertex_part += 32; - //std::cout << "\n\nvertex_part = " << vertex_part << std::endl << "already_found = " << already_found << std::endl << "(vertex_part&already_found) = " << (vertex_part&already_found) << std::endl; - if ( vertex_part == 0 ){ - // If header stuff has been found save it under first. - // I.E. in a polyline the first set of information is linetype and layer, all of what should be in here - first.push_back( section[i] ); - } - else if ( (vertex_part&already_found) == 0 ){ - // Now work on what would be the vertex information - // New information is still being found so keep saving it - others.push_back( section[i] ); - //std::cout << "add to others" << std::endl; - already_found += vertex_part; // Keep track of what has been found - } - else{ - sections.push_back( others ); - //std::cout << "sections.size() = " << sections.size() << std::endl; - // Now clear the information out and start over - others.clear(); - others.push_back( section[i] ); - already_found = vertex_part; - } - } - - // Now put on the last data that was found - if (!others.empty()){ - sections.push_back(others); - } - - reset_extents(); - basic_entity( first ); - points.clear(); - static char string[10000]; - buldge = 0; - pline_flag = 0; - curves_flag = 0; - for (int i = 0; i < first.size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - first[i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - first[i].value_char(string); - start_width = atoi(string); - break; - case 41: - first[i].value_char(string); - end_width = atoi(string); - break; - case 75: - first[i].value_char(string); - curves_flag = atoi(string); - break; - } - } - // Now add the VERTEX entities to the POLYLINE - for (int i = 0; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } -} - - - -std::vector< vertex > lwpolyline::ret_points(){ - return points; -} - - -double lwpolyline::bulge(int point){ - return points[point].ret_bulge(); -} - -double lwpolyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; -} - -double lwpolyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -double lwpolyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; -} - -bool lwpolyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); -} - -void lwpolyline::display(){ - std::cout << "lwpolyline\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// ARC -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -arc::arc( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - case 50: - info[i].value_char(string); - start_angle = atof(string); - break; - case 51: - info[i].value_char(string); - end_angle = atof(string); - break; - default: - break; - } - } -} - -double arc::ret_radius(){ - return radius; -} - - -double arc::ret_srt_ang(){ - return start_angle; -} - - -double arc::ret_end_ang(){ - return end_angle; -} - - -void arc::display(){ - std::cout << "ARC\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << "\tstart_angle = " << start_angle << "end_angle = " << end_angle << std::flush; -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// CIRCLE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -circle::circle( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - } - } -} - -void circle::display(){ - std::cout << "CIRCLE\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << std::flush; -} - - -double circle::ret_radius(){ - return radius; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LINE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -line::line( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 11: - info[i].value_char(string); - xf = atof(string); - break; - case 21: - info[i].value_char(string); - yf = atof(string); - break; - case 31: - info[i].value_char(string); - zf = atof(string); - break; - } - } - test_coord(xf,yf); - -} - -void line::display(){ - std::cout << "LINE\n"; - entity_display(); - std::cout << "\n\txf = " << xf << "\tyf = " << yf << "\tzf = " << zf << std::flush; -} - - -double line::ret_xf(){ - return xf; -} - -double line::ret_yf(){ - return yf; -} - -double line::ret_zf(){ - return zf; -} - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// TEXT -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -text::text( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 1: - info[i].value_char(dxf_text); // directly copy the text into a string - break; - case 40: - info[i].value_char(string); - text_height = atof(string); - break; - case 50: - info[i].value_char(string); - text_rotation = atof(string); - break; - } - } -} - -char * text::ret_text(char *string){ - return( strcpy(string,dxf_text) ); -} - -double text::ret_txt_ht(){ - return text_height; -} - -double text::ret_txt_rot(){ - return text_rotation; -} - -void text::display(){ - char tmp[10000]; - std::cout << "TEXT\n"; - entity_display(); - std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// INSERT -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -insert::insert( std::vector< dxfpair > info){ - ret_x_sf = 0; - ret_y_sf = 0; - ret_z_sf = 0; - ret_rotation = 0; - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(block_name); // directly copy the text into a string - break; - case 41: - info[i].value_char(string); - x_scale_factor = atof(string); - break; - case 42: - info[i].value_char(string); - y_scale_factor = atof(string); - break; - case 43: - info[i].value_char(string); - z_scale_factor = atof(string); - break; - case 50: - info[i].value_char(string); - rotation = atof(string); - break; - } - } -} - - -char * insert::name(char *string){ - return( strcpy(string,block_name) ); -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// entities -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -entities::entities(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - int value; - char string[10000]; - std::vector< dxfpair > single_line; - std::vector< std::vector< dxfpair > > pline; - pline.clear(); - single_line.clear(); - - for(int i = 0; i < sections.size(); i++){ - sections[i][0].value_char(string); - value = detmine_entity(string); - switch( value ){ - case 0: - // Get everything from the start of the polyline designation to an SEQEND value - pline.clear(); // First clear out the pline information - do{ - pline.push_back( sections[i] ); - sections[++i][0].value_char(string); - }while( strncmp(string,"SEQEND",6) != 0 ); - ents_polyline.push_back( polyline( pline ) ); - break; - - case 1: - // ARC - ents_arc.push_back( arc( sections[i] ) ); - break; - - case 2: - // CIRCLE - ents_circle.push_back( circle( sections[i] ) ); - break; - - case 3: - // LINE - ents_line.push_back( line( sections[i] ) ); - break; - case 11: - // TEXT - ents_text.push_back( text( sections[i] ) ); - break; - case 21: - // LWPOLYLINE - ents_lwpolyline.push_back( lwpolyline( sections[i] ) ); - case 9: - // INSERT - ents_insert.push_back( insert( sections[i] ) ); - - //default: - // Nothing here - } - - } - -} - - -// Maybe all of this could be turned into fewer function by using templates, but no time right now. MBS - -std::vector< polyline > entities::ret_plines(){ - std::vector< polyline > pls; - pls.clear(); - for(int i = 0; i < ents_polyline.size();i++){ - pls.push_back( ents_polyline[i] ); - } - return pls; -} - -std::vector< lwpolyline > entities::ret_lwplines(){ - std::vector< lwpolyline > lwpls; - lwpls.clear(); - for(int i = 0; i < ents_lwpolyline.size();i++){ - lwpls.push_back( ents_lwpolyline[i] ); - } - return lwpls; -} - - -std::vector< arc > entities::ret_arcs(){ - std::vector< arc > a; - a.clear(); - for(int i = 0; i < ents_arc.size();i++){ - a.push_back( ents_arc[i] ); - } - return a; -} - -std::vector< circle > entities::ret_circles(){ - std::vector< circle > circs; - circs.clear(); - for(int i = 0; i < ents_circle.size();i++){ - circs.push_back( ents_circle[i] ); - } - return circs; -} - - -std::vector< line > entities::ret_lines(){ - std::vector< line > lns; - lns.clear(); - for(int i = 0; i < ents_line.size();i++){ - lns.push_back( ents_line[i] ); - } - return lns; -} - - -std::vector< text > entities::ret_texts(){ - std::vector< text > txts; - txts.clear(); - for(int i = 0; i < ents_text.size();i++){ - txts.push_back( ents_text[i] ); - } - return txts; -} - - -std::vector< insert > entities::ret_inserts(){ - std::vector< insert > ins; - ins.clear(); - for(int i = 0; i < ents_insert.size();i++){ - ins.push_back( ents_insert[i] ); - } - return ins; -} - - - -// Overload the return function to depend on the layer -std::vector< polyline > entities::ret_plines(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; -} - - -std::vector< lwpolyline > entities::ret_lwplines(char * layer){ - char temp[10000]; - std::vector< lwpolyline > lwpls; - lwpls.clear(); - - for(int i = 0; i < ents_lwpolyline.size();i++){ - if ( strcmp( layer,ents_lwpolyline[i].ret_layer_name(temp) ) == 0 ){ - lwpls.push_back( ents_lwpolyline[i] ); - } - } - return lwpls; -} - - -std::vector< circle > entities::ret_circles(char * layer){ - char temp[10000]; - std::vector< circle > circs; - circs.clear(); - - for(int i = 0; i < ents_circle.size();i++){ - if ( strcmp( layer,ents_circle[i].ret_layer_name(temp) ) == 0 ){ - circs.push_back( ents_circle[i] ); - } - } - return circs; -} - - -std::vector< line > entities::ret_lines(char * layer){ - char temp[10000]; - std::vector< line > lns; - lns.clear(); - - for(int i = 0; i < ents_line.size();i++){ - if ( strcmp( layer,ents_line[i].ret_layer_name(temp) ) == 0 ){ - lns.push_back( ents_line[i] ); - } - } - return lns; -} - - -std::vector< text > entities::ret_texts(char * layer){ - char temp[10000]; - std::vector< text > txts; - txts.clear(); - - for(int i = 0; i < ents_text.size();i++){ - if ( strcmp( layer,ents_text[i].ret_layer_name(temp) ) == 0 ){ - txts.push_back( ents_text[i] ); - } - } - return txts; -} - - -/*std::vector< ellipse > entities::ret_ellipses(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; -}*/ - - -std::vector< arc > entities::ret_arcs(char * layer){ - char temp[10000]; - std::vector< arc > a; - a.clear(); - - for(int i = 0; i < ents_arc.size();i++){ - if ( strcmp( layer,ents_arc[i].ret_layer_name(temp) ) == 0 ){ - a.push_back( ents_arc[i] ); - } - } - return a; -} - - -std::vector< insert > entities::ret_inserts(char * layer){ - char temp[10000]; - std::vector< insert > ins; - ins.clear(); - - for(int i = 0; i < ents_insert.size();i++){ - if ( strcmp( layer,ents_insert[i].ret_layer_name(temp) ) == 0 ){ - ins.push_back( ents_insert[i] ); - } - } - return ins; -} - - - - -void entities::display_all(){ - for (int i = 0; i < ents_polyline.size(); i++){ - ents_polyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_lwpolyline.size(); i++){ - ents_lwpolyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_circle.size(); i++){ - ents_circle[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_text.size(); i++){ - ents_text[i].display(); - } -} - - diff --git a/src/extension/dxf2svg/entities.h b/src/extension/dxf2svg/entities.h deleted file mode 100644 index 3afd949b0..000000000 --- a/src/extension/dxf2svg/entities.h +++ /dev/null @@ -1,256 +0,0 @@ -/* Class for interpereting the entities found in a DXF file -Matt Squires -Google SOC -2 July 05 -*/ - -#ifndef DXF_ENTITIES_H -#define DXF_ENTITIES_H - -#include"read_dxf.h" -#include<vector> - - - - -class entity{ - public: - void basic_entity( std::vector< dxfpair > info); // Extract all of the typical entity information (e.g. layer name, positions) - void entity_display(); - double ret_x(); - double ret_y(); - double ret_z(); - char* ret_layer_name(char* string); - char* ret_ltype_name(char* string); - double ret_min_x(); - double ret_max_x(); - double ret_min_y(); - double ret_max_y(); - - - protected: - char layer[10000]; - char linetype[10000]; - double x; - double y; - double z; - double min_x; - double max_x; - double min_y; - double max_y; - void reset_extents(); - void test_coord(double x, double y); -}; - - - - - -class vertex : public entity { - public: - vertex( std::vector< dxfpair > info); - void display(); - double ret_bulge(); - - private: - double bulge; -}; - - - - - -class polyline : public entity { - public: - polyline( std::vector< std::vector< dxfpair > > sections ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; -}; - -class lwpolyline : public entity { - public: - lwpolyline( std::vector< dxfpair > section ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; -}; - -class arc : public entity { - public: - arc( std::vector< dxfpair > info); - double ret_radius(); - double ret_srt_ang(); - double ret_end_ang(); - void display(); - - private: - double radius; - double start_angle; - double end_angle; -}; - - - - -class circle : public entity { - public: - circle( std::vector< dxfpair > info); - void display(); - double ret_radius(); - - private: - double radius; -}; - - -class line : public entity { - public: - line( std::vector< dxfpair > info); - void display(); - double ret_xf(); - double ret_yf(); - double ret_zf(); - - private: - double xf; - double yf; - double zf; -}; - -class ellipse : public entity { - public: - ellipse( std::vector< dxfpair > info); - void display(); - double ret_x_ma; - double ret_y_ma; - double ret_z_ma; - double ret_ratio; - double ret_start_p; - double ret_end_p; - - - private: - double x_major_axis; - double y_major_axis; - double z_major_axis; - double ratio; - double start_param; - double end_param; -}; - - - -class text : public entity { - public: - text( std::vector< dxfpair > info); - void display(); - char * ret_text(char *string); - double ret_txt_ht(); - double ret_txt_rot(); - - private: - char dxf_text[10000]; - double text_height; // dxf 40 - double text_rotation; //dxf 50 -}; - - -class insert : public entity { - public: - insert( std::vector< dxfpair > info); - void display(); - char* name(char* string); - double ret_x_sf; - double ret_y_sf; - double ret_z_sf; - double ret_rotation; - - private: - char block_name[10000]; - double x_scale_factor; - double y_scale_factor; - double z_scale_factor; - double rotation; -}; - - - - - - -class entities{ - // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. - // I also think that there are others in my same boat that prefer stl containers because they are much easier to use - public: - entities(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors - void display_all(); - std::vector< polyline > ret_plines(); - std::vector< circle > ret_circles(); - std::vector< line > ret_lines(); - std::vector< text > ret_texts(); - std::vector< ellipse > ret_ellipses(); - std::vector< arc > ret_arcs(); - std::vector< lwpolyline > ret_lwplines(); - std::vector< insert > ret_inserts(); - // Overload the return function to depend on the layer - std::vector< polyline > ret_plines(char * layer); - std::vector< circle > ret_circles(char * layer); - std::vector< line > ret_lines(char * layer); - std::vector< text > ret_texts(char * layer); - std::vector< ellipse > ret_ellipses(char * layer); - std::vector< arc > ret_arcs(char * layer); - std::vector< lwpolyline > ret_lwplines(char * layer); - std::vector< insert > ret_inserts(char * layer); - - int plines_size(); - int circles_size(); - int lines_size(); - int texts_size(); - - - - private: - void add_polyline(polyline pline); - void add_circle(circle circ); - void add_line(line ln); - - std::vector< polyline > ents_polyline; - std::vector< arc > ents_arc; - std::vector< circle > ents_circle; - std::vector< line > ents_line; - std::vector< ellipse > ents_ellipse; - std::vector< text > ents_text; - std::vector< lwpolyline > ents_lwpolyline; - std::vector< insert > ents_insert; - - -}; - - - -#endif diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp deleted file mode 100644 index 8a17a0d84..000000000 --- a/src/extension/dxf2svg/entities2elements.cpp +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Code for converting dxf entities to SVG elements - * There are multiple ways for converting different items - * If possible most DXF enetities will be converted to paths because that is the most flexable object - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - - -/* - -Matt Squires -SoC 2005 - -*/ - -#include "entities2elements.h" -#include "tables2svg_info.h" -#include <iostream> -#include <math.h> -#include <string.h> -#include <stdlib.h> -// The names indicate the DXF entitiy first and the SVG element last - -// Common elements -char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out){ - // This is used for arcs, polylines, and lwpolylines - char temp[50]; - - // Assume that we are adding to the input and not starting over - strcat(out," A "); - // For arcs there is only one radius - strcat(out,gcvt(scaling*r,precision,temp) ); - strcat(out,","); - strcat(out,gcvt(scaling*r,precision,temp) ); - - strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only - // Determine if it is a large arc - if ( (end_ang > start_ang) && ( (end_ang - start_ang) > 180) ){ - //strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag - strcat(out," 1, "); // Large arc flag...Always use a zero sweep flag - } - else{ - //strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag - strcat(out," 0,"); - } - // This may be easier if I allow r to be plus and minus, but for now this works - if (bulge > 0){ - strcat(out,"0 "); - } - else{ - strcat(out,"1 "); - } -} - -// Build Coordinate -void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){ - // Pairs of coords with units will be used so often build a function build a dedicated function for returning such - - char temp[20]; - if (units != NULL) scaling = 1; // If units have been defined then ignore the scaling parameter - strcat(out, gcvt(scaling*ent->ret_x(),precision,temp) ); // There must be a better function for double to ascii conversion that is defined in most libraries - if (units != NULL) strcat(out, units); - strcat(out, delim); - strcat(out, gcvt(-scaling*ent->ret_y(),precision,temp) ); // Because SVG has a the Y-axis pointed down multiply by -1 - if (units != NULL) strcat(out, units); - strcat(out, " "); -} - -// DXF Polyline -> SVG -// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported -void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ - // 0 is pline2path - // 1 is pline2pline - // 2 is pline2polygon - - - char delim[2]; - - std::vector< vertex >::iterator vver_iter; - std::vector< vertex > points = pline.ret_points(); - - if (type < 1){ - // Put the first Move To at the first, everything else will be a lineto - strcpy(delim," "); - strcat(out, "M "); - coord( &points[0], precision, delim, units, scaling, out ); - double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude - if ( prev_mag_bulge > pow(0.1,precision) ){ - to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out); - } - for (int i = 1; i < points.size(); i++){ - if ( prev_mag_bulge < pow(0.1,precision) ){ - // If the previous point was a bulge then don't use a line to - strcat(out, "L "); - } - coord( &points[i], precision, delim, units, scaling, out ); - // If bulge > some precsion then add bulge - double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); - if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )){ - to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); - } - prev_mag_bulge = mag_bulge; - } - if ( pline.is_closed() ){ - strcat(out,"z"); - } - strcat(out,"\" "); - } - else{ - strcpy(delim,","); - for (int i = 0; i < points.size(); i++){ - coord( &points[i], precision, delim, NULL, scaling, out ); - // If bulge > some precsion then add bulge - } - // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point - if ( (type == 1) && pline.is_closed() ){ - coord( &points[0], precision, delim, NULL, scaling, out ); - } - } - -} - -char* pline2path(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - char *out_ptr; - char out[10000] = "<path d=\""; - entity *ent_ptr = &pline; - char temp[20]; - int precision = 6; - - pline2svg(pline, 0, precision, units, scaling, plot_info, out); - // Add some line information - strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information - - strcat(out," />"); - out_ptr = out; - return out_ptr; -} - -char* pline2pline(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves - entity *ent_ptr = &pline; - char temp[2000]; - int precision = 6; - - char out[10000] = "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" "; - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - //strcpy(temp," "); - - strcat(out,"points=\""); - - //strcat(out,"<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" points=\""); - pline2svg(pline, 1, precision, units, scaling, plot_info, out); - // Add some line information - // if the DXF pline is closed then add an extra point - - strcat(out,"\"/>"); - char *out_ptr = out; - return out_ptr; -} -char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed - //return pline2svg(pline, 2, 6, units, double scaling,out); -} - - -// DXF LWPolyline -> SVG - - -// This could be a template with polyline and lwpolyline but right now it is not that important -void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out); // General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported -void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ - // 0 is pline2path - // 1 is pline2pline - // 2 is pline2polygon - - - char delim[2]; - - std::vector< vertex >::iterator vver_iter; - std::vector< vertex > points = pline.ret_points(); - - if (type < 1){ - // Put the first Move To at the first, everything else will be a lineto - strcpy(delim," "); - strcat(out, "M "); - coord( &points[0], precision, delim, NULL, scaling, out ); - double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude - if ( prev_mag_bulge > pow(0.1,precision) ){ - to_arc(pline.bulge(0),pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out); - } - - for (int i = 1; i < points.size(); i++){ - if ( prev_mag_bulge < pow(0.1,precision) ){ - // If the previous point was a bulge then don't use a line to - strcat(out, "L "); - } - coord( &points[i], precision, delim, NULL , scaling, out ); - // If bulge > some precsion then add bulge - double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); - if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )){ // Make sure the final point doesn't add a bulge on accident - to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); - } - prev_mag_bulge = mag_bulge; - } - if ( pline.is_closed() ){ - strcat(out,"z"); - } - strcat(out,"\" "); - } - else{ - strcpy(delim,","); - for (int i = 0; i < points.size(); i++){ - coord( &points[i], precision, delim, units, scaling, out ); - // If bulge > some precsion then add bulge - } - // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point - if ( (type == 1) && pline.is_closed() ){ - coord( &points[0], precision, delim, units, scaling, out ); - } - } - -} - -char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info){ - // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - char *out_ptr; - char out[10000] = "<path d=\""; - entity *ent_ptr = &pline; - char temp[20]; - int precision = 6; - - lwpline2svg(pline, 0, precision, units, scaling, plot_info, out); - // Add some line information - strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information - - strcat(out," />"); - out_ptr = out; - return out_ptr; -} - -// DXF ARC -> SVG -char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out){ - // So far this appears to be the only way to convert arcs into something recognized by SVG - char *out_ptr; - char temp[20]; - entity *ent_ptr = &a; - - strcpy(out,"<path d=\"M"); - // Calculate the starting point from the center and the start angle. As far as I can tell the rotation is CCW in the dxf notation and it in degrees - strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_srt_ang()*3.14159/180 )),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_srt_ang()*3.14159/180 )),precision,temp) ); - strcat(out," A "); - // For arcs there is only one radius - strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) ); - - strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only - // Determine if it is a large arc - if ( (a.ret_end_ang() > a.ret_srt_ang()) && ( (a.ret_end_ang() - a.ret_srt_ang()) > 180) ){ - strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag - } - else{ - strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag - } - - //The final point - strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_end_ang()*3.14159/180 )),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_end_ang()*3.14159/180 )),precision,temp) ); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - strcat(out, " />"); - - - out_ptr = out; - return out_ptr; - -} - - -// DXF Circle -> SVG -char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){ - // Direct conversion of DXF circle to SVG circle - char *out_ptr; - char temp[1000]="\" cy=\""; - entity *ent_ptr = ˆ - strcpy(out,"<circle cx=\""); - coord(ent_ptr, precision,temp, units, scaling, out); - strcat(out,"\" r=\""); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,units); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - //plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - //pattern2dasharray(plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)), precision, scaling, out); // Add the linetype information - strcat(out, " />"); - out_ptr = out; - return out_ptr; -} - -char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){ - // Conversion of DXF circle to SVG circle assuming the path will represent the circle - - char *out_ptr; - char temp[20]=","; - entity *ent_ptr = ˆ - - strcpy(out,"<path d=\"M"); - // The starting point is x-r,y so subtract off the radius from the x coord - strcat(out,gcvt(ent_ptr->ret_x()-circ.ret_radius(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) ); - - strcat(out," a"); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,","); - strcat(out,gcvt(circ.ret_radius(),precision,temp) ); - strcat(out,"0 0,0 0,0\" fill=\"none\" stroke=\"black\" stroke-width=\"1\""); - - out_ptr = out; - return out_ptr; -} - - -// DXF Line -> SVG -char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out){ - // Directly convert DXF to SVG because it works - char *out_ptr; - char temp[20]; - entity *ent_ptr = &ln; - - strcpy(out,"<line x1=\""); - strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y1=\""); - strcat(out,gcvt(-1*ent_ptr->ret_y(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,units); - - strcat(out,"\" x2=\""); - strcat(out,gcvt(ln.ret_xf(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y2=\""); - strcat(out,gcvt(-1*ln.ret_yf(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,units); - strcat(out,"\" stroke-width=\"1\" stroke=\"black\" "); - ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)); - pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information - strcat(out, " />"); - - out_ptr = out; - return out_ptr; -} - - -char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out){ - // Convert DXF line to SVG path - - char *out_ptr; - char temp[20]; - entity *ent_ptr = &ln; - - strcpy(out,"<path d=\"M"); - strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(scaling*ent_ptr->ret_y(),precision,temp) ); - - strcat(out," L"); - strcat(out,gcvt(scaling*ln.ret_xf(),precision,temp) ); - strcat(out," "); - strcat(out,gcvt(scaling*ln.ret_yf(),precision,temp) ); - strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" /"); - - out_ptr = out; - return out_ptr; -} - -// DXF Text -> SVG -char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out){ - // Directly convert DXF to SVG because it works - char *out_ptr; - char temp[10000]; - entity *ent_ptr = &txt; - - // If the text is rotated use the transform matrix - - if ( txt.ret_txt_rot() > precision ){ - double ca = cos(0.017453*txt.ret_txt_rot()); // ca = cosine(a) - double sa = sin(-0.017453*txt.ret_txt_rot()); // sa = sine(a) - double tx = ent_ptr->ret_x()*scaling; - double ty = -ent_ptr->ret_y()*scaling; - // Apply a translation to the orgin, then a rotation, then a translation back to the original position - double a = ca; - double b = sa; - double c = -sa; - double d = ca; - double e = -1*(tx*ca-ty*sa-tx); - double f = -1*(tx*sa+ty*ca-ty); - - strcpy(out, "<g transform=\"matrix("); - strcat(out,gcvt(a,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(b,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(c,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(d,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(e,precision,temp) ); - strcat(out," "); - strcat(out,gcvt(f,precision,temp) ); - strcat(out,")\" >\n<text x=\""); - } - else{ - strcpy(out,"<text x=\""); - } - /* - strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) ); - strcat(out,units); - strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) ); - strcat(out,units); - */ - strcat(out,gcvt(ent_ptr->ret_x()*scaling,precision,temp) ); - //strcat(out,units); - strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis - strcat(out,gcvt(ent_ptr->ret_y()*scaling,precision,temp) ); - //strcat(out,units); - strcat(out,"\" font-family=\"Verdana\" font-size=\""); - strcat(out,gcvt(scaling*txt.ret_txt_ht(),precision,temp) ); - strcat(out,"\" Fill=\"black\""); - - strcat(out," >"); - // Now put in the text - strcat(out,txt.ret_text(temp)); - - // Now close the text element - strcat(out,"</text>"); - // If the text was rotated finish off the tranform group - if ( txt.ret_txt_rot() > precision ){ - strcat(out,"</g>"); - } - - out_ptr = out; - return out_ptr; -} - - - -// DXF Insert -> SVG -char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out){ - char *out_ptr; - char tmp_char[100000]; - - // get the block using the name from the insert information - block blk = blks.ret_block(in.name(tmp_char)); - - entity *ent_ptr = ∈ - entities *ents_ptr = &blk; - // For now just translations MBS 22 Aug 05 - strcpy(out, "<g transform=\"matrix(1,0,0,1,"); - strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,tmp_char) ); - strcat(out,","); - strcat(out,gcvt(-scaling*ent_ptr->ret_y(),precision,tmp_char) ); - strcat(out,")\" >\n"); - - - // Now convert the entities in the block - std::vector< polyline > plines = ents_ptr->ret_plines(); - std::vector< lwpolyline > lwplines = ents_ptr->ret_lwplines(); - std::vector< arc > arcs = ents_ptr->ret_arcs(); - std::vector< circle > circs = ents_ptr->ret_circles(); - std::vector< line > lns = ents_ptr->ret_lines(); - std::vector< text > txts = ents_ptr->ret_texts(); - - - - for(int i = 0; i < plines.size();i++){ - strcat( out,pline2pline(plines[i], units, scaling, plot_info ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < lwplines.size();i++){ - strcat( out,lwpline2path(lwplines[i], units, scaling, plot_info ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < arcs.size();i++){ - strcat( out, arc2path(arcs[i], 6,units, scaling, plot_info, tmp_char ) ); - strcat( out, "\n" ); - } - for(int i = 0; i < circs.size();i++){ - strcat( out, circle2circle(circs[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - for(int i = 0; i < lns.size();i++){ - strcat( out, line2line(lns[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - for(int i = 0; i < txts.size();i++){ - strcat( out, text2text(txts[i], 6, units, scaling, plot_info, tmp_char) ); - strcat( out, "\n" ); - } - // End the group - strcat(out,"</g>"); - - out_ptr = out; - return out_ptr; -} - - - -char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out){ - // output_type = 0 is to std:out - // output_type = 1 is to the input filename but with .dxf on the end - - // For now everything will go to stdout later may directed to other places - - // Get the various file informations as dependent on the layer type - std::vector< polyline > plines = ents.ret_plines(layer); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(layer); - std::vector< arc > arcs = ents.ret_arcs(layer); - std::vector< circle > circs = ents.ret_circles(layer); - std::vector< line > lns = ents.ret_lines(layer); - std::vector< text > txts = ents.ret_texts(layer); - std::vector< insert > ins = ents.ret_inserts(layer); - - // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better - char tmp_char[100000]; - for(int i = 0; i < plines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < lwplines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < arcs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - } - for(int i = 0; i < circs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < lns.size();i++){ - if (output_type == 0){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < txts.size();i++){ - if (output_type == 0){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < ins.size();i++){ - if (output_type == 0){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - } -} - - - -char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out){ - // output_type = 0 is to std:out - // output_type = 1 is to the input filename but with .dxf on the end - - // For now everything will go to stdout later may directed to other places - - // Get the various file informations as dependent on the layer type - std::vector< polyline > plines = ents.ret_plines(); - std::vector< lwpolyline > lwplines = ents.ret_lwplines(); - std::vector< arc > arcs = ents.ret_arcs(); - std::vector< circle > circs = ents.ret_circles(); - std::vector< line > lns = ents.ret_lines(); - std::vector< text > txts = ents.ret_texts(); - std::vector< insert > ins = ents.ret_inserts(); - - // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better - char tmp_char[100000]; - for(int i = 0; i < plines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < lwplines.size();i++){ - if (output_type == 0){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl; - } - } - for(int i = 0; i < arcs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl; - } - } - for(int i = 0; i < circs.size();i++){ - if (output_type == 0){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < lns.size();i++){ - if (output_type == 0){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < txts.size();i++){ - if (output_type == 0){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl; - } - } - for(int i = 0; i < ins.size();i++){ - if (output_type == 0){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - else if (output_type == 1){ - std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl; - } - } -} - - - diff --git a/src/extension/dxf2svg/entities2elements.h b/src/extension/dxf2svg/entities2elements.h deleted file mode 100644 index cceefcf15..000000000 --- a/src/extension/dxf2svg/entities2elements.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Method for converting dxf entities to SVG elements -There are multiple ways for converting different items - -If possible most DXF enetities will be converted to paths because that is the most flexable object - -Matt Squires -SoC 2005 - -*/ - -#include"entities.h" -#include"tables.h" -#include"blocks.h" - -// The names indicate the DXF entitiy first and the SVG element last - -// Common elements -char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out); // This is used for arcs, polylines, and lwpolylines - -// DXF Polyline -> SVG - -char* pline2path(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element -char* pline2pline(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves -char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed - -// DXF LWPolyline -> SVG -char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element - -// DXF ARC -> SVG -char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out); // So far this appears to be the only way to convert arcs into something recognized by SVG - - -// DXF Circle -> SVG -char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Direct conversion of DXF circle to SVG circle -char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Conversion of DXF circle to SVG circle assuming the path will represent the circle - - -// DXF Line -> SVG -char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVG because it works -char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Convert DXF line to SVG path - -// DXF Text -> SVG -char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVF assuming VERANDA font - -// DXF Insert -> SVG -char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out); - -// Write all of the possible enties with a variety of options - -char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out); // Write out the entities by layer designation -char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out); - - diff --git a/src/extension/dxf2svg/read_dxf.cpp b/src/extension/dxf2svg/read_dxf.cpp deleted file mode 100644 index 1a4eefbc9..000000000 --- a/src/extension/dxf2svg/read_dxf.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * For reading and slight parsing of dxf files - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - - -#include <fstream> -#include <string> -#include "read_dxf.h" - -#include <iostream> -#include <string.h> -#include <stdlib.h> -using namespace std; - - -int MAX_STR_LN = 10000; - -int section(char* value){ - if ( strncmp(value,"HEADER",6) == 0 ) return 0; - if ( strncmp(value,"CLASSES",7) == 0 ) return 1; - if ( strncmp(value,"TABLES",6) == 0 ) return 2; - if ( strncmp(value,"BLOCKS",6) == 0 ) return 3; - if ( strncmp(value,"ENTITIES",8) == 0 ) return 4; - if ( strncmp(value,"OBJECTS",7) == 0 ) return 5; - if ( strncmp(value,"THUMBNAILIMAGE",14) == 0 ) return 6; -} - - -dxfpair::dxfpair(int gcode, char val[10000]){ - group_code = gcode; - // Dynamically save the strings, otherwise the memory uses is bad - - for (int i = 0; i < strlen(val); i++){ - value.push_back(val[i]); - } -} - - -dxfpair::~dxfpair(){ - //delete [] value; -} - -char * dxfpair::value_char(char *string){ - int size = value.size(); - while( ( size > 0 ) && int(value[size-1]) < 33){ - // Strip off any control characters and spaces off the end of the string - size--; - } - for(int i = 0; i < size; i++){ - string[i] = value[i]; - } - string[size]=0; -} - -std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename){ - // In the dxf format information is paired into group codes that indicate the information that follows on the next line. The information on the next line is called the value - - int n =0; - - int group_code; - char value[MAX_STR_LN]; - - int section_num; - - - - - std::vector< std::vector< dxfpair > > out; - - std::vector< dxfpair > header; - std::vector< dxfpair > classes; - std::vector< dxfpair > tables; - std::vector< dxfpair > blocks; - std::vector< dxfpair > entities; - std::vector< dxfpair > objects; - std::vector< dxfpair > thumbnailimage; - - header.clear(); - classes.clear(); - tables.clear(); - blocks.clear(); - entities.clear(); - objects.clear(); - thumbnailimage.clear(); - - - // Open dxf file for reading - std::ifstream file(filename); - - if (!file.is_open()){ - exit (1); // Change this to an exception - } - - // Find the first SECTION header - - while ( (!file.eof()) ){ - n++; - - // get the first group code and value - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - - do{ - - // TO DO set all the chars to be caps for later comparison - - // Find the SECTION codes - if ( (group_code == 0 ) && ( strncmp(value,"SECTION",7) == 0 ) ){ - // Directly after a section value is the type of section ( e.g. HEADER, TABLES ) - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - section_num = section( value ); - if ( group_code == 2 ){ - // Make sure the the group code is 2 for the SECTION name - // This is a big block of mostly repetitive code, it will result in larger code, but would be faster than putting the switch in another while loop. If I still live in a time when file size mattered alot I would change it - //std::cout << "section_num = " << section_num << std::endl; - switch ( section_num ){ - case 0: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - header.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 1: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - if ( (group_code != 0) || (strncmp(value,"ENDSEC",6) != 0) ){ - // Some dxf files have blank sections. These are not handled by the do/while loop so break about if needed - do{ - classes.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - } - break; - case 2: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - tables.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); - break; - case 3: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - blocks.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 4: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - entities.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 5: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - objects.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - case 6: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - do{ - thumbnailimage.push_back( dxfpair( group_code, value ) ); - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later - break; - default: - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - } - } - } - file.getline(value,MAX_STR_LN); - group_code = atoi(value); - file.getline(value,MAX_STR_LN); - - n++; - }while( ( strncmp(value,"EOF",3) != 0 ) && (!file.eof()) ); - } - - out.push_back(header); - out.push_back(classes); - out.push_back(tables); - out.push_back(blocks); - out.push_back(entities); - out.push_back(objects); - out.push_back(thumbnailimage); - - return out; -} - - -std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section){ - //std::cout << "1" << std::endl; - //std::cout << "section.size() = " << section.size() << std::endl; - // Find where the major sections are and break into smaller parts - // Major section is defined as anything beween group_code 0 to 0 - std::vector< dxfpair > inner; - std::vector< std::vector< dxfpair > > outer; - //std::cout << "2" << std::endl; - for (int i = 0; i < section.size(); i++){ - //std::cout << "i = " << i << std::endl; - //std::cout << "section[i].value.size() = " << section[i].value.size() << std::endl; - - // Make sure no control codes like LF or CR are making it past this section - if ( (section[i].value.size() > 0) && int(section[i].value.back()) < 32 ){ - section[i].value.pop_back(); - } - //for(int j = 0;j < section[i].value.size();j++ ) std::cout << section[i].value[j]; - //std::cout << std::endl; - - inner.push_back( section[i] ); - - // If the next group code is 0 then push the previously found info on outer and start looking for data again - if (section[i+1].group_code == 0){ - //std::cout << "inner.push_back" << std::endl; - outer.push_back( inner ); - inner.clear(); - } - } - // Because putting the data on outer depends on find a GC=0 the last bit of data may be left behind so it inner has data in it put it on outer - if (!inner.empty()){ - outer.push_back( inner ); - inner.clear(); - } - //std::cout << "3" << std::endl; - if (section.back().group_code == 0){ - //outer.push_back( inner ); // Put the last part on if there is information, but I don't think it needs to. - } - - return outer; -} - diff --git a/src/extension/dxf2svg/read_dxf.h b/src/extension/dxf2svg/read_dxf.h deleted file mode 100644 index 7e008b4e0..000000000 --- a/src/extension/dxf2svg/read_dxf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Header file for reading dxf information and basic parsing. Interprting information is found in other files -*/ - -#ifndef READ_DXF_H -#define READ_DXF_H - -#include<vector> - - - -class dxfpair{ -public: - dxfpair(int gcode, char val[10000]); - virtual ~dxfpair(); - - char * value_char(char *string); - - // Leave this data public - int group_code; - std::vector< char > value; -}; - - - - -int section(char* value); // Convert the section titles into integers - -std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename); - -std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section ); // Find where the major sections are and break into smaller parts - -#endif diff --git a/src/extension/dxf2svg/tables.cpp b/src/extension/dxf2svg/tables.cpp deleted file mode 100644 index fcaff33c0..000000000 --- a/src/extension/dxf2svg/tables.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Code for the conversion of DXF information in the TABLES section - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - -#include"tables.h" -#include<iostream> - - - - -int determine_table(char* value){ - // Common Elements as far as I am concerend - if ( strncmp(value,"LAYER",5) == 0 ) return 0; - if ( strncmp(value,"LTYPE",5) == 0 ) return 1; - if ( strncmp(value,"STYLE",5) == 0 ) return 2; - if ( strncmp(value,"UCS",3) == 0 ) return 3; - if ( strncmp(value,"VIEW",4) == 0 ) return 4; - if ( strncmp(value,"VPORT",4) == 0 ) return 5; - if ( strncmp(value,"APPID",5) == 0 ) return 6; - if ( strncmp(value,"BLOCK_RECORD",12) == 0 ) return 7; - else return -1; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// TABLE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -int table::ret_maxN(){ - return max_number; -} - - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LAYER -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -layer::layer( std::vector< dxfpair > info){ - // Get the vertex information - - //basic_entity( info ); - //static char string[10000]; - char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(layer_name); - break; - case 6: - info[i].value_char(ltype_name); - break; - - case 62: - info[i].value_char(string); - color_number = atoi(string); - //std::cout << "I found a color and its number = " << color_number << std::endl; - break; - case 290: - info[i].value_char(string); - plotting_flag = atoi(string); - break; - } - } -} - -void layer::display(){ - std::cout << "LAYER\n"; - //std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; -} - -char* layer::name(char* string){ - return( strcpy(string,layer_name) ); -} - - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LTYPE -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -ltype::ltype( std::vector< dxfpair > info){ - // Get the linetype information - - //static char string[10000]; - char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(ltype_name); - break; - case 3: - info[i].value_char(descriptive_txt); - break; - case 73: - info[i].value_char(string); - num_elements = atoi(string); - break; - case 40: - info[i].value_char(string); - pattern_length = atof(string); - break; - case 49: - info[i].value_char(string); - pattern.push_back( atof(string) ); - break; - } - } -} - - - -char* ltype::name(char* string){ - return( strcpy(string,ltype_name) ); -} - - -std::vector< double > ltype::ret_pattern(){ - return pattern; -} - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// tables -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -tables::tables(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - int value; - char string[10000]; - - for(int i = 0; i < sections.size(); i++){ - //std::cout << "start" << std::endl; - sections[i][0].value_char(string); - value = determine_table(string); - //std::cout << "sections.size() = " << sections.size() << std::endl << "i = " << i << std::endl << "string = " << string << std::endl; - switch( value ){ - case 0: - // LAYER - //std::cout << "tables start layer " << std::endl; - tables_layer.push_back( layer( sections[i] ) ); - //std::cout << "tables end layer " << std::endl; - break; - - case 1: - // LTYPE - //std::cout << "tables start ltype " << std::endl; - tables_ltype.push_back( ltype( sections[i] ) ); - //std::cout << "tables end ltype " << std::endl; - break; - - //case 3: - // break; - - default: - break; - // Nothing here - } - - } - -} - - - - -ltype tables::ret_ltype(char ltype_name[10000], char layer_name[10000]){ - int string_len = 0; - char name[10000]; - char temp[10000]; - // The ltype information may be given in the entitity or in the layer information - // Assume that if there is a name defined in the linetype that it trumps any other layer information - if ( strlen(ltype_name) > 0 ) strcpy(name,ltype_name); - else strcpy(name,layer_name); - for (int i = 0; i < tables_ltype.size();i++){ - string_len = strlen(tables_ltype[i].name(temp)); - if (strncmp(tables_ltype[i].name(temp),name,string_len) == 0 ) return tables_ltype[i]; - } - return tables_ltype[0]; -} - - -layer tables::ret_layer(char layer_name[10000]){ - int string_len = 0; - char temp[10000]; - - for (int i = 0; i < tables_layer.size();i++){ - string_len = strlen(tables_layer[i].name(temp)); - if (strncmp(tables_layer[i].name(temp),layer_name,string_len) == 0 ) return tables_layer[i]; - } - return tables_layer[0]; -} - - -std::vector< layer > tables::ret_layers(){ - return tables_layer; -} diff --git a/src/extension/dxf2svg/tables.h b/src/extension/dxf2svg/tables.h deleted file mode 100644 index f63122eaf..000000000 --- a/src/extension/dxf2svg/tables.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Code for the conversion of DXF information in the TABLES section -Matt Squires -SoC -2005*/ - -#ifndef DXF_TABLES_H -#define DXF_TABLES_H - -#include<vector> -#include"read_dxf.h" - -class table{ - public: - int ret_maxN(); - private: - int max_number; -}; - - -class layer : public table{ - public: - layer( std::vector< dxfpair > info); - void display(); - char* name(char* string); - private: - char layer_name[10000]; - char ltype_name[10000]; // The layer may also hold the ltype infomation - int color_number; - int plotting_flag; - -}; - - -class ltype : public table{ - public: - ltype( std::vector< dxfpair > info); - char* name(char* string); - std::vector< double > ret_pattern(); - private: - char ltype_name[10000]; - char descriptive_txt[10000]; - int num_elements; - double pattern_length; - std::vector< double > pattern; - -}; - - -class tables{ - // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. - public: - tables(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors - void display_all(); - - ltype ret_ltype(char ltype_name[10000], char layer_name[10000]); - layer ret_layer(char layer_name[10000]); - - std::vector< layer > ret_layers(); - - - private: - //void add_dimstyle(polyline pline); - void add_layer(layer layr); - void add_ltype(ltype line_type); - - std::vector< layer > tables_layer; - std::vector< ltype > tables_ltype; -}; - - -#endif diff --git a/src/extension/dxf2svg/tables2svg_info.cpp b/src/extension/dxf2svg/tables2svg_info.cpp deleted file mode 100644 index c59060306..000000000 --- a/src/extension/dxf2svg/tables2svg_info.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Convert DXF table information to a format that is recognized by SVG - * - * Author: - * Matt Squires <squiresm@colorado.edu> - * - * Copyright (C) 2005 Matt Squires - * - * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details - */ - - -#include "tables2svg_info.h" -#include <math.h> -#include <iostream> -#include <stdlib.h> -#include <string.h> - -char* pattern2dasharray(ltype info, int precision, double scaling, char* out){ - std::vector< double > pattern = info.ret_pattern(); - char temp[50]; - char *out_ptr; - - - if (!pattern.empty()){ - strcat(out," stroke-dasharray=\""); - for(int i = 0; i < pattern.size()-1;i++){ - strcat(out,gcvt(scaling*sqrt(pow(pattern[i],2)),precision,temp) ); - strcat(out,","); - } - strcat( out,gcvt(scaling*sqrt(pow(pattern[pattern.size()-1],2)),precision,temp) ); - strcat(out,"\" "); - } - - out_ptr = out; - return out_ptr; -} diff --git a/src/extension/dxf2svg/tables2svg_info.h b/src/extension/dxf2svg/tables2svg_info.h deleted file mode 100644 index 2c99f034e..000000000 --- a/src/extension/dxf2svg/tables2svg_info.h +++ /dev/null @@ -1,9 +0,0 @@ -/* Convert DXF table information to a format that is recognized by SVG -Matt Squires -SOC 2005 -*/ - - -#include"tables.h" - -char* pattern2dasharray(ltype info, int precision, double scaling, char* temp); diff --git a/src/extension/dxf2svg/test_dxf.cpp b/src/extension/dxf2svg/test_dxf.cpp deleted file mode 100644 index c3bbdc141..000000000 --- a/src/extension/dxf2svg/test_dxf.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* test read_dxf */ -#include"read_dxf.h" -#include"entities.h" -#include"blocks.h" -#include"tables.h" -#include<iostream> -#include"entities2elements.h" - -using namespace std; - -int main(){ - std::vector< std::vector< dxfpair > > output, entities_info, blocks_info, tables_info; - //output = dxf_get_sections("circ_sqr.dxf"); - //output = dxf_get_sections("Labjack.dxf"); - //output = dxf_get_sections("mini_post.dxf"); - //output = dxf_get_sections("../8599-E0W.dxf"); - //output = dxf_get_sections("../bulged_lwpoly.dxf"); - //output = dxf_get_sections("../aspheric_lens.dxf"); - output = dxf_get_sections("../layers_colors.dxf"); - /*std::vector< dxfpair > header; - std::vector< dxfpair > classes; - std::vector< dxfpair > tables; - std::vector< dxfpair > blocks; - std::vector< dxfpair > entities; - std::vector< dxfpair > objects; - std::vector< dxfpair > thumbnailimage; - */ - - - //dxf_get_sections("circ_sqr.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage); - //dxf_get_sections("mini_post.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage); - - //cout << entities.size() << endl; - for (int i=0;i<output.size();i++) cout << "output[i].size()" << i << " = " << output[i].size() << endl; - //cout << endl; - //for (int i=0;i<output[0].size();i++) cout << output[0][i].group_code << "\t" << output[0][i].value << endl; - //cout << endl; - //for (int i=0;i<output[4].size();i++) cout << output[4][i].group_code << "\t" << output[4][i].value << endl; - - // Now display the different parts of the entities section - //cout << endl; - for (int i=0;i < output[4].size();i++){ - //cout << output[4][i].group_code << " " << output[4][i].value[0] << output[4][i].value[1] << endl; - } - cout << endl; - entities_info = separate_parts(output[4]); - cout << "entities_info.size() = " << entities_info.size() << endl; - - for (int i=0;i < entities_info.size();i++){ - //for (int j=0;j < entities_info[i].size();j++) cout << entities_info[i][j].group_code << " " << entities_info[i][j].value[0] << entities_info[i][j].value[1] << entities_info[i][j].value[2] << entities_info[i][j].value[3] << entities_info[i][j].value[4] << "\n"; - //cout << endl << endl << endl; - } - - cout << "blocks separate parts" << endl; - blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file. - cout << "sort separated parts" << endl; - blocks blks(blocks_info); // Sort the information in the tables - cout << "blocks_info.size() = " << blocks_info.size() << endl; - - for (int i=0;i < blocks_info.size();i++){ - //for (int j=0;j < blocks_info[i].size();j++) cout << blocks_info[i][j].group_code << " " << blocks_info[i][j].value[0] << blocks_info[i][j].value[1] << blocks_info[i][j].value[2] << blocks_info[i][j].value[3] << blocks_info[i][j].value[4] << "\n"; - //cout << endl << endl << endl; - } - - - tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file. - cout << "tables_info.size() = " << tables_info.size() << endl; - for (int i=0;i < tables_info.size();i++){ - //for (int j=0;j < tables_info[i].size();j++) cout << tables_info[i][j].group_code << " " << tables_info[i][j].value[0] << tables_info[i][j].value[1] << tables_info[i][j].value[2] << tables_info[i][j].value[3] << tables_info[i][j].value[4] << "\n"; - //cout << "i = " << i << endl << endl; - } - tables tbls(tables_info); // Sort the information in the tables - - - - cout << "This should change \n"; - - cout << "\n\nNow display all parsed info \n"; - entities ents(entities_info); - ents.display_all(); - - //char units[5] = "in"; - // char units[5] = ""; - - cout << "\nNow for the begining of the SVG...\n\n"; - - cout << "Polyline conversion\n"; - //std::vector< polyline > pl_tmp= ents.ret_plines(); - //cout << "pline2pline\n" << pline2pline(pl_tmp[0], units ) << endl; - //cout << "pline2pline\n" << pline2pline(ents.ret_plines()[0], units ) << endl; - //cout << "pline2path\n" << pline2path(ents.ret_plines()[0], units ); - - // char tmp_char[10000]; - - cout << "\nCircle conversion\n"; - //cout << "circle2circle\n" << circle2circle(ents.ret_circles()[0], 3, units, tmp_char) << endl; - - return 0; -} diff --git a/src/extension/init.cpp b/src/extension/init.cpp index ac3c90421..5555eddf6 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -56,6 +56,9 @@ #ifdef WITH_LIBVISIO #include "internal/vsd-input.h" #endif +#ifdef WITH_LIBCDR +#include "internal/cdr-input.h" +#endif #include "preferences.h" #include "io/sys.h" #ifdef WITH_DBUS @@ -191,6 +194,9 @@ init() #ifdef WITH_LIBVISIO Internal::VsdInput::init(); #endif +#ifdef WITH_LIBCDR + Internal::CdrInput::init(); +#endif /* Effects */ Internal::BlurEdge::init(); diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 1ea6caca9..9e55598df 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -12,6 +12,12 @@ ink_common_sources += \ extension/internal/vsd-input.h endif +if WITH_LIBCDR +ink_common_sources += \ + extension/internal/cdr-input.cpp \ + extension/internal/cdr-input.h +endif + if USE_IMAGE_MAGICK ink_common_sources += \ extension/internal/bitmap/imagemagick.cpp \ diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp new file mode 100644 index 000000000..e6c400fb5 --- /dev/null +++ b/src/extension/internal/cdr-input.cpp @@ -0,0 +1,332 @@ +/* + * This file came from libwpg as a source, their utility wpg2svg + * specifically. It has been modified to work as an Inkscape extension. + * The Inkscape extension code is covered by this copyright, but the + * rest is covered by the one bellow. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#include <stdio.h> +#include "config.h" + +#include "cdr-input.h" + +#ifdef WITH_LIBCDR + +#include <string> +#include <cstring> + +#include <libcdr/libcdr.h> +#include <libwpd-stream/libwpd-stream.h> + +#include <gtkmm/alignment.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/drawingarea.h> +#include <gtkmm/frame.h> +#include <gtkmm/scale.h> + +#include "extension/system.h" +#include "extension/input.h" +#include "document.h" + +#include "document-private.h" +#include "document-undo.h" +#include "inkscape.h" + +#include "dialogs/dialog-events.h" +#include <gtk/gtk.h> +#include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" +#include <glibmm/i18n.h> + +#include <gdkmm/general.h> + +#include "svg-view.h" +#include "svg-view-widget.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + + +class CdrImportDialog : public Gtk::Dialog { +public: + CdrImportDialog(const std::vector<WPXString> &vec); + virtual ~CdrImportDialog(); + + bool showDialog(); + unsigned getSelectedPage(); + void getImportSettings(Inkscape::XML::Node *prefs); + +private: + void _setPreviewPage(unsigned page); + + // Signal handlers +#if !WITH_GTKMM_3_0 + bool _onExposePreview(GdkEventExpose *event); +#endif + + void _onPageNumberChanged(); + + class Gtk::Button * cancelbutton; + class Gtk::Button * okbutton; + class Gtk::Label * _labelSelect; + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; + class Gtk::Label * _labelTotalPages; + class Gtk::VBox * vbox1; + class Gtk::VBox * vbox2; + class Gtk::Widget * _previewArea; + + const std::vector<WPXString> &_vec; // Document to be imported + unsigned _current_page; // Current selected page + int _preview_width, _preview_height; // Size of the preview area +}; + +CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec) + : _vec(vec), _current_page(1) +{ + int num_pages = _vec.size(); + if ( num_pages <= 1 ) + return; + cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); + okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); + + // Page number +#if WITH_GTKMM_3_0 + Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); +#else + Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( + new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); +#endif + _labelTotalPages = Gtk::manage(new class Gtk::Label()); + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); + _labelTotalPages->set_label(label_text); + g_free(label_text); + + vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0); + _previewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + + vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); + cancelbutton->set_can_focus(); + cancelbutton->set_can_default(); + cancelbutton->set_relief(Gtk::RELIEF_NORMAL); + okbutton->set_can_focus(); + okbutton->set_can_default(); + okbutton->set_relief(Gtk::RELIEF_NORMAL); + this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); + _labelSelect->set_line_wrap(false); + _labelSelect->set_use_markup(false); + _labelSelect->set_selectable(false); + _pageNumberSpin->set_can_focus(); + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); + _pageNumberSpin->set_numeric(true); + _pageNumberSpin->set_digits(0); + _pageNumberSpin->set_wrap(false); + _labelTotalPages->set_line_wrap(false); + _labelTotalPages->set_use_markup(false); + _labelTotalPages->set_selectable(false); + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + this->get_vbox()->set_homogeneous(false); + this->get_vbox()->set_spacing(0); + this->get_vbox()->pack_start(*vbox2); + this->set_title(_("Page Selector")); + this->set_modal(true); + sp_transientize(GTK_WIDGET(this->gobj())); //Make transient + this->property_window_position().set_value(Gtk::WIN_POS_NONE); + this->set_resizable(true); + this->property_destroy_with_parent().set_value(false); + this->get_action_area()->add(*_labelSelect); + this->add_action_widget(*_pageNumberSpin, -7); + this->get_action_area()->add(*_labelTotalPages); + this->add_action_widget(*cancelbutton, -6); + this->add_action_widget(*okbutton, -5); + cancelbutton->show(); + okbutton->show(); + _labelSelect->show(); + _pageNumberSpin->show(); + _labelTotalPages->show(); + vbox1->show(); + _previewArea->show(); + vbox2->show(); + + // Connect signals + _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged)); +} + +CdrImportDialog::~CdrImportDialog() {} + +bool CdrImportDialog::showDialog() +{ + show(); + gint b = run(); + hide(); + if ( b == Gtk::RESPONSE_OK ) { + return TRUE; + } else { + return FALSE; + } +} + +unsigned CdrImportDialog::getSelectedPage() +{ + return _current_page; +} + +void CdrImportDialog::_onPageNumberChanged() +{ + unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int()); + _current_page = CLAMP(page, 1U, _vec.size()); + _setPreviewPage(_current_page); +} + +/** + * \brief Renders the given page's thumbnail + */ +void CdrImportDialog::_setPreviewPage(unsigned page) +{ + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0); + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); + std::swap(_previewArea, tmpPreviewArea); + if (tmpPreviewArea) { + _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() ); + delete tmpPreviewArea; + } + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); + _previewArea->show_now(); +} + +SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) +{ + WPXFileStream input(uri); + + if (!libcdr::CDRDocument::isSupported(&input)) { + return NULL; + } + + libcdr::CDRStringVector output; + if (!libcdr::CDRDocument::generateSVG(&input, output)) { + return NULL; + } + + if (output.empty()) { + return NULL; + } + + std::vector<WPXString> tmpSVGOutput; + for (unsigned i=0; i<output.size(); ++i) { + WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); + tmpString.append(output[i]); + tmpSVGOutput.push_back(tmpString); + } + + unsigned page_num = 1; + + // If only one page is present, import that one without bothering user + if (tmpSVGOutput.size() > 1) { + CdrImportDialog *dlg = 0; + if (inkscape_use_gui()) { + dlg = new CdrImportDialog(tmpSVGOutput); + if (!dlg->showDialog()) { + delete dlg; + return NULL; + } + } + + // Get needed page + if (dlg) { + page_num = dlg->getSelectedPage(); + if (page_num < 1) + page_num = 1; + if (page_num > tmpSVGOutput.size()) + page_num = tmpSVGOutput.size(); + } + } + + SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); + return doc; +} + +#include "clear-n_.h" + +void CdrInput::init(void) +{ + /* CDR */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Input") "</name>\n" + "<id>org.inkscape.input.cdr</id>\n" + "<input>\n" + "<extension>.cdr</extension>\n" + "<mimetype>image/x-xcdr</mimetype>\n" + "<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n" + "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CDT */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW templates input") "</name>\n" + "<id>org.inkscape.input.cdt</id>\n" + "<input>\n" + "<extension>.cdt</extension>\n" + "<mimetype>application/x-xcdt</mimetype>\n" + "<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n" + "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CCX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n" + "<id>org.inkscape.input.ccx</id>\n" + "<input>\n" + "<extension>.ccx</extension>\n" + "<mimetype>application/x-xccx</mimetype>\n" + "<filetypename>" N_("Corel DRAW Compressed Exchange files (*.ccx)") "</filetypename>\n" + "<filetypetooltip>" N_("Open compressed exchange files saved in Corel DRAW") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + /* CMX */ + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Corel DRAW Presentation Exchange files input") "</name>\n" + "<id>org.inkscape.input.cmx</id>\n" + "<input>\n" + "<extension>.cmx</extension>\n" + "<mimetype>application/x-xcmx</mimetype>\n" + "<filetypename>" N_("Corel DRAW Presentation Exchange files (*.cmx)") "</filetypename>\n" + "<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n" + "</input>\n" + "</inkscape-extension>", new CdrInput()); + + return; + +} // init + +} } } /* namespace Inkscape, Extension, Implementation */ +#endif /* WITH_LIBCDR */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h new file mode 100644 index 000000000..10af41d5a --- /dev/null +++ b/src/extension/internal/cdr-input.h @@ -0,0 +1,54 @@ +/* + * This code abstracts the libwpg interfaces into the Inkscape + * input extension interface. + * + * Authors: + * Fridrich Strba (fridrich.strba@bluewin.ch) + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef __EXTENSION_INTERNAL_CDROUTPUT_H__ +#define __EXTENSION_INTERNAL_CDROUTPUT_H__ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef WITH_LIBCDR + +#include <gtkmm/dialog.h> + +#include "../implementation/implementation.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +class CdrInput : public Inkscape::Extension::Implementation::Implementation { + CdrInput () { }; +public: + SPDocument *open( Inkscape::Extension::Input *mod, + const gchar *uri ); + static void init( void ); + +}; + +} } } /* namespace Inkscape, Extension, Implementation */ + +#endif /* WITH_LIBCDR */ +#endif /* __EXTENSION_INTERNAL_CDROUTPUT_H__ */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 785059cca..09079453f 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -3,7 +3,7 @@ /* Change the 'COLOR' above to be your file name */ /* - * Copyright (C) 2011 Authors: + * Copyright (C) 2013 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * @@ -20,7 +20,8 @@ * Invert * Lighting * Lightness-contrast - * Nudge + * Nudge RGB + * Nudge CMY * Quadritone * Solarize * Tritone @@ -211,7 +212,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "<filter inkscape:label=\"Channel Painting\" style=\"color-interpolation-filters:sRGB;\" >\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Channel Painting\">\n" "<feColorMatrix values=\"%s\" type=\"saturate\" result=\"colormatrix1\" />\n" "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix2\" />\n" "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood\" />\n" @@ -1163,31 +1164,25 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext) Filter's parameters: Offsets * Red - * x (-100.->100., default -7) -> offset1 (dx) - * y (-100.->100., default 5) -> offset1 (dy) + * x (-100.->100., default -6) -> offset1 (dx) + * y (-100.->100., default -6) -> offset1 (dy) * Green - * x (-100.->100., default 0) -> offset2 (dx) - * y (-100.->100., default 10) -> offset2 (dy) + * x (-100.->100., default 6) -> offset2 (dx) + * y (-100.->100., default 7) -> offset2 (dy) * Blue - * x (-100.->100., default 3) -> offset3 (dx) - * y (-100.->100., default -9) -> offset3 (dy) + * x (-100.->100., default 1) -> offset3 (dx) + * y (-100.->100., default -16) -> offset3 (dy) Color - * Background color (guint, default -1)-> flood (flood-color, flood-opacity) - * Blend type (enum [normal,multiply and screen], default screen) -> blend1,2,3 (mode) - * Blend source (enum, default color) -> - * color: blend1 (in="flood") - * image: blend1 (in="SourceGraphic") - * background: blend1 (in="BackgroundImage") - * Composite (enum [in,over], default over) -> composite (operator) + * Background color (guint, default 255)-> flood (flood-color, flood-opacity) */ -class Nudge : public Inkscape::Extension::Internal::Filter::Filter { +class NudgeRGB : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - Nudge ( ) : Filter() { }; - virtual ~Nudge ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + NudgeRGB ( ) : Filter() { }; + virtual ~NudgeRGB ( ) { if (_filter != NULL) g_free((void *)_filter); return; } static void init (void) { Inkscape::Extension::build_from_mem( @@ -1197,31 +1192,17 @@ public: "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"offsettab\" _gui-text=\"Offset\">\n" "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n" - "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-7</param>\n" - "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">5</param>\n" + "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" "<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n" - "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">0</param>\n" - "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">10</param>\n" + "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n" - "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">3</param>\n" - "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-9</param>\n" + "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" "</page>\n" "<page name=\"coltab\" _gui-text=\"Color\">\n" "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n" - "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "</param>\n" - "<param name=\"source\" gui-text=\"" N_("Blend source:") "\" type=\"enum\">\n" - "<_item value=\"flood\">" N_("Color") "</_item>\n" - "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n" - "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n" - "</param>\n" - "<param name=\"composite\" gui-text=\"" N_("Composite:") "\" type=\"enum\">\n" - "<_item value=\"over\">" N_("Over") "</_item>\n" - "<_item value=\"in\">" N_("In") "</_item>\n" - "</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -1233,12 +1214,12 @@ public: "</effects-menu>\n" "<menu-tip>" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "</menu-tip>\n" "</effect>\n" - "</inkscape-extension>\n", new Nudge()); + "</inkscape-extension>\n", new NudgeRGB()); }; }; gchar const * -Nudge::get_filter_text (Inkscape::Extension::Extension * ext) +NudgeRGB::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); @@ -1249,10 +1230,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream bx; std::ostringstream by; - std::ostringstream blend; - std::ostringstream source; - std::ostringstream composite; - std::ostringstream a; std::ostringstream r; std::ostringstream g; @@ -1265,10 +1242,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) bx << ext->get_param_float("bx"); by << ext->get_param_float("by"); - blend << ext->get_param_enum("blend"); - source << ext->get_param_enum("source"); - composite << ext->get_param_enum("composite"); - guint32 color = ext->get_param_color("color"); r << ((color >> 24) & 0xff); g << ((color >> 16) & 0xff); @@ -1280,25 +1253,135 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext) "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n" "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n" - "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend1\" />\n" + "<feBlend in2=\"flood\" mode=\"screen\" result=\"blend1\" />\n" "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 \" result=\"colormatrix2\" />\n" "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n" - "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n" + "<feBlend in2=\"blend1\" mode=\"screen\" result=\"blend2\" />\n" "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n" "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 \" result=\"colormatrix3\" />\n" - "<feBlend in2=\"offset3\" mode=\"%s\" result=\"blend3\" />\n" - "<feComposite in2=\"SourceGraphic\" operator=\"%s\" />\n" + "<feBlend in2=\"offset3\" mode=\"screen\" result=\"blend3\" />\n" "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), - rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(), - gx.str().c_str(), gy.str().c_str(), blend.str().c_str(), - bx.str().c_str(), by.str().c_str(), blend.str().c_str(), - composite.str().c_str() ); + rx.str().c_str(), ry.str().c_str(), + gx.str().c_str(), gy.str().c_str(), + bx.str().c_str(), by.str().c_str() ); return _filter; }; /* Nudge RGB filter */ /** + \brief Custom predefined Nudge CMY filter. + + Nudge CMY channels separately and blend them to different types of backgrounds + + Filter's parameters: + Offsets + * Cyan + * x (-100.->100., default -6) -> offset1 (dx) + * y (-100.->100., default -6) -> offset1 (dy) + * Magenta + * x (-100.->100., default 6) -> offset2 (dx) + * y (-100.->100., default 7) -> offset2 (dy) + * Yellow + * x (-100.->100., default 1) -> offset3 (dx) + * y (-100.->100., default -16) -> offset3 (dy) + Color + * Background color (guint, default -1)-> flood (flood-color, flood-opacity) +*/ +class NudgeCMY : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NudgeCMY ( ) : Filter() { }; + virtual ~NudgeCMY ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Nudge CMY") "</name>\n" + "<id>org.inkscape.effect.filter.NudgeCMY</id>\n" + "<param name=\"tab\" type=\"notebook\">\n" + "<page name=\"offsettab\" _gui-text=\"Offset\">\n" + "<_param name=\"cyanOffset\" type=\"description\" appearance=\"header\">" N_("Cyan offset") "</_param>\n" + "<param name=\"cx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"cy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<_param name=\"magentaOffset\" type=\"description\" appearance=\"header\">" N_("Magenta offset") "</_param>\n" + "<param name=\"mx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"my\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" + "<_param name=\"yellowOffset\" type=\"description\" appearance=\"header\">" N_("Yellow offset") "</_param>\n" + "<param name=\"yx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"yy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" + "</page>\n" + "<page name=\"coltab\" _gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" + "</page>\n" + "</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Color") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Nudge CMY channels separately and blend them to different types of backgrounds") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new NudgeCMY()); + }; +}; + +gchar const * +NudgeCMY::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream cx; + std::ostringstream cy; + std::ostringstream mx; + std::ostringstream my; + std::ostringstream yx; + std::ostringstream yy; + + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + + cx << ext->get_param_float("cx"); + cy << ext->get_param_float("cy"); + mx << ext->get_param_float("mx"); + my << ext->get_param_float("my"); + yx << ext->get_param_float("yx"); + yy << ext->get_param_float("yy"); + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge CMY\">\n" + "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" + "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0 \" result=\"colormatrix1\" />\n" + "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n" + "<feBlend in2=\"flood\" mode=\"multiply\" result=\"blend1\" />\n" + "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0 \" result=\"colormatrix2\" />\n" + "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n" + "<feBlend in2=\"blend1\" mode=\"multiply\" result=\"blend2\" />\n" + "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n" + "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0 \" result=\"colormatrix3\" />\n" + "<feBlend in2=\"offset3\" mode=\"multiply\" result=\"blend3\" />\n" + "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + cx.str().c_str(), cy.str().c_str(), + mx.str().c_str(), my.str().c_str(), + yx.str().c_str(), yy.str().c_str() ); + + return _filter; + +}; /* Nudge CMY filter */ + +/** \brief Custom predefined Quadritone filter. Replace hue by two colors. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index b5d47ae45..0273d1669 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -64,7 +64,8 @@ Filter::filters_all (void ) Invert::init(); Lighting::init(); LightnessContrast::init(); - Nudge::init(); + NudgeRGB::init(); + NudgeCMY::init(); Quadritone::init(); Solarize::init(); Tritone::init(); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index af597685b..9f7a45f7f 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -172,7 +172,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie // no filter if (filternode == NULL) { - g_warning("no assoziating filter found!"); + g_warning("no assigned filter found!"); continue; } diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index d76358a96..415776607 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -3,7 +3,7 @@ /* Change the 'SHADOWS' above to be your file name */ /* - * Copyright (C) 2011 Authors: + * Copyright (C) 2013 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * @@ -39,6 +39,7 @@ namespace Filter { inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic") innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic") outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset") + shadow = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="offset") * Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color) * Use object's color (boolean, default false) -> composite1 (in1, in2) */ @@ -60,11 +61,12 @@ public: "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" - "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n" + "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n" "<_item value=\"outer\">" N_("Outer") "</_item>\n" "<_item value=\"inner\">" N_("Inner") "</_item>\n" "<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n" "<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n" + "<_item value=\"shadow\">" N_("Shadow only") "</_item>\n" "</param>\n" "</page>\n" "<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n" @@ -151,11 +153,16 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2op << "out"; comp2in1 << "offset"; comp2in2 << "SourceGraphic"; - } else { //innercut + } else if ((g_ascii_strcasecmp("innercut", type) == 0)){ comp1op << "out"; comp1in1 << "flood"; comp1in2 << "SourceGraphic"; comp2op << "in"; + } else { //shadow + comp1op << "in"; + comp2op << "atop"; + comp2in1 << "offset"; + comp2in2 << "offset"; } _filter = g_strdup_printf( diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 187318417..12e5150cb 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -185,8 +185,8 @@ unsigned VsdImportDialog::getSelectedPage() void VsdImportDialog::_onPageNumberChanged() { - int page = _pageNumberSpin->get_value_as_int(); - _current_page = CLAMP(page, 1, _vec.size()); + unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int()); + _current_page = CLAMP(page, 1U, _vec.size()); _setPreviewPage(_current_page); } diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 809bd6c00..a43927e81 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -31,10 +31,6 @@ #include "display/nr-filter-types.h" /* FeBlend base class */ - -static void sp_feBlend_class_init(SPFeBlendClass *klass); -static void sp_feBlend_init(SPFeBlend *feBlend); - static void sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feBlend_release(SPObject *object); static void sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value); @@ -42,28 +38,7 @@ static void sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feBlend_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feBlend_build_renderer(SPFilterPrimitive *sp_prim, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feBlend_parent_class; - -GType -sp_feBlend_get_type() -{ - static GType feBlend_type = 0; - - if (!feBlend_type) { - GTypeInfo feBlend_info = { - sizeof(SPFeBlendClass), - NULL, NULL, - (GClassInitFunc) sp_feBlend_class_init, - NULL, NULL, - sizeof(SPFeBlend), - 16, - (GInstanceInitFunc) sp_feBlend_init, - NULL, /* value_table */ - }; - feBlend_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeBlend", &feBlend_info, (GTypeFlags)0); - } - return feBlend_type; -} +G_DEFINE_TYPE(SPFeBlend, sp_feBlend, SP_TYPE_FILTER_PRIMITIVE); static void sp_feBlend_class_init(SPFeBlendClass *klass) @@ -71,8 +46,6 @@ sp_feBlend_class_init(SPFeBlendClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feBlend_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feBlend_build; sp_object_class->release = sp_feBlend_release; sp_object_class->write = sp_feBlend_write; @@ -98,8 +71,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re { SPFeBlend *blend = SP_FEBLEND(object); - if (((SPObjectClass *) feBlend_parent_class)->build) { - ((SPObjectClass *) feBlend_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feBlend_parent_class)->build) { + ((SPObjectClass *) sp_feBlend_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -123,8 +96,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re static void sp_feBlend_release(SPObject *object) { - if (((SPObjectClass *) feBlend_parent_class)->release) - ((SPObjectClass *) feBlend_parent_class)->release(object); + if (((SPObjectClass *) sp_feBlend_parent_class)->release) + ((SPObjectClass *) sp_feBlend_parent_class)->release(object); } static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value) @@ -186,8 +159,8 @@ sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feBlend_parent_class)->set) - ((SPObjectClass *) feBlend_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feBlend_parent_class)->set) + ((SPObjectClass *) sp_feBlend_parent_class)->set(object, key, value); break; } @@ -218,8 +191,8 @@ sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2)); } - if (((SPObjectClass *) feBlend_parent_class)->update) { - ((SPObjectClass *) feBlend_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feBlend_parent_class)->update) { + ((SPObjectClass *) sp_feBlend_parent_class)->update(object, ctx, flags); } } @@ -267,8 +240,8 @@ sp_feBlend_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML:: } repr->setAttribute("mode", mode); - if (((SPObjectClass *) feBlend_parent_class)->write) { - ((SPObjectClass *) feBlend_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feBlend_parent_class)->write) { + ((SPObjectClass *) sp_feBlend_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index b88b84037..aaf1c2986 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -30,10 +30,6 @@ #include "display/nr-filter-colormatrix.h" /* FeColorMatrix base class */ - -static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass); -static void sp_feColorMatrix_init(SPFeColorMatrix *feColorMatrix); - static void sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feColorMatrix_release(SPObject *object); static void sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *value); @@ -41,28 +37,7 @@ static void sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feColorMatrix_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feColorMatrix_parent_class; - -GType -sp_feColorMatrix_get_type() -{ - static GType feColorMatrix_type = 0; - - if (!feColorMatrix_type) { - GTypeInfo feColorMatrix_info = { - sizeof(SPFeColorMatrixClass), - NULL, NULL, - (GClassInitFunc) sp_feColorMatrix_class_init, - NULL, NULL, - sizeof(SPFeColorMatrix), - 16, - (GInstanceInitFunc) sp_feColorMatrix_init, - NULL, /* value_table */ - }; - feColorMatrix_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeColorMatrix", &feColorMatrix_info, (GTypeFlags)0); - } - return feColorMatrix_type; -} +G_DEFINE_TYPE(SPFeColorMatrix, sp_feColorMatrix, SP_TYPE_FILTER_PRIMITIVE); static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) @@ -70,8 +45,6 @@ sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feColorMatrix_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feColorMatrix_build; sp_object_class->release = sp_feColorMatrix_release; sp_object_class->write = sp_feColorMatrix_write; @@ -93,8 +66,8 @@ sp_feColorMatrix_init(SPFeColorMatrix */*feColorMatrix*/) static void sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feColorMatrix_parent_class)->build) { - ((SPObjectClass *) feColorMatrix_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->build) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -108,8 +81,8 @@ sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::No static void sp_feColorMatrix_release(SPObject *object) { - if (((SPObjectClass *) feColorMatrix_parent_class)->release) - ((SPObjectClass *) feColorMatrix_parent_class)->release(object); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->release) + ((SPObjectClass *) sp_feColorMatrix_parent_class)->release(object); } static Inkscape::Filters::FilterColorMatrixType sp_feColorMatrix_read_type(gchar const *value){ @@ -158,8 +131,8 @@ sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *str) } break; default: - if (((SPObjectClass *) feColorMatrix_parent_class)->set) - ((SPObjectClass *) feColorMatrix_parent_class)->set(object, key, str); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->set) + ((SPObjectClass *) sp_feColorMatrix_parent_class)->set(object, key, str); break; } } @@ -177,8 +150,8 @@ sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feColorMatrix_parent_class)->update) { - ((SPObjectClass *) feColorMatrix_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->update) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->update(object, ctx, flags); } } @@ -194,8 +167,8 @@ sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feColorMatrix_parent_class)->write) { - ((SPObjectClass *) feColorMatrix_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feColorMatrix_parent_class)->write) { + ((SPObjectClass *) sp_feColorMatrix_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 8cc388dd0..71e1ffe8e 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -28,10 +28,6 @@ #include "display/nr-filter-component-transfer.h" /* FeComponentTransfer base class */ - -static void sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass); -static void sp_feComponentTransfer_init(SPFeComponentTransfer *feComponentTransfer); - static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feComponentTransfer_release(SPObject *object); static void sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,35 +36,14 @@ static void sp_feComponentTransfer_build_renderer(SPFilterPrimitive *primitive, static void sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); static Inkscape::XML::Node *sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPFilterPrimitiveClass *feComponentTransfer_parent_class; -GType -sp_feComponentTransfer_get_type() -{ - static GType feComponentTransfer_type = 0; - - if (!feComponentTransfer_type) { - GTypeInfo feComponentTransfer_info = { - sizeof(SPFeComponentTransferClass), - NULL, NULL, - (GClassInitFunc) sp_feComponentTransfer_class_init, - NULL, NULL, - sizeof(SPFeComponentTransfer), - 16, - (GInstanceInitFunc) sp_feComponentTransfer_init, - NULL, /* value_table */ - }; - feComponentTransfer_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComponentTransfer", &feComponentTransfer_info, (GTypeFlags)0); - } - return feComponentTransfer_type; -} +G_DEFINE_TYPE(SPFeComponentTransfer, sp_feComponentTransfer, SP_TYPE_FILTER_PRIMITIVE); static void sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feComponentTransfer_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feComponentTransfer_build; sp_object_class->release = sp_feComponentTransfer_release; @@ -93,8 +68,8 @@ sp_feComponentTransfer_init(SPFeComponentTransfer */*feComponentTransfer*/) static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feComponentTransfer_parent_class)->build) { - ((SPObjectClass *) feComponentTransfer_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->build) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -144,8 +119,8 @@ sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, { SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object); - if (((SPObjectClass *) feComponentTransfer_parent_class)->child_added) - (* ((SPObjectClass *) feComponentTransfer_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->child_added) + (* ((SPObjectClass *) sp_feComponentTransfer_parent_class)->child_added)(object, child, ref); sp_feComponentTransfer_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -160,8 +135,8 @@ sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child { SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object); - if (((SPObjectClass *) feComponentTransfer_parent_class)->remove_child) - (* ((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feComponentTransfer_parent_class)->remove_child)(object, child); sp_feComponentTransfer_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -173,8 +148,8 @@ sp_feComponentTransfer_remove_child(SPObject *object, Inkscape::XML::Node *child static void sp_feComponentTransfer_release(SPObject *object) { - if (((SPObjectClass *) feComponentTransfer_parent_class)->release) - ((SPObjectClass *) feComponentTransfer_parent_class)->release(object); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->release) + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->release(object); } /** @@ -189,8 +164,8 @@ sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *valu switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feComponentTransfer_parent_class)->set) - ((SPObjectClass *) feComponentTransfer_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->set) + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->set(object, key, value); break; } } @@ -208,8 +183,8 @@ sp_feComponentTransfer_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feComponentTransfer_parent_class)->update) { - ((SPObjectClass *) feComponentTransfer_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->update) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->update(object, ctx, flags); } } @@ -225,8 +200,8 @@ sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Document *doc, Ink repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feComponentTransfer_parent_class)->write) { - ((SPObjectClass *) feComponentTransfer_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feComponentTransfer_parent_class)->write) { + ((SPObjectClass *) sp_feComponentTransfer_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 66e8e3415..d490f336c 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -26,10 +26,6 @@ #include "sp-filter.h" /* FeComposite base class */ - -static void sp_feComposite_class_init(SPFeCompositeClass *klass); -static void sp_feComposite_init(SPFeComposite *feComposite); - static void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feComposite_release(SPObject *object); static void sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feComposite_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feComposite_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feComposite_parent_class; - -GType -sp_feComposite_get_type() -{ - static GType feComposite_type = 0; - - if (!feComposite_type) { - GTypeInfo feComposite_info = { - sizeof(SPFeCompositeClass), - NULL, NULL, - (GClassInitFunc) sp_feComposite_class_init, - NULL, NULL, - sizeof(SPFeComposite), - 16, - (GInstanceInitFunc) sp_feComposite_init, - NULL, /* value_table */ - }; - feComposite_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComposite", &feComposite_info, (GTypeFlags)0); - } - return feComposite_type; -} +G_DEFINE_TYPE(SPFeComposite, sp_feComposite, SP_TYPE_FILTER_PRIMITIVE); static void sp_feComposite_class_init(SPFeCompositeClass *klass) @@ -66,8 +41,6 @@ sp_feComposite_class_init(SPFeCompositeClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feComposite_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feComposite_build; sp_object_class->release = sp_feComposite_release; sp_object_class->write = sp_feComposite_write; @@ -96,8 +69,8 @@ sp_feComposite_init(SPFeComposite *feComposite) static void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feComposite_parent_class)->build) { - ((SPObjectClass *) feComposite_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feComposite_parent_class)->build) { + ((SPObjectClass *) sp_feComposite_parent_class)->build(object, document, repr); } SPFeComposite *comp = SP_FECOMPOSITE(object); @@ -128,8 +101,8 @@ sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node static void sp_feComposite_release(SPObject *object) { - if (((SPObjectClass *) feComposite_parent_class)->release) - ((SPObjectClass *) feComposite_parent_class)->release(object); + if (((SPObjectClass *) sp_feComposite_parent_class)->release) + ((SPObjectClass *) sp_feComposite_parent_class)->release(object); } static FeCompositeOperator @@ -212,8 +185,8 @@ sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value) break; default: - if (((SPObjectClass *) feComposite_parent_class)->set) - ((SPObjectClass *) feComposite_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feComposite_parent_class)->set) + ((SPObjectClass *) sp_feComposite_parent_class)->set(object, key, value); break; } @@ -246,8 +219,8 @@ sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2)); } - if (((SPObjectClass *) feComposite_parent_class)->update) { - ((SPObjectClass *) feComposite_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feComposite_parent_class)->update) { + ((SPObjectClass *) sp_feComposite_parent_class)->update(object, ctx, flags); } } @@ -309,8 +282,8 @@ sp_feComposite_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X repr->setAttribute("k4", 0); } - if (((SPObjectClass *) feComposite_parent_class)->write) { - ((SPObjectClass *) feComposite_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feComposite_parent_class)->write) { + ((SPObjectClass *) sp_feComposite_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 470bfb64a..d002ef731 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -29,10 +29,6 @@ #include "display/nr-filter-convolve-matrix.h" /* FeConvolveMatrix base class */ - -static void sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass); -static void sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix); - static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feConvolveMatrix_release(SPObject *object); static void sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,28 +36,7 @@ static void sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags static Inkscape::XML::Node *sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feConvolveMatrix_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feConvolveMatrix_parent_class; - -GType -sp_feConvolveMatrix_get_type() -{ - static GType feConvolveMatrix_type = 0; - - if (!feConvolveMatrix_type) { - GTypeInfo feConvolveMatrix_info = { - sizeof(SPFeConvolveMatrixClass), - NULL, NULL, - (GClassInitFunc) sp_feConvolveMatrix_class_init, - NULL, NULL, - sizeof(SPFeConvolveMatrix), - 16, - (GInstanceInitFunc) sp_feConvolveMatrix_init, - NULL, /* value_table */ - }; - feConvolveMatrix_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeConvolveMatrix", &feConvolveMatrix_info, (GTypeFlags)0); - } - return feConvolveMatrix_type; -} +G_DEFINE_TYPE(SPFeConvolveMatrix, sp_feConvolveMatrix, SP_TYPE_FILTER_PRIMITIVE); static void sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) @@ -69,8 +44,6 @@ sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feConvolveMatrix_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feConvolveMatrix_build; sp_object_class->release = sp_feConvolveMatrix_release; sp_object_class->write = sp_feConvolveMatrix_write; @@ -104,8 +77,8 @@ sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix) static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feConvolveMatrix_parent_class)->build) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->build) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -126,8 +99,8 @@ sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML: static void sp_feConvolveMatrix_release(SPObject *object) { - if (((SPObjectClass *) feConvolveMatrix_parent_class)->release) - ((SPObjectClass *) feConvolveMatrix_parent_class)->release(object); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->release) + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->release(object); } static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){ @@ -265,8 +238,8 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feConvolveMatrix_parent_class)->set) - ((SPObjectClass *) feConvolveMatrix_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->set) + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->set(object, key, value); break; } @@ -285,8 +258,8 @@ sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feConvolveMatrix_parent_class)->update) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->update) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->update(object, ctx, flags); } } @@ -303,8 +276,8 @@ sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inksca } - if (((SPObjectClass *) feConvolveMatrix_parent_class)->write) { - ((SPObjectClass *) feConvolveMatrix_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feConvolveMatrix_parent_class)->write) { + ((SPObjectClass *) sp_feConvolveMatrix_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 0f2f29d67..66dd825f6 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -18,10 +18,13 @@ # include "config.h" #endif +#include "strneq.h" + #include "attributes.h" #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/svg-icc-color.h" #include "filters/diffuselighting.h" #include "filters/distantlight.h" #include "filters/pointlight.h" @@ -31,10 +34,6 @@ #include "display/nr-filter-diffuselighting.h" /* FeDiffuseLighting base class */ - -static void sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass); -static void sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting); - static void sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feDiffuseLighting_release(SPObject *object); static void sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value); @@ -52,35 +51,13 @@ static Inkscape::XML::Node *sp_feDiffuseLighting_write(SPObject *object, Inkscap static void sp_feDiffuseLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffuselighting); -static SPFilterPrimitiveClass *feDiffuseLighting_parent_class; - -GType -sp_feDiffuseLighting_get_type() -{ - static GType feDiffuseLighting_type = 0; - - if (!feDiffuseLighting_type) { - GTypeInfo feDiffuseLighting_info = { - sizeof(SPFeDiffuseLightingClass), - NULL, NULL, - (GClassInitFunc) sp_feDiffuseLighting_class_init, - NULL, NULL, - sizeof(SPFeDiffuseLighting), - 16, - (GInstanceInitFunc) sp_feDiffuseLighting_init, - NULL, /* value_table */ - }; - feDiffuseLighting_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeDiffuseLighting", &feDiffuseLighting_info, (GTypeFlags)0); - } - return feDiffuseLighting_type; -} +G_DEFINE_TYPE(SPFeDiffuseLighting, sp_feDiffuseLighting, SP_TYPE_FILTER_PRIMITIVE); static void sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feDiffuseLighting_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feDiffuseLighting_build; sp_object_class->release = sp_feDiffuseLighting_release; @@ -100,6 +77,8 @@ sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting) feDiffuseLighting->surfaceScale = 1; feDiffuseLighting->diffuseConstant = 1; feDiffuseLighting->lighting_color = 0xffffffff; + feDiffuseLighting->icc = NULL; + //TODO kernelUnit feDiffuseLighting->renderer = NULL; @@ -116,8 +95,8 @@ sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting) static void sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDiffuseLighting_parent_class)->build) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->build) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -134,8 +113,8 @@ sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_feDiffuseLighting_release(SPObject *object) { - if (((SPObjectClass *) feDiffuseLighting_parent_class)->release) - ((SPObjectClass *) feDiffuseLighting_parent_class)->release(object); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->release) + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->release(object); } /** @@ -202,6 +181,16 @@ sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value) feDiffuseLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff); //if a value was read if (cend_ptr) { + while (g_ascii_isspace(*cend_ptr)) { + ++cend_ptr; + } + if (strneq(cend_ptr, "icc-color(", 10)) { + if (!feDiffuseLighting->icc) feDiffuseLighting->icc = new SVGICCColor(); + if ( ! sp_svg_read_icc_color( cend_ptr, feDiffuseLighting->icc ) ) { + delete feDiffuseLighting->icc; + feDiffuseLighting->icc = NULL; + } + } feDiffuseLighting->lighting_color_set = TRUE; } else { //lighting_color already contains the default value @@ -213,8 +202,8 @@ sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feDiffuseLighting_parent_class)->set) - ((SPObjectClass *) feDiffuseLighting_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->set) + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->set(object, key, value); break; } @@ -233,8 +222,8 @@ sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "lighting-color" ); } - if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->update) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->update(object, ctx, flags); } } @@ -269,8 +258,8 @@ sp_feDiffuseLighting_write(SPObject *object, Inkscape::XML::Document *doc, Inksc } else repr->setAttribute("lighting-color", NULL); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->write) { - ((SPObjectClass *) feDiffuseLighting_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->write) { + ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->write(object, doc, repr, flags); } return repr; @@ -284,8 +273,8 @@ sp_feDiffuseLighting_child_added(SPObject *object, Inkscape::XML::Node *child, I { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->child_added) - (* ((SPObjectClass *) feDiffuseLighting_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->child_added) + (* ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->child_added)(object, child, ref); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -300,8 +289,8 @@ sp_feDiffuseLighting_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) feDiffuseLighting_parent_class)->remove_child) - (* ((SPObjectClass *) feDiffuseLighting_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feDiffuseLighting_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feDiffuseLighting_parent_class)->remove_child)(object, child); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -311,8 +300,8 @@ static void sp_feDiffuseLighting_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object); - if (((SPObjectClass *) (feDiffuseLighting_parent_class))->order_changed) - (* ((SPObjectClass *) (feDiffuseLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); + if (((SPObjectClass *) (sp_feDiffuseLighting_parent_class))->order_changed) + (* ((SPObjectClass *) (sp_feDiffuseLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); sp_feDiffuseLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -354,6 +343,8 @@ static void sp_feDiffuseLighting_build_renderer(SPFilterPrimitive *primitive, In nr_diffuselighting->diffuseConstant = sp_diffuselighting->diffuseConstant; nr_diffuselighting->surfaceScale = sp_diffuselighting->surfaceScale; nr_diffuselighting->lighting_color = sp_diffuselighting->lighting_color; + nr_diffuselighting->set_icc(sp_diffuselighting->icc); + //We assume there is at most one child nr_diffuselighting->light_type = Inkscape::Filters::NO_LIGHT; if (SP_IS_FEDISTANTLIGHT(primitive->children)) { diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h index a23346622..99dccb394 100644 --- a/src/filters/diffuselighting.h +++ b/src/filters/diffuselighting.h @@ -15,17 +15,14 @@ #include "sp-filter-primitive.h" #include "number-opt-number.h" -namespace Inkscape { -namespace Filters { -class FilterDiffuseLighting; -} } - #define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) #define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) #define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) #define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) #define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) +class SVGICCColor; + namespace Inkscape { namespace Filters { class FilterDiffuseLighting; @@ -42,6 +39,7 @@ struct SPFeDiffuseLighting : public SPFilterPrimitive { guint32 lighting_color; guint lighting_color_set : 1; Inkscape::Filters::FilterDiffuseLighting *renderer; + SVGICCColor *icc; }; struct SPFeDiffuseLightingClass { diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 69a678c26..408ffce9e 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -26,10 +26,6 @@ #include "display/nr-filter-displacement-map.h" /* FeDisplacementMap base class */ - -static void sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass); -static void sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap); - static void sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feDisplacementMap_release(SPObject *object); static void sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flag static void sp_feDisplacementMap_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static Inkscape::XML::Node *sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPFilterPrimitiveClass *feDisplacementMap_parent_class; - -GType -sp_feDisplacementMap_get_type() -{ - static GType feDisplacementMap_type = 0; - - if (!feDisplacementMap_type) { - GTypeInfo feDisplacementMap_info = { - sizeof(SPFeDisplacementMapClass), - NULL, NULL, - (GClassInitFunc) sp_feDisplacementMap_class_init, - NULL, NULL, - sizeof(SPFeDisplacementMap), - 16, - (GInstanceInitFunc) sp_feDisplacementMap_init, - NULL, /* value_table */ - }; - feDisplacementMap_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeDisplacementMap", &feDisplacementMap_info, (GTypeFlags)0); - } - return feDisplacementMap_type; -} +G_DEFINE_TYPE(SPFeDisplacementMap, sp_feDisplacementMap, SP_TYPE_FILTER_PRIMITIVE); static void sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass) @@ -66,8 +41,6 @@ sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feDisplacementMap_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feDisplacementMap_build; sp_object_class->release = sp_feDisplacementMap_release; sp_object_class->write = sp_feDisplacementMap_write; @@ -93,8 +66,8 @@ sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap) static void sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDisplacementMap_parent_class)->build) { - ((SPObjectClass *) feDisplacementMap_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->build) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -121,8 +94,8 @@ sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML static void sp_feDisplacementMap_release(SPObject *object) { - if (((SPObjectClass *) feDisplacementMap_parent_class)->release) - ((SPObjectClass *) feDisplacementMap_parent_class)->release(object); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->release) + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->release(object); } static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSelector(gchar const *value) @@ -191,8 +164,8 @@ sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feDisplacementMap_parent_class)->set) - ((SPObjectClass *) feDisplacementMap_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->set) + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->set(object, key, value); break; } @@ -224,8 +197,8 @@ sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flags) object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2)); } - if (((SPObjectClass *) feDisplacementMap_parent_class)->update) { - ((SPObjectClass *) feDisplacementMap_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->update) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->update(object, ctx, flags); } } @@ -277,8 +250,8 @@ sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Document *doc, Inksc repr->setAttribute("yChannelSelector", get_channelselector_name(disp->yChannelSelector)); - if (((SPObjectClass *) feDisplacementMap_parent_class)->write) { - ((SPObjectClass *) feDisplacementMap_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feDisplacementMap_parent_class)->write) { + ((SPObjectClass *) sp_feDisplacementMap_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 891049415..5e1c35a95 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FeDistantLight class */ - -static void sp_fedistantlight_class_init(SPFeDistantLightClass *klass); -static void sp_fedistantlight_init(SPFeDistantLight *fedistantlight); - static void sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fedistantlight_release(SPObject *object); static void sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feDistantLight_parent_class; - -GType -sp_fedistantlight_get_type() -{ - static GType fedistantlight_type = 0; - - if (!fedistantlight_type) { - GTypeInfo fedistantlight_info = { - sizeof(SPFeDistantLightClass), - NULL, NULL, - (GClassInitFunc) sp_fedistantlight_class_init, - NULL, NULL, - sizeof(SPFeDistantLight), - 16, - (GInstanceInitFunc) sp_fedistantlight_init, - NULL, /* value_table */ - }; - fedistantlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeDistantLight", &fedistantlight_info, (GTypeFlags)0); - } - return fedistantlight_type; -} +G_DEFINE_TYPE(SPFeDistantLight, sp_fedistantlight, SP_TYPE_OBJECT); static void sp_fedistantlight_class_init(SPFeDistantLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feDistantLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fedistantlight_build; sp_object_class->release = sp_fedistantlight_release; sp_object_class->write = sp_fedistantlight_write; @@ -95,8 +67,8 @@ sp_fedistantlight_init(SPFeDistantLight *fedistantlight) static void sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feDistantLight_parent_class)->build) { - ((SPObjectClass *) feDistantLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->build) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -170,8 +142,8 @@ sp_fedistantlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feDistantLight_parent_class)->set) { - ((SPObjectClass *) feDistantLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->set) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->set(object, key, value); } break; } @@ -192,8 +164,8 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "elevation" ); } - if (((SPObjectClass *) feDistantLight_parent_class)->update) { - ((SPObjectClass *) feDistantLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->update) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->update(object, ctx, flags); } } @@ -214,8 +186,8 @@ sp_fedistantlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape if (fedistantlight->elevation_set) sp_repr_set_css_double(repr, "elevation", fedistantlight->elevation); - if (((SPObjectClass *) feDistantLight_parent_class)->write) { - ((SPObjectClass *) feDistantLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fedistantlight_parent_class)->write) { + ((SPObjectClass *) sp_fedistantlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp index ee1af8904..ca93cf6d8 100644 --- a/src/filters/gaussian-blur.cpp +++ b/src/filters/gaussian-blur.cpp @@ -31,10 +31,6 @@ //#include "macros.h" /* GaussianBlur base class */ - -static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass); -static void sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur); - static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_gaussianBlur_release(SPObject *object); static void sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value); @@ -42,28 +38,7 @@ static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_gaussianBlur_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *gaussianBlur_parent_class; - -GType -sp_gaussianBlur_get_type() -{ - static GType gaussianBlur_type = 0; - - if (!gaussianBlur_type) { - GTypeInfo gaussianBlur_info = { - sizeof(SPGaussianBlurClass), - NULL, NULL, - (GClassInitFunc) sp_gaussianBlur_class_init, - NULL, NULL, - sizeof(SPGaussianBlur), - 16, - (GInstanceInitFunc) sp_gaussianBlur_init, - NULL, /* value_table */ - }; - gaussianBlur_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPGaussianBlur", &gaussianBlur_info, (GTypeFlags)0); - } - return gaussianBlur_type; -} +G_DEFINE_TYPE(SPGaussianBlur, sp_gaussianBlur, SP_TYPE_FILTER_PRIMITIVE); static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) @@ -71,8 +46,6 @@ sp_gaussianBlur_class_init(SPGaussianBlurClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - gaussianBlur_parent_class = (SPFilterPrimitiveClass *)g_type_class_peek_parent(klass); - sp_object_class->build = sp_gaussianBlur_build; sp_object_class->release = sp_gaussianBlur_release; sp_object_class->write = sp_gaussianBlur_write; @@ -95,8 +68,8 @@ sp_gaussianBlur_init(SPGaussianBlur */*gaussianBlur*/) static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) gaussianBlur_parent_class)->build) { - ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->build) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->build(object, document, repr); } object->readAttr( "stdDeviation" ); @@ -110,8 +83,8 @@ static void sp_gaussianBlur_release(SPObject *object) { - if (((SPObjectClass *) gaussianBlur_parent_class)->release) - ((SPObjectClass *) gaussianBlur_parent_class)->release(object); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->release) + ((SPObjectClass *) sp_gaussianBlur_parent_class)->release(object); } /** @@ -128,8 +101,8 @@ sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) gaussianBlur_parent_class)->set) - ((SPObjectClass *) gaussianBlur_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->set) + ((SPObjectClass *) sp_gaussianBlur_parent_class)->set(object, key, value); break; } @@ -145,8 +118,8 @@ sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "stdDeviation" ); } - if (((SPObjectClass *) gaussianBlur_parent_class)->update) { - ((SPObjectClass *) gaussianBlur_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->update) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->update(object, ctx, flags); } } @@ -162,8 +135,8 @@ sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) gaussianBlur_parent_class)->write) { - ((SPObjectClass *) gaussianBlur_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_gaussianBlur_parent_class)->write) { + ((SPObjectClass *) sp_gaussianBlur_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/image.cpp b/src/filters/image.cpp index f6ef310f7..ec31e59a7 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -30,10 +30,6 @@ #include "display/nr-filter-image.h" /* FeImage base class */ - -static void sp_feImage_class_init(SPFeImageClass *klass); -static void sp_feImage_init(SPFeImage *feImage); - static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feImage_release(SPObject *object); static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *value); @@ -41,35 +37,13 @@ static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feImage_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feImage_parent_class; - -GType sp_feImage_get_type() -{ - static GType feImage_type = 0; - - if (!feImage_type) { - GTypeInfo feImage_info = { - sizeof(SPFeImageClass), - NULL, NULL, - (GClassInitFunc) sp_feImage_class_init, - NULL, NULL, - sizeof(SPFeImage), - 16, - (GInstanceInitFunc) sp_feImage_init, - NULL, /* value_table */ - }; - feImage_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeImage", &feImage_info, (GTypeFlags)0); - } - return feImage_type; -} +G_DEFINE_TYPE(SPFeImage, sp_feImage, SP_TYPE_FILTER_PRIMITIVE); static void sp_feImage_class_init(SPFeImageClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feImage_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feImage_build; sp_object_class->release = sp_feImage_release; sp_object_class->write = sp_feImage_write; @@ -96,8 +70,8 @@ static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::X SPFeImage *feImage = SP_FEIMAGE(object); feImage->document = document; - if (((SPObjectClass *) feImage_parent_class)->build) { - ((SPObjectClass *) feImage_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feImage_parent_class)->build) { + ((SPObjectClass *) sp_feImage_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -117,8 +91,8 @@ static void sp_feImage_release(SPObject *object) feImage->_href_modified_connection.disconnect(); if (feImage->SVGElemRef) delete feImage->SVGElemRef; - if (((SPObjectClass *) feImage_parent_class)->release) - ((SPObjectClass *) feImage_parent_class)->release(object); + if (((SPObjectClass *) sp_feImage_parent_class)->release) + ((SPObjectClass *) sp_feImage_parent_class)->release(object); } static void sp_feImage_elem_modified(SPObject* /*href*/, guint /*flags*/, SPObject* obj) @@ -247,8 +221,8 @@ static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *valu break; default: - if (((SPObjectClass *) feImage_parent_class)->set) - ((SPObjectClass *) feImage_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feImage_parent_class)->set) + ((SPObjectClass *) sp_feImage_parent_class)->set(object, key, value); break; } @@ -266,8 +240,8 @@ static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) /* do something to trigger redisplay, updates? */ } - if (((SPObjectClass *) feImage_parent_class)->update) { - ((SPObjectClass *) feImage_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feImage_parent_class)->update) { + ((SPObjectClass *) sp_feImage_parent_class)->update(object, ctx, flags); } } @@ -282,8 +256,8 @@ static Inkscape::XML::Node * sp_feImage_write(SPObject *object, Inkscape::XML::D repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feImage_parent_class)->write) { - ((SPObjectClass *) feImage_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feImage_parent_class)->write) { + ((SPObjectClass *) sp_feImage_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index b5a6d7dad..7346a0892 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -25,10 +25,6 @@ #include "display/nr-filter-merge.h" /* FeMerge base class */ - -static void sp_feMerge_class_init(SPFeMergeClass *klass); -static void sp_feMerge_init(SPFeMerge *feMerge); - static void sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMerge_release(SPObject *object); static void sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value); @@ -36,28 +32,7 @@ static void sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMerge_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feMerge_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feMerge_parent_class; - -GType -sp_feMerge_get_type() -{ - static GType feMerge_type = 0; - - if (!feMerge_type) { - GTypeInfo feMerge_info = { - sizeof(SPFeMergeClass), - NULL, NULL, - (GClassInitFunc) sp_feMerge_class_init, - NULL, NULL, - sizeof(SPFeMerge), - 16, - (GInstanceInitFunc) sp_feMerge_init, - NULL, /* value_table */ - }; - feMerge_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeMerge", &feMerge_info, (GTypeFlags)0); - } - return feMerge_type; -} +G_DEFINE_TYPE(SPFeMerge, sp_feMerge, SP_TYPE_FILTER_PRIMITIVE); static void sp_feMerge_class_init(SPFeMergeClass *klass) @@ -65,8 +40,6 @@ sp_feMerge_class_init(SPFeMergeClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feMerge_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feMerge_build; sp_object_class->release = sp_feMerge_release; sp_object_class->write = sp_feMerge_write; @@ -89,8 +62,8 @@ sp_feMerge_init(SPFeMerge */*feMerge*/) static void sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feMerge_parent_class)->build) { - ((SPObjectClass *) feMerge_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feMerge_parent_class)->build) { + ((SPObjectClass *) sp_feMerge_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -102,8 +75,8 @@ sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re static void sp_feMerge_release(SPObject *object) { - if (((SPObjectClass *) feMerge_parent_class)->release) - ((SPObjectClass *) feMerge_parent_class)->release(object); + if (((SPObjectClass *) sp_feMerge_parent_class)->release) + ((SPObjectClass *) sp_feMerge_parent_class)->release(object); } /** @@ -118,8 +91,8 @@ sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value) switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feMerge_parent_class)->set) - ((SPObjectClass *) feMerge_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMerge_parent_class)->set) + ((SPObjectClass *) sp_feMerge_parent_class)->set(object, key, value); break; } @@ -135,8 +108,8 @@ sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } - if (((SPObjectClass *) feMerge_parent_class)->update) { - ((SPObjectClass *) feMerge_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMerge_parent_class)->update) { + ((SPObjectClass *) sp_feMerge_parent_class)->update(object, ctx, flags); } } @@ -153,8 +126,8 @@ sp_feMerge_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML:: } - if (((SPObjectClass *) feMerge_parent_class)->write) { - ((SPObjectClass *) feMerge_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMerge_parent_class)->write) { + ((SPObjectClass *) sp_feMerge_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 639928305..fa193ad77 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -23,46 +23,19 @@ #include "filters/merge.h" #include "display/nr-filter-types.h" -static void sp_feMergeNode_class_init(SPFeMergeNodeClass *klass); -static void sp_feMergeNode_init(SPFeMergeNode *skeleton); - static void sp_feMergeNode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMergeNode_release(SPObject *object); static void sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feMergeNode_parent_class; - -GType -sp_feMergeNode_get_type() -{ - static GType feMergeNode_type = 0; - - if (!feMergeNode_type) { - GTypeInfo feMergeNode_info = { - sizeof(SPFeMergeNodeClass), - NULL, NULL, - (GClassInitFunc) sp_feMergeNode_class_init, - NULL, NULL, - sizeof(SPFeMergeNode), - 16, - (GInstanceInitFunc) sp_feMergeNode_init, - NULL, /* value_table */ - }; - feMergeNode_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeMergeNode", &feMergeNode_info, (GTypeFlags)0); - } - return feMergeNode_type; -} +G_DEFINE_TYPE(SPFeMergeNode, sp_feMergeNode, SP_TYPE_OBJECT); static void sp_feMergeNode_class_init(SPFeMergeNodeClass *klass) { - //GObjectClass *gobject_class = (GObjectClass *)klass; SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feMergeNode_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feMergeNode_build; sp_object_class->release = sp_feMergeNode_release; sp_object_class->write = sp_feMergeNode_write; @@ -95,8 +68,8 @@ sp_feMergeNode_release(SPObject *object) { /* deal with our children and our selves here */ - if (((SPObjectClass *) feMergeNode_parent_class)->release) - ((SPObjectClass *) feMergeNode_parent_class)->release(object); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->release) + ((SPObjectClass *) sp_feMergeNode_parent_class)->release(object); } /** @@ -117,8 +90,8 @@ sp_feMergeNode_set(SPObject *object, unsigned int key, gchar const *value) } /* See if any parents need this value. */ - if (((SPObjectClass *) feMergeNode_parent_class)->set) { - ((SPObjectClass *) feMergeNode_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->set) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->set(object, key, value); } } @@ -134,8 +107,8 @@ sp_feMergeNode_update(SPObject *object, SPCtx *ctx, guint flags) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } - if (((SPObjectClass *) feMergeNode_parent_class)->update) { - ((SPObjectClass *) feMergeNode_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->update) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->update(object, ctx, flags); } } @@ -157,8 +130,8 @@ sp_feMergeNode_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X } } - if (((SPObjectClass *) feMergeNode_parent_class)->write) { - ((SPObjectClass *) feMergeNode_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMergeNode_parent_class)->write) { + ((SPObjectClass *) sp_feMergeNode_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 42327d59f..886a10311 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -27,10 +27,6 @@ #include "display/nr-filter-morphology.h" /* FeMorphology base class */ - -static void sp_feMorphology_class_init(SPFeMorphologyClass *klass); -static void sp_feMorphology_init(SPFeMorphology *feMorphology); - static void sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feMorphology_release(SPObject *object); static void sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value); @@ -38,36 +34,13 @@ static void sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMorphology_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feMorphology_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feMorphology_parent_class; - -GType -sp_feMorphology_get_type() -{ - static GType feMorphology_type = 0; - - if (!feMorphology_type) { - GTypeInfo feMorphology_info = { - sizeof(SPFeMorphologyClass), - NULL, NULL, - (GClassInitFunc) sp_feMorphology_class_init, - NULL, NULL, - sizeof(SPFeMorphology), - 16, - (GInstanceInitFunc) sp_feMorphology_init, - NULL, /* value_table */ - }; - feMorphology_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeMorphology", &feMorphology_info, (GTypeFlags)0); - } - return feMorphology_type; -} +G_DEFINE_TYPE(SPFeMorphology, sp_feMorphology, SP_TYPE_FILTER_PRIMITIVE); static void sp_feMorphology_class_init(SPFeMorphologyClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - - feMorphology_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feMorphology_build; sp_object_class->release = sp_feMorphology_release; @@ -92,8 +65,8 @@ sp_feMorphology_init(SPFeMorphology *feMorphology) static void sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feMorphology_parent_class)->build) { - ((SPObjectClass *) feMorphology_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feMorphology_parent_class)->build) { + ((SPObjectClass *) sp_feMorphology_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -107,8 +80,8 @@ sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod static void sp_feMorphology_release(SPObject *object) { - if (((SPObjectClass *) feMorphology_parent_class)->release) - ((SPObjectClass *) feMorphology_parent_class)->release(object); + if (((SPObjectClass *) sp_feMorphology_parent_class)->release) + ((SPObjectClass *) sp_feMorphology_parent_class)->release(object); } static Inkscape::Filters::FilterMorphologyOperator sp_feMorphology_read_operator(gchar const *value){ @@ -151,8 +124,8 @@ sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feMorphology_parent_class)->set) - ((SPObjectClass *) feMorphology_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feMorphology_parent_class)->set) + ((SPObjectClass *) sp_feMorphology_parent_class)->set(object, key, value); break; } @@ -171,8 +144,8 @@ sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feMorphology_parent_class)->update) { - ((SPObjectClass *) feMorphology_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feMorphology_parent_class)->update) { + ((SPObjectClass *) sp_feMorphology_parent_class)->update(object, ctx, flags); } } @@ -188,8 +161,8 @@ sp_feMorphology_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feMorphology_parent_class)->write) { - ((SPObjectClass *) feMorphology_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feMorphology_parent_class)->write) { + ((SPObjectClass *) sp_feMorphology_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index f45169aba..2851f4f7d 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -26,10 +26,6 @@ #include "display/nr-filter-offset.h" /* FeOffset base class */ - -static void sp_feOffset_class_init(SPFeOffsetClass *klass); -static void sp_feOffset_init(SPFeOffset *feOffset); - static void sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feOffset_release(SPObject *object); static void sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value); @@ -37,28 +33,7 @@ static void sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feOffset_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feOffset_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feOffset_parent_class; - -GType -sp_feOffset_get_type() -{ - static GType feOffset_type = 0; - - if (!feOffset_type) { - GTypeInfo feOffset_info = { - sizeof(SPFeOffsetClass), - NULL, NULL, - (GClassInitFunc) sp_feOffset_class_init, - NULL, NULL, - sizeof(SPFeOffset), - 16, - (GInstanceInitFunc) sp_feOffset_init, - NULL, /* value_table */ - }; - feOffset_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeOffset", &feOffset_info, (GTypeFlags)0); - } - return feOffset_type; -} +G_DEFINE_TYPE(SPFeOffset, sp_feOffset, SP_TYPE_FILTER_PRIMITIVE); static void sp_feOffset_class_init(SPFeOffsetClass *klass) @@ -66,8 +41,6 @@ sp_feOffset_class_init(SPFeOffsetClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feOffset_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feOffset_build; sp_object_class->release = sp_feOffset_release; sp_object_class->write = sp_feOffset_write; @@ -92,8 +65,8 @@ sp_feOffset_init(SPFeOffset *feOffset) static void sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feOffset_parent_class)->build) { - ((SPObjectClass *) feOffset_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feOffset_parent_class)->build) { + ((SPObjectClass *) sp_feOffset_parent_class)->build(object, document, repr); } object->readAttr( "dx" ); @@ -106,8 +79,8 @@ sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r static void sp_feOffset_release(SPObject *object) { - if (((SPObjectClass *) feOffset_parent_class)->release) - ((SPObjectClass *) feOffset_parent_class)->release(object); + if (((SPObjectClass *) sp_feOffset_parent_class)->release) + ((SPObjectClass *) sp_feOffset_parent_class)->release(object); } /** @@ -137,8 +110,8 @@ sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value) /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feOffset_parent_class)->set) - ((SPObjectClass *) feOffset_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feOffset_parent_class)->set) + ((SPObjectClass *) sp_feOffset_parent_class)->set(object, key, value); break; } @@ -155,8 +128,8 @@ sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "dy" ); } - if (((SPObjectClass *) feOffset_parent_class)->update) { - ((SPObjectClass *) feOffset_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feOffset_parent_class)->update) { + ((SPObjectClass *) sp_feOffset_parent_class)->update(object, ctx, flags); } } @@ -172,8 +145,8 @@ sp_feOffset_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feOffset_parent_class)->write) { - ((SPObjectClass *) feOffset_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feOffset_parent_class)->write) { + ((SPObjectClass *) sp_feOffset_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index ee6824d00..a512172d1 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FePointLight class */ - -static void sp_fepointlight_class_init(SPFePointLightClass *klass); -static void sp_fepointlight_init(SPFePointLight *fepointlight); - static void sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fepointlight_release(SPObject *object); static void sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *fePointLight_parent_class; - -GType -sp_fepointlight_get_type() -{ - static GType fepointlight_type = 0; - - if (!fepointlight_type) { - GTypeInfo fepointlight_info = { - sizeof(SPFePointLightClass), - NULL, NULL, - (GClassInitFunc) sp_fepointlight_class_init, - NULL, NULL, - sizeof(SPFePointLight), - 16, - (GInstanceInitFunc) sp_fepointlight_init, - NULL, /* value_table */ - }; - fepointlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFePointLight", &fepointlight_info, (GTypeFlags)0); - } - return fepointlight_type; -} +G_DEFINE_TYPE(SPFePointLight, sp_fepointlight, SP_TYPE_OBJECT); static void sp_fepointlight_class_init(SPFePointLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - fePointLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fepointlight_build; sp_object_class->release = sp_fepointlight_release; sp_object_class->write = sp_fepointlight_write; @@ -98,8 +70,8 @@ sp_fepointlight_init(SPFePointLight *fepointlight) static void sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) fePointLight_parent_class)->build) { - ((SPObjectClass *) fePointLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fepointlight_parent_class)->build) { + ((SPObjectClass *) sp_fepointlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -192,8 +164,8 @@ sp_fepointlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) fePointLight_parent_class)->set) { - ((SPObjectClass *) fePointLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fepointlight_parent_class)->set) { + ((SPObjectClass *) sp_fepointlight_parent_class)->set(object, key, value); } break; } @@ -215,8 +187,8 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "z" ); } - if (((SPObjectClass *) fePointLight_parent_class)->update) { - ((SPObjectClass *) fePointLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fepointlight_parent_class)->update) { + ((SPObjectClass *) sp_fepointlight_parent_class)->update(object, ctx, flags); } } @@ -239,8 +211,8 @@ sp_fepointlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: if (fepointlight->z_set) sp_repr_set_css_double(repr, "z", fepointlight->z); - if (((SPObjectClass *) fePointLight_parent_class)->write) { - ((SPObjectClass *) fePointLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fepointlight_parent_class)->write) { + ((SPObjectClass *) sp_fepointlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 71a705c94..a7a19e11d 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -18,10 +18,13 @@ # include "config.h" #endif +#include "strneq.h" + #include "attributes.h" #include "svg/svg.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/svg-icc-color.h" #include "filters/specularlighting.h" #include "filters/distantlight.h" #include "filters/pointlight.h" @@ -31,10 +34,6 @@ #include "display/nr-filter-specularlighting.h" /* FeSpecularLighting base class */ - -static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass); -static void sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting); - static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feSpecularLighting_release(SPObject *object); static void sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value); @@ -52,35 +51,13 @@ static Inkscape::XML::Node *sp_feSpecularLighting_write(SPObject *object, Inksca static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting); -static SPFilterPrimitiveClass *feSpecularLighting_parent_class; - -GType -sp_feSpecularLighting_get_type() -{ - static GType feSpecularLighting_type = 0; - - if (!feSpecularLighting_type) { - GTypeInfo feSpecularLighting_info = { - sizeof(SPFeSpecularLightingClass), - NULL, NULL, - (GClassInitFunc) sp_feSpecularLighting_class_init, - NULL, NULL, - sizeof(SPFeSpecularLighting), - 16, - (GInstanceInitFunc) sp_feSpecularLighting_init, - NULL, /* value_table */ - }; - feSpecularLighting_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeSpecularLighting", &feSpecularLighting_info, (GTypeFlags)0); - } - return feSpecularLighting_type; -} +G_DEFINE_TYPE(SPFeSpecularLighting, sp_feSpecularLighting, SP_TYPE_FILTER_PRIMITIVE); static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feSpecularLighting_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feSpecularLighting_build; sp_object_class->release = sp_feSpecularLighting_release; @@ -101,6 +78,8 @@ sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting) feSpecularLighting->specularConstant = 1; feSpecularLighting->specularExponent = 1; feSpecularLighting->lighting_color = 0xffffffff; + feSpecularLighting->icc = NULL; + //TODO kernelUnit feSpecularLighting->renderer = NULL; @@ -118,8 +97,8 @@ sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting) static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feSpecularLighting_parent_class)->build) { - ((SPObjectClass *) feSpecularLighting_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->build) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -137,8 +116,8 @@ sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XM static void sp_feSpecularLighting_release(SPObject *object) { - if (((SPObjectClass *) feSpecularLighting_parent_class)->release) - ((SPObjectClass *) feSpecularLighting_parent_class)->release(object); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->release) + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->release(object); } /** @@ -228,6 +207,16 @@ sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value feSpecularLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff); //if a value was read if (cend_ptr) { + while (g_ascii_isspace(*cend_ptr)) { + ++cend_ptr; + } + if (strneq(cend_ptr, "icc-color(", 10)) { + if (!feSpecularLighting->icc) feSpecularLighting->icc = new SVGICCColor(); + if ( ! sp_svg_read_icc_color( cend_ptr, feSpecularLighting->icc ) ) { + delete feSpecularLighting->icc; + feSpecularLighting->icc = NULL; + } + } feSpecularLighting->lighting_color_set = TRUE; } else { //lighting_color already contains the default value @@ -239,8 +228,8 @@ sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) feSpecularLighting_parent_class)->set) - ((SPObjectClass *) feSpecularLighting_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->set) + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->set(object, key, value); break; } @@ -260,8 +249,8 @@ sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "lighting-color" ); } - if (((SPObjectClass *) feSpecularLighting_parent_class)->update) { - ((SPObjectClass *) feSpecularLighting_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->update) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->update(object, ctx, flags); } } @@ -292,8 +281,8 @@ sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Document *doc, Inks sp_svg_write_color(c, sizeof(c), fespecularlighting->lighting_color); repr->setAttribute("lighting-color", c); } - if (((SPObjectClass *) feSpecularLighting_parent_class)->write) { - ((SPObjectClass *) feSpecularLighting_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->write) { + ((SPObjectClass *) sp_feSpecularLighting_parent_class)->write(object, doc, repr, flags); } return repr; @@ -307,8 +296,8 @@ sp_feSpecularLighting_child_added(SPObject *object, Inkscape::XML::Node *child, { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) feSpecularLighting_parent_class)->child_added) - (* ((SPObjectClass *) feSpecularLighting_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->child_added) + (* ((SPObjectClass *) sp_feSpecularLighting_parent_class)->child_added)(object, child, ref); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -323,8 +312,8 @@ sp_feSpecularLighting_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) feSpecularLighting_parent_class)->remove_child) - (* ((SPObjectClass *) feSpecularLighting_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_feSpecularLighting_parent_class)->remove_child) + (* ((SPObjectClass *) sp_feSpecularLighting_parent_class)->remove_child)(object, child); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -334,8 +323,8 @@ static void sp_feSpecularLighting_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object); - if (((SPObjectClass *) (feSpecularLighting_parent_class))->order_changed) - (* ((SPObjectClass *) (feSpecularLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); + if (((SPObjectClass *) (sp_feSpecularLighting_parent_class))->order_changed) + (* ((SPObjectClass *) (sp_feSpecularLighting_parent_class))->order_changed) (object, child, old_ref, new_ref); sp_feSpecularLighting_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -378,6 +367,8 @@ static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, I nr_specularlighting->specularExponent = sp_specularlighting->specularExponent; nr_specularlighting->surfaceScale = sp_specularlighting->surfaceScale; nr_specularlighting->lighting_color = sp_specularlighting->lighting_color; + nr_specularlighting->set_icc(sp_specularlighting->icc); + //We assume there is at most one child nr_specularlighting->light_type = Inkscape::Filters::NO_LIGHT; if (SP_IS_FEDISTANTLIGHT(primitive->children)) { diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h index 90d1f9f62..44bd98c6c 100644 --- a/src/filters/specularlighting.h +++ b/src/filters/specularlighting.h @@ -23,6 +23,8 @@ #define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) #define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) +class SVGICCColor; + namespace Inkscape { namespace Filters { class FilterSpecularLighting; @@ -41,6 +43,7 @@ struct SPFeSpecularLighting : public SPFilterPrimitive { NumberOptNumber kernelUnitLength; guint32 lighting_color; guint lighting_color_set : 1; + SVGICCColor *icc; Inkscape::Filters::FilterSpecularLighting *renderer; }; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 7be83ed00..181e39990 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -30,47 +30,19 @@ #include "macros.h" /* FeSpotLight class */ - -static void sp_fespotlight_class_init(SPFeSpotLightClass *klass); -static void sp_fespotlight_init(SPFeSpotLight *fespotlight); - static void sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fespotlight_release(SPObject *object); static void sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value); static void sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *feSpotLight_parent_class; - -GType -sp_fespotlight_get_type() -{ - static GType fespotlight_type = 0; - - if (!fespotlight_type) { - GTypeInfo fespotlight_info = { - sizeof(SPFeSpotLightClass), - NULL, NULL, - (GClassInitFunc) sp_fespotlight_class_init, - NULL, NULL, - sizeof(SPFeSpotLight), - 16, - (GInstanceInitFunc) sp_fespotlight_init, - NULL, /* value_table */ - }; - fespotlight_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeSpotLight", &fespotlight_info, (GTypeFlags)0); - } - return fespotlight_type; -} +G_DEFINE_TYPE(SPFeSpotLight, sp_fespotlight, SP_TYPE_OBJECT); static void sp_fespotlight_class_init(SPFeSpotLightClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - feSpotLight_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_fespotlight_build; sp_object_class->release = sp_fespotlight_release; sp_object_class->write = sp_fespotlight_write; @@ -108,8 +80,8 @@ sp_fespotlight_init(SPFeSpotLight *fespotlight) static void sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feSpotLight_parent_class)->build) { - ((SPObjectClass *) feSpotLight_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_fespotlight_parent_class)->build) { + ((SPObjectClass *) sp_fespotlight_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -290,8 +262,8 @@ sp_fespotlight_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) feSpotLight_parent_class)->set) { - ((SPObjectClass *) feSpotLight_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_fespotlight_parent_class)->set) { + ((SPObjectClass *) sp_fespotlight_parent_class)->set(object, key, value); } break; } @@ -318,8 +290,8 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "limitingConeAngle" ); } - if (((SPObjectClass *) feSpotLight_parent_class)->update) { - ((SPObjectClass *) feSpotLight_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_fespotlight_parent_class)->update) { + ((SPObjectClass *) sp_fespotlight_parent_class)->update(object, ctx, flags); } } @@ -352,8 +324,8 @@ sp_fespotlight_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::X if (fespotlight->limitingConeAngle_set) sp_repr_set_css_double(repr, "limitingConeAngle", fespotlight->limitingConeAngle); - if (((SPObjectClass *) feSpotLight_parent_class)->write) { - ((SPObjectClass *) feSpotLight_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_fespotlight_parent_class)->write) { + ((SPObjectClass *) sp_fespotlight_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index 42a59ede8..d2725f50c 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -23,10 +23,6 @@ #include "display/nr-filter-tile.h" /* FeTile base class */ - -static void sp_feTile_class_init(SPFeTileClass *klass); -static void sp_feTile_init(SPFeTile *feTile); - static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feTile_release(SPObject *object); static void sp_feTile_set(SPObject *object, unsigned int key, gchar const *value); @@ -34,28 +30,7 @@ static void sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feTile_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feTile_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feTile_parent_class; - -GType -sp_feTile_get_type() -{ - static GType feTile_type = 0; - - if (!feTile_type) { - GTypeInfo feTile_info = { - sizeof(SPFeTileClass), - NULL, NULL, - (GClassInitFunc) sp_feTile_class_init, - NULL, NULL, - sizeof(SPFeTile), - 16, - (GInstanceInitFunc) sp_feTile_init, - NULL, /* value_table */ - }; - feTile_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTile", &feTile_info, (GTypeFlags)0); - } - return feTile_type; -} +G_DEFINE_TYPE(SPFeTile, sp_feTile, SP_TYPE_FILTER_PRIMITIVE); static void sp_feTile_class_init(SPFeTileClass *klass) @@ -63,8 +38,6 @@ sp_feTile_class_init(SPFeTileClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feTile_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feTile_build; sp_object_class->release = sp_feTile_release; sp_object_class->write = sp_feTile_write; @@ -86,8 +59,8 @@ sp_feTile_init(SPFeTile */*feTile*/) static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feTile_parent_class)->build) { - ((SPObjectClass *) feTile_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feTile_parent_class)->build) { + ((SPObjectClass *) sp_feTile_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -99,8 +72,8 @@ sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep static void sp_feTile_release(SPObject *object) { - if (((SPObjectClass *) feTile_parent_class)->release) - ((SPObjectClass *) feTile_parent_class)->release(object); + if (((SPObjectClass *) sp_feTile_parent_class)->release) + ((SPObjectClass *) sp_feTile_parent_class)->release(object); } /** @@ -115,8 +88,8 @@ sp_feTile_set(SPObject *object, unsigned int key, gchar const *value) switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ default: - if (((SPObjectClass *) feTile_parent_class)->set) - ((SPObjectClass *) feTile_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feTile_parent_class)->set) + ((SPObjectClass *) sp_feTile_parent_class)->set(object, key, value); break; } @@ -135,8 +108,8 @@ sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feTile_parent_class)->update) { - ((SPObjectClass *) feTile_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feTile_parent_class)->update) { + ((SPObjectClass *) sp_feTile_parent_class)->update(object, ctx, flags); } } @@ -152,8 +125,8 @@ sp_feTile_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feTile_parent_class)->write) { - ((SPObjectClass *) feTile_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feTile_parent_class)->write) { + ((SPObjectClass *) sp_feTile_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index 9d1448c70..c4d4ca4ae 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -29,10 +29,6 @@ #include "display/nr-filter-turbulence.h" /* FeTurbulence base class */ - -static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass); -static void sp_feTurbulence_init(SPFeTurbulence *feTurbulence); - static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_feTurbulence_release(SPObject *object); static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value); @@ -40,28 +36,7 @@ static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter); -static SPFilterPrimitiveClass *feTurbulence_parent_class; - -GType -sp_feTurbulence_get_type() -{ - static GType feTurbulence_type = 0; - - if (!feTurbulence_type) { - GTypeInfo feTurbulence_info = { - sizeof(SPFeTurbulenceClass), - NULL, NULL, - (GClassInitFunc) sp_feTurbulence_class_init, - NULL, NULL, - sizeof(SPFeTurbulence), - 16, - (GInstanceInitFunc) sp_feTurbulence_init, - NULL, /* value_table */ - }; - feTurbulence_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTurbulence", &feTurbulence_info, (GTypeFlags)0); - } - return feTurbulence_type; -} +G_DEFINE_TYPE(SPFeTurbulence, sp_feTurbulence, SP_TYPE_FILTER_PRIMITIVE); static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) @@ -69,8 +44,6 @@ sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; - feTurbulence_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_feTurbulence_build; sp_object_class->release = sp_feTurbulence_release; sp_object_class->write = sp_feTurbulence_write; @@ -94,8 +67,8 @@ sp_feTurbulence_init(SPFeTurbulence *feTurbulence) static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) feTurbulence_parent_class)->build) { - ((SPObjectClass *) feTurbulence_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->build) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->build(object, document, repr); } /*LOAD ATTRIBUTES FROM REPR HERE*/ @@ -112,8 +85,8 @@ sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod static void sp_feTurbulence_release(SPObject *object) { - if (((SPObjectClass *) feTurbulence_parent_class)->release) - ((SPObjectClass *) feTurbulence_parent_class)->release(object); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->release) + ((SPObjectClass *) sp_feTurbulence_parent_class)->release(object); } static bool sp_feTurbulence_read_stitchTiles(gchar const *value){ @@ -200,8 +173,8 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) } break; default: - if (((SPObjectClass *) feTurbulence_parent_class)->set) - ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->set) + ((SPObjectClass *) sp_feTurbulence_parent_class)->set(object, key, value); break; } @@ -220,8 +193,8 @@ sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) feTurbulence_parent_class)->update) { - ((SPObjectClass *) feTurbulence_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->update) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->update(object, ctx, flags); } } @@ -237,8 +210,8 @@ sp_feTurbulence_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape:: repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) feTurbulence_parent_class)->write) { - ((SPObjectClass *) feTurbulence_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_feTurbulence_parent_class)->write) { + ((SPObjectClass *) sp_feTurbulence_parent_class)->write(object, doc, repr, flags); } /* turbulence doesn't take input */ diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 3c656527e..a62be624c 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -75,8 +75,6 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -static void sp_flood_context_class_init(SPFloodContextClass *klass); -static void sp_flood_context_init(SPFloodContext *flood_context); static void sp_flood_context_dispose(GObject *object); static void sp_flood_context_setup(SPEventContext *ec); @@ -86,35 +84,13 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem static void sp_flood_finish(SPFloodContext *rc); -static SPEventContextClass *parent_class; - - -GType sp_flood_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPFloodContextClass), - NULL, NULL, - (GClassInitFunc) sp_flood_context_class_init, - NULL, NULL, - sizeof(SPFloodContext), - 4, - (GInstanceInitFunc) sp_flood_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPFloodContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPFloodContext, sp_flood_context, SP_TYPE_EVENT_CONTEXT); static void sp_flood_context_class_init(SPFloodContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_flood_context_dispose; event_context_class->setup = sp_flood_context_setup; @@ -160,7 +136,7 @@ static void sp_flood_context_dispose(GObject *object) delete rc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_flood_context_parent_class)->dispose(object); } /** @@ -181,8 +157,8 @@ static void sp_flood_context_setup(SPEventContext *ec) { SPFloodContext *rc = SP_FLOOD_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_flood_context_parent_class)->setup) { + ((SPEventContextClass *) sp_flood_context_parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -1166,8 +1142,8 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem break; } - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if (((SPEventContextClass *) sp_flood_context_parent_class)->item_handler) { + ret = ((SPEventContextClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -1274,8 +1250,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_flood_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_flood_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 231490771..8fd002d70 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -51,8 +51,6 @@ using Inkscape::DocumentUndo; -static void sp_gradient_context_class_init(SPGradientContextClass *klass); -static void sp_gradient_context_init(SPGradientContext *gr_context); static void sp_gradient_context_dispose(GObject *object); static void sp_gradient_context_setup(SPEventContext *ec); @@ -61,35 +59,13 @@ static gint sp_gradient_context_root_handler(SPEventContext *event_context, GdkE static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint state, guint32 etime); -static SPEventContextClass *parent_class; - - -GType sp_gradient_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPGradientContextClass), - NULL, NULL, - (GClassInitFunc) sp_gradient_context_class_init, - NULL, NULL, - sizeof(SPGradientContext), - 4, - (GInstanceInitFunc) sp_gradient_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPGradientContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPGradientContext, sp_gradient_context, SP_TYPE_EVENT_CONTEXT); static void sp_gradient_context_class_init(SPGradientContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_gradient_context_dispose; event_context_class->setup = sp_gradient_context_setup; @@ -127,7 +103,7 @@ static void sp_gradient_context_dispose(GObject *object) rc->subselcon->disconnect(); delete rc->subselcon; - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_gradient_context_parent_class)->dispose(object); } const gchar *gr_handle_descr [] = { @@ -204,8 +180,8 @@ static void sp_gradient_context_setup(SPEventContext *ec) { SPGradientContext *rc = SP_GRADIENT_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_gradient_context_parent_class)->setup) { + ((SPEventContextClass *) sp_gradient_context_parent_class)->setup(ec); } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -879,8 +855,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_gradient_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_gradient_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 4fafa191e..0e9957ca3 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -19,34 +19,9 @@ #include "document.h" #include "helper/action.h" -static void sp_action_class_init (SPActionClass *klass); -static void sp_action_init (SPAction *action); static void sp_action_finalize (GObject *object); -static GObjectClass *parent_class; - -/** - * Register SPAction class and return its type. - */ -GType -sp_action_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPActionClass), - NULL, NULL, - (GClassInitFunc) sp_action_class_init, - NULL, NULL, - sizeof(SPAction), - 0, - (GInstanceInitFunc) sp_action_init, - NULL - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPAction", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPAction, sp_action, G_TYPE_OBJECT); /** * SPAction vtable initialization. @@ -54,8 +29,6 @@ sp_action_get_type (void) static void sp_action_class_init (SPActionClass *klass) { - parent_class = (GObjectClass*) g_type_class_ref(G_TYPE_OBJECT); - GObjectClass *object_class = (GObjectClass *) klass; object_class->finalize = sp_action_finalize; } @@ -84,19 +57,19 @@ sp_action_init (SPAction *action) static void sp_action_finalize (GObject *object) { - SPAction *action = SP_ACTION(object); + SPAction *action = SP_ACTION(object); - g_free (action->image); - g_free (action->tip); - g_free (action->name); - g_free (action->id); + g_free (action->image); + g_free (action->tip); + g_free (action->name); + g_free (action->id); action->signal_perform.~signal(); action->signal_set_sensitive.~signal(); action->signal_set_active.~signal(); action->signal_set_name.~signal(); - parent_class->finalize (object); + G_OBJECT_CLASS(sp_action_parent_class)->finalize (object); } /** diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp index bb2254a1b..af07c03c1 100644 --- a/src/helper/unit-menu.cpp +++ b/src/helper/unit-menu.cpp @@ -52,39 +52,16 @@ struct SPUnitSelectorClass { enum {SET_UNIT, LAST_SIGNAL}; -static void sp_unit_selector_class_init(SPUnitSelectorClass *klass); -static void sp_unit_selector_init(SPUnitSelector *selector); static void sp_unit_selector_finalize(GObject *object); -static GtkHBoxClass *unit_selector_parent_class; static guint signals[LAST_SIGNAL] = {0}; -GType sp_unit_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPUnitSelectorClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_unit_selector_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPUnitSelector), - 0, // n_preallocs - (GInstanceInitFunc)sp_unit_selector_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_HBOX, "SPUnitSelector", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPUnitSelector, sp_unit_selector, GTK_TYPE_HBOX); static void sp_unit_selector_class_init(SPUnitSelectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - unit_selector_parent_class = GTK_HBOX_CLASS(g_type_class_peek_parent(klass)); signals[SET_UNIT] = g_signal_new("set_unit", G_TYPE_FROM_CLASS(klass), @@ -142,7 +119,7 @@ sp_unit_selector_finalize(GObject *object) selector->unit = NULL; - G_OBJECT_CLASS(unit_selector_parent_class)->finalize(object); + G_OBJECT_CLASS(sp_unit_selector_parent_class)->finalize(object); } GtkWidget * diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 7a1e000fb..c8eacfe02 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -36,9 +36,9 @@ struct IdReference { const char *attr; // property or href-like attribute }; -typedef std::map<std::string, std::list<IdReference> > refmap_type; +typedef std::map<Glib::ustring, std::list<IdReference> > refmap_type; -typedef std::pair<SPObject*, std::string> id_changeitem_type; +typedef std::pair<SPObject*, Glib::ustring> id_changeitem_type; typedef std::list<id_changeitem_type> id_changelist_type; const char *href_like_attributes[] = { @@ -298,7 +298,6 @@ void change_def_references(SPObject *from_obj, SPObject *to_obj) { refmap_type *refmap = new refmap_type; - id_changelist_type id_changes; SPDocument *current_doc = from_obj->document; std::string old_id(from_obj->getId()); @@ -324,9 +323,15 @@ change_def_references(SPObject *from_obj, SPObject *to_obj) */ void rename_id(SPObject *elem, Glib::ustring const &new_name) { - gchar *id = g_strdup(new_name.c_str()); + if (new_name.empty()){ + g_message("Invalid Id, will not change."); + return; + } + gchar *id = g_strdup(new_name.c_str()); //id is not empty here as new_name is check to be not empty g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_'); - if (!*id || !isalnum (*id)) { + Glib::ustring new_name2 = id; //will not fail as id can not be NULL, see length check on new_name + g_free (id); + if (!isalnum (new_name2[0])) { g_message("Invalid Id, will not change."); return; } @@ -337,31 +342,27 @@ void rename_id(SPObject *elem, Glib::ustring const &new_name) find_references(current_doc->getRoot(), refmap); std::string old_id(elem->getId()); - std::string new_id(id); - if (id && current_doc->getObjectById(id)) { + if (current_doc->getObjectById(id)) { // Choose a new ID. // To try to preserve any meaningfulness that the original ID // may have had, the new ID is the old ID followed by a hyphen // and one or more digits. - new_id += '-'; + new_name2 += '-'; for (;;) { - new_id += "0123456789"[std::rand() % 10]; - const char *str = new_id.c_str(); - if (current_doc->getObjectById(str) == NULL) + new_name2 += "0123456789"[std::rand() % 10]; + if (current_doc->getObjectById(new_name2) == NULL) break; } } // Change to the new ID - elem->getRepr()->setAttribute("id", new_id.c_str()); + elem->getRepr()->setAttribute("id", new_name2.c_str()); // Make a note of this change, if we need to fix up refs to it if (refmap->find(old_id) != refmap->end()) { id_changes.push_back(id_changeitem_type(elem, old_id)); } fix_up_refs(refmap, id_changes); - - g_free (id); delete refmap; } diff --git a/src/ink-action.cpp b/src/ink-action.cpp index c79cebd1e..dd1fe5484 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -7,8 +7,6 @@ #include "widgets/button.h" -static void ink_action_class_init( InkActionClass* klass ); -static void ink_action_init( InkAction* action ); static void ink_action_finalize( GObject* obj ); static void ink_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ink_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -16,8 +14,6 @@ static void ink_action_set_property( GObject* obj, guint propId, const GValue *v static GtkWidget* ink_action_create_menu_item( GtkAction* action ); static GtkWidget* ink_action_create_tool_item( GtkAction* action ); -static GtkActionClass* gInkActionParentClass = 0; - struct _InkActionPrivate { gchar* iconId; @@ -26,28 +22,7 @@ struct _InkActionPrivate #define INK_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_ACTION_TYPE, InkActionPrivate ) ) -GType ink_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( InkActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ink_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( InkAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ink_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_ACTION, "InkAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(InkAction, ink_action, GTK_TYPE_ACTION); enum { PROP_INK_ID = 1, @@ -57,7 +32,6 @@ enum { static void ink_action_class_init( InkActionClass* klass ) { if ( klass ) { - gInkActionParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass * objClass = G_OBJECT_CLASS( klass ); objClass->finalize = ink_action_finalize; @@ -203,7 +177,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) g_free( label ); label = 0; } else { - item = gInkActionParentClass->create_menu_item( action ); + item = GTK_ACTION_CLASS(ink_action_parent_class)->create_menu_item( action ); } return item; @@ -212,7 +186,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) static GtkWidget* ink_action_create_tool_item( GtkAction* action ) { InkAction* act = INK_ACTION( action ); - GtkWidget* item = gInkActionParentClass->create_tool_item(action); + GtkWidget* item = GTK_ACTION_CLASS(ink_action_parent_class)->create_tool_item(action); if ( act->private_data->iconId ) { if ( GTK_IS_TOOL_BUTTON(item) ) { @@ -241,8 +215,6 @@ static GtkWidget* ink_action_create_tool_item( GtkAction* action ) /* --------------------------------------------------------------- */ -static void ink_toggle_action_class_init( InkToggleActionClass* klass ); -static void ink_toggle_action_init( InkToggleAction* action ); static void ink_toggle_action_finalize( GObject* obj ); static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -252,8 +224,6 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ); static void ink_toggle_action_update_icon( InkToggleAction* action ); -static GtkToggleActionClass* gInkToggleActionParentClass = 0; - struct _InkToggleActionPrivate { gchar* iconId; @@ -262,34 +232,11 @@ struct _InkToggleActionPrivate #define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) ) -GType ink_toggle_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( InkToggleActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ink_toggle_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( InkToggleAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ink_toggle_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_TOGGLE_ACTION, "InkToggleAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} - +G_DEFINE_TYPE(InkToggleAction, ink_toggle_action, GTK_TYPE_TOGGLE_ACTION); static void ink_toggle_action_class_init( InkToggleActionClass* klass ) { if ( klass ) { - gInkToggleActionParentClass = GTK_TOGGLE_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass * objClass = G_OBJECT_CLASS( klass ); objClass->finalize = ink_toggle_action_finalize; @@ -413,7 +360,7 @@ void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *v static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action ) { - GtkWidget* item = gInkToggleActionParentClass->parent_class.create_menu_item(action); + GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_menu_item(action); return item; } @@ -422,7 +369,7 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) { InkToggleAction* act = INK_TOGGLE_ACTION( action ); - GtkWidget* item = gInkToggleActionParentClass->parent_class.create_tool_item(action); + GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action); if ( GTK_IS_TOOL_BUTTON(item) ) { GtkToolButton* button = GTK_TOOL_BUTTON(item); if ( act->private_data->iconId ) { @@ -477,8 +424,6 @@ static void ink_toggle_action_update_icon( InkToggleAction* action ) /* --------------------------------------------------------------- */ -static void ink_radio_action_class_init( InkRadioActionClass* klass ); -static void ink_radio_action_init( InkRadioAction* action ); static void ink_radio_action_finalize( GObject* obj ); static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -486,8 +431,6 @@ static void ink_radio_action_set_property( GObject* obj, guint propId, const GVa static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ); static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ); -static GtkRadioActionClass* gInkRadioActionParentClass = 0; - struct _InkRadioActionPrivate { gchar* iconId; @@ -496,34 +439,11 @@ struct _InkRadioActionPrivate #define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) ) -GType ink_radio_action_get_type( void ) -{ - static GType myType = 0; - if ( !myType ) { - static const GTypeInfo myInfo = { - sizeof( InkRadioActionClass ), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)ink_radio_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof( InkRadioAction ), - 0, /* n_preallocs */ - (GInstanceInitFunc)ink_radio_action_init, - NULL - }; - - myType = g_type_register_static( GTK_TYPE_RADIO_ACTION, "InkRadioAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} - +G_DEFINE_TYPE(InkRadioAction, ink_radio_action, GTK_TYPE_RADIO_ACTION); static void ink_radio_action_class_init( InkRadioActionClass* klass ) { if ( klass ) { - gInkRadioActionParentClass = GTK_RADIO_ACTION_CLASS( g_type_class_peek_parent( klass ) ); GObjectClass * objClass = G_OBJECT_CLASS( klass ); objClass->finalize = ink_radio_action_finalize; @@ -642,7 +562,7 @@ void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *va static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ) { - GtkWidget* item = gInkRadioActionParentClass->parent_class.parent_class.create_menu_item(action); + GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_menu_item(action); return item; } @@ -650,7 +570,7 @@ static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ) static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) { InkRadioAction* act = INK_RADIO_ACTION( action ); - GtkWidget* item = gInkRadioActionParentClass->parent_class.parent_class.create_tool_item(action); + GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action); if ( act->private_data->iconId ) { if ( GTK_IS_TOOL_BUTTON(item) ) { @@ -681,34 +601,7 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) // ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 -static void ink_tool_menu_action_init (InkToolMenuAction *tma); -static void ink_tool_menu_action_class_init (InkToolMenuActionClass *klass); - -GType -ink_tool_menu_action_get_type (void) -{ - static GType myType = 0; - if (! myType) - { - static const GTypeInfo myInfo = - { - sizeof (InkToolMenuActionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ink_tool_menu_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (InkToolMenuAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) ink_tool_menu_action_init, - NULL - }; - - myType = g_type_register_static( INK_ACTION_TYPE, "InkToolMenuAction", &myInfo, (GTypeFlags)0 ); - } - - return myType; -} +G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE); static void ink_tool_menu_action_class_init (InkToolMenuActionClass *klass) diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index d9b1b0965..a28ec4f53 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -25,6 +25,7 @@ #include <iostream> #include <string.h> +#include <glibmm/ustring.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> @@ -37,7 +38,7 @@ static GtkWidget* create_menu_item( GtkAction* action ); // Internal static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ); -static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); +static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); // Callbacks static void combo_box_changed_cb( GtkComboBox* widget, gpointer data ); @@ -63,9 +64,13 @@ enum { }; static guint signals[N_SIGNALS] = {0}; -static GtkActionClass *ink_comboboxentry_action_parent_class = NULL; static GQuark gDataName = 0; +static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action); +static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass); + +G_DEFINE_TYPE(Ink_ComboBoxEntry_Action, ink_comboboxentry_action, GTK_TYPE_ACTION); + static void ink_comboboxentry_action_finalize (GObject *object) { // Free any allocated resources. @@ -174,8 +179,8 @@ ink_comboboxentry_action_connect_proxy (GtkAction *action, GTK_ACTION_CLASS (ink_comboboxentry_action_parent_class)->connect_proxy (action, proxy); } - -static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass) +static void +ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); @@ -192,8 +197,6 @@ static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass * klass->parent_class.create_tool_item = create_tool_item; klass->parent_class.create_menu_item = create_menu_item; - ink_comboboxentry_action_parent_class = GTK_ACTION_CLASS(g_type_class_peek_parent (klass) ); - g_object_class_install_property ( gobject_class, PROP_MODEL, @@ -292,34 +295,6 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->focusWidget = NULL; } -GType ink_comboboxentry_action_get_type () -{ - static GType ink_comboboxentry_action_type = 0; - - if (!ink_comboboxentry_action_type) { - static const GTypeInfo ink_comboboxentry_action_info = { - sizeof(Ink_ComboBoxEntry_ActionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ink_comboboxentry_action_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(Ink_ComboBoxEntry_Action), - 0, /* n_preallocs */ - (GInstanceInitFunc)ink_comboboxentry_action_init, /* instance_init */ - NULL /* value_table */ - }; - - ink_comboboxentry_action_type = g_type_register_static (GTK_TYPE_ACTION, - "Ink_ComboBoxEntry_Action", - &ink_comboboxentry_action_info, - (GTypeFlags)0 ); - } - - return ink_comboboxentry_action_type; -} - - Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name, const gchar *label, const gchar *tooltip, @@ -439,7 +414,7 @@ GtkWidget* create_tool_item( GtkAction* action ) } else { - item = ink_comboboxentry_action_parent_class->create_tool_item( action ); + item = GTK_ACTION_CLASS(ink_comboboxentry_action_parent_class)->create_tool_item( action ); } @@ -451,7 +426,7 @@ GtkWidget* create_menu_item( GtkAction* action ) { GtkWidget* item = 0; - item = ink_comboboxentry_action_parent_class->create_menu_item( action ); + item = GTK_ACTION_CLASS(ink_comboboxentry_action_parent_class)->create_menu_item( action ); g_warning( "ink_comboboxentry_action: create_menu_item not implemented" ); // One can easily modify ege-select-one-action routine to implement this. return item; @@ -495,10 +470,12 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_text( ink_comboboxentry_action->entry, text ); // Show or hide warning + bool clear = true; if( ink_comboboxentry_action->active == -1 && - ink_comboboxentry_action->warning != NULL && - check_comma_separated_text( ink_comboboxentry_action ) ) { - { + ink_comboboxentry_action->warning != NULL ) { + Glib::ustring missing = check_comma_separated_text( ink_comboboxentry_action ); + if( !missing.empty() ) { + GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); if (isStock) { @@ -510,15 +487,21 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_WARNING ); } + // Can't add tooltip until icon set + Glib::ustring warning = ink_comboboxentry_action->warning; + warning += ": "; + warning += missing; + gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, + GTK_ENTRY_ICON_SECONDARY, + warning.c_str() ); + clear = false; } - // Can't add tooltip until icon set - gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, - GTK_ENTRY_ICON_SECONDARY, - ink_comboboxentry_action->warning ); - } else { + } + + if( clear ) { gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), - GTK_ENTRY_ICON_SECONDARY, - NULL ); + GTK_ENTRY_ICON_SECONDARY, + NULL ); gtk_entry_set_icon_from_stock( GTK_ENTRY(ink_comboboxentry_action->entry), GTK_ENTRY_ICON_SECONDARY, NULL ); @@ -657,18 +640,21 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta } -// Checks if all comma separated text fragments are in the list. +// Checks if all comma separated text fragments are in the list and +// returns a ustring with a list of missing fragments. // This is useful for checking if all fonts in a font-family fallback // list are available on the system. -// The return value is set to the number of missing text fragments. +// // This routine could also create a Pango Markup string to show which -// fragments are invalid. -// It is envisioned that one can construct a Pango Markup String here -// so that individual text fragments can be flagged as not being in the -// list. -static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { +// fragments are invalid in the entry box itself. See: +// http://developer.gnome.org/pango/stable/PangoMarkupFormat.html +// However... it appears that while one can retrieve the PangoLayout +// for a GtkEntry box, it is only a copy and changing it has no effect. +// PangoLayout * pl = gtk_entry_get_layout( entry ); +// pango_layout_set_markup( pl, "NEW STRING", -1 ); // DOESN'T WORK +static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { - gint ret_val = 0; + Glib::ustring missing; // Parse fallback_list using a comma as deliminator gchar** tokens = g_strsplit( action->text, ",", 0 ); @@ -680,21 +666,18 @@ static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { g_strstrip( tokens[i] ); if( get_active_row_from_text( action, tokens[i] ) == -1 ) { - ret_val += 1; + missing += tokens[i]; + missing += ", "; } ++i; } g_strfreev( tokens ); - // Pango Markup notes: - // GString* Pango_Markup = g_string_new(""); - // if not present: - // g_string_sprintfa( Pango_Markup, "<span strikethrough=\"true\" strikethrough_color=\"#880000\">%s</span>", tokens[i] ); - // PangoLayout * pl = gtk_entry_get_layout( entry ); - // pango_layout_set_markup( pl, Pango_Markup->str, -1 ); - // g_string_free( Pango_Markup, TRUE ); - - return ret_val; + // Remove extra comma and space from end. + if( missing.size() >= 2 ) { + missing.resize( missing.size()-2 ); + } + return missing; } // Callbacks --------------------------------------------------- diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 98904a47a..a9220d867 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -28,7 +28,7 @@ typedef INK_UNORDERED_MAP<PangoFontDescription*, font_instance*, font_descr_hash size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { int h = 0; h *= 1128467; - char const *theF = pango_font_description_get_family(x); + char const *theF = sp_font_description_get_family(x); h += (theF)?g_str_hash(theF):0; h *= 1128467; h += (int)pango_font_description_get_style(x); @@ -42,8 +42,8 @@ size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { } bool font_descr_equal::operator()( PangoFontDescription *const&a, PangoFontDescription *const &b) const { //if ( pango_font_description_equal(a,b) ) return true; - char const *fa = pango_font_description_get_family(a); - char const *fb = pango_font_description_get_family(b); + char const *fa = sp_font_description_get_family(a); + char const *fb = sp_font_description_get_family(b); if ( ( fa && fb == NULL ) || ( fb && fa == NULL ) ) return false; if ( fa && fb && strcmp(fa,fb) != 0 ) return false; if ( pango_font_description_get_style(a) != pango_font_description_get_style(b) ) return false; @@ -395,6 +395,33 @@ Glib::ustring font_factory::ConstructFontSpecification(font_instance *font) return pangoString; } +/* + * Wrap calls to pango_font_description_get_family + * and replace some of the pango font names with generic css names + * http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#generic-font-families + * + * This function should be called in place of pango_font_description_get_family() + */ +const char *sp_font_description_get_family(PangoFontDescription const *fontDescr) { + + static std::map<Glib::ustring, Glib::ustring> fontNameMap; + std::map<Glib::ustring, Glib::ustring>::iterator it; + + if (fontNameMap.empty()) { + fontNameMap.insert(std::make_pair("Sans", "sans-serif")); + fontNameMap.insert(std::make_pair("Serif", "serif")); + fontNameMap.insert(std::make_pair("Monospace", "monospace")); + } + + const char *pangoFamily = pango_font_description_get_family(fontDescr); + + if (pangoFamily && ((it = fontNameMap.find(pangoFamily)) != fontNameMap.end())) { + return ((Glib::ustring)it->second).c_str(); + } + + return pangoFamily; +} + Glib::ustring font_factory::GetUIFamilyString(PangoFontDescription const *fontDescr) { Glib::ustring family; @@ -403,7 +430,8 @@ Glib::ustring font_factory::GetUIFamilyString(PangoFontDescription const *fontDe if (fontDescr) { // For now, keep it as family name taken from pango - const char *pangoFamily = pango_font_description_get_family(fontDescr); + const char *pangoFamily = sp_font_description_get_family(fontDescr); + if( pangoFamily ) { family = pangoFamily; } @@ -454,7 +482,7 @@ Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & // what constitutes a "family" in our own UI may be different from how Pango // sees it. - // Find the PangoFontDescription associated with the font specification string. + // Find the PangoFontDescription associated with the old font specification string. PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); @@ -464,15 +492,23 @@ Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & // Make copy PangoFontDescription *descr = pango_font_description_copy((*it).second); - // Grab the UI Family string from the descr + // Grab the old UI Family string from the descr Glib::ustring uiFamily = GetUIFamilyString(descr); // Replace the UI Family name with the new family name std::size_t found = fontSpec.find(uiFamily); if (found != Glib::ustring::npos) { + + // Add comma to end of newFamily... commas at end don't hurt but are + // required if the last part of a family name is a valid font style + // (e.g. "Arial Black"). + Glib::ustring newFamilyComma = newFamily; + if( *newFamilyComma.rbegin() != ',' ) { + newFamilyComma += ","; + } newFontSpec = fontSpec; newFontSpec.erase(found, uiFamily.size()); - newFontSpec.insert(found, newFamily); + newFontSpec.insert(found, newFamilyComma); // If the new font specification does not exist in the reference maps, // search for the next best match for the faces in that style @@ -711,11 +747,13 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) Glib::ustring styleUIName = GetUIStyleString(faceDescr); if (!familyUIName.empty() && !styleUIName.empty()) { + // Find the right place to put the style information, adding // a map entry for the family name if it doesn't yet exist FamilyToStylesMap::iterator iter = map->find(familyUIName); + // Insert new family if (iter == map->end()) { map->insert(std::make_pair(familyUIName, std::list<Glib::ustring>())); } @@ -745,6 +783,7 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) ConstructFontSpecification(faceDescr))); fontInstanceMap.insert( std::make_pair(ConstructFontSpecification(faceDescr), faceDescr)); + } else { pango_font_description_free(faceDescr); } @@ -815,7 +854,14 @@ font_instance* font_factory::FaceFromUIStrings(char const *uiFamily, char const g_assert(uiFamily && uiStyle); if (uiFamily && uiStyle) { - Glib::ustring uiString = Glib::ustring(uiFamily) + Glib::ustring(uiStyle); + + // If font list, take only first font in list + gchar** tokens = g_strsplit( uiFamily, ",", 0 ); + g_strstrip( tokens[0] ); + + Glib::ustring uiString = Glib::ustring(tokens[0]) + Glib::ustring(uiStyle); + + g_strfreev( tokens ); UIStringToPangoStringMap::iterator uiToPangoIter = fontStringMap.find(uiString); @@ -854,7 +900,7 @@ font_instance* font_factory::FaceFromPangoString(char const *pangoString) descr = pango_font_description_from_string(pangoString); } - if (descr && (pango_font_description_get_family(descr) != NULL)) { + if (descr && (sp_font_description_get_family(descr) != NULL)) { fontInstance = Face(descr); } @@ -902,7 +948,7 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) // workaround for bug #1025565. // fonts without families blow up Pango. - if (pango_font_description_get_family(descr) != NULL) { + if (sp_font_description_get_family(descr) != NULL) { nFace = pango_font_map_load_font(fontServer,fontContext,descr); } else { diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 42f975ab7..12046079e 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -54,6 +54,9 @@ struct font_descr_equal : public std::binary_function<PangoFontDescription*, Pan int style_name_compare(char const *aa, char const *bb); int family_name_compare(char const *a, char const *b); +// Wraps calls to pango_font_description_get_family with some name substitution +const char *sp_font_description_get_family(PangoFontDescription const *fontDescr); + // Map type for gathering UI family and style strings typedef std::map<Glib::ustring, std::list<Glib::ustring> > FamilyToStylesMap; diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index f26b157da..61225ad0c 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -285,14 +285,14 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int bool b = (weight >= PANGO_WEIGHT_BOLD); res = g_strdup_printf ("%s%s%s%s", - pango_font_description_get_family(descr), + sp_font_description_get_family(descr), (b || i || o) ? "-" : "", (b) ? "Bold" : "", (i) ? "Italic" : ((o) ? "Oblique" : "") ); free_res = true; } } else if ( strcmp(key,"family") == 0 ) { - res=(char*)pango_font_description_get_family(descr); + res=(char*)sp_font_description_get_family(descr); free_res=false; } else if ( strcmp(key,"style") == 0 ) { PangoStyle v=pango_font_description_get_style(descr); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index bf746b41f..1d086b57b 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -340,7 +340,7 @@ Glib::ustring Layout::getFontFamily(unsigned span_index) const return ""; if (_spans[span_index].font) { - return pango_font_description_get_family(_spans[span_index].font->descr); + return sp_font_description_get_family(_spans[span_index].font->descr); } return ""; @@ -368,7 +368,7 @@ Glib::ustring Layout::dumpAsText() const snprintf(line, sizeof(line), " in chunk %d (x=%f, baselineshift=%f)\n", _spans[span_index].in_chunk, _chunks[_spans[span_index].in_chunk].left_x, _spans[span_index].baseline_shift); result += line; if (_spans[span_index].font) { - snprintf(line, sizeof(line), " font '%s' %f %s %s\n", pango_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); + snprintf(line, sizeof(line), " font '%s' %f %s %s\n", sp_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); result += line; } snprintf(line, sizeof(line), " x_start = %f, x_end = %f\n", _spans[span_index].x_start, _spans[span_index].x_end); diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 1f0e7a244..cd939bf7d 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -335,7 +335,7 @@ public: PathDescrBezierTo & fin, bool before, Geom::Point & pos, Geom::Point & tgt, double &len, double &rad); static void OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor, - double width, JoinType join, double miter); + double width, JoinType join, double miter, int nType); static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX); diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index f00798c8a..7f8853e31 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -387,7 +387,7 @@ void Path::SubContractOutline(int off, int num_pd, if (closeIfNeeded) { if ( Geom::LInfty (curX- firstP) < 0.0001 ) { OutlineJoin (dest, firstP, curT, firstT, width, join, - miter); + miter, nType); dest->Close (); } else { PathDescrLineTo temp(firstP); @@ -404,7 +404,7 @@ void Path::SubContractOutline(int off, int num_pd, Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, - miter); + miter, nType); } dest->LineTo (enPos+width*enNor); @@ -413,7 +413,7 @@ void Path::SubContractOutline(int off, int num_pd, Geom::Point pos; pos = firstP; OutlineJoin (dest, enPos, enNor, firstT, width, join, - miter); + miter, nType); dest->Close (); } } @@ -429,7 +429,7 @@ void Path::SubContractOutline(int off, int num_pd, if (Geom::LInfty (curX - firstP) < 0.0001) { OutlineJoin (dest, firstP, curT, firstT, width, join, - miter); + miter, nType); dest->Close (); } else @@ -445,7 +445,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { OutlineJoin (dest, stPos, curT, stNor, width, join, - miter); + miter, nType); } dest->LineTo (enPos+width*enNor); @@ -453,7 +453,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { OutlineJoin (dest, enPos, enNor, firstT, width, join, - miter); + miter, nType); dest->Close (); } } @@ -497,7 +497,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } int n_d = dest->LineTo (nextX+width*enNor); @@ -547,7 +547,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -603,7 +603,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -661,7 +661,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - if (stTle > 0) OutlineJoin (dest, pos, curT, stNor, width, join, miter); + if (stTle > 0) OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } int n_d = dest->LineTo (nextX+width*enNor); if (n_d >= 0) { @@ -692,7 +692,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure Geom::Point pos; pos = curX; - OutlineJoin (dest, pos, curT, stNor, width, join, miter); + OutlineJoin (dest, pos, curT, stNor, width, join, miter, nType); } callsData.piece = curP; @@ -729,7 +729,7 @@ void Path::SubContractOutline(int off, int num_pd, } else { // jointure Geom::Point pos=curX; - OutlineJoin (dest, pos, stTgt, stNor, width, join, miter); + OutlineJoin (dest, pos, stTgt, stNor, width, join, miter, nType); // dest->LineTo(curX+width*stNor.x,curY+width*stNor.y); } } @@ -1164,7 +1164,7 @@ Path::TangentOnBezAt (double at, Geom::Point const &iS, void Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor, double width, - JoinType join, double miter) + JoinType join, double miter, int nType) { /* Arbitrarily decide if we're on the inside or outside of a half turn. @@ -1188,8 +1188,20 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point } else { if ((angSi > 0 && width >= 0) || (angSi < 0 && width < 0)) { // This is an inside join -> join is independent of chosen JoinType. - dest->LineTo (pos); - dest->LineTo (pos + width*enNor); + if ((dest->descr_cmd[dest->descr_cmd.size() - 1]->getType() == descr_lineto) && (nType == descr_lineto)) { + Geom::Point const biss = unit_vector(Geom::rot90( stNor - enNor )); + double c2 = Geom::dot (biss, enNor); + if (fabs(c2) > 0.707107) { // apply only to obtuse angles + double l = width / c2; + PathDescrLineTo* nLine = dynamic_cast<PathDescrLineTo*>(dest->descr_cmd[dest->descr_cmd.size() - 1]); + nLine->p = pos + l*biss; // relocate to bisector + } else { + dest->LineTo (pos + width*enNor); + } + } else { +// dest->LineTo (pos); // redundant + dest->LineTo (pos + width*enNor); + } } else if (angSi == 0 && TurnInside) { // Half turn (180 degrees) ... inside (see above). dest->LineTo (pos + width*enNor); } else { // This is an outside join -> chosen JoinType should be applied. @@ -1241,8 +1253,14 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point if ( fabs(l) > miter) { dest->LineTo (pos + width*enNor); } else { - dest->LineTo (pos+l*biss); - dest->LineTo (pos+width*enNor); + if (dest->descr_cmd[dest->descr_cmd.size() - 1]->getType() == descr_lineto) { + PathDescrLineTo* nLine = dynamic_cast<PathDescrLineTo*>(dest->descr_cmd[dest->descr_cmd.size() - 1]); + nLine->p = pos+l*biss; // relocate to bisector + } else { + dest->LineTo (pos+l*biss); + } + if (nType != descr_lineto) + dest->LineTo (pos+width*enNor); } } else { // Bevel join dest->LineTo (pos + width*enNor); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index fc755b9dc..feabfa02d 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -41,8 +41,6 @@ #include "lpe-tool-context.h" -static void sp_lpetool_context_class_init(SPLPEToolContextClass *klass); -static void sp_lpetool_context_init(SPLPEToolContext *erc); static void sp_lpetool_context_dispose(GObject *object); static void sp_lpetool_context_setup(SPEventContext *ec); @@ -66,28 +64,7 @@ SubtoolEntry lpesubtools[] = { {Inkscape::LivePathEffect::MIRROR_SYMMETRY, "draw-geometry-mirror"} }; -static SPPenContextClass *lpetool_parent_class = 0; - -GType sp_lpetool_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPLPEToolContextClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_lpetool_context_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPLPEToolContext), - 0, // n_preallocs - (GInstanceInitFunc)sp_lpetool_context_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_PEN_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPLPEToolContext, sp_lpetool_context, SP_TYPE_PEN_CONTEXT); static void sp_lpetool_context_class_init(SPLPEToolContextClass *klass) @@ -95,8 +72,6 @@ sp_lpetool_context_class_init(SPLPEToolContextClass *klass) GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - lpetool_parent_class = (SPPenContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_lpetool_context_dispose; event_context_class->setup = sp_lpetool_context_setup; @@ -140,7 +115,7 @@ sp_lpetool_context_dispose(GObject *object) delete lc->_lpetool_message_context; } - G_OBJECT_CLASS(lpetool_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_lpetool_context_parent_class)->dispose(object); } static void @@ -148,8 +123,8 @@ sp_lpetool_context_setup(SPEventContext *ec) { SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(ec); - if (((SPEventContextClass *) lpetool_parent_class)->setup) - ((SPEventContextClass *) lpetool_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->setup) + ((SPEventContextClass *) sp_lpetool_context_parent_class)->setup(ec); Inkscape::Selection *selection = sp_desktop_selection (ec->desktop); SPItem *item = selection->singleItem(); @@ -204,8 +179,8 @@ sp_lpetool_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) /* //pass on up to parent class to handle common attributes. - if ( lpetool_parent_class->set ) { - lpetool_parent_class->set(ec, key, val); + if ( sp_lpetool_context_parent_class->set ) { + sp_lpetool_context_parent_class->set(ec, key, val); } */ } @@ -234,8 +209,8 @@ sp_lpetool_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *even } if (!ret) { - if (((SPEventContextClass *) lpetool_parent_class)->item_handler) - ret = ((SPEventContextClass *) lpetool_parent_class)->item_handler(ec, item, event); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler) + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->item_handler(ec, item, event); } return ret; @@ -252,7 +227,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (sp_pen_context_has_waiting_LPE(lc)) { // quit when we are waiting for a LPE to be applied - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); return ret; } @@ -284,7 +259,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) sp_pen_context_wait_for_LPE_mouse_clicks(lc, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type)); // we pass the mouse click on to pen tool as the first click which it should collect - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); } break; @@ -320,8 +295,8 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) lpetool_parent_class)->root_handler) { - ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/marker.cpp b/src/marker.cpp index 8acac805b..ba5cd4b05 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -35,9 +35,6 @@ struct SPMarkerView { std::vector<Inkscape::DrawingItem *> items; }; -static void sp_marker_class_init (SPMarkerClass *klass); -static void sp_marker_init (SPMarker *marker); - static void sp_marker_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_marker_release (SPObject *object); static void sp_marker_set (SPObject *object, unsigned int key, const gchar *value); @@ -51,30 +48,7 @@ static void sp_marker_print (SPItem *item, SPPrintContext *ctx); static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems); -static SPGroupClass *parent_class = 0; - -/** - * Registers the SPMarker class with Gdk and returns its type number. - */ -GType -sp_marker_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPMarkerClass), - NULL, NULL, - (GClassInitFunc) sp_marker_class_init, - NULL, NULL, - sizeof (SPMarker), - 16, - (GInstanceInitFunc) sp_marker_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_GROUP, "SPMarker", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPMarker, sp_marker, SP_TYPE_GROUP); /** * Initializes a SPMarkerClass object. Establishes the function pointers to the class' @@ -85,18 +59,16 @@ static void sp_marker_class_init(SPMarkerClass *klass) SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); SPItemClass *sp_item_class = reinterpret_cast<SPItemClass *>(klass); - parent_class = reinterpret_cast<SPGroupClass *>(g_type_class_ref(SP_TYPE_GROUP)); - - sp_object_class->build = sp_marker_build; - sp_object_class->release = sp_marker_release; - sp_object_class->set = sp_marker_set; - sp_object_class->update = sp_marker_update; - sp_object_class->write = sp_marker_write; + sp_object_class->build = sp_marker_build; + sp_object_class->release = sp_marker_release; + sp_object_class->set = sp_marker_set; + sp_object_class->update = sp_marker_update; + sp_object_class->write = sp_marker_write; - sp_item_class->show = sp_marker_private_show; - sp_item_class->hide = sp_marker_private_hide; - sp_item_class->bbox = sp_marker_bbox; - sp_item_class->print = sp_marker_print; + sp_item_class->show = sp_marker_private_show; + sp_item_class->hide = sp_marker_private_hide; + sp_item_class->bbox = sp_marker_bbox; + sp_item_class->print = sp_marker_print; } /** @@ -132,8 +104,8 @@ static void sp_marker_build(SPObject *object, SPDocument *document, Inkscape::XM object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (reinterpret_cast<SPObjectClass *>(parent_class)->build) { - reinterpret_cast<SPObjectClass *>(parent_class)->build(object, document, repr); + if (reinterpret_cast<SPObjectClass *>(sp_marker_parent_class)->build) { + reinterpret_cast<SPObjectClass *>(sp_marker_parent_class)->build(object, document, repr); } } @@ -156,12 +128,12 @@ static void sp_marker_release(SPObject *object) while (marker->views) { // Destroy all DrawingItems etc. // Parent class ::hide method - reinterpret_cast<SPItemClass *>(parent_class)->hide(marker, marker->views->key); + reinterpret_cast<SPItemClass *>(sp_marker_parent_class)->hide(marker, marker->views->key); sp_marker_view_remove (marker, marker->views, TRUE); } - if (reinterpret_cast<SPObjectClass *>(parent_class)->release) { - reinterpret_cast<SPObjectClass *>(parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_marker_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_marker_parent_class)->release(object); } } @@ -311,8 +283,8 @@ static void sp_marker_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_marker_parent_class)->set) + ((SPObjectClass *) sp_marker_parent_class)->set (object, key, value); break; } } @@ -430,8 +402,8 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + if (((SPObjectClass *) (sp_marker_parent_class))->update) { + ((SPObjectClass *) (sp_marker_parent_class))->update (object, (SPCtx *) &rctx, flags); } // As last step set additional transform of drawing group @@ -503,8 +475,8 @@ sp_marker_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X //XML Tree being used directly here while it shouldn't be.... repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_marker_parent_class))->write) + ((SPObjectClass *) (sp_marker_parent_class))->write (object, xml_doc, repr, flags); return repr; } @@ -572,7 +544,7 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) if (view && (view->items.size() != size)) { /* Free old view and allocate new */ /* Parent class ::hide method */ - ((SPItemClass *) parent_class)->hide ((SPItem *) marker, key); + ((SPItemClass *) sp_marker_parent_class)->hide ((SPItem *) marker, key); sp_marker_view_remove (marker, view, TRUE); view = NULL; } @@ -611,7 +583,7 @@ sp_marker_show_instance ( SPMarker *marker, Inkscape::DrawingItem *parent, } if (!v->items[pos]) { /* Parent class ::show method */ - v->items[pos] = ((SPItemClass *) parent_class)->show ((SPItem *) marker, + v->items[pos] = ((SPItemClass *) sp_marker_parent_class)->show ((SPItem *) marker, parent->drawing(), key, SP_ITEM_REFERENCE_FLAGS); if (v->items[pos]) { @@ -658,7 +630,7 @@ sp_marker_hide (SPMarker *marker, unsigned int key) next = v->next; if (v->key == key) { /* Parent class ::hide method */ - ((SPItemClass *) parent_class)->hide ((SPItem *) marker, key); + ((SPItemClass *) sp_marker_parent_class)->hide ((SPItem *) marker, key); sp_marker_view_remove (marker, v, TRUE); return; } diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 7a04b9915..dc23cf5c6 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -47,16 +47,12 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; -static void sp_measure_context_class_init(SPMeasureContextClass *klass); -static void sp_measure_context_init(SPMeasureContext *measure_context); static void sp_measure_context_setup(SPEventContext *ec); static void sp_measure_context_finish(SPEventContext *ec); static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -static SPEventContextClass *parent_class; - static gint xp = 0; // where drag started static gint yp = 0; static gint tolerance = 0; @@ -68,26 +64,7 @@ boost::optional<Geom::Point> lastEnd; std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; -GType sp_measure_context_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPMeasureContextClass), - NULL, NULL, - reinterpret_cast<GClassInitFunc>(sp_measure_context_class_init), // TODO needs two params? - NULL, NULL, - sizeof(SPMeasureContext), - 4, - reinterpret_cast<GInstanceInitFunc>(sp_measure_context_init), // TODO needs two params? - NULL, // value_table - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeasureContext", &info, static_cast<GTypeFlags>(0)); - } - - return type; -} +G_DEFINE_TYPE(SPMeasureContext, sp_measure_context, SP_TYPE_EVENT_CONTEXT); namespace { @@ -258,8 +235,6 @@ static void sp_measure_context_class_init(SPMeasureContextClass *klass) { SPEventContextClass *event_context_class = reinterpret_cast<SPEventContextClass *>(klass); - parent_class = static_cast<SPEventContextClass*>(g_type_class_peek_parent(klass)); - event_context_class->setup = sp_measure_context_setup; event_context_class->finish = sp_measure_context_finish; @@ -290,8 +265,8 @@ static void sp_measure_context_finish(SPEventContext *ec) static void sp_measure_context_setup(SPEventContext *ec) { - if (parent_class->setup) { - parent_class->setup(ec); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup) { + SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup(ec); } } @@ -299,8 +274,8 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte { gint ret = FALSE; - if (parent_class->item_handler) { - ret = parent_class->item_handler(event_context, item, event); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler) { + ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -789,8 +764,8 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } if (!ret) { - if (parent_class->root_handler) { - ret = parent_class->root_handler(event_context, event); + if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->root_handler) { + ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/mesh-context.cpp b/src/mesh-context.cpp index 8fd016702..36712d15d 100644 --- a/src/mesh-context.cpp +++ b/src/mesh-context.cpp @@ -53,8 +53,6 @@ using Inkscape::DocumentUndo; -static void sp_mesh_context_class_init(SPMeshContextClass *klass); -static void sp_mesh_context_init(SPMeshContext *gr_context); static void sp_mesh_context_dispose(GObject *object); static void sp_mesh_context_setup(SPEventContext *ec); @@ -63,35 +61,13 @@ static gint sp_mesh_context_root_handler(SPEventContext *event_context, GdkEvent static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const pt, guint state, guint32 etime); -static SPEventContextClass *parent_class; - - -GType sp_mesh_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPMeshContextClass), - NULL, NULL, - (GClassInitFunc) sp_mesh_context_class_init, - NULL, NULL, - sizeof(SPMeshContext), - 4, - (GInstanceInitFunc) sp_mesh_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPMeshContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPMeshContext, sp_mesh_context, SP_TYPE_EVENT_CONTEXT); static void sp_mesh_context_class_init(SPMeshContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_mesh_context_dispose; event_context_class->setup = sp_mesh_context_setup; @@ -129,7 +105,7 @@ static void sp_mesh_context_dispose(GObject *object) rc->subselcon->disconnect(); delete rc->subselcon; - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_mesh_context_parent_class)->dispose(object); } const gchar *ms_handle_descr [] = { @@ -270,8 +246,8 @@ static void sp_mesh_context_setup(SPEventContext *ec) { SPMeshContext *rc = SP_MESH_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_mesh_context_parent_class)->setup) { + ((SPEventContextClass *) sp_mesh_context_parent_class)->setup(ec); } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -948,8 +924,8 @@ sp_mesh_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_mesh_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_mesh_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index a5b79cf82..3055f8504 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -71,9 +71,6 @@ //BSpline End using Inkscape::ControlManager; - -static void sp_pen_context_class_init(SPPenContextClass *klass); -static void sp_pen_context_init(SPPenContext *pc); static void sp_pen_context_dispose(GObject *object); static void sp_pen_context_setup(SPEventContext *ec); @@ -132,35 +129,12 @@ static void pen_enable_events(SPPenContext *const pc); static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; -static SPDrawContextClass *pen_parent_class; - static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state); static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap); static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical - -/** - * Register SPPenContext with Gdk and return its type. - */ -GType sp_pen_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPenContextClass), - NULL, NULL, - (GClassInitFunc) sp_pen_context_class_init, - NULL, NULL, - sizeof(SPPenContext), - 4, - (GInstanceInitFunc) sp_pen_context_init, - NULL, // value_table - }; - type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPenContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPenContext, sp_pen_context, SP_TYPE_DRAW_CONTEXT); /** * Initialize the SPPenContext vtable. @@ -173,8 +147,6 @@ static void sp_pen_context_class_init(SPPenContextClass *klass) object_class = (GObjectClass *) klass; event_context_class = (SPEventContextClass *) klass; - pen_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass); - object_class->dispose = sp_pen_context_dispose; event_context_class->setup = sp_pen_context_setup; @@ -235,7 +207,7 @@ static void sp_pen_context_dispose(GObject *object) pc->cl1 = NULL; } - G_OBJECT_CLASS(pen_parent_class)->dispose(object); + G_OBJECT_CLASS(sp_pen_context_parent_class)->dispose(object); if (pc->expecting_clicks_for_LPE > 0) { // we received too few clicks to sanely set the parameter path so we remove the LPE from the item @@ -272,8 +244,8 @@ static void sp_pen_context_setup(SPEventContext *ec) { SPPenContext *pc = SP_PEN_CONTEXT(ec); - if (((SPEventContextClass *) pen_parent_class)->setup) { - ((SPEventContextClass *) pen_parent_class)->setup(ec); + if (((SPEventContextClass *) sp_pen_context_parent_class)->setup) { + ((SPEventContextClass *) sp_pen_context_parent_class)->setup(ec); } ControlManager &mgr = ControlManager::getManager(); @@ -334,8 +306,8 @@ static void sp_pen_context_finish(SPEventContext *ec) pen_cancel (pc); } - if (((SPEventContextClass *) pen_parent_class)->finish) { - ((SPEventContextClass *) pen_parent_class)->finish(ec); + if (((SPEventContextClass *) sp_pen_context_parent_class)->finish) { + ((SPEventContextClass *) sp_pen_context_parent_class)->finish(ec); } } @@ -416,8 +388,8 @@ static gint sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEve } if (!ret) { - if (((SPEventContextClass *) pen_parent_class)->item_handler) - ret = ((SPEventContextClass *) pen_parent_class)->item_handler(ec, item, event); + if (((SPEventContextClass *) sp_pen_context_parent_class)->item_handler) + ret = ((SPEventContextClass *) sp_pen_context_parent_class)->item_handler(ec, item, event); } return ret; @@ -459,7 +431,7 @@ static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = ((SPEventContextClass *) pen_parent_class)->root_handler; + = ((SPEventContextClass *) sp_pen_context_parent_class)->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index cce04abb7..5c5780fbb 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); } diff --git a/src/persp3d.cpp b/src/persp3d.cpp index a20537d95..2744efb75 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -27,9 +27,6 @@ using Inkscape::DocumentUndo; -static void persp3d_class_init(Persp3DClass *klass); -static void persp3d_init(Persp3D *persp); - static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void persp3d_release(SPObject *object); static void persp3d_set(SPObject *object, unsigned key, gchar const *value); @@ -41,8 +38,6 @@ static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gcha static void persp3d_update_with_point (Persp3DImpl *persp_impl, Proj::Axis const axis, Proj::Pt2 const &new_image); static gchar * persp3d_pt_to_str (Persp3DImpl *persp_impl, Proj::Axis const axis); -static SPObjectClass *persp3d_parent_class; - static int global_counter = 0; /* Constructor/destructor for the internal class */ @@ -54,28 +49,7 @@ Persp3DImpl::Persp3DImpl() { my_counter = global_counter++; } -/** - * Registers Persp3d class and returns its type. - */ -GType -persp3d_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(Persp3DClass), - NULL, NULL, - (GClassInitFunc) persp3d_class_init, - NULL, NULL, - sizeof(Persp3D), - 16, - (GInstanceInitFunc) persp3d_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "Persp3D", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(Persp3D, persp3d, SP_TYPE_OBJECT); static Inkscape::XML::NodeEventVector const persp3d_repr_events = { NULL, /* child_added */ @@ -92,8 +66,6 @@ static void persp3d_class_init(Persp3DClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - persp3d_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = persp3d_build; sp_object_class->release = persp3d_release; sp_object_class->set = persp3d_set; diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 33ccee93c..040127ae3 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -49,8 +49,6 @@ using Inkscape::DocumentUndo; //static const double goldenratio = 1.61803398874989484820; // golden ratio -static void sp_rect_context_class_init(SPRectContextClass *klass); -static void sp_rect_context_init(SPRectContext *rect_context); static void sp_rect_context_dispose(GObject *object); static void sp_rect_context_setup(SPEventContext *ec); @@ -64,35 +62,13 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state); static void sp_rect_finish(SPRectContext *rc); static void sp_rect_cancel(SPRectContext *rc); -static SPEventContextClass *parent_class; - - -GType sp_rect_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPRectContextClass), - NULL, NULL, - (GClassInitFunc) sp_rect_context_class_init, - NULL, NULL, - sizeof(SPRectContext), - 4, - (GInstanceInitFunc) sp_rect_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPRectContext", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPRectContext, sp_rect_context, SP_TYPE_EVENT_CONTEXT); static void sp_rect_context_class_init(SPRectContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass); - object_class->dispose = sp_rect_context_dispose; event_context_class->setup = sp_rect_context_setup; @@ -133,8 +109,8 @@ static void sp_rect_context_finish(SPEventContext *ec) sp_rect_finish(rc); rc->sel_changed_connection.disconnect(); - if (((SPEventContextClass *) parent_class)->finish) { - ((SPEventContextClass *) parent_class)->finish(ec); + if (((SPEventContextClass *) sp_rect_context_parent_class)->finish) { + ((SPEventContextClass *) sp_rect_context_parent_class)->finish(ec); } } @@ -161,7 +137,7 @@ static void sp_rect_context_dispose(GObject *object) delete rc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_rect_context_parent_class)->dispose(object); } /** @@ -182,8 +158,8 @@ static void sp_rect_context_setup(SPEventContext *ec) { SPRectContext *rc = SP_RECT_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) sp_rect_context_parent_class)->setup) { + ((SPEventContextClass *) sp_rect_context_parent_class)->setup(ec); } ec->shape_editor = new ShapeEditor(ec->desktop); @@ -245,8 +221,8 @@ static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem * break; } - if (((SPEventContextClass *) parent_class)->item_handler) { - ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); + if (((SPEventContextClass *) sp_rect_context_parent_class)->item_handler) { + ret = ((SPEventContextClass *) sp_rect_context_parent_class)->item_handler(event_context, item, event); } return ret; @@ -458,8 +434,8 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) sp_rect_context_parent_class)->root_handler) { + ret = ((SPEventContextClass *) sp_rect_context_parent_class)->root_handler(event_context, event); } } diff --git a/src/select-context.cpp b/src/select-context.cpp index 5934d615c..2684cbc1e 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -51,9 +51,6 @@ using Inkscape::DocumentUndo; - -static void sp_select_context_class_init(SPSelectContextClass *klass); -static void sp_select_context_init(SPSelectContext *select_context); static void sp_select_context_dispose(GObject *object); static void sp_select_context_setup(SPEventContext *ec); @@ -61,8 +58,6 @@ static void sp_select_context_set(SPEventContext *ec, Inkscape::Preferences::Ent static gint sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -static SPEventContextClass *parent_class; - static GdkCursor *CursorSelectMouseover = NULL; static GdkCursor *CursorSelectDragging = NULL; GdkPixbuf *handles[13]; @@ -74,25 +69,7 @@ static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; -GType -sp_select_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPSelectContextClass), - NULL, NULL, - (GClassInitFunc) sp_select_context_class_init, - NULL, NULL, - sizeof(SPSelectContext), - 4, - (GInstanceInitFunc) sp_select_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPSelectContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPSelectContext, sp_select_context, SP_TYPE_EVENT_CONTEXT); static void sp_select_context_class_init(SPSelectContextClass *klass) @@ -100,8 +77,6 @@ sp_select_context_class_init(SPSelectContextClass *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_select_context_dispose; event_context_class->setup = sp_select_context_setup; @@ -180,7 +155,7 @@ sp_select_context_dispose(GObject *object) CursorSelectMouseover = NULL; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_select_context_parent_class)->dispose(object); } static void @@ -188,8 +163,8 @@ sp_select_context_setup(SPEventContext *ec) { SPSelectContext *select_context = SP_SELECT_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_select_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_select_context_parent_class))->setup(ec); } SPDesktop *desktop = ec->desktop; @@ -432,8 +407,8 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE } 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_select_context_parent_class))->item_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_select_context_parent_class))->item_handler(event_context, item, event); } return ret; @@ -1150,8 +1125,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_select_context_parent_class))->root_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_select_context_parent_class))->root_handler(event_context, event); } return ret; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 64bb95508..b6c6baaf7 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -813,8 +813,6 @@ gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position, return TRUE; } - knot->desktop->setPosition(*position); - // When holding shift while rotating or skewing, the transformation will be // relative to the point opposite of the handle; otherwise it will be relative // to the center as set for the selection diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 517512eb2..8b52cf400 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -25,9 +25,6 @@ #include "ui/view/view.h" #include "document.h" -static void sp_anchor_class_init(SPAnchorClass *ac); -static void sp_anchor_init(SPAnchor *anchor); - static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_anchor_release(SPObject *object); static void sp_anchor_set(SPObject *object, unsigned int key, const gchar *value); @@ -36,38 +33,13 @@ static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Doc static gchar *sp_anchor_description(SPItem *item); static gint sp_anchor_event(SPItem *item, SPEvent *event); -static SPGroupClass *parent_class; - -GType sp_anchor_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPAnchorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_anchor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPAnchor), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_anchor_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GROUP, "SPAnchor", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPAnchor, sp_anchor, SP_TYPE_GROUP); static void sp_anchor_class_init(SPAnchorClass *ac) { SPObjectClass *sp_object_class = (SPObjectClass *) ac; SPItemClass *item_class = (SPItemClass *) ac; - parent_class = (SPGroupClass *) g_type_class_ref(SP_TYPE_GROUP); - sp_object_class->build = sp_anchor_build; sp_object_class->release = sp_anchor_release; sp_object_class->set = sp_anchor_set; @@ -84,8 +56,8 @@ static void sp_anchor_init(SPAnchor *anchor) static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_anchor_parent_class))->build) { + ((SPObjectClass *) (sp_anchor_parent_class))->build(object, document, repr); } object->readAttr( "xlink:type" ); @@ -107,8 +79,8 @@ static void sp_anchor_release(SPObject *object) anchor->href = NULL; } - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_anchor_parent_class)->release) { + ((SPObjectClass *) sp_anchor_parent_class)->release(object); } } @@ -132,8 +104,8 @@ static void sp_anchor_set(SPObject *object, unsigned int key, const gchar *value object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_anchor_parent_class))->set) { + ((SPObjectClass *) (sp_anchor_parent_class))->set(object, key, value); } break; } @@ -164,8 +136,8 @@ static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Doc COPY_ATTR(repr, object->getRepr(), "target"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_anchor_parent_class))->write) { + ((SPObjectClass *) (sp_anchor_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 47d9be2c1..059cbcf2b 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -37,46 +37,34 @@ struct SPClipPathView { Geom::OptRect bbox; }; -SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); -SPClipPathView *sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); - -SPObjectGroupClass * SPClipPathClass::static_parent_class = 0; - -GType -SPClipPath::sp_clippath_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPClipPathClass), - NULL, NULL, - (GClassInitFunc) SPClipPathClass::sp_clippath_class_init, - NULL, NULL, - sizeof(SPClipPath), - 16, - (GInstanceInitFunc) SPClipPath::init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPClipPath", &info, (GTypeFlags)0); - } - return type; -} - -void SPClipPathClass::sp_clippath_class_init(SPClipPathClass *klass) +static void sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_clippath_release(SPObject * object); +static void sp_clippath_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); +static void sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags); +static void sp_clippath_modified(SPObject *object, guint flags); +static Inkscape::XML::Node* sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static SPClipPathView* sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); +static SPClipPathView* sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); + +G_DEFINE_TYPE(SPClipPath, sp_clippath, SP_TYPE_OBJECTGROUP); + +static void +sp_clippath_class_init(SPClipPathClass *klass) { SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); - static_parent_class = SP_OBJECTGROUP_CLASS(g_type_class_ref(SP_TYPE_OBJECTGROUP)); - - sp_object_class->build = SPClipPath::build; - sp_object_class->release = SPClipPath::release; - sp_object_class->set = SPClipPath::set; - sp_object_class->child_added = SPClipPath::childAdded; - sp_object_class->update = SPClipPath::update; - sp_object_class->modified = SPClipPath::modified; - sp_object_class->write = SPClipPath::write; + + sp_object_class->build = sp_clippath_build; + sp_object_class->release = sp_clippath_release; + sp_object_class->set = sp_clippath_set; + sp_object_class->child_added = sp_clippath_child_added; + sp_object_class->update = sp_clippath_update; + sp_object_class->modified = sp_clippath_modified; + sp_object_class->write = sp_clippath_write; } -void SPClipPath::init(SPClipPath *cp) +static void +sp_clippath_init(SPClipPath *cp) { cp->clipPathUnits_set = FALSE; cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; @@ -84,10 +72,11 @@ void SPClipPath::init(SPClipPath *cp) cp->display = NULL; } -void SPClipPath::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void +sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) SPClipPathClass::static_parent_class)->build) - ((SPObjectClass *) SPClipPathClass::static_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_clippath_parent_class)->build) + ((SPObjectClass *) sp_clippath_parent_class)->build(object, document, repr); object->readAttr( "style" ); object->readAttr( "clipPathUnits" ); @@ -96,7 +85,8 @@ void SPClipPath::build(SPObject *object, SPDocument *document, Inkscape::XML::No document->addResource("clipPath", object); } -void SPClipPath::release(SPObject * object) +static void +sp_clippath_release(SPObject * object) { if (object->document) { // Unregister ourselves @@ -109,12 +99,13 @@ void SPClipPath::release(SPObject * object) cp->display = sp_clippath_view_list_remove(cp->display, cp->display); } - if (((SPObjectClass *) (SPClipPathClass::static_parent_class))->release) { - ((SPObjectClass *) SPClipPathClass::static_parent_class)->release(object); + if (((SPObjectClass *) (sp_clippath_parent_class))->release) { + ((SPObjectClass *) sp_clippath_parent_class)->release(object); } } -void SPClipPath::set(SPObject *object, unsigned int key, gchar const *value) +static void +sp_clippath_set(SPObject *object, unsigned int key, gchar const *value) { SPClipPath *cp = SP_CLIPPATH(object); @@ -137,18 +128,19 @@ void SPClipPath::set(SPObject *object, unsigned int key, gchar const *value) sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) { - ((SPObjectClass *) SPClipPathClass::static_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_clippath_parent_class)->set) { + ((SPObjectClass *) sp_clippath_parent_class)->set(object, key, value); } } break; } } -void SPClipPath::childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void +sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /* Invoke SPObjectGroup implementation */ - ((SPObjectClass *) (SPClipPathClass::static_parent_class))->child_added(object, child, ref); + ((SPObjectClass *) (sp_clippath_parent_class))->child_added(object, child, ref); /* Show new object */ SPObject *ochild = object->document->getObjectByRepr(child); @@ -165,7 +157,8 @@ void SPClipPath::childAdded(SPObject *object, Inkscape::XML::Node *child, Inksca } } -void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -202,7 +195,8 @@ void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags) } } -void SPClipPath::modified(SPObject *object, guint flags) +static void +sp_clippath_modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -227,14 +221,15 @@ void SPClipPath::modified(SPObject *object, guint flags) } } -Inkscape::XML::Node *SPClipPath::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_clippath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:clipPath"); } - if (((SPObjectClass *) (SPClipPathClass::static_parent_class))->write) { - ((SPObjectClass *) (SPClipPathClass::static_parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_clippath_parent_class))->write) { + ((SPObjectClass *) (sp_clippath_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 22877c3a9..a77383c63 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -15,7 +15,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type()) +#define SP_TYPE_CLIPPATH (sp_clippath_get_type()) #define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CLIPPATH, SPClipPath)) #define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_CLIPPATH, SPClipPathClass)) #define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH)) @@ -27,6 +27,7 @@ class SPClipPathView; #include "uri-references.h" #include "xml/node.h" +GType sp_clippath_get_type() G_GNUC_CONST; namespace Inkscape { @@ -53,16 +54,6 @@ public: Geom::OptRect geometricBounds(Geom::Affine const &transform); private: - static void init(SPClipPath *clippath); - - static void build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void release(SPObject * object); - static void set(SPObject *object, unsigned int key, gchar const *value); - static void childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); - static void update(SPObject *object, SPCtx *ctx, guint flags); - static void modified(SPObject *object, guint flags); - static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - friend class SPClipPathClass; }; @@ -71,9 +62,6 @@ public: SPObjectGroupClass parent_class; private: - static void sp_clippath_class_init(SPClipPathClass *klass); - static SPObjectGroupClass *static_parent_class; - friend class SPClipPath; }; diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 2737b3f5c..f7a906163 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -20,55 +20,45 @@ #include "xml/repr.h" #include "document.h" -SPObjectClass * SPDefsClass::static_parent_class = 0; - -GType SPDefs::sp_defs_get_type(void) +static void sp_defs_release (SPObject *object); +static void sp_defs_update (SPObject *object, + SPCtx *ctx, + guint flags); +static void sp_defs_modified(SPObject *object, + guint flags); +static Inkscape::XML::Node* sp_defs_write (SPObject *object, + Inkscape::XML::Document *doc, + Inkscape::XML::Node *repr, + guint flags); + +G_DEFINE_TYPE(SPDefs, sp_defs, SP_TYPE_OBJECT); + +static void +sp_defs_class_init(SPDefsClass *dc) { - static GType defs_type = 0; - - if (!defs_type) { - GTypeInfo defs_info = { - sizeof(SPDefsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) SPDefsClass::sp_defs_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPDefs), - 16, /* n_preallocs */ - (GInstanceInitFunc) init, - NULL, /* value_table */ - }; - defs_type = g_type_register_static(SP_TYPE_OBJECT, "SPDefs", &defs_info, (GTypeFlags) 0); - } - - return defs_type; -} - -void SPDefsClass::sp_defs_class_init(SPDefsClass *dc) -{ - static_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); SPObjectClass *sp_object_class = (SPObjectClass *) dc; - sp_object_class->release = SPDefs::release; - sp_object_class->update = SPDefs::update; - sp_object_class->modified = SPDefs::modified; - sp_object_class->write = SPDefs::write; + sp_object_class->release = sp_defs_release; + sp_object_class->update = sp_defs_update; + sp_object_class->modified = sp_defs_modified; + sp_object_class->write = sp_defs_write; } -void SPDefs::init(SPDefs */*defs*/) +static void +sp_defs_init(SPDefs * /*defs*/) { - } -void SPDefs::release(SPObject *object) +static void +sp_defs_release(SPObject *object) { - if (((SPObjectClass *) (SPDefsClass::static_parent_class))->release) { - ((SPObjectClass *) (SPDefsClass::static_parent_class))->release(object); + if (((SPObjectClass *) (sp_defs_parent_class))->release) { + ((SPObjectClass *) (sp_defs_parent_class))->release(object); } } -void SPDefs::update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -87,7 +77,8 @@ void SPDefs::update(SPObject *object, SPCtx *ctx, guint flags) } } -void SPDefs::modified(SPObject *object, guint flags) +static void +sp_defs_modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -113,7 +104,8 @@ void SPDefs::modified(SPObject *object, guint flags) } } -Inkscape::XML::Node * SPDefs::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { @@ -141,8 +133,8 @@ Inkscape::XML::Node * SPDefs::write(SPObject *object, Inkscape::XML::Document *x } } - if (((SPObjectClass *) (SPDefsClass::static_parent_class))->write) { - (* ((SPObjectClass *) (SPDefsClass::static_parent_class))->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_defs_parent_class))->write) { + (* ((SPObjectClass *) (sp_defs_parent_class))->write)(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-defs.h b/src/sp-defs.h index 83003f4ad..e1d343979 100644 --- a/src/sp-defs.h +++ b/src/sp-defs.h @@ -15,23 +15,16 @@ #include "sp-object.h" -#define SP_TYPE_DEFS (SPDefs::sp_defs_get_type()) +#define SP_TYPE_DEFS (sp_defs_get_type()) #define SP_DEFS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_DEFS, SPDefs)) #define SP_DEFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_DEFS, SPDefsClass)) #define SP_IS_DEFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_DEFS)) #define SP_IS_DEFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_DEFS)) +GType sp_defs_get_type(void) G_GNUC_CONST; + class SPDefs : public SPObject { -public: - static GType sp_defs_get_type(void); - private: - static void init(SPDefs *defs); - static void release(SPObject *object); - static void update(SPObject *object, SPCtx *ctx, guint flags); - static void modified(SPObject *object, guint flags); - static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - friend class SPDefsClass; }; @@ -40,9 +33,6 @@ public: SPObjectClass parent_class; private: - static void sp_defs_class_init(SPDefsClass *dc); - static SPObjectClass *static_parent_class; - friend class SPDefs; }; diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp index bbc47ecbb..9b27c4d17 100644 --- a/src/sp-desc.cpp +++ b/src/sp-desc.cpp @@ -16,36 +16,13 @@ #include "sp-desc.h" #include "xml/repr.h" -static void sp_desc_class_init(SPDescClass *klass); -static void sp_desc_init(SPDesc *rect); static Inkscape::XML::Node *sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *desc_parent_class; - -GType sp_desc_get_type (void) -{ - static GType desc_type = 0; - - if (!desc_type) { - GTypeInfo desc_info = { - sizeof (SPDescClass), - NULL, NULL, - (GClassInitFunc) sp_desc_class_init, - NULL, NULL, - sizeof (SPDesc), - 16, - (GInstanceInitFunc) sp_desc_init, - NULL, /* value_table */ - }; - desc_type = g_type_register_static (SP_TYPE_OBJECT, "SPDesc", &desc_info, (GTypeFlags)0); - } - return desc_type; -} +G_DEFINE_TYPE(SPDesc, sp_desc, SP_TYPE_OBJECT); static void sp_desc_class_init(SPDescClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)(klass); - desc_parent_class = (SPObjectClass *)(g_type_class_ref(SP_TYPE_OBJECT)); sp_object_class->write = sp_desc_write; } @@ -63,8 +40,8 @@ static Inkscape::XML::Node *sp_desc_write(SPObject *object, Inkscape::XML::Docum repr = object->getRepr()->duplicate(doc); } - if ((static_cast<SPObjectClass *>(desc_parent_class))->write) { - (static_cast<SPObjectClass *>(desc_parent_class))->write(object, doc, repr, flags); + if ((static_cast<SPObjectClass *>(sp_desc_parent_class))->write) { + (static_cast<SPObjectClass *>(sp_desc_parent_class))->write(object, doc, repr, flags); } return repr; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 6fe3a599b..8a9793852 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -64,9 +64,6 @@ static double sp_round(double x, double y) } #endif -static void sp_genericellipse_class_init(SPGenericEllipseClass *klass); -static void sp_genericellipse_init(SPGenericEllipse *ellipse); - static void sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_genericellipse_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); @@ -79,29 +76,7 @@ static Inkscape::XML::Node *sp_genericellipse_write(SPObject *object, Inkscape:: static gboolean sp_arc_set_elliptical_path_attribute(SPArc *arc, Inkscape::XML::Node *repr); -static SPShapeClass *ge_parent_class; - -GType -sp_genericellipse_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPGenericEllipseClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_genericellipse_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPGenericEllipse), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_genericellipse_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_SHAPE, "SPGenericEllipse", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPGenericEllipse, sp_genericellipse, SP_TYPE_SHAPE); static void sp_genericellipse_class_init(SPGenericEllipseClass *klass) { @@ -110,8 +85,6 @@ static void sp_genericellipse_class_init(SPGenericEllipseClass *klass) SPLPEItemClass *lpe_item_class = (SPLPEItemClass *) klass; SPShapeClass *shape_class = (SPShapeClass *) klass; - ge_parent_class = (SPShapeClass*) g_type_class_ref(SP_TYPE_SHAPE); - sp_object_class->update = sp_genericellipse_update; sp_object_class->write = sp_genericellipse_write; @@ -154,8 +127,8 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags) static_cast<SPShape *>(object)->setShape(); } - if (((SPObjectClass *) ge_parent_class)->update) - ((SPObjectClass *) ge_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_genericellipse_parent_class)->update) + ((SPObjectClass *) sp_genericellipse_parent_class)->update(object, ctx, flags); } static void @@ -371,8 +344,8 @@ static Inkscape::XML::Node *sp_genericellipse_write(SPObject *object, Inkscape:: } sp_genericellipse_set_shape ((SPShape *) ellipse); // evaluate SPCurve - if (((SPObjectClass *) ge_parent_class)->write) { - ((SPObjectClass *) ge_parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_genericellipse_parent_class)->write) { + ((SPObjectClass *) sp_genericellipse_parent_class)->write(object, xml_doc, repr, flags); } return repr; @@ -380,45 +353,18 @@ static Inkscape::XML::Node *sp_genericellipse_write(SPObject *object, Inkscape:: /* SVG <ellipse> element */ -static void sp_ellipse_class_init(SPEllipseClass *klass); -static void sp_ellipse_init(SPEllipse *ellipse); - static void sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *sp_ellipse_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_ellipse_set(SPObject *object, unsigned int key, gchar const *value); static gchar *sp_ellipse_description(SPItem *item); -static SPGenericEllipseClass *ellipse_parent_class; - -GType -sp_ellipse_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPEllipseClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_ellipse_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPEllipse), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_ellipse_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GENERICELLIPSE, "SPEllipse", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPEllipse, sp_ellipse, SP_TYPE_GENERICELLIPSE); static void sp_ellipse_class_init(SPEllipseClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *item_class = (SPItemClass *) klass; - ellipse_parent_class = (SPGenericEllipseClass*) g_type_class_ref(SP_TYPE_GENERICELLIPSE); - sp_object_class->build = sp_ellipse_build; sp_object_class->write = sp_ellipse_write; sp_object_class->set = sp_ellipse_set; @@ -435,8 +381,8 @@ sp_ellipse_init(SPEllipse */*ellipse*/) static void sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) ellipse_parent_class)->build) - (* ((SPObjectClass *) ellipse_parent_class)->build) (object, document, repr); + if (((SPObjectClass *) sp_ellipse_parent_class)->build) + (* ((SPObjectClass *) sp_ellipse_parent_class)->build) (object, document, repr); object->readAttr( "cx" ); object->readAttr( "cy" ); @@ -460,8 +406,8 @@ sp_ellipse_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X sp_repr_set_svg_double(repr, "rx", ellipse->rx.computed); sp_repr_set_svg_double(repr, "ry", ellipse->ry.computed); - if (((SPObjectClass *) ellipse_parent_class)->write) - (* ((SPObjectClass *) ellipse_parent_class)->write) (object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_ellipse_parent_class)->write) + (* ((SPObjectClass *) sp_ellipse_parent_class)->write) (object, xml_doc, repr, flags); return repr; } @@ -495,8 +441,8 @@ sp_ellipse_set(SPObject *object, unsigned int key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) ellipse_parent_class)->set) - ((SPObjectClass *) ellipse_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_ellipse_parent_class)->set) + ((SPObjectClass *) sp_ellipse_parent_class)->set(object, key, value); break; } } @@ -527,37 +473,12 @@ sp_ellipse_position_set(SPEllipse *ellipse, gdouble x, gdouble y, gdouble rx, gd /* SVG <circle> element */ -static void sp_circle_class_init(SPCircleClass *klass); -static void sp_circle_init(SPCircle *circle); - static void sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *sp_circle_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_circle_set(SPObject *object, unsigned int key, gchar const *value); static gchar *sp_circle_description(SPItem *item); -static SPGenericEllipseClass *circle_parent_class; - -GType -sp_circle_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCircleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_circle_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPCircle), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_circle_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GENERICELLIPSE, "SPCircle", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCircle, sp_circle, SP_TYPE_GENERICELLIPSE); static void sp_circle_class_init(SPCircleClass *klass) @@ -565,8 +486,6 @@ sp_circle_class_init(SPCircleClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *item_class = (SPItemClass *) klass; - circle_parent_class = (SPGenericEllipseClass*) g_type_class_ref(SP_TYPE_GENERICELLIPSE); - sp_object_class->build = sp_circle_build; sp_object_class->write = sp_circle_write; sp_object_class->set = sp_circle_set; @@ -583,8 +502,8 @@ sp_circle_init(SPCircle */*circle*/) static void sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) circle_parent_class)->build) - (* ((SPObjectClass *) circle_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_circle_parent_class)->build) + (* ((SPObjectClass *) sp_circle_parent_class)->build)(object, document, repr); object->readAttr( "cx" ); object->readAttr( "cy" ); @@ -606,8 +525,8 @@ sp_circle_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM sp_repr_set_svg_double(repr, "cy", ellipse->cy.computed); sp_repr_set_svg_double(repr, "r", ellipse->rx.computed); - if (((SPObjectClass *) circle_parent_class)->write) - ((SPObjectClass *) circle_parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_circle_parent_class)->write) + ((SPObjectClass *) sp_circle_parent_class)->write(object, xml_doc, repr, flags); return repr; } @@ -636,8 +555,8 @@ sp_circle_set(SPObject *object, unsigned int key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) circle_parent_class)->set) - ((SPObjectClass *) circle_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_circle_parent_class)->set) + ((SPObjectClass *) sp_circle_parent_class)->set(object, key, value); break; } } @@ -649,9 +568,6 @@ static gchar *sp_circle_description(SPItem */*item*/) /* <path sodipodi:type="arc"> element */ -static void sp_arc_class_init(SPArcClass *klass); -static void sp_arc_init(SPArc *arc); - static void sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *sp_arc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_arc_set(SPObject *object, unsigned int key, gchar const *value); @@ -659,29 +575,7 @@ static void sp_arc_modified(SPObject *object, guint flags); static gchar *sp_arc_description(SPItem *item); -static SPGenericEllipseClass *arc_parent_class; - -GType -sp_arc_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPArcClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_arc_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPArc), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_arc_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GENERICELLIPSE, "SPArc", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPArc, sp_arc, SP_TYPE_GENERICELLIPSE); static void sp_arc_class_init(SPArcClass *klass) @@ -689,8 +583,6 @@ sp_arc_class_init(SPArcClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *item_class = (SPItemClass *) klass; - arc_parent_class = (SPGenericEllipseClass*) g_type_class_ref(SP_TYPE_GENERICELLIPSE); - sp_object_class->build = sp_arc_build; sp_object_class->write = sp_arc_write; sp_object_class->set = sp_arc_set; @@ -708,8 +600,8 @@ sp_arc_init(SPArc */*arc*/) static void sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) arc_parent_class)->build) - (* ((SPObjectClass *) arc_parent_class)->build) (object, document, repr); + if (((SPObjectClass *) sp_arc_parent_class)->build) + (* ((SPObjectClass *) sp_arc_parent_class)->build) (object, document, repr); object->readAttr( "sodipodi:cx" ); object->readAttr( "sodipodi:cy" ); @@ -797,8 +689,8 @@ sp_arc_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:: // write d= sp_arc_set_elliptical_path_attribute(arc, repr); - if (((SPObjectClass *) arc_parent_class)->write) - ((SPObjectClass *) arc_parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_arc_parent_class)->write) + ((SPObjectClass *) sp_arc_parent_class)->write(object, xml_doc, repr, flags); return repr; } @@ -850,8 +742,8 @@ sp_arc_set(SPObject *object, unsigned int key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) arc_parent_class)->set) - ((SPObjectClass *) arc_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_arc_parent_class)->set) + ((SPObjectClass *) sp_arc_parent_class)->set(object, key, value); break; } } @@ -863,8 +755,8 @@ sp_arc_modified(SPObject *object, guint flags) ((SPShape *) object)->setShape(); } - if (((SPObjectClass *) arc_parent_class)->modified) - ((SPObjectClass *) arc_parent_class)->modified(object, flags); + if (((SPObjectClass *) sp_arc_parent_class)->modified) + ((SPObjectClass *) sp_arc_parent_class)->modified(object, flags); } static gchar *sp_arc_description(SPItem *item) diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index 91354ab60..5074be354 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -17,6 +17,8 @@ #include "svg/svg-length.h" #include "sp-shape.h" +G_BEGIN_DECLS + /* Common parent class */ #define SP_TYPE_GENERICELLIPSE (sp_genericellipse_get_type ()) @@ -102,4 +104,6 @@ GType sp_arc_get_type (void); void sp_arc_position_set (SPArc * arc, gdouble x, gdouble y, gdouble rx, gdouble ry); Geom::Point sp_arc_get_xy (SPArc *ge, gdouble arg); +G_END_DECLS + #endif diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index c7dce3850..e3a44d8bb 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -38,10 +38,6 @@ using std::pair; #include "display/nr-filter.h" /* Filter base class */ - -static void sp_filter_class_init(SPFilterClass *klass); -static void sp_filter_init(SPFilter *filter); - static void sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_filter_release(SPObject *object); static void sp_filter_set(SPObject *object, unsigned int key, gchar const *value); @@ -55,37 +51,13 @@ static Inkscape::XML::Node *sp_filter_write(SPObject *object, Inkscape::XML::Doc static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); -static SPObjectClass *filter_parent_class; - -GType -sp_filter_get_type() -{ - static GType filter_type = 0; - - if (!filter_type) { - GTypeInfo filter_info = { - sizeof(SPFilterClass), - NULL, NULL, - (GClassInitFunc) sp_filter_class_init, - NULL, NULL, - sizeof(SPFilter), - 16, - (GInstanceInitFunc) sp_filter_init, - NULL, /* value_table */ - }; - filter_type = g_type_register_static(SP_TYPE_OBJECT, "SPFilter", &filter_info, (GTypeFlags)0); - } - return filter_type; -} +G_DEFINE_TYPE(SPFilter, sp_filter, SP_TYPE_OBJECT); static void sp_filter_class_init(SPFilterClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - filter_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_filter_build; sp_object_class->release = sp_filter_release; sp_object_class->write = sp_filter_write; @@ -141,8 +113,8 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->readAttr( "filterRes" ); object->readAttr( "xlink:href" ); - if (((SPObjectClass *) filter_parent_class)->build) { - ((SPObjectClass *) filter_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_filter_parent_class)->build) { + ((SPObjectClass *) sp_filter_parent_class)->build(object, document, repr); } //is this necessary? @@ -174,8 +146,8 @@ static void sp_filter_release(SPObject *object) filter->modified_connection.~connection(); delete filter->_image_name; - if (((SPObjectClass *) filter_parent_class)->release) - ((SPObjectClass *) filter_parent_class)->release(object); + if (((SPObjectClass *) sp_filter_parent_class)->release) + ((SPObjectClass *) sp_filter_parent_class)->release(object); } /** @@ -249,8 +221,8 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) filter_parent_class)->set) { - ((SPObjectClass *) filter_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_filter_parent_class)->set) { + ((SPObjectClass *) sp_filter_parent_class)->set(object, key, value); } break; } @@ -271,8 +243,8 @@ sp_filter_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) filter_parent_class)->update) { - ((SPObjectClass *) filter_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_filter_parent_class)->update) { + ((SPObjectClass *) sp_filter_parent_class)->update(object, ctx, flags); } } @@ -367,8 +339,8 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N g_free(uri_string); } - if (((SPObjectClass *) filter_parent_class)->write) { - ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_filter_parent_class)->write) { + ((SPObjectClass *) sp_filter_parent_class)->write(object, doc, repr, flags); } return repr; @@ -407,8 +379,8 @@ sp_filter_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM { //SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->child_added) - (* ((SPObjectClass *) filter_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_filter_parent_class)->child_added) + (* ((SPObjectClass *) sp_filter_parent_class)->child_added)(object, child, ref); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -421,8 +393,8 @@ sp_filter_remove_child(SPObject *object, Inkscape::XML::Node *child) { // SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->remove_child) - (* ((SPObjectClass *) filter_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_filter_parent_class)->remove_child) + (* ((SPObjectClass *) sp_filter_parent_class)->remove_child)(object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 7a0c5e0b8..c588335d8 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -14,8 +14,6 @@ #include "sp-string.h" #include "document.h" -static void sp_flowdiv_class_init (SPFlowdivClass *klass); -static void sp_flowdiv_init (SPFlowdiv *group); static void sp_flowdiv_release (SPObject *object); static Inkscape::XML::Node *sp_flowdiv_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_flowdiv_update (SPObject *object, SPCtx *ctx, unsigned int flags); @@ -23,8 +21,6 @@ static void sp_flowdiv_modified (SPObject *object, guint flags); static void sp_flowdiv_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); static void sp_flowdiv_set (SPObject *object, unsigned int key, const gchar *value); -static void sp_flowtspan_class_init (SPFlowtspanClass *klass); -static void sp_flowtspan_init (SPFlowtspan *group); static void sp_flowtspan_release (SPObject *object); static Inkscape::XML::Node *sp_flowtspan_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_flowtspan_update (SPObject *object, SPCtx *ctx, unsigned int flags); @@ -32,8 +28,6 @@ static void sp_flowtspan_modified (SPObject *object, guint flags); static void sp_flowtspan_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); static void sp_flowtspan_set (SPObject *object, unsigned int key, const gchar *value); -static void sp_flowpara_class_init (SPFlowparaClass *klass); -static void sp_flowpara_init (SPFlowpara *group); static void sp_flowpara_release (SPObject *object); static Inkscape::XML::Node *sp_flowpara_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_flowpara_update (SPObject *object, SPCtx *ctx, unsigned int flags); @@ -41,51 +35,20 @@ static void sp_flowpara_modified (SPObject *object, guint flags); static void sp_flowpara_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); static void sp_flowpara_set (SPObject *object, unsigned int key, const gchar *value); -static void sp_flowline_class_init (SPFlowlineClass *klass); static void sp_flowline_release (SPObject *object); -static void sp_flowline_init (SPFlowline *group); static Inkscape::XML::Node *sp_flowline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_flowline_modified (SPObject *object, guint flags); -static void sp_flowregionbreak_class_init (SPFlowregionbreakClass *klass); static void sp_flowregionbreak_release (SPObject *object); -static void sp_flowregionbreak_init (SPFlowregionbreak *group); static Inkscape::XML::Node *sp_flowregionbreak_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_flowregionbreak_modified (SPObject *object, guint flags); -static SPItemClass * flowdiv_parent_class; -static SPItemClass * flowtspan_parent_class; -static SPItemClass * flowpara_parent_class; -static SPObjectClass * flowline_parent_class; -static SPObjectClass * flowregionbreak_parent_class; - -GType sp_flowdiv_get_type(void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowdivClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowdiv_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowdiv), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowdiv_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_ITEM, "SPFlowdiv", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowdiv, sp_flowdiv, SP_TYPE_ITEM); static void sp_flowdiv_class_init(SPFlowdivClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - flowdiv_parent_class = reinterpret_cast<SPItemClass *>(g_type_class_ref(SP_TYPE_ITEM)); - sp_object_class->build = sp_flowdiv_build; sp_object_class->set = sp_flowdiv_set; sp_object_class->release = sp_flowdiv_release; @@ -100,8 +63,8 @@ static void sp_flowdiv_init(SPFlowdiv */*group*/) static void sp_flowdiv_release(SPObject *object) { - if (reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->release) { - reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->release(object); } } @@ -110,8 +73,8 @@ static void sp_flowdiv_update(SPObject *object, SPCtx *ctx, unsigned int flags) SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); SPItemCtx cctx = *ictx; - if (reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->update) { - reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->update(object, ctx, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->update) { + reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -144,8 +107,8 @@ static void sp_flowdiv_update(SPObject *object, SPCtx *ctx, unsigned int flags) static void sp_flowdiv_modified(SPObject *object, guint flags) { - if (reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->modified) { - reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->modified(object, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->modified) { + reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -173,15 +136,15 @@ static void sp_flowdiv_build(SPObject *object, SPDocument *doc, Inkscape::XML::N { object->_requireSVGVersion(Inkscape::Version(1, 2)); - if (reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->build) { - reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->build(object, doc, repr); + if (reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->build) { + reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->build(object, doc, repr); } } static void sp_flowdiv_set(SPObject *object, unsigned int key, const gchar *value) { - if (reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->set) { - reinterpret_cast<SPObjectClass *>(flowdiv_parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_flowdiv_parent_class)->set(object, key, value); } } @@ -222,8 +185,8 @@ static Inkscape::XML::Node *sp_flowdiv_write(SPObject *object, Inkscape::XML::Do } } - if (((SPObjectClass *) (flowdiv_parent_class))->write) { - ((SPObjectClass *) (flowdiv_parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowdiv_parent_class))->write) { + ((SPObjectClass *) (sp_flowdiv_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -233,35 +196,12 @@ static Inkscape::XML::Node *sp_flowdiv_write(SPObject *object, Inkscape::XML::Do /* * */ - -GType -sp_flowtspan_get_type (void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowtspanClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowtspan_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowtspan), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowtspan_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_ITEM, "SPFlowtspan", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowtspan, sp_flowtspan, SP_TYPE_ITEM); static void sp_flowtspan_class_init(SPFlowtspanClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - flowtspan_parent_class = reinterpret_cast<SPItemClass *>(g_type_class_ref(SP_TYPE_ITEM)); - sp_object_class->build = sp_flowtspan_build; sp_object_class->set = sp_flowtspan_set; sp_object_class->release = sp_flowtspan_release; @@ -276,8 +216,8 @@ static void sp_flowtspan_init(SPFlowtspan */*group*/) static void sp_flowtspan_release(SPObject *object) { - if (reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->release) { - reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->release(object); } } @@ -286,8 +226,8 @@ static void sp_flowtspan_update(SPObject *object, SPCtx *ctx, unsigned int flags SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); SPItemCtx cctx = *ictx; - if (reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->update) { - reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->update(object, ctx, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->update) { + reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -320,8 +260,8 @@ static void sp_flowtspan_update(SPObject *object, SPCtx *ctx, unsigned int flags static void sp_flowtspan_modified(SPObject *object, guint flags) { - if (reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->modified) { - reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->modified(object, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->modified) { + reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -347,15 +287,15 @@ static void sp_flowtspan_modified(SPObject *object, guint flags) static void sp_flowtspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - if (reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->build) { - reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->build(object, doc, repr); + if (reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->build) { + reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->build(object, doc, repr); } } static void sp_flowtspan_set(SPObject *object, unsigned int key, const gchar *value) { - if (reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->set) { - reinterpret_cast<SPObjectClass *>(flowtspan_parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_flowtspan_parent_class)->set(object, key, value); } } @@ -396,8 +336,8 @@ static Inkscape::XML::Node *sp_flowtspan_write(SPObject *object, Inkscape::XML:: } } - if (((SPObjectClass *) (flowtspan_parent_class))->write) { - ((SPObjectClass *) (flowtspan_parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowtspan_parent_class))->write) { + ((SPObjectClass *) (sp_flowtspan_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -408,35 +348,12 @@ static Inkscape::XML::Node *sp_flowtspan_write(SPObject *object, Inkscape::XML:: /* * */ - -GType -sp_flowpara_get_type (void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowparaClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowpara_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowpara), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowpara_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_ITEM, "SPFlowpara", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowpara, sp_flowpara, SP_TYPE_ITEM); static void sp_flowpara_class_init(SPFlowparaClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - flowpara_parent_class = reinterpret_cast<SPItemClass *>(g_type_class_ref(SP_TYPE_ITEM)); - sp_object_class->build = sp_flowpara_build; sp_object_class->set = sp_flowpara_set; sp_object_class->release = sp_flowpara_release; @@ -451,8 +368,8 @@ static void sp_flowpara_init (SPFlowpara */*group*/) static void sp_flowpara_release(SPObject *object) { - if (reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->release) { - reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->release(object); } } @@ -461,8 +378,8 @@ static void sp_flowpara_update(SPObject *object, SPCtx *ctx, unsigned int flags) SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); SPItemCtx cctx = *ictx; - if (reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->update) { - reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->update(object, ctx, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->update) { + reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -495,8 +412,8 @@ static void sp_flowpara_update(SPObject *object, SPCtx *ctx, unsigned int flags) static void sp_flowpara_modified(SPObject *object, guint flags) { - if (reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->modified) { - reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->modified(object, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->modified) { + reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -522,15 +439,15 @@ static void sp_flowpara_modified(SPObject *object, guint flags) static void sp_flowpara_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - if (reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->build) { - reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->build(object, doc, repr); + if (reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->build) { + reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->build(object, doc, repr); } } static void sp_flowpara_set(SPObject *object, unsigned int key, const gchar *value) { - if (reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->set) { - reinterpret_cast<SPObjectClass *>(flowpara_parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_flowpara_parent_class)->set(object, key, value); } } @@ -569,8 +486,8 @@ static Inkscape::XML::Node *sp_flowpara_write(SPObject *object, Inkscape::XML::D } } - if (((SPObjectClass *) (flowpara_parent_class))->write) { - ((SPObjectClass *) (flowpara_parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowpara_parent_class))->write) { + ((SPObjectClass *) (sp_flowpara_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -579,34 +496,12 @@ static Inkscape::XML::Node *sp_flowpara_write(SPObject *object, Inkscape::XML::D /* * */ - -GType sp_flowline_get_type(void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowlineClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowline_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowline), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowline_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_OBJECT, "SPFlowline", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowline, sp_flowline, SP_TYPE_OBJECT); static void sp_flowline_class_init(SPFlowlineClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - flowline_parent_class = reinterpret_cast<SPObjectClass *>(g_type_class_ref(SP_TYPE_OBJECT)); - sp_object_class->release = sp_flowline_release; sp_object_class->write = sp_flowline_write; sp_object_class->modified = sp_flowline_modified; @@ -618,15 +513,15 @@ static void sp_flowline_init(SPFlowline */*group*/) static void sp_flowline_release(SPObject *object) { - if (reinterpret_cast<SPObjectClass *>(flowline_parent_class)->release) { - reinterpret_cast<SPObjectClass *>(flowline_parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->release(object); } } static void sp_flowline_modified(SPObject *object, guint flags) { - if (reinterpret_cast<SPObjectClass *>(flowline_parent_class)->modified) { - reinterpret_cast<SPObjectClass *>(flowline_parent_class)->modified(object, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->modified) { + reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -644,8 +539,8 @@ static Inkscape::XML::Node *sp_flowline_write(SPObject *object, Inkscape::XML::D } else { } - if (reinterpret_cast<SPObjectClass *>(flowline_parent_class)->write) { - reinterpret_cast<SPObjectClass *>(flowline_parent_class)->write(object, xml_doc, repr, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->write) { + reinterpret_cast<SPObjectClass *>(sp_flowline_parent_class)->write(object, xml_doc, repr, flags); } return repr; @@ -654,34 +549,12 @@ static Inkscape::XML::Node *sp_flowline_write(SPObject *object, Inkscape::XML::D /* * */ - -GType sp_flowregionbreak_get_type(void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowregionbreakClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowregionbreak_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowregionbreak), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowregionbreak_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_OBJECT, "SPFlowregionbreak", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowregionbreak, sp_flowregionbreak, SP_TYPE_OBJECT); static void sp_flowregionbreak_class_init(SPFlowregionbreakClass *klass) { SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - flowregionbreak_parent_class = reinterpret_cast<SPObjectClass *>(g_type_class_ref(SP_TYPE_OBJECT)); - sp_object_class->release = sp_flowregionbreak_release; sp_object_class->write = sp_flowregionbreak_write; sp_object_class->modified = sp_flowregionbreak_modified; @@ -693,15 +566,15 @@ static void sp_flowregionbreak_init(SPFlowregionbreak */*group*/) static void sp_flowregionbreak_release(SPObject *object) { - if (reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->release) { - reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->release(object); + if (reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->release) { + reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->release(object); } } static void sp_flowregionbreak_modified(SPObject *object, guint flags) { - if (reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->modified) { - reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->modified(object, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->modified) { + reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -719,8 +592,8 @@ static Inkscape::XML::Node *sp_flowregionbreak_write(SPObject *object, Inkscape: } else { } - if (reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->write) { - reinterpret_cast<SPObjectClass *>(flowregionbreak_parent_class)->write(object, xml_doc, repr, flags); + if (reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->write) { + reinterpret_cast<SPObjectClass *>(sp_flowregionbreak_parent_class)->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 649193c33..a8de68f9b 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -24,8 +24,6 @@ #include "livarot/Path.h" #include "livarot/Shape.h" -static void sp_flowregion_class_init (SPFlowregionClass *klass); -static void sp_flowregion_init (SPFlowregion *group); static void sp_flowregion_dispose (GObject *object); static void sp_flowregion_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); @@ -36,10 +34,8 @@ static Inkscape::XML::Node *sp_flowregion_write (SPObject *object, Inkscape::XML static gchar * sp_flowregion_description (SPItem * item); -static SPItemClass * flowregion_parent_class; +G_DEFINE_TYPE(SPFlowregion, sp_flowregion, SP_TYPE_ITEM); -static void sp_flowregionexclude_class_init (SPFlowregionExcludeClass *klass); -static void sp_flowregionexclude_init (SPFlowregionExclude *group); static void sp_flowregionexclude_dispose (GObject *object); static void sp_flowregionexclude_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); @@ -50,33 +46,9 @@ static Inkscape::XML::Node *sp_flowregionexclude_write (SPObject *object, Inksca static gchar * sp_flowregionexclude_description (SPItem * item); -static SPItemClass * flowregionexclude_parent_class; - static void GetDest(SPObject* child,Shape **computed); -GType -sp_flowregion_get_type (void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowregionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowregion_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowregion), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowregion_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_ITEM, "SPFlowregion", &group_info, (GTypeFlags)0); - } - return group_type; -} - static void sp_flowregion_class_init (SPFlowregionClass *klass) { @@ -88,8 +60,6 @@ sp_flowregion_class_init (SPFlowregionClass *klass) sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - flowregion_parent_class = (SPItemClass *)g_type_class_ref (SP_TYPE_ITEM); - object_class->dispose = sp_flowregion_dispose; sp_object_class->child_added = sp_flowregion_child_added; @@ -120,8 +90,8 @@ static void sp_flowregion_child_added(SPObject *object, Inkscape::XML::Node *chi { SP_ITEM(object); - if (((SPObjectClass *) (flowregion_parent_class))->child_added) { - (* ((SPObjectClass *) (flowregion_parent_class))->child_added) (object, child, ref); + if (((SPObjectClass *) (sp_flowregion_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_flowregion_parent_class))->child_added) (object, child, ref); } object->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -132,8 +102,8 @@ static void sp_flowregion_child_added(SPObject *object, Inkscape::XML::Node *chi static void sp_flowregion_remove_child (SPObject * object, Inkscape::XML::Node * child) { - if (((SPObjectClass *) (flowregion_parent_class))->remove_child) - (* ((SPObjectClass *) (flowregion_parent_class))->remove_child) (object, child); + if (((SPObjectClass *) (sp_flowregion_parent_class))->remove_child) + (* ((SPObjectClass *) (sp_flowregion_parent_class))->remove_child) (object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -146,8 +116,8 @@ static void sp_flowregion_update(SPObject *object, SPCtx *ctx, unsigned int flag SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (flowregion_parent_class))->update) { - ((SPObjectClass *) (flowregion_parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_flowregion_parent_class))->update) { + ((SPObjectClass *) (sp_flowregion_parent_class))->update (object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -250,8 +220,8 @@ static Inkscape::XML::Node *sp_flowregion_write(SPObject *object, Inkscape::XML: } } - if (((SPObjectClass *) (flowregion_parent_class))->write) { - ((SPObjectClass *) (flowregion_parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowregion_parent_class))->write) { + ((SPObjectClass *) (sp_flowregion_parent_class))->write (object, xml_doc, repr, flags); } return repr; @@ -268,27 +238,7 @@ static gchar *sp_flowregion_description(SPItem */*item*/) * */ -GType -sp_flowregionexclude_get_type (void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPFlowregionExcludeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowregionexclude_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPFlowregionExclude), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowregionexclude_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_ITEM, "SPFlowregionExclude", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowregionExclude, sp_flowregionexclude, SP_TYPE_ITEM); static void sp_flowregionexclude_class_init (SPFlowregionExcludeClass *klass) @@ -301,8 +251,6 @@ sp_flowregionexclude_class_init (SPFlowregionExcludeClass *klass) sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - flowregionexclude_parent_class = (SPItemClass *)g_type_class_ref (SP_TYPE_ITEM); - object_class->dispose = sp_flowregionexclude_dispose; sp_object_class->child_added = sp_flowregionexclude_child_added; @@ -334,8 +282,8 @@ static void sp_flowregionexclude_child_added(SPObject *object, Inkscape::XML::No { SP_ITEM(object); - if (((SPObjectClass *) (flowregionexclude_parent_class))->child_added) { - (* ((SPObjectClass *) (flowregionexclude_parent_class))->child_added) (object, child, ref); + if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) (object, child, ref); } object->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -346,8 +294,8 @@ static void sp_flowregionexclude_child_added(SPObject *object, Inkscape::XML::No static void sp_flowregionexclude_remove_child (SPObject * object, Inkscape::XML::Node * child) { - if (((SPObjectClass *) (flowregionexclude_parent_class))->remove_child) - (* ((SPObjectClass *) (flowregionexclude_parent_class))->remove_child) (object, child); + if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->remove_child) + (* ((SPObjectClass *) (sp_flowregionexclude_parent_class))->remove_child) (object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -360,8 +308,8 @@ static void sp_flowregionexclude_update(SPObject *object, SPCtx *ctx, unsigned i SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (flowregionexclude_parent_class))->update) { - ((SPObjectClass *) (flowregionexclude_parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->update) { + ((SPObjectClass *) (sp_flowregionexclude_parent_class))->update (object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -458,8 +406,8 @@ static Inkscape::XML::Node *sp_flowregionexclude_write(SPObject *object, Inkscap } } - if (((SPObjectClass *) (flowregionexclude_parent_class))->write) { - ((SPObjectClass *) (flowregionexclude_parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->write) { + ((SPObjectClass *) (sp_flowregionexclude_parent_class))->write (object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index dc5b1d8bd..1d95c2f8a 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -34,8 +34,6 @@ #include "display/drawing-text.h" -static void sp_flowtext_class_init(SPFlowtextClass *klass); -static void sp_flowtext_init(SPFlowtext *group); static void sp_flowtext_dispose(GObject *object); static void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); @@ -53,29 +51,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::Sna static Inkscape::DrawingItem *sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); static void sp_flowtext_hide(SPItem *item, unsigned key); -static SPItemClass *parent_class; - -GType -sp_flowtext_get_type(void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof(SPFlowtextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_flowtext_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPFlowtext), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_flowtext_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static(SP_TYPE_ITEM, "SPFlowtext", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPFlowtext, sp_flowtext, SP_TYPE_ITEM); static void sp_flowtext_class_init(SPFlowtextClass *klass) @@ -84,8 +60,6 @@ sp_flowtext_class_init(SPFlowtextClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *item_class = (SPItemClass *) klass; - parent_class = (SPItemClass *)g_type_class_ref(SP_TYPE_ITEM); - object_class->dispose = sp_flowtext_dispose; sp_object_class->child_added = sp_flowtext_child_added; @@ -122,8 +96,8 @@ sp_flowtext_dispose(GObject *object) static void sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) - (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); + if (((SPObjectClass *) (sp_flowtext_parent_class))->child_added) + (* ((SPObjectClass *) (sp_flowtext_parent_class))->child_added)(object, child, ref); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -133,8 +107,8 @@ sp_flowtext_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: static void sp_flowtext_remove_child(SPObject *object, Inkscape::XML::Node *child) { - if (((SPObjectClass *) (parent_class))->remove_child) - (* ((SPObjectClass *) (parent_class))->remove_child)(object, child); + if (((SPObjectClass *) (sp_flowtext_parent_class))->remove_child) + (* ((SPObjectClass *) (sp_flowtext_parent_class))->remove_child)(object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -145,8 +119,8 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update(object, ctx, flags); + if (((SPObjectClass *) (sp_flowtext_parent_class))->update) { + ((SPObjectClass *) (sp_flowtext_parent_class))->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -225,8 +199,8 @@ sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r { object->_requireSVGVersion(Inkscape::Version(1, 2)); - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); + if (((SPObjectClass *) (sp_flowtext_parent_class))->build) { + (* ((SPObjectClass *) (sp_flowtext_parent_class))->build)(object, document, repr); } object->readAttr( "inkscape:layoutOptions" ); // must happen after css has been read @@ -284,8 +258,8 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value) break; } default: - if (((SPObjectClass *) (parent_class))->set) { - (* ((SPObjectClass *) (parent_class))->set)(object, key, value); + if (((SPObjectClass *) (sp_flowtext_parent_class))->set) { + (* ((SPObjectClass *) (sp_flowtext_parent_class))->set)(object, key, value); } break; } @@ -320,8 +294,8 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D } } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_flowtext_parent_class))->write) { + ((SPObjectClass *) (sp_flowtext_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -404,8 +378,8 @@ sp_flowtext_show(SPItem *item, Inkscape::Drawing &drawing, unsigned/* key*/, uns static void sp_flowtext_hide(SPItem *item, unsigned int key) { - if (((SPItemClass *) parent_class)->hide) - ((SPItemClass *) parent_class)->hide(item, key); + if (((SPItemClass *) sp_flowtext_parent_class)->hide) + ((SPItemClass *) sp_flowtext_parent_class)->hide(item, key); } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index e9faabdc6..4288a5d64 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -261,9 +261,6 @@ static std::vector<FontFaceStretchType> sp_read_fontFaceStretchType(gchar const return v; } -static void sp_fontface_class_init(SPFontFaceClass *fc); -static void sp_fontface_init(SPFontFace *font); - static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fontface_release(SPObject *object); static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value); @@ -273,37 +270,12 @@ static void sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child static void sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags); -static SPObjectClass *parent_class; - -GType sp_fontface_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPFontFaceClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_fontface_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPFontFace), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_fontface_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPFontFace", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPFontFace, sp_fontface, SP_TYPE_OBJECT); static void sp_fontface_class_init(SPFontFaceClass *fc) { SPObjectClass *sp_object_class = (SPObjectClass *) fc; - parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_fontface_build; sp_object_class->release = sp_fontface_release; sp_object_class->set = sp_fontface_set; @@ -369,8 +341,8 @@ static void sp_fontface_init(SPFontFace *face) static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->build) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->build(object, document, repr); } object->readAttr( "font-family" ); @@ -420,8 +392,8 @@ sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: { SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->child_added) - (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->child_added) + (* (SP_OBJECT_CLASS(sp_fontface_parent_class))->child_added)(object, child, ref); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -436,8 +408,8 @@ sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->remove_child) - (* ((SPObjectClass *) parent_class)->remove_child)(object, child); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->remove_child) + (* (SP_OBJECT_CLASS(sp_fontface_parent_class))->remove_child)(object, child); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -445,10 +417,8 @@ sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child) static void sp_fontface_release(SPObject *object) { - //SPFontFace *font = SP_FONTFACE(object); - - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->release) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->release(object); } } @@ -736,8 +706,8 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val break; } default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->set) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->set(object, key, value); } break; } @@ -785,8 +755,8 @@ sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "overline-thickness" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->update) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->update(object, ctx, flags); } } @@ -873,8 +843,8 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->write) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-font-face.h b/src/sp-font-face.h index e492ba091..691c1f883 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -23,6 +23,8 @@ #include "sp-object.h" +G_BEGIN_DECLS + #define SP_TYPE_FONTFACE (sp_fontface_get_type ()) #define SP_FONTFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FONTFACE, SPFontFace)) #define SP_FONTFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_FONTFACE, SPFontFaceClass)) @@ -115,5 +117,7 @@ struct SPFontFaceClass { GType sp_fontface_get_type (void); +G_END_DECLS + #endif //#ifndef __SP_FONTFACE_H__ #endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 852e6ba5d..6ebbd5218 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -25,9 +25,6 @@ #include "display/nr-svgfonts.h" -static void sp_font_class_init(SPFontClass *fc); -static void sp_font_init(SPFont *font); - static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_font_release(SPObject *object); static void sp_font_set(SPObject *object, unsigned int key, const gchar *value); @@ -37,39 +34,12 @@ static void sp_font_child_added(SPObject *object, Inkscape::XML::Node *child, In static void sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_font_update(SPObject *object, SPCtx *ctx, guint flags); -// static gchar *sp_font_description(SPItem *item); - -static SPObjectClass *parent_class; - -GType sp_font_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPFontClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_font_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPFont), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_font_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPFont", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPFont, sp_font, SP_TYPE_OBJECT); static void sp_font_class_init(SPFontClass *fc) { SPObjectClass *sp_object_class = (SPObjectClass *) fc; - parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_font_build; sp_object_class->release = sp_font_release; sp_object_class->set = sp_font_set; @@ -98,8 +68,8 @@ static void sp_font_init(SPFont *font) static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_font_parent_class))->build) { + ((SPObjectClass *) (sp_font_parent_class))->build(object, document, repr); } object->readAttr( "horiz-origin-x" ); @@ -125,8 +95,8 @@ sp_font_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML: { SPFont *f = SP_FONT(object); - if (((SPObjectClass *) parent_class)->child_added) - (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_font_parent_class)->child_added) + (* ((SPObjectClass *) sp_font_parent_class)->child_added)(object, child, ref); sp_font_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -141,8 +111,8 @@ sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFont *f = SP_FONT(object); - if (((SPObjectClass *) parent_class)->remove_child) - (* ((SPObjectClass *) parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_font_parent_class)->remove_child) + (* ((SPObjectClass *) sp_font_parent_class)->remove_child)(object, child); sp_font_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -153,8 +123,8 @@ static void sp_font_release(SPObject *object) //SPFont *font = SP_FONT(object); object->document->removeResource("font", object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_font_parent_class)->release) { + ((SPObjectClass *) sp_font_parent_class)->release(object); } } @@ -219,8 +189,8 @@ static void sp_font_set(SPObject *object, unsigned int key, const gchar *value) break; } default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_font_parent_class))->set) { + ((SPObjectClass *) (sp_font_parent_class))->set(object, key, value); } break; } @@ -241,8 +211,8 @@ sp_font_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "vert-adv-y" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_font_parent_class)->update) { + ((SPObjectClass *) sp_font_parent_class)->update(object, ctx, flags); } } @@ -274,8 +244,8 @@ static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Docum COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_font_parent_class))->write) { + ((SPObjectClass *) (sp_font_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 719375688..e14ef8667 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -23,46 +23,18 @@ #include "document.h" #include <cstring> -static void sp_glyph_class_init(SPGlyphClass *gc); -static void sp_glyph_init(SPGlyph *glyph); - static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_glyph_release(SPObject *object); static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value); static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags); -static SPObjectClass *parent_class; - -GType sp_glyph_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPGlyphClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_glyph_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPGlyph), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_glyph_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPGlyph", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPGlyph, sp_glyph, SP_TYPE_OBJECT); static void sp_glyph_class_init(SPGlyphClass *gc) { SPObjectClass *sp_object_class = (SPObjectClass *) gc; - parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); - sp_object_class->build = sp_glyph_build; sp_object_class->release = sp_glyph_release; sp_object_class->set = sp_glyph_set; @@ -88,8 +60,8 @@ static void sp_glyph_init(SPGlyph *glyph) static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_glyph_parent_class))->build) { + ((SPObjectClass *) (sp_glyph_parent_class))->build(object, document, repr); } object->readAttr( "unicode" ); @@ -108,8 +80,8 @@ static void sp_glyph_release(SPObject *object) { //SPGlyph *glyph = SP_GLYPH(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_glyph_parent_class)->release) { + ((SPObjectClass *) sp_glyph_parent_class)->release(object); } } @@ -233,8 +205,8 @@ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value) } default: { - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_glyph_parent_class))->set) { + ((SPObjectClass *) (sp_glyph_parent_class))->set(object, key, value); } break; } @@ -264,8 +236,8 @@ sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "vert-adv-y" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_glyph_parent_class)->update) { + ((SPObjectClass *) sp_glyph_parent_class)->update(object, ctx, flags); } } @@ -306,8 +278,8 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Docu COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_glyph_parent_class))->write) { + ((SPObjectClass *) (sp_glyph_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index d7add805d..1f2cfdd41 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -61,36 +61,24 @@ //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH // SPStop -static void sp_stop_class_init(SPStopClass *klass); -static void sp_stop_init(SPStop *stop); - static void sp_stop_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_stop_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_stop_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static SPObjectClass *stop_parent_class; +G_DEFINE_TYPE(SPStop, sp_stop, SP_TYPE_OBJECT); // SPMeshRow -static void sp_meshrow_class_init(SPMeshRowClass *klass); -static void sp_meshrow_init(SPMeshRow *meshrow); - static void sp_meshrow_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_meshrow_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_meshrow_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static SPObjectClass *meshrow_parent_class; +G_DEFINE_TYPE(SPMeshRow, sp_meshrow, SP_TYPE_OBJECT); // SPMeshPatch -static void sp_meshpatch_class_init(SPMeshPatchClass *klass); -static void sp_meshpatch_init(SPMeshPatch *meshpatch); - static void sp_meshpatch_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_meshpatch_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_meshpatch_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static SPObjectClass *meshpatch_parent_class; +G_DEFINE_TYPE(SPMeshPatch, sp_meshpatch, SP_TYPE_OBJECT); class SPGradientImpl @@ -117,37 +105,12 @@ class SPGradientImpl }; /** - * Registers SPStop class and returns its type. - */ -GType -sp_stop_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPStopClass), - NULL, NULL, - (GClassInitFunc) sp_stop_class_init, - NULL, NULL, - sizeof(SPStop), - 16, - (GInstanceInitFunc) sp_stop_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPStop", &info, (GTypeFlags)0); - } - return type; -} - -/** * Callback to initialize SPStop vtable. */ static void sp_stop_class_init(SPStopClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - stop_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_stop_build; sp_object_class->set = sp_stop_set; sp_object_class->write = sp_stop_write; @@ -170,8 +133,8 @@ sp_stop_init(SPStop *stop) */ static void sp_stop_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) stop_parent_class)->build) - (* ((SPObjectClass *) stop_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_stop_parent_class)->build) + (* ((SPObjectClass *) sp_stop_parent_class)->build)(object, document, repr); object->readAttr( "offset" ); object->readAttr( "stop-color" ); @@ -256,8 +219,8 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) break; } default: { - if (((SPObjectClass *) stop_parent_class)->set) - (* ((SPObjectClass *) stop_parent_class)->set)(object, key, value); + if (((SPObjectClass *) sp_stop_parent_class)->set) + (* ((SPObjectClass *) sp_stop_parent_class)->set)(object, key, value); break; } } @@ -278,8 +241,8 @@ sp_stop_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: Glib::ustring colorStr = stop->specified_color.toString(); gfloat opacity = stop->opacity; - if (((SPObjectClass *) stop_parent_class)->write) { - (* ((SPObjectClass *) stop_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_stop_parent_class)->write) { + (* ((SPObjectClass *) sp_stop_parent_class)->write)(object, xml_doc, repr, flags); } // Since we do a hackish style setting here (because SPStyle does not support stop-color and @@ -410,37 +373,12 @@ sp_stop_get_rgba32(SPStop const *const stop) */ /** - * Registers SPMeshRow class and returns its type. - */ -GType -sp_meshrow_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPMeshRowClass), - NULL, NULL, - (GClassInitFunc) sp_meshrow_class_init, - NULL, NULL, - sizeof(SPMeshRow), - 16, - (GInstanceInitFunc) sp_meshrow_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPMeshRow", &info, (GTypeFlags)0); - } - return type; -} - -/** * Callback to initialize SPMeshRow vtable. */ static void sp_meshrow_class_init(SPMeshRowClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - meshrow_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_meshrow_build; sp_object_class->set = sp_meshrow_set; sp_object_class->write = sp_meshrow_write; @@ -459,8 +397,8 @@ static void sp_meshrow_init(SPMeshRow * /*meshrow*/) */ static void sp_meshrow_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) meshrow_parent_class)->build) - (* ((SPObjectClass *) meshrow_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_meshrow_parent_class)->build) + (* ((SPObjectClass *) sp_meshrow_parent_class)->build)(object, document, repr); // No attributes } @@ -485,8 +423,8 @@ sp_meshrow_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X repr = xml_doc->createElement("svg:meshRow"); } - if (((SPObjectClass *) meshrow_parent_class)->write) { - (* ((SPObjectClass *) meshrow_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_meshrow_parent_class)->write) { + (* ((SPObjectClass *) sp_meshrow_parent_class)->write)(object, xml_doc, repr, flags); } return repr; @@ -497,37 +435,12 @@ sp_meshrow_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X */ /** - * Registers SPMeshPatch class and returns its type. - */ -GType -sp_meshpatch_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPMeshPatchClass), - NULL, NULL, - (GClassInitFunc) sp_meshpatch_class_init, - NULL, NULL, - sizeof(SPMeshPatch), - 16, - (GInstanceInitFunc) sp_meshpatch_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPMeshPatch", &info, (GTypeFlags)0); - } - return type; -} - -/** * Callback to initialize SPMeshPatch vtable. */ static void sp_meshpatch_class_init(SPMeshPatchClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - meshpatch_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_meshpatch_build; sp_object_class->set = sp_meshpatch_set; sp_object_class->write = sp_meshpatch_write; @@ -546,8 +459,8 @@ static void sp_meshpatch_init(SPMeshPatch * /*meshpatch*/) */ static void sp_meshpatch_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) meshpatch_parent_class)->build) - (* ((SPObjectClass *) meshpatch_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_meshpatch_parent_class)->build) + (* ((SPObjectClass *) sp_meshpatch_parent_class)->build)(object, document, repr); object->readAttr( "tensor" ); } @@ -586,8 +499,8 @@ sp_meshpatch_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape: repr = xml_doc->createElement("svg:meshPatch"); } - if (((SPObjectClass *) meshpatch_parent_class)->write) { - (* ((SPObjectClass *) meshpatch_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_meshpatch_parent_class)->write) { + (* ((SPObjectClass *) sp_meshpatch_parent_class)->write)(object, xml_doc, repr, flags); } return repr; @@ -1496,9 +1409,6 @@ sp_gradient_set_gs2d_matrix(SPGradient *gr, Geom::Affine const &ctm, * Linear Gradient */ -static void sp_lineargradient_class_init(SPLinearGradientClass *klass); -static void sp_lineargradient_init(SPLinearGradient *lg); - static void sp_lineargradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -1506,31 +1416,7 @@ static void sp_lineargradient_set(SPObject *object, unsigned key, gchar const *v static Inkscape::XML::Node *sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); - -static SPGradientClass *lg_parent_class; - -/** - * Register SPLinearGradient class and return its type. - */ -GType -sp_lineargradient_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPLinearGradientClass), - NULL, NULL, - (GClassInitFunc) sp_lineargradient_class_init, - NULL, NULL, - sizeof(SPLinearGradient), - 16, - (GInstanceInitFunc) sp_lineargradient_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GRADIENT, "SPLinearGradient", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPLinearGradient, sp_lineargradient, SP_TYPE_GRADIENT); /** * SPLinearGradient vtable initialization. @@ -1540,8 +1426,6 @@ static void sp_lineargradient_class_init(SPLinearGradientClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPPaintServerClass *ps_class = (SPPaintServerClass *) klass; - lg_parent_class = (SPGradientClass*)g_type_class_ref(SP_TYPE_GRADIENT); - sp_object_class->build = sp_lineargradient_build; sp_object_class->set = sp_lineargradient_set; sp_object_class->write = sp_lineargradient_write; @@ -1567,8 +1451,8 @@ static void sp_lineargradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) lg_parent_class)->build) - (* ((SPObjectClass *) lg_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_lineargradient_parent_class)->build) + (* ((SPObjectClass *) sp_lineargradient_parent_class)->build)(object, document, repr); object->readAttr( "x1" ); object->readAttr( "y1" ); @@ -1602,8 +1486,8 @@ sp_lineargradient_set(SPObject *object, unsigned key, gchar const *value) object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) lg_parent_class)->set) - (* ((SPObjectClass *) lg_parent_class)->set)(object, key, value); + if (((SPObjectClass *) sp_lineargradient_parent_class)->set) + (* ((SPObjectClass *) sp_lineargradient_parent_class)->set)(object, key, value); break; } } @@ -1629,8 +1513,8 @@ sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inks if ((flags & SP_OBJECT_WRITE_ALL) || lg->y2._set) sp_repr_set_svg_double(repr, "y2", lg->y2.computed); - if (((SPObjectClass *) lg_parent_class)->write) - (* ((SPObjectClass *) lg_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_lineargradient_parent_class)->write) + (* ((SPObjectClass *) sp_lineargradient_parent_class)->write)(object, xml_doc, repr, flags); return repr; } @@ -1659,9 +1543,6 @@ sp_lineargradient_set_position(SPLinearGradient *lg, * Radial Gradient */ -static void sp_radialgradient_class_init(SPRadialGradientClass *klass); -static void sp_radialgradient_init(SPRadialGradient *rg); - static void sp_radialgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -1669,31 +1550,7 @@ static void sp_radialgradient_set(SPObject *object, unsigned key, gchar const *v static Inkscape::XML::Node *sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); - -static SPGradientClass *rg_parent_class; - -/** - * Register SPRadialGradient class and return its type. - */ -GType -sp_radialgradient_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPRadialGradientClass), - NULL, NULL, - (GClassInitFunc) sp_radialgradient_class_init, - NULL, NULL, - sizeof(SPRadialGradient), - 16, - (GInstanceInitFunc) sp_radialgradient_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GRADIENT, "SPRadialGradient", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPRadialGradient, sp_radialgradient, SP_TYPE_GRADIENT); /** * SPRadialGradient vtable initialization. @@ -1703,8 +1560,6 @@ static void sp_radialgradient_class_init(SPRadialGradientClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPPaintServerClass *ps_class = (SPPaintServerClass *) klass; - rg_parent_class = (SPGradientClass*)g_type_class_ref(SP_TYPE_GRADIENT); - sp_object_class->build = sp_radialgradient_build; sp_object_class->set = sp_radialgradient_set; sp_object_class->write = sp_radialgradient_write; @@ -1731,8 +1586,8 @@ sp_radialgradient_init(SPRadialGradient *rg) static void sp_radialgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) rg_parent_class)->build) - (* ((SPObjectClass *) rg_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_radialgradient_parent_class)->build) + (* ((SPObjectClass *) sp_radialgradient_parent_class)->build)(object, document, repr); object->readAttr( "cx" ); object->readAttr( "cy" ); @@ -1789,8 +1644,8 @@ sp_radialgradient_set(SPObject *object, unsigned key, gchar const *value) object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) rg_parent_class)->set) - ((SPObjectClass *) rg_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_radialgradient_parent_class)->set) + ((SPObjectClass *) sp_radialgradient_parent_class)->set(object, key, value); break; } } @@ -1813,8 +1668,8 @@ sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inks if ((flags & SP_OBJECT_WRITE_ALL) || rg->fx._set) sp_repr_set_svg_double(repr, "fx", rg->fx.computed); if ((flags & SP_OBJECT_WRITE_ALL) || rg->fy._set) sp_repr_set_svg_double(repr, "fy", rg->fy.computed); - if (((SPObjectClass *) rg_parent_class)->write) - (* ((SPObjectClass *) rg_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_radialgradient_parent_class)->write) + (* ((SPObjectClass *) sp_radialgradient_parent_class)->write)(object, xml_doc, repr, flags); return repr; } @@ -1845,9 +1700,6 @@ sp_radialgradient_set_position(SPRadialGradient *rg, //#define MESH_DEBUG -static void sp_meshgradient_class_init(SPMeshGradientClass *klass); -static void sp_meshgradient_init(SPMeshGradient *mg); - static void sp_meshgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -1855,31 +1707,7 @@ static void sp_meshgradient_set(SPObject *object, unsigned key, gchar const *val static Inkscape::XML::Node *sp_meshgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static cairo_pattern_t *sp_meshgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); - -static SPGradientClass *mg_parent_class; - -/** - * Register SPMeshGradient class and return its type. - */ -GType -sp_meshgradient_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPMeshGradientClass), - NULL, NULL, - (GClassInitFunc) sp_meshgradient_class_init, - NULL, NULL, - sizeof(SPMeshGradient), - 16, - (GInstanceInitFunc) sp_meshgradient_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GRADIENT, "SPMeshGradient", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPMeshGradient, sp_meshgradient, SP_TYPE_GRADIENT); /** * SPMeshGradient vtable initialization. @@ -1892,8 +1720,6 @@ static void sp_meshgradient_class_init(SPMeshGradientClass *klass) SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPPaintServerClass *ps_class = (SPPaintServerClass *) klass; - mg_parent_class = (SPGradientClass*)g_type_class_ref(SP_TYPE_GRADIENT); - sp_object_class->build = sp_meshgradient_build; sp_object_class->set = sp_meshgradient_set; sp_object_class->write = sp_meshgradient_write; @@ -1918,8 +1744,8 @@ sp_meshgradient_init(SPMeshGradient *mg) static void sp_meshgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) mg_parent_class)->build) - (* ((SPObjectClass *) mg_parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_meshgradient_parent_class)->build) + (* ((SPObjectClass *) sp_meshgradient_parent_class)->build)(object, document, repr); // Start coordinate of mesh object->readAttr( "x" ); @@ -1948,8 +1774,8 @@ sp_meshgradient_set(SPObject *object, unsigned key, gchar const *value) object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) mg_parent_class)->set) - ((SPObjectClass *) mg_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_meshgradient_parent_class)->set) + ((SPObjectClass *) sp_meshgradient_parent_class)->set(object, key, value); break; } } @@ -1973,8 +1799,8 @@ sp_meshgradient_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inksca if ((flags & SP_OBJECT_WRITE_ALL) || mg->x._set) sp_repr_set_svg_double(repr, "x", mg->x.computed); if ((flags & SP_OBJECT_WRITE_ALL) || mg->y._set) sp_repr_set_svg_double(repr, "y", mg->y.computed); - if (((SPObjectClass *) mg_parent_class)->write) - (* ((SPObjectClass *) mg_parent_class)->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_meshgradient_parent_class)->write) + (* ((SPObjectClass *) sp_meshgradient_parent_class)->write)(object, xml_doc, repr, flags); return repr; } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 7b5d56638..ce8879f70 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -76,9 +76,6 @@ #define MAGIC_EPSILON_TOO 1e-18 // TODO: also check if it is correct to be using two different epsilon values -static void sp_image_class_init (SPImageClass * klass); -static void sp_image_init (SPImage * image); - static void sp_image_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static void sp_image_release (SPObject * object); static void sp_image_set (SPObject *object, unsigned int key, const gchar *value); @@ -94,7 +91,6 @@ static Inkscape::DrawingItem *sp_image_show (SPItem *item, Inkscape::Drawing &dr static Geom::Affine sp_image_set_transform (SPItem *item, Geom::Affine const &xform); static void sp_image_set_curve(SPImage *image); - static GdkPixbuf *sp_image_repr_read_image( time_t& modTime, gchar*& pixPath, const gchar *href, const gchar *absref, const gchar *base ); static GdkPixbuf *sp_image_pixbuf_force_rgba (GdkPixbuf * pixbuf); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); @@ -102,9 +98,6 @@ static void sp_image_update_canvas_image (SPImage *image); static GdkPixbuf * sp_image_repr_read_dataURI (const gchar * uri_data); static GdkPixbuf * sp_image_repr_read_b64 (const gchar * uri_data); -static SPItemClass *parent_class; - - extern "C" { void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length ); @@ -519,33 +512,12 @@ GdkPixbuf* pixbuf_new_from_file( const char *filename, GError **error ) } } -GType sp_image_get_type(void) -{ - static GType image_type = 0; - if (!image_type) { - GTypeInfo image_info = { - sizeof (SPImageClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_image_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPImage), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_image_init, - NULL, /* value_table */ - }; - image_type = g_type_register_static (SPItem::getType (), "SPImage", &image_info, (GTypeFlags)0); - } - return image_type; -} +G_DEFINE_TYPE(SPImage, sp_image, SP_TYPE_ITEM); static void sp_image_class_init( SPImageClass * klass ) { - SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - SPItemClass *item_class = reinterpret_cast<SPItemClass *>(klass); - - parent_class = reinterpret_cast<SPItemClass*>(g_type_class_ref(SPItem::getType())); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); + SPItemClass *item_class = SP_ITEM_CLASS(klass); sp_object_class->build = sp_image_build; sp_object_class->release = sp_image_release; @@ -586,8 +558,8 @@ static void sp_image_init( SPImage *image ) static void sp_image_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_image_parent_class)->build) { + ((SPObjectClass *) sp_image_parent_class)->build (object, document, repr); } object->readAttr( "xlink:href" ); @@ -637,8 +609,8 @@ static void sp_image_release( SPObject *object ) image->curve = image->curve->unref(); } - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_image_parent_class)->release) { + ((SPObjectClass *) sp_image_parent_class)->release (object); } } @@ -756,8 +728,8 @@ static void sp_image_set( SPObject *object, unsigned int key, const gchar *value break; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) default: - if (((SPObjectClass *) (parent_class))->set) - ((SPObjectClass *) (parent_class))->set (object, key, value); + if (((SPObjectClass *) (sp_image_parent_class))->set) + ((SPObjectClass *) (sp_image_parent_class))->set (object, key, value); break; } @@ -769,8 +741,8 @@ static void sp_image_update( SPObject *object, SPCtx *ctx, unsigned int flags ) SPImage *image = SP_IMAGE(object); SPDocument *doc = object->document; - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_image_parent_class))->update) { + ((SPObjectClass *) (sp_image_parent_class))->update (object, ctx, flags); } if (flags & SP_IMAGE_HREF_MODIFIED_FLAG) { @@ -973,8 +945,8 @@ static void sp_image_modified( SPObject *object, unsigned int flags ) { SPImage *image = SP_IMAGE (object); - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if (((SPObjectClass *) (sp_image_parent_class))->modified) { + (* ((SPObjectClass *) (sp_image_parent_class))->modified) (object, flags); } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { @@ -1016,8 +988,8 @@ static Inkscape::XML::Node *sp_image_write( SPObject *object, Inkscape::XML::Doc } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_image_parent_class))->write) { + ((SPObjectClass *) (sp_image_parent_class))->write (object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index de2c79ec6..4df20b439 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -53,8 +53,6 @@ using Inkscape::DocumentUndo; -static void sp_group_class_init (SPGroupClass *klass); -static void sp_group_init (SPGroup *group); static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_group_release(SPObject *object); static void sp_group_dispose(GObject *object); @@ -77,29 +75,7 @@ static void sp_group_snappoints (SPItem const *item, std::vector<Inkscape::SnapC static void sp_group_update_patheffect(SPLPEItem *lpeitem, bool write); static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write); -static SPLPEItemClass * parent_class; - -GType -sp_group_get_type (void) -{ - static GType group_type = 0; - if (!group_type) { - GTypeInfo group_info = { - sizeof (SPGroupClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_group_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPGroup), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_group_init, - NULL, /* value_table */ - }; - group_type = g_type_register_static (SP_TYPE_LPE_ITEM, "SPGroup", &group_info, (GTypeFlags)0); - } - return group_type; -} +G_DEFINE_TYPE(SPGroup, sp_group, SP_TYPE_LPE_ITEM); static void sp_group_class_init (SPGroupClass *klass) @@ -114,8 +90,6 @@ sp_group_class_init (SPGroupClass *klass) item_class = (SPItemClass *) klass; lpe_item_class = (SPLPEItemClass *) klass; - parent_class = (SPLPEItemClass *)g_type_class_ref (SP_TYPE_LPE_ITEM); - object_class->dispose = sp_group_dispose; sp_object_class->child_added = sp_group_child_added; @@ -150,8 +124,8 @@ static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML { object->readAttr( "inkscape:groupmode" ); - if (((SPObjectClass *)parent_class)->build) { - ((SPObjectClass *)parent_class)->build(object, document, repr); + if (((SPObjectClass *)sp_group_parent_class)->build) { + ((SPObjectClass *)sp_group_parent_class)->build(object, document, repr); } } @@ -159,8 +133,8 @@ static void sp_group_release(SPObject *object) { if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) { object->document->removeResource("layer", object); } - if (((SPObjectClass *)parent_class)->release) { - ((SPObjectClass *)parent_class)->release(object); + if (((SPObjectClass *)sp_group_parent_class)->release) { + ((SPObjectClass *)sp_group_parent_class)->release(object); } } @@ -175,8 +149,8 @@ static void sp_group_child_added(SPObject *object, Inkscape::XML::Node *child, I { SPGroup *group = SP_GROUP(object); - if (((SPObjectClass *) (parent_class))->child_added) { - (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref); + if (((SPObjectClass *) (sp_group_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_group_parent_class))->child_added) (object, child, ref); } group->group->onChildAdded(child); @@ -187,8 +161,8 @@ static void sp_group_child_added(SPObject *object, Inkscape::XML::Node *child, I static void sp_group_remove_child (SPObject * object, Inkscape::XML::Node * child) { - if (((SPObjectClass *) (parent_class))->remove_child) - (* ((SPObjectClass *) (parent_class))->remove_child) (object, child); + if (((SPObjectClass *) (sp_group_parent_class))->remove_child) + (* ((SPObjectClass *) (sp_group_parent_class))->remove_child) (object, child); SP_GROUP(object)->group->onChildRemoved(child); } @@ -196,8 +170,8 @@ sp_group_remove_child (SPObject * object, Inkscape::XML::Node * child) static void sp_group_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { - if (((SPObjectClass *) (parent_class))->order_changed) - (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref); + if (((SPObjectClass *) (sp_group_parent_class))->order_changed) + (* ((SPObjectClass *) (sp_group_parent_class))->order_changed) (object, child, old_ref, new_ref); SP_GROUP(object)->group->onOrderChanged(child, old_ref, new_ref); } @@ -205,8 +179,8 @@ sp_group_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape:: static void sp_group_update (SPObject *object, SPCtx *ctx, unsigned int flags) { - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_group_parent_class))->update) + ((SPObjectClass *) (sp_group_parent_class))->update (object, ctx, flags); SP_GROUP(object)->group->onUpdate(ctx, flags); } @@ -214,8 +188,8 @@ sp_group_update (SPObject *object, SPCtx *ctx, unsigned int flags) static void sp_group_modified (SPObject *object, guint flags) { - if (((SPObjectClass *) (parent_class))->modified) - ((SPObjectClass *) (parent_class))->modified (object, flags); + if (((SPObjectClass *) (sp_group_parent_class))->modified) + ((SPObjectClass *) (sp_group_parent_class))->modified (object, flags); SP_GROUP(object)->group->onModified(flags); } @@ -269,8 +243,8 @@ static Inkscape::XML::Node * sp_group_write(SPObject *object, Inkscape::XML::Doc repr->setAttribute("inkscape:groupmode", value); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_group_parent_class))->write) { + ((SPObjectClass *) (sp_group_parent_class))->write (object, xml_doc, repr, flags); } return repr; @@ -307,8 +281,8 @@ static void sp_group_set(SPObject *object, unsigned key, char const *value) { } break; default: { - if (((SPObjectClass *) (parent_class))->set) { - (* ((SPObjectClass *) (parent_class))->set)(object, key, value); + if (((SPObjectClass *) (sp_group_parent_class))->set) { + (* ((SPObjectClass *) (sp_group_parent_class))->set)(object, key, value); } } } @@ -787,8 +761,8 @@ void CGroup::hide (unsigned int key) { l = g_slist_remove (l, o); } - if (((SPItemClass *) parent_class)->hide) - ((SPItemClass *) parent_class)->hide (_group, key); + if (((SPItemClass *) sp_group_parent_class)->hide) + ((SPItemClass *) sp_group_parent_class)->hide (_group, key); } void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *, Inkscape::XML::Node *) diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 559ff80ac..19d71ed44 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -75,53 +75,52 @@ #define noSP_ITEM_DEBUG_IDLE -SPObjectClass * SPItemClass::static_parent_class=0; - -/** - * Registers SPItem class and returns its type number. - */ -GType -SPItem::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPItemClass), - NULL, NULL, - (GClassInitFunc) SPItemClass::sp_item_class_init, - NULL, NULL, - sizeof(SPItem), - 16, - (GInstanceInitFunc) sp_item_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPItem", &info, (GTypeFlags)0); - } - return type; -} +static void sp_item_build (SPObject *object, + SPDocument *document, + Inkscape::XML::Node *repr); +static void sp_item_release(SPObject *object); +static void sp_item_set (SPObject *object, + unsigned key, + gchar const *value); +static void sp_item_update (SPObject *object, + SPCtx *ctx, + guint flags); +static Inkscape::XML::Node* sp_item_write (SPObject *object, + Inkscape::XML::Document *doc, + Inkscape::XML::Node *repr, + guint flags); + +static SPItemView* sp_item_view_list_remove(SPItemView *list, + SPItemView *view); + +static gchar *sp_item_private_description(SPItem *item); +static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + +G_DEFINE_TYPE(SPItem, sp_item, SP_TYPE_OBJECT); /** * SPItem vtable initialization. */ -void SPItemClass::sp_item_class_init(SPItemClass *klass) +static void +sp_item_class_init(SPItemClass *klass) { SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); - static_parent_class = SP_OBJECT_CLASS(g_type_class_ref(SP_TYPE_OBJECT)); - sp_object_class->build = SPItem::sp_item_build; - sp_object_class->release = SPItem::sp_item_release; - sp_object_class->set = SPItem::sp_item_set; - sp_object_class->update = SPItem::sp_item_update; - sp_object_class->write = SPItem::sp_item_write; + sp_object_class->build = sp_item_build; + sp_object_class->release = sp_item_release; + sp_object_class->set = sp_item_set; + sp_object_class->update = sp_item_update; + sp_object_class->write = sp_item_write; - klass->description = SPItem::sp_item_private_description; - klass->snappoints = SPItem::sp_item_private_snappoints; + klass->description = sp_item_private_description; + klass->snappoints = sp_item_private_snappoints; } /** * Callback for SPItem object initialization. */ -void SPItem::sp_item_init(SPItem *item) +static void +sp_item_init(SPItem *item) { item->init(); } @@ -412,7 +411,8 @@ void SPItem::moveTo(SPItem *target, gboolean intoafter) { } -void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void +sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "style" ); object->readAttr( "transform" ); @@ -425,12 +425,13 @@ void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); - if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build) { - (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build)(object, document, repr); + if ((SP_OBJECT_CLASS(sp_item_parent_class))->build) { + (* (SP_OBJECT_CLASS(sp_item_parent_class))->build)(object, document, repr); } } -void SPItem::sp_item_release(SPObject *object) +static void +sp_item_release(SPObject *object) { SPItem *item = SP_ITEM(object); @@ -445,8 +446,8 @@ void SPItem::sp_item_release(SPObject *object) delete item->clip_ref; delete item->mask_ref; - if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release) { - (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release(object); + if ((SP_OBJECT_CLASS(sp_item_parent_class))->release) { + (SP_OBJECT_CLASS(sp_item_parent_class))->release(object); } while (item->display) { @@ -456,7 +457,8 @@ void SPItem::sp_item_release(SPObject *object) item->_transformed_signal.~signal(); } -void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) +static void +sp_item_set(SPObject *object, unsigned key, gchar const *value) { SPItem *item = SP_ITEM(object); @@ -539,8 +541,8 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set) { - (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set)(object, key, value); + if ((SP_OBJECT_CLASS(sp_item_parent_class))->set) { + (* (SP_OBJECT_CLASS(sp_item_parent_class))->set)(object, key, value); } } break; @@ -597,12 +599,13 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_item_update(SPObject *object, SPCtx *ctx, guint flags) { SPItem *item = SP_ITEM(object); - if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update) { - (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update)(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_item_parent_class))->update) { + (* (SP_OBJECT_CLASS(sp_item_parent_class))->update)(object, ctx, flags); } // any of the modifications defined in sp-object.h might change bbox, @@ -657,7 +660,8 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) item->avoidRef->handleSettingChange(); } -Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPItem *item = SP_ITEM(object); @@ -717,8 +721,8 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML } } - if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write) { - (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_item_parent_class))->write) { + (SP_OBJECT_CLASS(sp_item_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -898,7 +902,8 @@ unsigned SPItem::pos_in_parent() return 0; } -void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector<Inkscape::SnapCandidatePoint> &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) +static void +sp_item_private_snappoints(SPItem const * /*item*/, std::vector<Inkscape::SnapCandidatePoint> &/*p*/, Inkscape::SnapPreferences const * /*snapprefs*/) { /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp @@ -966,7 +971,8 @@ void SPItem::invoke_print(SPPrintContext *ctx) } } -gchar *SPItem::sp_item_private_description(SPItem */*item*/) +static gchar* +sp_item_private_description(SPItem * /*item*/) { return g_strdup(_("Object")); } @@ -1558,7 +1564,8 @@ SPItemView *SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, uns return new_view; } -SPItemView *SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) +static SPItemView* +sp_item_view_list_remove(SPItemView *list, SPItemView *view) { SPItemView *ret = list; if (view == list) { diff --git a/src/sp-item.h b/src/sp-item.h index 2c7bd5a5d..85ef3531e 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -101,16 +101,16 @@ public: class SPItem; class SPItemClass; -#define SP_TYPE_ITEM (SPItem::getType ()) +#define SP_TYPE_ITEM (sp_item_get_type ()) #define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) #define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) #define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) +GType sp_item_get_type() G_GNUC_CONST; /** Abstract base class for all visible shapes. */ class SPItem : public SPObject { public: - static GType getType(); enum BBoxType { // legacy behavior: includes crude stroke, markers; excludes long miters, blur margin; is known to be wrong for caps APPROXIMATE_BBOX, @@ -227,19 +227,7 @@ private: mutable bool _is_evaluated; mutable EvaluatedStatus _evaluated_status; - static void sp_item_init(SPItem *item); - - static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void sp_item_release(SPObject *object); - static void sp_item_set(SPObject *object, unsigned key, gchar const *value); - static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); - static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - static gchar *sp_item_private_description(SPItem *item); - static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, Inkscape::DrawingItem *arenaitem); - static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); @@ -278,11 +266,8 @@ public: /** Emit event, if applicable */ gint (* event) (SPItem *item, SPEvent *event); - private: - static SPObjectClass *static_parent_class; - static void sp_item_class_init(SPItemClass *klass); - - friend class SPItem; +private: + friend class SPItem; }; // Utility diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 06604a1d6..218d0c3b1 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -24,51 +24,38 @@ #include "document.h" #include "inkscape.h" -SPShapeClass * SPLineClass::static_parent_class = 0; - -GType SPLine::sp_line_get_type(void) -{ - static GType line_type = 0; - - if (!line_type) { - GTypeInfo line_info = { - sizeof(SPLineClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) SPLineClass::sp_line_class_init, - NULL, /* klass_finalize */ - NULL, /* klass_data */ - sizeof(SPLine), - 16, /* n_preallocs */ - (GInstanceInitFunc) init, - NULL, /* value_table */ - }; - line_type = g_type_register_static(SP_TYPE_SHAPE, "SPLine", &line_info,(GTypeFlags)0); - } - return line_type; -} - -void SPLineClass::sp_line_class_init(SPLineClass *klass) +static void sp_line_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +static void sp_line_set(SPObject *object, unsigned int key, const gchar *value); +static Inkscape::XML::Node* sp_line_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static void sp_line_update(SPObject *object, SPCtx *ctx, guint flags); +static gchar* sp_line_get_description(SPItem * item); +static Geom::Affine sp_line_set_transform(SPItem *item, Geom::Affine const &xform); +static void sp_line_set_shape(SPShape *shape); +static void sp_line_convert_to_guides(SPItem *item); + +G_DEFINE_TYPE(SPLine, sp_line, SP_TYPE_SHAPE); + +static void +sp_line_class_init(SPLineClass *klass) { - SPLineClass::static_parent_class = (SPShapeClass *) g_type_class_ref(SP_TYPE_SHAPE); - SPObjectClass *sp_object_class = (SPObjectClass *) klass; - sp_object_class->build = SPLine::build; - sp_object_class->set = SPLine::set; - sp_object_class->write = SPLine::write; + SPItemClass *item_class = (SPItemClass *) klass; + SPShapeClass *shape_class = (SPShapeClass *) klass; - SPItemClass *item_class = (SPItemClass *) klass; - item_class->description = SPLine::getDescription; - item_class->set_transform = SPLine::setTransform; - item_class->convert_to_guides = SPLine::convertToGuides; + sp_object_class->build = sp_line_build; + sp_object_class->set = sp_line_set; + sp_object_class->write = sp_line_write; + sp_object_class->update = sp_line_update; - sp_object_class->update = SPLine::update; + item_class->description = sp_line_get_description; + item_class->set_transform = sp_line_set_transform; + item_class->convert_to_guides = sp_line_convert_to_guides; - SPShapeClass *shape_class = (SPShapeClass *) klass; - shape_class->set_shape = SPLine::setShape; + shape_class->set_shape = sp_line_set_shape; } -void SPLine::init(SPLine * line) +static void +sp_line_init(SPLine * line) { line->x1.unset(); line->y1.unset(); @@ -77,10 +64,11 @@ void SPLine::init(SPLine * line) } -void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +static void +sp_line_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { - ((SPObjectClass *) SPLineClass::static_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_line_parent_class)->build) { + ((SPObjectClass *) sp_line_parent_class)->build(object, document, repr); } object->readAttr( "x1" ); @@ -89,7 +77,8 @@ void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node object->readAttr( "y2" ); } -void SPLine::set(SPObject *object, unsigned int key, const gchar *value) +static void +sp_line_set(SPObject *object, unsigned int key, const gchar *value) { SPLine * line = SP_LINE(object); @@ -113,14 +102,15 @@ void SPLine::set(SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) SPLineClass::static_parent_class)->set) { - ((SPObjectClass *) SPLineClass::static_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_line_parent_class)->set) { + ((SPObjectClass *) sp_line_parent_class)->set(object, key, value); } break; } } -void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) +static void +sp_line_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPLine *line = SP_LINE(object); @@ -139,13 +129,14 @@ void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) ((SPShape *) object)->setShape(); } - if (((SPObjectClass *) SPLineClass::static_parent_class)->update) { - ((SPObjectClass *) SPLineClass::static_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_line_parent_class)->update) { + ((SPObjectClass *) sp_line_parent_class)->update(object, ctx, flags); } } -Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_line_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPLine *line = SP_LINE(object); @@ -162,19 +153,21 @@ Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *x sp_repr_set_svg_double(repr, "x2", line->x2.computed); sp_repr_set_svg_double(repr, "y2", line->y2.computed); - if (((SPObjectClass *) (SPLineClass::static_parent_class))->write) { - ((SPObjectClass *) (SPLineClass::static_parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_line_parent_class))->write) { + ((SPObjectClass *) (sp_line_parent_class))->write(object, xml_doc, repr, flags); } return repr; } -gchar * SPLine::getDescription(SPItem */*item*/) +static gchar* +sp_line_get_description(SPItem * /*item*/) { return g_strdup(_("<b>Line</b>")); } -void SPLine::convertToGuides(SPItem *item) +static void +sp_line_convert_to_guides(SPItem *item) { SPLine *line = SP_LINE(item); Geom::Point points[2]; @@ -187,7 +180,8 @@ void SPLine::convertToGuides(SPItem *item) SPGuide::createSPGuide(item->document, points[0], points[1]); } -Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) +static Geom::Affine +sp_line_set_transform(SPItem *item, Geom::Affine const &xform) { SPLine *line = SP_LINE(item); Geom::Point points[2]; @@ -210,7 +204,8 @@ Geom::Affine SPLine::setTransform(SPItem *item, Geom::Affine const &xform) return Geom::identity(); } -void SPLine::setShape(SPShape *shape) +static void +sp_line_set_shape(SPShape *shape) { SPLine *line = SP_LINE(shape); diff --git a/src/sp-line.h b/src/sp-line.h index 182f85a5c..836b2df67 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -19,7 +19,7 @@ -#define SP_TYPE_LINE (SPLine::sp_line_get_type()) +#define SP_TYPE_LINE (sp_line_get_type()) #define SP_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_LINE, SPLine)) #define SP_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_LINE, SPLineClass)) #define SP_IS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_LINE)) @@ -28,28 +28,16 @@ class SPLine; class SPLineClass; +GType sp_line_get_type(void) G_GNUC_CONST; + class SPLine : public SPShape { public: SVGLength x1; SVGLength y1; SVGLength x2; SVGLength y2; - static GType sp_line_get_type(void); private: - static void init(SPLine *line); - - static void build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void set(SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - static gchar *getDescription(SPItem * item); - static Geom::Affine setTransform(SPItem *item, Geom::Affine const &xform); - - static void update(SPObject *object, SPCtx *ctx, guint flags); - static void setShape(SPShape *shape); - static void convertToGuides(SPItem *item); - friend class SPLineClass; }; @@ -58,9 +46,6 @@ public: SPShapeClass parent_class; private: - static SPShapeClass *static_parent_class; - static void sp_line_class_init(SPLineClass *klass); - friend class SPLine; }; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 3b8999eda..e8629ff70 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -39,9 +39,6 @@ #include <algorithm> /* LPEItem base class */ - -static void sp_lpe_item_class_init(SPLPEItemClass *klass); -static void sp_lpe_item_init(SPLPEItem *lpe_item); static void sp_lpe_item_finalize(GObject *object); static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -64,34 +61,12 @@ typedef std::list<std::string> HRefList; static std::string patheffectlist_write_svg(PathEffectList const & list); static std::string hreflist_write_svg(HRefList const & list); -static SPItemClass *parent_class; - -GType -sp_lpe_item_get_type() -{ - static GType lpe_item_type = 0; - - if (!lpe_item_type) { - GTypeInfo lpe_item_info = { - sizeof(SPLPEItemClass), - NULL, NULL, - (GClassInitFunc) sp_lpe_item_class_init, - NULL, NULL, - sizeof(SPLPEItem), - 16, - (GInstanceInitFunc) sp_lpe_item_init, - NULL, /* value_table */ - }; - lpe_item_type = g_type_register_static(SP_TYPE_ITEM, "SPLPEItem", &lpe_item_info, (GTypeFlags)0); - } - return lpe_item_type; -} +G_DEFINE_TYPE(SPLPEItem, sp_lpe_item, SP_TYPE_ITEM); static void sp_lpe_item_class_init(SPLPEItemClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); - parent_class = SP_ITEM_CLASS(g_type_class_peek_parent(klass)); gobject_class->finalize = sp_lpe_item_finalize; sp_object_class->build = sp_lpe_item_build; @@ -119,8 +94,8 @@ sp_lpe_item_init(SPLPEItem *lpeitem) static void sp_lpe_item_finalize(GObject *object) { - if (((GObjectClass *) (parent_class))->finalize) { - (* ((GObjectClass *) (parent_class))->finalize)(object); + if (((GObjectClass *) (sp_lpe_item_parent_class))->finalize) { + (* ((GObjectClass *) (sp_lpe_item_parent_class))->finalize)(object); } } @@ -133,8 +108,8 @@ static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape:: { object->readAttr( "inkscape:path-effect" ); - if ((SP_OBJECT_CLASS(parent_class))->build) { - (SP_OBJECT_CLASS(parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->build) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->build(object, document, repr); } } @@ -165,8 +140,8 @@ static void sp_lpe_item_release(SPObject *object) delete lpeitem->path_effect_list; lpeitem->path_effect_list = NULL; - if ((SP_OBJECT_CLASS(parent_class))->release) - (SP_OBJECT_CLASS(parent_class))->release(object); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->release) + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->release(object); } /** @@ -234,8 +209,8 @@ static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *val } break; default: - if ((SP_OBJECT_CLASS(parent_class))->set) { - (SP_OBJECT_CLASS(parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->set) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->set(object, key, value); } break; } @@ -247,8 +222,8 @@ static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *val static void sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags) { - if ((SP_OBJECT_CLASS(parent_class))->update) { - (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->update) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->update(object, ctx, flags); } // update the helperpaths of all LPEs applied to the item @@ -264,8 +239,8 @@ static void sp_lpe_item_modified (SPObject *object, unsigned int flags) sp_lpe_item_update_patheffect(SP_LPE_ITEM(object), true, true); } - if ((SP_OBJECT_CLASS(parent_class))->modified) { - (* (SP_OBJECT_CLASS(parent_class))->modified) (object, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->modified) { + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->modified) (object, flags); } } @@ -285,8 +260,8 @@ static Inkscape::XML::Node * sp_lpe_item_write(SPObject *object, Inkscape::XML:: } } - if ((SP_OBJECT_CLASS(parent_class))->write) { - (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->write) { + (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -666,8 +641,8 @@ void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt) static void sp_lpe_item_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if ((SP_OBJECT_CLASS(parent_class))->child_added) - (* (SP_OBJECT_CLASS(parent_class))->child_added) (object, child, ref); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->child_added) + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->child_added) (object, child, ref); if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) { SPObject *ochild = object->get_child_by_repr(child); @@ -686,8 +661,8 @@ static void sp_lpe_item_remove_child(SPObject * object, Inkscape::XML::Node * ch } } - if ((SP_OBJECT_CLASS(parent_class))->remove_child) - (* (SP_OBJECT_CLASS(parent_class))->remove_child) (object, child); + if ((SP_OBJECT_CLASS(sp_lpe_item_parent_class))->remove_child) + (* (SP_OBJECT_CLASS(sp_lpe_item_parent_class))->remove_child) (object, child); } static std::string patheffectlist_write_svg(PathEffectList const & list) diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 785a626f8..4243c9811 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -34,9 +34,6 @@ struct SPMaskView { Geom::OptRect bbox; }; -static void sp_mask_class_init (SPMaskClass *klass); -static void sp_mask_init (SPMask *mask); - static void sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_mask_release (SPObject * object); static void sp_mask_set (SPObject *object, unsigned int key, const gchar *value); @@ -48,33 +45,11 @@ static Inkscape::XML::Node *sp_mask_write (SPObject *object, Inkscape::XML::Docu SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view); -static SPObjectGroupClass *parent_class; - -GType -sp_mask_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPMaskClass), - NULL, NULL, - (GClassInitFunc) sp_mask_class_init, - NULL, NULL, - sizeof (SPMask), - 16, - (GInstanceInitFunc) sp_mask_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_OBJECTGROUP, "SPMask", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPMask, sp_mask, SP_TYPE_OBJECTGROUP); static void sp_mask_class_init (SPMaskClass *klass) { - parent_class = SP_OBJECTGROUP_CLASS(g_type_class_ref(SP_TYPE_OBJECTGROUP)); - SPObjectClass *sp_object_class = (SPObjectClass *) klass; sp_object_class->build = sp_mask_build; sp_object_class->release = sp_mask_release; @@ -100,8 +75,8 @@ sp_mask_init (SPMask *mask) static void sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_mask_parent_class)->build) { + ((SPObjectClass *) sp_mask_parent_class)->build (object, document, repr); } object->readAttr( "maskUnits" ); @@ -124,8 +99,8 @@ static void sp_mask_release (SPObject * object) cp->display = sp_mask_view_list_remove (cp->display, cp->display); } - if (((SPObjectClass *) (parent_class))->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) (sp_mask_parent_class))->release) { + ((SPObjectClass *) sp_mask_parent_class)->release (object); } } @@ -162,8 +137,8 @@ sp_mask_set (SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_mask_parent_class)->set) + ((SPObjectClass *) sp_mask_parent_class)->set (object, key, value); break; } } @@ -172,7 +147,7 @@ static void sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /* Invoke SPObjectGroup implementation */ - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + ((SPObjectClass *) (sp_mask_parent_class))->child_added (object, child, ref); /* Show new object */ SPObject *ochild = object->document->getObjectByRepr(child); @@ -258,8 +233,8 @@ sp_mask_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML repr = xml_doc->createElement("svg:mask"); } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_mask_parent_class))->write) + ((SPObjectClass *) (sp_mask_parent_class))->write (object, xml_doc, repr, flags); return repr; } diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 831bb5a70..9978d0a3a 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -33,46 +33,19 @@ /* Metadata base class */ -static void sp_metadata_class_init (SPMetadataClass *klass); -static void sp_metadata_init (SPMetadata *metadata); - static void sp_metadata_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static void sp_metadata_release (SPObject *object); static void sp_metadata_set (SPObject *object, unsigned int key, const gchar *value); static void sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_metadata_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *metadata_parent_class; - -GType -sp_metadata_get_type (void) -{ - static GType metadata_type = 0; - - if (!metadata_type) { - GTypeInfo metadata_info = { - sizeof (SPMetadataClass), - NULL, NULL, - (GClassInitFunc) sp_metadata_class_init, - NULL, NULL, - sizeof (SPMetadata), - 16, - (GInstanceInitFunc) sp_metadata_init, - NULL, /* value_table */ - }; - metadata_type = g_type_register_static (SP_TYPE_OBJECT, "SPMetadata", &metadata_info, (GTypeFlags)0); - } - return metadata_type; -} +G_DEFINE_TYPE(SPMetadata, sp_metadata, SP_TYPE_OBJECT); static void sp_metadata_class_init (SPMetadataClass *klass) { - //GObjectClass *gobject_class = (GObjectClass *)klass; SPObjectClass *sp_object_class = (SPObjectClass *)klass; - metadata_parent_class = (SPObjectClass*)g_type_class_peek_parent (klass); - sp_object_class->build = sp_metadata_build; sp_object_class->release = sp_metadata_release; sp_object_class->write = sp_metadata_write; @@ -123,8 +96,8 @@ static void sp_metadata_build(SPObject *object, SPDocument *document, Inkscape:: } } - if (((SPObjectClass *) metadata_parent_class)->build) - ((SPObjectClass *) metadata_parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_metadata_parent_class)->build) + ((SPObjectClass *) sp_metadata_parent_class)->build (object, document, repr); } /** @@ -136,8 +109,8 @@ static void sp_metadata_release(SPObject *object) // handle ourself - if (((SPObjectClass *) metadata_parent_class)->release) - ((SPObjectClass *) metadata_parent_class)->release (object); + if (((SPObjectClass *) sp_metadata_parent_class)->release) + ((SPObjectClass *) sp_metadata_parent_class)->release (object); } /** @@ -150,8 +123,8 @@ static void sp_metadata_set(SPObject *object, unsigned int key, const gchar *val SP_METADATA(object); // ensures the object is of the proper type. // see if any parents need this value - if (reinterpret_cast<SPObjectClass *>(metadata_parent_class)->set) { - reinterpret_cast<SPObjectClass *>(metadata_parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_metadata_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_metadata_parent_class)->set(object, key, value); } } @@ -170,8 +143,8 @@ static void sp_metadata_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) metadata_parent_class)->update) - ((SPObjectClass *) metadata_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_metadata_parent_class)->update) + ((SPObjectClass *) sp_metadata_parent_class)->update(object, ctx, flags); } /** @@ -190,8 +163,8 @@ static Inkscape::XML::Node *sp_metadata_write(SPObject *object, Inkscape::XML::D } } - if (((SPObjectClass *) metadata_parent_class)->write) { - ((SPObjectClass *) metadata_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_metadata_parent_class)->write) { + ((SPObjectClass *) sp_metadata_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index fdf75253e..bdf993e5b 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -21,45 +21,17 @@ #include "sp-missing-glyph.h" #include "document.h" -static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc); -static void sp_missing_glyph_init(SPMissingGlyph *glyph); - static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_missing_glyph_release(SPObject *object); static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar *value); static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *parent_class; - -GType sp_missing_glyph_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPMissingGlyphClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_missing_glyph_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPMissingGlyph), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_missing_glyph_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPMissingGlyph", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPMissingGlyph, sp_missing_glyph, SP_TYPE_OBJECT); static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc) { SPObjectClass *sp_object_class = (SPObjectClass *) gc; - parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); - sp_object_class->build = sp_missing_glyph_build; sp_object_class->release = sp_missing_glyph_release; sp_object_class->set = sp_missing_glyph_set; @@ -78,8 +50,8 @@ static void sp_missing_glyph_init(SPMissingGlyph *glyph) static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->build) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->build(object, document, repr); } object->readAttr( "d" ); @@ -93,8 +65,8 @@ static void sp_missing_glyph_release(SPObject *object) { //SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_missing_glyph_parent_class)->release) { + ((SPObjectClass *) sp_missing_glyph_parent_class)->release(object); } } @@ -150,8 +122,8 @@ static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar } default: { - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->set) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->set(object, key, value); } break; } @@ -186,8 +158,8 @@ static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::X COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_missing_glyph_parent_class))->write) { + ((SPObjectClass *) (sp_missing_glyph_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 2f158df9d..f417dd275 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -49,9 +49,6 @@ using Inkscape::DocumentUndo; #define DEFAULTBORDERCOLOR 0x000000ff #define DEFAULTPAGECOLOR 0xffffff00 -static void sp_namedview_class_init(SPNamedViewClass *klass); -static void sp_namedview_init(SPNamedView *namedview); - static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_namedview_release(SPObject *object); static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value); @@ -65,35 +62,11 @@ static void sp_namedview_show_single_guide(SPGuide* guide, bool show); static gboolean sp_str_to_bool(const gchar *str); static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); -static SPObjectGroupClass * parent_class; - -GType -sp_namedview_get_type() -{ - static GType namedview_type = 0; - if (!namedview_type) { - GTypeInfo namedview_info = { - sizeof(SPNamedViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_namedview_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPNamedView), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_namedview_init, - NULL, /* value_table */ - }; - namedview_type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPNamedView", &namedview_info, (GTypeFlags)0); - } - return namedview_type; -} +G_DEFINE_TYPE(SPNamedView, sp_namedview, SP_TYPE_OBJECTGROUP); static void sp_namedview_class_init(SPNamedViewClass * klass) { - SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - - parent_class = reinterpret_cast<SPObjectGroupClass *>(g_type_class_ref(SP_TYPE_OBJECTGROUP)); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); sp_object_class->build = sp_namedview_build; sp_object_class->release = sp_namedview_release; @@ -215,8 +188,8 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: SPNamedView *nv = (SPNamedView *) object; SPObjectGroup *og = (SPObjectGroup *) object; - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); + if (((SPObjectClass *) (sp_namedview_parent_class))->build) { + (* ((SPObjectClass *) (sp_namedview_parent_class))->build)(object, document, repr); } object->readAttr( "inkscape:document-units" ); @@ -303,8 +276,8 @@ static void sp_namedview_release(SPObject *object) namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry } - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_namedview_parent_class)->release) { + ((SPObjectClass *) sp_namedview_parent_class)->release(object); } namedview->snap_manager.~SnapManager(); @@ -624,8 +597,8 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va break; } default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if (((SPObjectClass *) (sp_namedview_parent_class))->set) { + ((SPObjectClass *) (sp_namedview_parent_class))->set(object, key, value); } break; } @@ -676,8 +649,8 @@ static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *chil { SPNamedView *nv = (SPNamedView *) object; - if (((SPObjectClass *) (parent_class))->child_added) { - (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); + if (((SPObjectClass *) (sp_namedview_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_namedview_parent_class))->child_added)(object, child, ref); } if (!strcmp(child->name(), "inkscape:grid")) { @@ -730,8 +703,8 @@ static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *chi } } - if (((SPObjectClass *) (parent_class))->remove_child) { - (* ((SPObjectClass *) (parent_class))->remove_child)(object, child); + if (((SPObjectClass *) (sp_namedview_parent_class))->remove_child) { + (* ((SPObjectClass *) (sp_namedview_parent_class))->remove_child)(object, child); } } diff --git a/src/sp-namedview.h b/src/sp-namedview.h index e83ead69e..8191ef6d6 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -25,6 +25,8 @@ #include "snap.h" #include "document.h" +G_BEGIN_DECLS + struct SPUnit; namespace Inkscape { @@ -112,6 +114,8 @@ void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr); void sp_namedview_show_grids(SPNamedView *namedview, bool show, bool dirty_document); Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedview); +G_END_DECLS + #endif /* !INKSCAPE_SP_NAMEDVIEW_H */ diff --git a/src/sp-object.h b/src/sp-object.h index b3f3e6c2f..5828eda13 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -800,10 +800,7 @@ private: public: - /** - * Registers the SPObject class with Gdk and returns its type number. - */ - static GType get_type(); + static GType get_type() {return sp_object_get_type();} /** * Callback for attr_changed node event. diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index bc8a46252..95511aea3 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -68,8 +68,6 @@ class SPDocument; * radius (look in object-edit). */ -static void sp_offset_class_init (SPOffsetClass * klass); -static void sp_offset_init (SPOffset * offset); static void sp_offset_finalize(GObject *obj); static void sp_offset_build (SPObject * object, SPDocument * document, @@ -102,38 +100,7 @@ static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *i // reappearing in offset when the radius becomes too large static bool use_slow_but_correct_offset_method=false; - -// nothing special here, same for every class in sodipodi/inkscape -static SPShapeClass *parent_class; - -/** - * Register SPOffset class and return its type number. - */ -GType -sp_offset_get_type (void) -{ - static GType offset_type = 0; - - if (!offset_type) - { - GTypeInfo offset_info = { - sizeof (SPOffsetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_offset_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPOffset), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_offset_init, - NULL, /* value_table */ - }; - offset_type = - g_type_register_static (SP_TYPE_SHAPE, "SPOffset", &offset_info, - (GTypeFlags) 0); - } - return offset_type; -} +G_DEFINE_TYPE(SPOffset, sp_offset, SP_TYPE_SHAPE); /** * SPOffset vtable initialization. @@ -146,8 +113,6 @@ sp_offset_class_init(SPOffsetClass *klass) SPItemClass *item_class = (SPItemClass *) klass; SPShapeClass *shape_class = (SPShapeClass *) klass; - parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); - gobject_class->finalize = sp_offset_finalize; sp_object_class->build = sp_offset_build; @@ -213,8 +178,8 @@ sp_offset_finalize(GObject *obj) static void sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_offset_parent_class)->build) + ((SPObjectClass *) sp_offset_parent_class)->build (object, document, repr); //XML Tree being used directly here while it shouldn't be. if (object->getRepr()->attribute("inkscape:radius")) { @@ -290,8 +255,8 @@ sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM repr->setAttribute("d", d); g_free (d); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, + if (((SPObjectClass *) (sp_offset_parent_class))->write) + ((SPObjectClass *) (sp_offset_parent_class))->write (object, xml_doc, repr, flags | SP_SHAPE_WRITE_PATH); return repr; @@ -317,8 +282,8 @@ sp_offset_release(SPObject *object) offset->sourceHref = NULL; offset->sourceRef->detach(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_offset_parent_class)->release) { + ((SPObjectClass *) sp_offset_parent_class)->release (object); } } @@ -389,8 +354,8 @@ sp_offset_set(SPObject *object, unsigned key, gchar const *value) } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_offset_parent_class)->set) + ((SPObjectClass *) sp_offset_parent_class)->set (object, key, value); break; } } @@ -411,8 +376,8 @@ sp_offset_update(SPObject *object, SPCtx *ctx, guint flags) } offset->isUpdating=false; - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if (((SPObjectClass *) sp_offset_parent_class)->update) + ((SPObjectClass *) sp_offset_parent_class)->update (object, ctx, flags); } /** @@ -725,8 +690,8 @@ sp_offset_set_shape(SPShape *shape) */ static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - if (((SPItemClass *) parent_class)->snappoints) { - ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs); + if (((SPItemClass *) sp_offset_parent_class)->snappoints) { + ((SPItemClass *) sp_offset_parent_class)->snappoints (item, p, snapprefs); } } diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index ae4a60ba6..298b39117 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -20,12 +20,8 @@ #include "sp-gradient.h" #include "xml/node.h" -static void sp_paint_server_class_init(SPPaintServerClass *psc); - static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); -static SPObjectClass *parent_class; - SPPaintServer *SPPaintServerReference::getObject() const { return static_cast<SPPaintServer *>(URIReference::getObject()); @@ -36,35 +32,15 @@ bool SPPaintServerReference::_acceptObject(SPObject *obj) const return SP_IS_PAINT_SERVER(obj); } -GType SPPaintServer::get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPaintServerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_paint_server_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPPaintServer), - 16, /* n_preallocs */ - (GInstanceInitFunc) SPPaintServer::init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPPaintServer", &info, (GTypeFlags) 0); - } - return type; -} +G_DEFINE_TYPE(SPPaintServer, sp_paint_server, SP_TYPE_OBJECT); static void sp_paint_server_class_init(SPPaintServerClass *psc) { psc->pattern_new = sp_paint_server_create_dummy_pattern; - - parent_class = static_cast<SPObjectClass *>(g_type_class_ref(SP_TYPE_OBJECT)); } -void SPPaintServer::init(SPPaintServer * /*ps*/) +static void +sp_paint_server_init(SPPaintServer * /*ps*/) { } diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index a266ee5a5..f4948dfdb 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -20,24 +20,21 @@ #include "sp-object.h" #include "uri-references.h" -#define SP_TYPE_PAINT_SERVER (SPPaintServer::get_type()) +#define SP_TYPE_PAINT_SERVER (sp_paint_server_get_type()) #define SP_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PAINT_SERVER, SPPaintServer)) #define SP_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_PAINT_SERVER, SPPaintServerClass)) #define SP_IS_PAINT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PAINT_SERVER)) #define SP_IS_PAINT_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_PAINT_SERVER)) +GType sp_paint_server_get_type(void) G_GNUC_CONST; + struct SPPaintServer : public SPObject { protected: bool swatch; public: - static GType get_type(void); - bool isSwatch() const; bool isSolid() const; - -private: - static void init(SPPaintServer *ps); }; struct SPPaintServerClass { diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 107ceac16..478a689e3 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -51,8 +51,6 @@ #define noPATH_VERBOSE -static void sp_path_class_init(SPPathClass *klass); -static void sp_path_init(SPPath *path); static void sp_path_finalize(GObject *obj); static void sp_path_release(SPObject *object); @@ -67,31 +65,7 @@ static void sp_path_convert_to_guides(SPItem *item); static void sp_path_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_path_update_patheffect(SPLPEItem *lpeitem, bool write); -static SPShapeClass *parent_class; - -/** - * Gets the GType object for SPPathClass - */ -GType -sp_path_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPPathClass), - NULL, NULL, - (GClassInitFunc) sp_path_class_init, - NULL, NULL, - sizeof(SPPath), - 16, - (GInstanceInitFunc) sp_path_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_SHAPE, "SPPath", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPPath, sp_path, SP_TYPE_SHAPE); /** * Does the object-oriented work of initializing the class structure @@ -106,8 +80,6 @@ sp_path_class_init(SPPathClass * klass) SPItemClass *item_class = (SPItemClass *) klass; SPLPEItemClass *lpe_item_class = (SPLPEItemClass *) klass; - parent_class = (SPShapeClass *)g_type_class_peek_parent(klass); - gobject_class->finalize = sp_path_finalize; sp_object_class->build = sp_path_build; @@ -216,8 +188,8 @@ sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) sp_conn_end_pair_build(object); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_path_parent_class)->build) { + ((SPObjectClass *) sp_path_parent_class)->build(object, document, repr); } object->readAttr( "inkscape:original-d" ); @@ -237,8 +209,8 @@ sp_path_release(SPObject *object) path->connEndPair.release(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_path_parent_class)->release) { + ((SPObjectClass *) sp_path_parent_class)->release(object); } } @@ -294,8 +266,8 @@ sp_path_set(SPObject *object, unsigned int key, gchar const *value) path->connEndPair.setAttr(key, value); break; default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_path_parent_class)->set) { + ((SPObjectClass *) sp_path_parent_class)->set(object, key, value); } break; } @@ -337,8 +309,8 @@ g_message("sp_path_write writes 'd' attribute"); SP_PATH(shape)->connEndPair.writeRepr(repr); - if (((SPObjectClass *)(parent_class))->write) { - ((SPObjectClass *)(parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *)(sp_path_parent_class))->write) { + ((SPObjectClass *)(sp_path_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -351,8 +323,8 @@ sp_path_update(SPObject *object, SPCtx *ctx, guint flags) flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_path_parent_class)->update) { + ((SPObjectClass *) sp_path_parent_class)->update(object, ctx, flags); } SPPath *path = SP_PATH(object); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index f18199e96..754a75e87 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -40,10 +40,6 @@ /* * Pattern */ - -static void sp_pattern_class_init (SPPatternClass *klass); -static void sp_pattern_init (SPPattern *gr); - static void sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_pattern_release (SPObject *object); static void sp_pattern_set (SPObject *object, unsigned int key, const gchar *value); @@ -55,29 +51,7 @@ static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); -static SPPaintServerClass * pattern_parent_class; - -GType -sp_pattern_get_type (void) -{ - static GType pattern_type = 0; - if (!pattern_type) { - GTypeInfo pattern_info = { - sizeof (SPPatternClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_pattern_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPPattern), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_pattern_init, - NULL, /* value_table */ - }; - pattern_type = g_type_register_static (SP_TYPE_PAINT_SERVER, "SPPattern", &pattern_info, (GTypeFlags)0); - } - return pattern_type; -} +G_DEFINE_TYPE(SPPattern, sp_pattern, SP_TYPE_PAINT_SERVER); static void sp_pattern_class_init (SPPatternClass *klass) @@ -88,8 +62,6 @@ sp_pattern_class_init (SPPatternClass *klass) sp_object_class = (SPObjectClass *) klass; ps_class = (SPPaintServerClass *) klass; - pattern_parent_class = (SPPaintServerClass*)g_type_class_ref (SP_TYPE_PAINT_SERVER); - sp_object_class->build = sp_pattern_build; sp_object_class->release = sp_pattern_release; sp_object_class->set = sp_pattern_set; @@ -129,8 +101,8 @@ sp_pattern_init (SPPattern *pat) static void sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) pattern_parent_class)->build) - (* ((SPObjectClass *) pattern_parent_class)->build) (object, document, repr); + if (((SPObjectClass *) sp_pattern_parent_class)->build) + (* ((SPObjectClass *) sp_pattern_parent_class)->build) (object, document, repr); object->readAttr( "patternUnits" ); object->readAttr( "patternContentUnits" ); @@ -164,8 +136,8 @@ static void sp_pattern_release(SPObject *object) pat->modified_connection.~connection(); - if (((SPObjectClass *) pattern_parent_class)->release) { - ((SPObjectClass *) pattern_parent_class)->release (object); + if (((SPObjectClass *) sp_pattern_parent_class)->release) { + ((SPObjectClass *) sp_pattern_parent_class)->release (object); } } @@ -280,8 +252,8 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value) } break; default: - if (((SPObjectClass *) pattern_parent_class)->set) - ((SPObjectClass *) pattern_parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_pattern_parent_class)->set) + ((SPObjectClass *) sp_pattern_parent_class)->set (object, key, value); break; } } diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index eee8d50bc..94000cc9d 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -25,46 +25,18 @@ #include "xml/repr.h" #include "document.h" -static void sp_polygon_class_init(SPPolygonClass *pc); -static void sp_polygon_init(SPPolygon *polygon); - static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static gchar *sp_polygon_description(SPItem *item); -static SPShapeClass *parent_class; - -GType sp_polygon_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPPolygonClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_polygon_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPPolygon), - 0, // n_preallocs - (GInstanceInitFunc)sp_polygon_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_SHAPE, "SPPolygon", &info, static_cast<GTypeFlags>(0)); - } - - return type; -} +G_DEFINE_TYPE(SPPolygon, sp_polygon, SP_TYPE_SHAPE); static void sp_polygon_class_init(SPPolygonClass *pc) { SPObjectClass *sp_object_class = (SPObjectClass *) pc; SPItemClass *item_class = (SPItemClass *) pc; - parent_class = (SPShapeClass *) g_type_class_ref(SP_TYPE_SHAPE); - sp_object_class->build = sp_polygon_build; sp_object_class->write = sp_polygon_write; sp_object_class->set = sp_polygon_set; @@ -79,8 +51,8 @@ static void sp_polygon_init(SPPolygon */*polygon*/) static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_polygon_parent_class)->build) { + ((SPObjectClass *) sp_polygon_parent_class)->build(object, document, repr); } object->readAttr( "points" ); @@ -126,8 +98,8 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Do repr->setAttribute("points", str); g_free(str); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_polygon_parent_class))->write) { + ((SPObjectClass *) (sp_polygon_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -213,8 +185,8 @@ void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value) break; } default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_polygon_parent_class)->set) { + ((SPObjectClass *) sp_polygon_parent_class)->set(object, key, value); } break; } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 8dbed2a22..e5d89a802 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -20,61 +20,44 @@ #include "xml/repr.h" #include "document.h" -SPShapeClass * SPPolyLineClass::static_parent_class=0; +static void sp_polyline_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +static void sp_polyline_set(SPObject *object, unsigned int key, const gchar *value); +static Inkscape::XML::Node* sp_polyline_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static gchar* sp_polyline_get_description(SPItem * item); -GType SPPolyLine::sp_polyline_get_type(void) -{ - static GType polyline_type = 0; - - if (!polyline_type) { - GTypeInfo polyline_info = { - sizeof (SPPolyLineClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init, - NULL, /* klass_finalize */ - NULL, /* klass_data */ - sizeof (SPPolyLine), - 16, /* n_preallocs */ - (GInstanceInitFunc) SPPolyLine::init, - NULL, /* value_table */ - }; - polyline_type = g_type_register_static (SP_TYPE_SHAPE, "SPPolyLine", &polyline_info, (GTypeFlags)0); - } - return polyline_type; -} -void SPPolyLineClass::sp_polyline_class_init(SPPolyLineClass *klass) +G_DEFINE_TYPE(SPPolyLine, sp_polyline, SP_TYPE_SHAPE); + +static void +sp_polyline_class_init(SPPolyLineClass *klass) { - //GObjectClass * gobject_class = (GObjectClass *) klass; SPObjectClass * sp_object_class = (SPObjectClass *) klass; SPItemClass * item_class = (SPItemClass *) klass; - static_parent_class = (SPShapeClass *)g_type_class_ref(SP_TYPE_SHAPE); - - sp_object_class->build = SPPolyLine::build; - sp_object_class->set = SPPolyLine::set; - sp_object_class->write = SPPolyLine::write; + sp_object_class->build = sp_polyline_build; + sp_object_class->set = sp_polyline_set; + sp_object_class->write = sp_polyline_write; - item_class->description = SPPolyLine::getDescription; + item_class->description = sp_polyline_get_description; } -void SPPolyLine::init(SPPolyLine * /*polyline*/) +static void +sp_polyline_init(SPPolyLine * /*polyline*/) { - /* Nothing here */ } -void SPPolyLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +static void +sp_polyline_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - - if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) { - ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_polyline_parent_class)->build) { + ((SPObjectClass *) sp_polyline_parent_class)->build (object, document, repr); } object->readAttr( "points" ); } -void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value) +static void +sp_polyline_set(SPObject *object, unsigned int key, const gchar *value) { SPPolyLine *polyline = SP_POLYLINE(object); @@ -125,14 +108,15 @@ void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value) break; } default: - if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) { - ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_polyline_parent_class)->set) { + ((SPObjectClass *) sp_polyline_parent_class)->set (object, key, value); } break; } } -Inkscape::XML::Node *SPPolyLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_polyline_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SP_POLYLINE(object); @@ -144,14 +128,15 @@ Inkscape::XML::Node *SPPolyLine::write(SPObject *object, Inkscape::XML::Document repr->mergeFrom(object->getRepr(), "id"); } - if (((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write) { - ((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_polyline_parent_class))->write) { + ((SPObjectClass *) (sp_polyline_parent_class))->write (object, xml_doc, repr, flags); } return repr; } -gchar *SPPolyLine::getDescription(SPItem * /*item*/) +static gchar* +sp_polyline_get_description(SPItem * /*item*/) { return g_strdup(_("<b>Polyline</b>")); } diff --git a/src/sp-polyline.h b/src/sp-polyline.h index 277529b49..047868692 100644 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@ -5,7 +5,7 @@ -#define SP_TYPE_POLYLINE (SPPolyLine::sp_polyline_get_type ()) +#define SP_TYPE_POLYLINE (sp_polyline_get_type ()) #define SP_POLYLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_POLYLINE, SPPolyLine)) #define SP_POLYLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_POLYLINE, SPPolyLineClass)) #define SP_IS_POLYLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_POLYLINE)) @@ -14,19 +14,10 @@ class SPPolyLine; class SPPolyLineClass; -class SPPolyLine : public SPShape { -public: - static GType sp_polyline_get_type (void); +GType sp_polyline_get_type (void) G_GNUC_CONST; +class SPPolyLine : public SPShape { private: - static void init(SPPolyLine *polyline); - - static void build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void set(SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - static gchar * getDescription(SPItem * item); - friend class SPPolyLineClass; }; @@ -35,9 +26,6 @@ public: SPShapeClass parent_class; private: - static SPShapeClass *static_parent_class; - static void sp_polyline_class_init (SPPolyLineClass *klass); - friend class SPPolyLine; }; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 393c70895..e9ae6dff4 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -31,11 +31,6 @@ #include "svg/svg.h" #include "xml/repr.h" -class SPDesktop; - -static void sp_root_class_init(SPRootClass *klass); -static void sp_root_init(SPRoot *root); - static void sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_root_release(SPObject *object); static void sp_root_set(SPObject *object, unsigned int key, gchar const *value); @@ -48,29 +43,7 @@ static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Docum static Inkscape::DrawingItem *sp_root_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); static void sp_root_print(SPItem *item, SPPrintContext *ctx); -static SPGroupClass *parent_class; - -/** - * Returns the type info of sp_root, including its class sizes and initialization routines. - */ -GType sp_root_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPRootClass), - NULL, NULL, - (GClassInitFunc) sp_root_class_init, - NULL, NULL, - sizeof(SPRoot), - 16, - (GInstanceInitFunc) sp_root_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_GROUP, "SPRoot", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPRoot, sp_root, SP_TYPE_GROUP); /** * Initializes an SPRootClass object by setting its class and parent class objects, and registering @@ -81,8 +54,6 @@ static void sp_root_class_init(SPRootClass *klass) SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); SPItemClass *sp_item_class = reinterpret_cast<SPItemClass *>(klass); - parent_class = reinterpret_cast<SPGroupClass *>(g_type_class_ref(SP_TYPE_GROUP)); - sp_object_class->build = sp_root_build; sp_object_class->release = sp_root_release; sp_object_class->set = sp_root_set; @@ -147,8 +118,8 @@ static void sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML: object->readAttr( "preserveAspectRatio" ); object->readAttr( "onload" ); - if (((SPObjectClass *) parent_class)->build) - (* ((SPObjectClass *) parent_class)->build) (object, document, repr); + if (((SPObjectClass *) sp_root_parent_class)->build) + (* ((SPObjectClass *) sp_root_parent_class)->build) (object, document, repr); // Search for first <defs> node for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { @@ -171,8 +142,8 @@ static void sp_root_release(SPObject *object) SPRoot *root = (SPRoot *) object; root->defs = NULL; - if (((SPObjectClass *) parent_class)->release) - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_root_parent_class)->release) + ((SPObjectClass *) sp_root_parent_class)->release(object); } /** @@ -315,8 +286,8 @@ static void sp_root_set(SPObject *object, unsigned int key, gchar const *value) break; default: /* Pass the set event to the parent */ - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_root_parent_class)->set) { + ((SPObjectClass *) sp_root_parent_class)->set(object, key, value); } break; } @@ -331,8 +302,8 @@ static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, In SPRoot *root = (SPRoot *) object; SPGroup *group = (SPGroup *) object; - if (((SPObjectClass *) (parent_class))->child_added) { - (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); + if (((SPObjectClass *) (sp_root_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_root_parent_class))->child_added)(object, child, ref); } SPObject *co = object->document->getObjectByRepr(child); @@ -371,8 +342,8 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child) } } - if (((SPObjectClass *) (parent_class))->remove_child) { - (* ((SPObjectClass *) (parent_class))->remove_child)(object, child); + if (((SPObjectClass *) (sp_root_parent_class))->remove_child) { + (* ((SPObjectClass *) (sp_root_parent_class))->remove_child)(object, child); } } @@ -508,8 +479,8 @@ static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags) rctx.i2vp = Geom::identity(); /* And invoke parent method */ - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update(object, (SPCtx *) &rctx, flags); + if (((SPObjectClass *) (sp_root_parent_class))->update) + ((SPObjectClass *) (sp_root_parent_class))->update(object, (SPCtx *) &rctx, flags); /* As last step set additional transform of drawing group */ for (SPItemView *v = root->display; v != NULL; v = v->next) { @@ -527,8 +498,8 @@ static void sp_root_modified(SPObject *object, guint flags) { SPRoot *root = SP_ROOT(object); - if (((SPObjectClass *) (parent_class))->modified) - (* ((SPObjectClass *) (parent_class))->modified)(object, flags); + if (((SPObjectClass *) (sp_root_parent_class))->modified) + (* ((SPObjectClass *) (sp_root_parent_class))->modified)(object, flags); /* fixme: (Lauris) */ if (!object->parent && (flags & SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { @@ -576,8 +547,8 @@ sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: repr->setAttribute("viewBox", os.str().c_str()); } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_root_parent_class))->write) + ((SPObjectClass *) (sp_root_parent_class))->write(object, xml_doc, repr, flags); return repr; } @@ -591,8 +562,8 @@ sp_root_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigne SPRoot *root = SP_ROOT(item); Inkscape::DrawingItem *ai; - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show(item, drawing, key, flags); + if (((SPItemClass *) (sp_root_parent_class))->show) { + ai = ((SPItemClass *) (sp_root_parent_class))->show(item, drawing, key, flags); if (ai) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); g->setChildTransform(root->c2p); @@ -613,8 +584,8 @@ static void sp_root_print(SPItem *item, SPPrintContext *ctx) sp_print_bind(ctx, root->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print(item, ctx); + if (((SPItemClass *) (sp_root_parent_class))->print) { + ((SPItemClass *) (sp_root_parent_class))->print(item, ctx); } sp_print_release(ctx); diff --git a/src/sp-script.cpp b/src/sp-script.cpp index f18d231b0..736ddb4c9 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -16,9 +16,6 @@ #include <cstring> #include "document.h" -static void sp_script_class_init(SPScriptClass *sc); -static void sp_script_init(SPScript *script); - static void sp_script_release(SPObject *object); static void sp_script_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_script_modified(SPObject *object, guint flags); @@ -26,34 +23,10 @@ static void sp_script_set(SPObject *object, unsigned int key, gchar const *value static void sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *parent_class; - -GType sp_script_get_type(void) -{ - static GType script_type = 0; - - if (!script_type) { - GTypeInfo script_info = { - sizeof(SPScriptClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_script_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPScript), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_script_init, - NULL, /* value_table */ - }; - script_type = g_type_register_static(SP_TYPE_OBJECT, "SPScript", &script_info, (GTypeFlags) 0); - } - - return script_type; -} +G_DEFINE_TYPE(SPScript, sp_script, SP_TYPE_OBJECT); static void sp_script_class_init(SPScriptClass *sc) { - parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); SPObjectClass *sp_object_class = (SPObjectClass *) sc; sp_object_class->build = sp_script_build; @@ -78,8 +51,8 @@ static void sp_script_init(SPScript */*script*/) static void sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_script_parent_class)->build) { + ((SPObjectClass *) sp_script_parent_class)->build(object, document, repr); } //Read values of key attributes from XML nodes into object. @@ -95,8 +68,8 @@ static void sp_script_release(SPObject *object) object->document->removeResource("script", object); } - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_script_parent_class)->release) { + ((SPObjectClass *) sp_script_parent_class)->release(object); } } @@ -120,8 +93,8 @@ sp_script_set(SPObject *object, unsigned int key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_script_parent_class)->set) + ((SPObjectClass *) sp_script_parent_class)->set(object, key, value); break; } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index d5556ba9e..4037b302c 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -54,58 +54,47 @@ #define noSHAPE_VERBOSE void sp_shape_print (SPItem * item, SPPrintContext * ctx); - -SPLPEItemClass * SPShapeClass::parent_class = 0; - -/** - * Registers the SPShape class with Gdk and returns its type number. - */ -GType SPShape::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPShapeClass), - NULL, NULL, - (GClassInitFunc) SPShapeClass::sp_shape_class_init, - NULL, NULL, - sizeof (SPShape), - 16, - (GInstanceInitFunc) sp_shape_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_LPE_ITEM, "SPShape", &info, (GTypeFlags)0); - } - return type; -} +static void sp_shape_finalize (GObject *object); +static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +static void sp_shape_release (SPObject *object); +static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); +static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); +static void sp_shape_modified (SPObject *object, unsigned int flags); +static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static Geom::OptRect sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); +static Inkscape::DrawingItem *sp_shape_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); +static void sp_shape_hide (SPItem *item, unsigned int key); +static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); +static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai); + +G_DEFINE_TYPE(SPShape, sp_shape, SP_TYPE_LPE_ITEM); /** * Initializes a SPShapeClass object. Establishes the function pointers to the class' * member routines in the class vtable, and sets pointers to parent classes. */ -void SPShapeClass::sp_shape_class_init(SPShapeClass *klass) +static void +sp_shape_class_init(SPShapeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); SPItemClass * item_class = SP_ITEM_CLASS(klass); SPLPEItemClass * lpe_item_class = SP_LPE_ITEM_CLASS(klass); - parent_class = (SPLPEItemClass *)g_type_class_peek_parent (klass); - - gobject_class->finalize = SPShape::sp_shape_finalize; + gobject_class->finalize = sp_shape_finalize; - sp_object_class->build = SPShape::sp_shape_build; - sp_object_class->release = SPShape::sp_shape_release; - sp_object_class->set = SPShape::sp_shape_set; - sp_object_class->update = SPShape::sp_shape_update; - sp_object_class->modified = SPShape::sp_shape_modified; - sp_object_class->write = SPShape::sp_shape_write; + sp_object_class->build = sp_shape_build; + sp_object_class->release = sp_shape_release; + sp_object_class->set = sp_shape_set; + sp_object_class->update = sp_shape_update; + sp_object_class->modified = sp_shape_modified; + sp_object_class->write = sp_shape_write; - item_class->bbox = SPShape::sp_shape_bbox; + item_class->bbox = sp_shape_bbox; item_class->print = sp_shape_print; - item_class->show = SPShape::sp_shape_show; - item_class->hide = SPShape::sp_shape_hide; - item_class->snappoints = SPShape::sp_shape_snappoints; + item_class->show = sp_shape_show; + item_class->hide = sp_shape_hide; + item_class->snappoints = sp_shape_snappoints; lpe_item_class->update_patheffect = NULL; klass->set_shape = NULL; @@ -114,7 +103,8 @@ void SPShapeClass::sp_shape_class_init(SPShapeClass *klass) /** * Initializes an SPShape object. */ -void SPShape::sp_shape_init(SPShape *shape) +static void +sp_shape_init(SPShape *shape) { for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) { new (&shape->_release_connect[i]) sigc::connection(); @@ -125,7 +115,8 @@ void SPShape::sp_shape_init(SPShape *shape) shape->_curve_before_lpe = NULL; } -void SPShape::sp_shape_finalize(GObject *object) +static void +sp_shape_finalize(GObject *object) { SPShape *shape=(SPShape *)object; @@ -136,8 +127,8 @@ void SPShape::sp_shape_finalize(GObject *object) shape->_modified_connect[i].~connection(); } - if (((GObjectClass *) (SPShapeClass::parent_class))->finalize) { - (* ((GObjectClass *) (SPShapeClass::parent_class))->finalize)(object); + if (((GObjectClass *) (sp_shape_parent_class))->finalize) { + (* ((GObjectClass *) (sp_shape_parent_class))->finalize)(object); } } @@ -148,10 +139,11 @@ void SPShape::sp_shape_finalize(GObject *object) * * \see SPObject::build() */ -void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void +sp_shape_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (SPShapeClass::parent_class))->build) { - (*((SPObjectClass *) (SPShapeClass::parent_class))->build) (object, document, repr); + if (((SPObjectClass *) (sp_shape_parent_class))->build) { + (*((SPObjectClass *) (sp_shape_parent_class))->build) (object, document, repr); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { @@ -169,7 +161,8 @@ void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::X * * \see SPObject::release() */ -void SPShape::sp_shape_release(SPObject *object) +static void +sp_shape_release(SPObject *object) { SPItem *item; SPShape *shape; @@ -196,24 +189,24 @@ void SPShape::sp_shape_release(SPObject *object) shape->_curve_before_lpe = shape->_curve_before_lpe->unref(); } - if (((SPObjectClass *) SPShapeClass::parent_class)->release) { - ((SPObjectClass *) SPShapeClass::parent_class)->release (object); + if (((SPObjectClass *) sp_shape_parent_class)->release) { + ((SPObjectClass *) sp_shape_parent_class)->release (object); } } - - -void SPShape::sp_shape_set(SPObject *object, unsigned int key, gchar const *value) +static void +sp_shape_set(SPObject *object, unsigned int key, gchar const *value) { - if (((SPObjectClass *) SPShapeClass::parent_class)->set) { - ((SPObjectClass *) SPShapeClass::parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_shape_parent_class)->set) { + ((SPObjectClass *) sp_shape_parent_class)->set(object, key, value); } } -Inkscape::XML::Node * SPShape::sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node* +sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - if (((SPObjectClass *)(SPShapeClass::parent_class))->write) { - ((SPObjectClass *)(SPShapeClass::parent_class))->write(object, doc, repr, flags); + if (((SPObjectClass *)(sp_shape_parent_class))->write) { + ((SPObjectClass *)(sp_shape_parent_class))->write(object, doc, repr, flags); } return repr; @@ -223,12 +216,13 @@ Inkscape::XML::Node * SPShape::sp_shape_write(SPObject *object, Inkscape::XML::D * Updates the shape when its attributes have changed. Also establishes * marker objects to match the style settings. */ -void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) +static void +sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) { SPShape *shape = (SPShape *) object; - if (((SPObjectClass *) (SPShapeClass::parent_class))->update) { - (* ((SPObjectClass *) (SPShapeClass::parent_class))->update) (object, ctx, flags); + if (((SPObjectClass *) (sp_shape_parent_class))->update) { + (* ((SPObjectClass *) (sp_shape_parent_class))->update) (object, ctx, flags); } /* This stanza checks that an object's marker style agrees with @@ -372,7 +366,8 @@ Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const & c) * * @todo figure out what to do when both 'marker' and for instance 'marker-end' are set. */ -void SPShape::sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) +static void +sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) { SPStyle *style = ((SPObject *) shape)->style; @@ -482,12 +477,13 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem /** * Sets modified flag for all sub-item views. */ -void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) +static void +sp_shape_modified(SPObject *object, unsigned int flags) { SPShape *shape = SP_SHAPE (object); - if (((SPObjectClass *) (SPShapeClass::parent_class))->modified) { - (* ((SPObjectClass *) (SPShapeClass::parent_class))->modified) (object, flags); + if (((SPObjectClass *) (sp_shape_parent_class))->modified) { + (* ((SPObjectClass *) (sp_shape_parent_class))->modified) (object, flags); } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { @@ -502,7 +498,8 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) * Calculates the bounding box for item, storing it into bbox. * This also includes the bounding boxes of any markers included in the shape. */ -Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType bboxtype) +static Geom::OptRect +sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType bboxtype) { SPShape const *shape = SP_SHAPE (item); Geom::OptRect bbox; @@ -792,7 +789,8 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ -Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) +static Inkscape::DrawingItem* +sp_shape_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = item; SPShape *shape = SP_SHAPE(item); @@ -835,7 +833,8 @@ Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing & /** * Hides/removes marker views from the shape. */ -void SPShape::sp_shape_hide(SPItem *item, unsigned int key) +static void +sp_shape_hide(SPItem *item, unsigned int key) { SPShape *shape; SPItemView *v; @@ -854,8 +853,8 @@ void SPShape::sp_shape_hide(SPItem *item, unsigned int key) } } - if (((SPItemClass *) SPShapeClass::parent_class)->hide) { - ((SPItemClass *) SPShapeClass::parent_class)->hide (item, key); + if (((SPItemClass *) sp_shape_parent_class)->hide) { + ((SPItemClass *) sp_shape_parent_class)->hide (item, key); } } @@ -1110,7 +1109,8 @@ void SPShape::setCurveInsync(SPCurve *new_curve, unsigned int owner) /** * Return all nodes in a path that are to be considered for snapping */ -void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) +static void +sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { g_assert(item != NULL); g_assert(SP_IS_SHAPE(item)); diff --git a/src/sp-shape.h b/src/sp-shape.h index 453750946..422281cae 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -22,7 +22,7 @@ #include <stddef.h> #include <sigc++/connection.h> -#define SP_TYPE_SHAPE (SPShape::getType ()) +#define SP_TYPE_SHAPE (sp_shape_get_type ()) #define SP_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SHAPE, SPShape)) #define SP_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SHAPE, SPShapeClass)) #define SP_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SHAPE)) @@ -32,13 +32,13 @@ class SPDesktop; namespace Inkscape { class DrawingItem; } +GType sp_shape_get_type (void) G_GNUC_CONST; /** * Base class for shapes, including <path> element */ class SPShape : public SPLPEItem { public: - static GType getType (void); void setShape (); SPCurve * getCurve () const; SPCurve * getCurveBeforeLPE () const; @@ -58,26 +58,6 @@ public: sigc::connection _modified_connect [SP_MARKER_LOC_QTY]; private: - static void sp_shape_init (SPShape *shape); - static void sp_shape_finalize (GObject *object); - - static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_shape_release (SPObject *object); - - static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); - static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); - static void sp_shape_modified (SPObject *object, unsigned int flags); - static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - static Geom::OptRect sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); - static Inkscape::DrawingItem *sp_shape_show (SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); - static void sp_shape_hide (SPItem *item, unsigned int key); - static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - - static void sp_shape_update_marker_view (SPShape *shape, Inkscape::DrawingItem *ai); - - - friend class SPShapeClass; }; @@ -89,9 +69,6 @@ public: void (* set_shape) (SPShape *shape); private: - static SPLPEItemClass *parent_class; - static void sp_shape_class_init (SPShapeClass *klass); - friend class SPShape; }; diff --git a/src/sp-skeleton.cpp b/src/sp-skeleton.cpp index 8910613f3..b0f5bc91f 100644 --- a/src/sp-skeleton.cpp +++ b/src/sp-skeleton.cpp @@ -39,47 +39,19 @@ #endif /* Skeleton base class */ - -static void sp_skeleton_class_init(SPSkeletonClass *klass); -static void sp_skeleton_init(SPSkeleton *skeleton); - static void sp_skeleton_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_skeleton_release(SPObject *object); static void sp_skeleton_set(SPObject *object, unsigned int key, gchar const *value); static void sp_skeleton_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_skeleton_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *skeleton_parent_class; - -GType -sp_skeleton_get_type() -{ - static GType skeleton_type = 0; - - if (!skeleton_type) { - GTypeInfo skeleton_info = { - sizeof(SPSkeletonClass), - NULL, NULL, - (GClassInitFunc) sp_skeleton_class_init, - NULL, NULL, - sizeof(SPSkeleton), - 16, - (GInstanceInitFunc) sp_skeleton_init, - NULL, /* value_table */ - }; - skeleton_type = g_type_register_static(SP_TYPE_OBJECT, "SPSkeleton", &skeleton_info, (GTypeFlags)0); - } - return skeleton_type; -} +G_DEFINE_TYPE(SPSkeleton, sp_skeleton, SP_TYPE_OBJECT); static void sp_skeleton_class_init(SPSkeletonClass *klass) { - //GObjectClass *gobject_class = (GObjectClass *)klass; SPObjectClass *sp_object_class = (SPObjectClass *)klass; - skeleton_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_skeleton_build; sp_object_class->release = sp_skeleton_release; sp_object_class->write = sp_skeleton_write; @@ -102,8 +74,8 @@ static void sp_skeleton_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { debug("0x%p",object); - if (((SPObjectClass *) skeleton_parent_class)->build) { - ((SPObjectClass *) skeleton_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_skeleton_parent_class)->build) { + ((SPObjectClass *) sp_skeleton_parent_class)->build(object, document, repr); } /* @@ -134,8 +106,8 @@ sp_skeleton_release(SPObject *object) /* deal with our children and our selves here */ - if (((SPObjectClass *) skeleton_parent_class)->release) - ((SPObjectClass *) skeleton_parent_class)->release(object); + if (((SPObjectClass *) sp_skeleton_parent_class)->release) + ((SPObjectClass *) sp_skeleton_parent_class)->release(object); } /** @@ -149,8 +121,8 @@ sp_skeleton_set(SPObject *object, unsigned int key, gchar const *value) //SPSkeleton *skeleton = SP_SKELETON(object); /* See if any parents need this value. */ - if (((SPObjectClass *) skeleton_parent_class)->set) { - ((SPObjectClass *) skeleton_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_skeleton_parent_class)->set) { + ((SPObjectClass *) sp_skeleton_parent_class)->set(object, key, value); } } @@ -170,8 +142,8 @@ sp_skeleton_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) skeleton_parent_class)->update) { - ((SPObjectClass *) skeleton_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_skeleton_parent_class)->update) { + ((SPObjectClass *) sp_skeleton_parent_class)->update(object, ctx, flags); } } @@ -194,8 +166,8 @@ sp_skeleton_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML: } } - if (((SPObjectClass *) skeleton_parent_class)->write) { - ((SPObjectClass *) skeleton_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_skeleton_parent_class)->write) { + ((SPObjectClass *) sp_skeleton_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index fd2672388..43e552d68 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -28,9 +28,6 @@ #include "sp-spiral.h" -static void sp_spiral_class_init (SPSpiralClass *klass); -static void sp_spiral_init (SPSpiral *spiral); - static void sp_spiral_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static Inkscape::XML::Node *sp_spiral_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_spiral_set (SPObject *object, unsigned int key, const gchar *value); @@ -44,33 +41,7 @@ static void sp_spiral_update_patheffect (SPLPEItem *lpeitem, bool write); static Geom::Point sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t); -static SPShapeClass *parent_class; - -/** - * Register SPSpiral class and return its type number. - */ -GType -sp_spiral_get_type (void) -{ - static GType spiral_type = 0; - - if (!spiral_type) { - GTypeInfo spiral_info = { - sizeof (SPSpiralClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_spiral_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPSpiral), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_spiral_init, - NULL, /* value_table */ - }; - spiral_type = g_type_register_static (SP_TYPE_SHAPE, "SPSpiral", &spiral_info, (GTypeFlags)0); - } - return spiral_type; -} +G_DEFINE_TYPE(SPSpiral, sp_spiral, SP_TYPE_SHAPE); /** * SPSpiral vtable initialization. @@ -82,8 +53,6 @@ static void sp_spiral_class_init(SPSpiralClass *klass) SPLPEItemClass *lpe_item_class = reinterpret_cast<SPLPEItemClass *>(klass); SPShapeClass *shape_class = reinterpret_cast<SPShapeClass *>(klass); - parent_class = reinterpret_cast<SPShapeClass *>(g_type_class_ref(SP_TYPE_SHAPE)); - sp_object_class->build = sp_spiral_build; sp_object_class->write = sp_spiral_write; sp_object_class->set = sp_spiral_set; @@ -117,8 +86,8 @@ sp_spiral_init (SPSpiral * spiral) */ static void sp_spiral_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (reinterpret_cast<SPObjectClass *>(parent_class)->build) { - reinterpret_cast<SPObjectClass *>(parent_class)->build(object, document, repr); + if (reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->build) { + reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->build(object, document, repr); } object->readAttr( "sodipodi:cx" ); @@ -168,8 +137,8 @@ sp_spiral_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X repr->setAttribute("d", d); g_free (d); - if (reinterpret_cast<SPObjectClass *>(parent_class)->write) { - reinterpret_cast<SPObjectClass *>(parent_class)->write(object, xml_doc, repr, flags | SP_SHAPE_WRITE_PATH); + if (reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->write) { + reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->write(object, xml_doc, repr, flags | SP_SHAPE_WRITE_PATH); } return repr; @@ -260,8 +229,8 @@ static void sp_spiral_set(SPObject *object, unsigned int key, const gchar *value object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (reinterpret_cast<SPObjectClass *>(parent_class)->set) { - reinterpret_cast<SPObjectClass *>(parent_class)->set(object, key, value); + if (reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->set) { + reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->set(object, key, value); } break; } @@ -276,8 +245,8 @@ static void sp_spiral_update(SPObject *object, SPCtx *ctx, guint flags) reinterpret_cast<SPShape *>(object)->setShape(); } - if (reinterpret_cast<SPObjectClass *>(parent_class)->update) { - reinterpret_cast<SPObjectClass *>(parent_class)->update(object, ctx, flags); + if (reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->update) { + reinterpret_cast<SPObjectClass *>(sp_spiral_parent_class)->update(object, ctx, flags); } } @@ -510,8 +479,8 @@ static void sp_spiral_snappoints(SPItem const *item, std::vector<Inkscape::SnapC Inkscape::SnapPreferences local_snapprefs = *snapprefs; local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); - if ((reinterpret_cast<SPItemClass *>(parent_class))->snappoints) { - (reinterpret_cast<SPItemClass *>(parent_class))->snappoints (item, p, &local_snapprefs); + if ((reinterpret_cast<SPItemClass *>(sp_spiral_parent_class))->snappoints) { + (reinterpret_cast<SPItemClass *>(sp_spiral_parent_class))->snappoints (item, p, &local_snapprefs); } if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 08de1732b..af2420340 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -32,9 +32,6 @@ #include "sp-star.h" -static void sp_star_class_init (SPStarClass *klass); -static void sp_star_init (SPStar *star); - static void sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static Inkscape::XML::Node *sp_star_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_star_set (SPObject *object, unsigned int key, const gchar *value); @@ -46,37 +43,14 @@ static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan static void sp_star_set_shape (SPShape *shape); static void sp_star_update_patheffect (SPLPEItem *lpeitem, bool write); -static SPShapeClass *parent_class; - -GType -sp_star_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (SPStarClass), - NULL, NULL, - (GClassInitFunc) sp_star_class_init, - NULL, NULL, - sizeof (SPStar), - 16, - (GInstanceInitFunc) sp_star_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_SHAPE, "SPStar", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPStar, sp_star, SP_TYPE_SHAPE); static void sp_star_class_init(SPStarClass *klass) { - SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass); - SPItemClass *item_class = reinterpret_cast<SPItemClass *>(klass); - SPLPEItemClass *lpe_item_class = reinterpret_cast<SPLPEItemClass *>(klass); - SPShapeClass *shape_class = reinterpret_cast<SPShapeClass *>(klass); - - parent_class = reinterpret_cast<SPShapeClass *>(g_type_class_ref(SP_TYPE_SHAPE)); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); + SPItemClass *item_class = SP_ITEM_CLASS(klass); + SPLPEItemClass *lpe_item_class = SP_LPE_ITEM_CLASS(klass); + SPShapeClass *shape_class = SP_SHAPE_CLASS(klass); sp_object_class->build = sp_star_build; sp_object_class->write = sp_star_write; @@ -107,8 +81,8 @@ sp_star_init (SPStar * star) static void sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_star_parent_class)->build) + ((SPObjectClass *) sp_star_parent_class)->build (object, document, repr); object->readAttr( "sodipodi:cx" ); object->readAttr( "sodipodi:cy" ); @@ -150,8 +124,8 @@ sp_star_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML repr->setAttribute("d", d); g_free (d); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_star_parent_class))->write) + ((SPObjectClass *) (sp_star_parent_class))->write (object, xml_doc, repr, flags); return repr; } @@ -250,8 +224,8 @@ sp_star_set (SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_star_parent_class)->set) + ((SPObjectClass *) sp_star_parent_class)->set (object, key, value); break; } } @@ -265,8 +239,8 @@ sp_star_update (SPObject *object, SPCtx *ctx, guint flags) ((SPShape *) object)->setShape (); } - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if (((SPObjectClass *) sp_star_parent_class)->update) + ((SPObjectClass *) sp_star_parent_class)->update (object, ctx, flags); } static void @@ -544,8 +518,8 @@ static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan Inkscape::SnapPreferences local_snapprefs = *snapprefs; local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); - if (((SPItemClass *) parent_class)->snappoints) { - ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs); + if (((SPItemClass *) sp_star_parent_class)->snappoints) { + ((SPItemClass *) sp_star_parent_class)->snappoints (item, p, &local_snapprefs); } if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { diff --git a/src/sp-string.cpp b/src/sp-string.cpp index 3512aa45a..2fe84ac6a 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -37,37 +37,12 @@ # SPSTRING #####################################################*/ -static void sp_string_class_init(SPStringClass *classname); -static void sp_string_init(SPString *string); - static void sp_string_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_string_release(SPObject *object); static void sp_string_read_content(SPObject *object); static void sp_string_update(SPObject *object, SPCtx *ctx, unsigned flags); -static SPObjectClass *string_parent_class; - -GType -sp_string_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPStringClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_string_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPString), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_string_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPString", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPString, sp_string, SP_TYPE_OBJECT); static void sp_string_class_init(SPStringClass *classname) @@ -76,8 +51,6 @@ sp_string_class_init(SPStringClass *classname) sp_object_class = (SPObjectClass *) classname; - string_parent_class = (SPObjectClass*)g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_string_build; sp_object_class->release = sp_string_release; sp_object_class->read_content = sp_string_read_content; @@ -95,8 +68,8 @@ sp_string_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { sp_string_read_content(object); - if (((SPObjectClass *) string_parent_class)->build) - ((SPObjectClass *) string_parent_class)->build(object, doc, repr); + if (((SPObjectClass *) sp_string_parent_class)->build) + ((SPObjectClass *) sp_string_parent_class)->build(object, doc, repr); } static void @@ -106,8 +79,8 @@ sp_string_release(SPObject *object) string->string.~ustring(); - if (((SPObjectClass *) string_parent_class)->release) - ((SPObjectClass *) string_parent_class)->release(object); + if (((SPObjectClass *) sp_string_parent_class)->release) + ((SPObjectClass *) sp_string_parent_class)->release(object); } static void @@ -156,8 +129,8 @@ sp_string_read_content(SPObject *object) static void sp_string_update(SPObject *object, SPCtx *ctx, unsigned flags) { - if (((SPObjectClass *) string_parent_class)->update) - ((SPObjectClass *) string_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_string_parent_class)->update) + ((SPObjectClass *) sp_string_parent_class)->update(object, ctx, flags); if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG)) { /* Parent style or we ourselves changed, so recalculate */ diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 2e14ae5ff..da7a575b7 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -7,42 +7,16 @@ #include "style.h" using Inkscape::XML::TEXT_NODE; -static void sp_style_elem_init(SPStyleElem *style_elem); -static void sp_style_elem_class_init(SPStyleElemClass *klass); static void sp_style_elem_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); static void sp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value); static void sp_style_elem_read_content(SPObject *); static Inkscape::XML::Node *sp_style_elem_write(SPObject *, Inkscape::XML::Document *, Inkscape::XML::Node *, guint flags); -static SPObjectClass *parent_class; - -GType -sp_style_elem_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPStyleElemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_style_elem_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPStyleElem), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_style_elem_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPStyleElem", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPStyleElem, sp_style_elem, SP_TYPE_OBJECT); static void sp_style_elem_class_init(SPStyleElemClass *klass) { - parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); /* FIXME */ klass->build = sp_style_elem_build; @@ -89,8 +63,8 @@ sp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value /* title is ignored. */ default: { - if (parent_class->set) { - parent_class->set(object, key, value); + if (SP_OBJECT_CLASS(sp_style_elem_parent_class)->set) { + SP_OBJECT_CLASS(sp_style_elem_parent_class)->set(object, key, value); } break; } @@ -138,8 +112,8 @@ sp_style_elem_write(SPObject *const object, Inkscape::XML::Document *xml_doc, In } /* todo: media */ - if (((SPObjectClass *) parent_class)->write) - ((SPObjectClass *) parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_style_elem_parent_class)->write) + ((SPObjectClass *) sp_style_elem_parent_class)->write(object, xml_doc, repr, flags); return repr; } @@ -402,8 +376,8 @@ sp_style_elem_build(SPObject *object, SPDocument *document, Inkscape::XML::Node }; rec_add_listener(*repr, &nodeEventVector, object); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_style_elem_parent_class)->build) { + ((SPObjectClass *) sp_style_elem_parent_class)->build(object, document, repr); } } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 56f862bf3..d4db403e3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,9 +26,6 @@ #include "sp-symbol.h" #include "document.h" -static void sp_symbol_class_init (SPSymbolClass *klass); -static void sp_symbol_init (SPSymbol *symbol); - static void sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_symbol_release (SPObject *object); static void sp_symbol_set (SPObject *object, unsigned int key, const gchar *value); @@ -42,35 +39,13 @@ static void sp_symbol_hide (SPItem *item, unsigned int key); static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); -static SPGroupClass *parent_class; - -GType -sp_symbol_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPSymbolClass), - NULL, NULL, - (GClassInitFunc) sp_symbol_class_init, - NULL, NULL, - sizeof (SPSymbol), - 16, - (GInstanceInitFunc) sp_symbol_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_GROUP, "SPSymbol", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPSymbol, sp_symbol, SP_TYPE_GROUP); static void sp_symbol_class_init(SPSymbolClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; SPItemClass *sp_item_class = (SPItemClass *) klass; - parent_class = (SPGroupClass *)g_type_class_ref (SP_TYPE_GROUP); - sp_object_class->build = sp_symbol_build; sp_object_class->release = sp_symbol_release; sp_object_class->set = sp_symbol_set; @@ -97,15 +72,15 @@ static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XM object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) sp_symbol_parent_class)->build) { + ((SPObjectClass *) sp_symbol_parent_class)->build (object, document, repr); } } static void sp_symbol_release(SPObject *object) { - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); + if (((SPObjectClass *) sp_symbol_parent_class)->release) { + ((SPObjectClass *) sp_symbol_parent_class)->release (object); } } @@ -202,16 +177,16 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) sp_symbol_parent_class)->set) + ((SPObjectClass *) sp_symbol_parent_class)->set (object, key, value); break; } } static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) { - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); + if (((SPObjectClass *) (sp_symbol_parent_class))->child_added) { + ((SPObjectClass *) (sp_symbol_parent_class))->child_added (object, child, ref); } } @@ -315,8 +290,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, (SPCtx *) &rctx, flags); } // As last step set additional transform of drawing group @@ -326,8 +301,8 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } else { // No-op - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->update) { + ((SPObjectClass *) (sp_symbol_parent_class))->update (object, ctx, flags); } } } @@ -336,8 +311,8 @@ static void sp_symbol_modified(SPObject *object, guint flags) { SP_SYMBOL(object); - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { + (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); } } @@ -355,8 +330,8 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->write) { + ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); } return repr; @@ -369,8 +344,8 @@ static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &dr if (symbol->cloned) { // Cloned <symbol> is actually renderable - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); + if (((SPItemClass *) (sp_symbol_parent_class))->show) { + ai = ((SPItemClass *) (sp_symbol_parent_class))->show (item, drawing, key, flags); Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); if (g) { g->setChildTransform(symbol->c2p); @@ -387,8 +362,8 @@ static void sp_symbol_hide(SPItem *item, unsigned int key) if (symbol->cloned) { /* Cloned <symbol> is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) { - ((SPItemClass *) (parent_class))->hide (item, key); + if (((SPItemClass *) (sp_symbol_parent_class))->hide) { + ((SPItemClass *) (sp_symbol_parent_class))->hide (item, key); } } } @@ -401,15 +376,15 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran if (symbol->cloned) { // Cloned <symbol> is actually renderable - if (((SPItemClass *) (parent_class))->bbox) { + if (((SPItemClass *) (sp_symbol_parent_class))->bbox) { Geom::Affine const a( symbol->c2p * transform ); - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } } else { // Need bounding box for Symbols dialog Geom::Affine const a; - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); + bbox = ((SPItemClass *) (sp_symbol_parent_class))->bbox(item, a, type); } return bbox; } @@ -422,8 +397,8 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_bind(ctx, symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); + if (((SPItemClass *) (sp_symbol_parent_class))->print) { + ((SPItemClass *) (sp_symbol_parent_class))->print (item, ctx); } sp_print_release (ctx); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 1b4246483..8d42b7d59 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -384,7 +384,7 @@ static char * sp_text_description(SPItem *item) char name_buf[256]; char *n; if (tf) { - tf->Name(name_buf, sizeof(name_buf)); + tf->Family(name_buf, sizeof(name_buf)); n = xml_quote_strdup(name_buf); tf->Unref(); } else { diff --git a/src/sp-title.cpp b/src/sp-title.cpp index ddeccede2..489a6f448 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -16,38 +16,14 @@ #include "sp-title.h" #include "xml/repr.h" -static void sp_title_class_init(SPTitleClass *klass); -static void sp_title_init(SPTitle *rect); static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *title_parent_class; - -GType -sp_title_get_type (void) -{ - static GType title_type = 0; - - if (!title_type) { - GTypeInfo title_info = { - sizeof (SPTitleClass), - NULL, NULL, - (GClassInitFunc) sp_title_class_init, - NULL, NULL, - sizeof (SPTitle), - 16, - (GInstanceInitFunc) sp_title_init, - NULL, /* value_table */ - }; - title_type = g_type_register_static (SP_TYPE_OBJECT, "SPTitle", &title_info, (GTypeFlags)0); - } - return title_type; -} +G_DEFINE_TYPE(SPTitle, sp_title, SP_TYPE_OBJECT); static void sp_title_class_init(SPTitleClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - title_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); sp_object_class->write = sp_title_write; } @@ -66,8 +42,8 @@ static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Docu repr = object->getRepr()->duplicate(doc); } - if (((SPObjectClass *) title_parent_class)->write) { - ((SPObjectClass *) title_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_title_parent_class)->write) { + ((SPObjectClass *) sp_title_parent_class)->write(object, doc, repr, flags); } return repr; diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 938b7c7cc..deee590af 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -52,8 +52,6 @@ static void build_string_from_root(Inkscape::XML::Node *root, Glib::ustring *ret /* TRef base class */ -static void sp_tref_class_init(SPTRefClass *tref_class); -static void sp_tref_init(SPTRef *tref); static void sp_tref_finalize(GObject *obj); static void sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -69,28 +67,7 @@ static gchar *sp_tref_description(SPItem *item); static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); static void sp_tref_delete_self(SPObject *deleted, SPTRef *self); -static SPObjectClass *tref_parent_class; - -GType -sp_tref_get_type() -{ - static GType tref_type = 0; - - if (!tref_type) { - GTypeInfo tref_info = { - sizeof(SPTRefClass), - NULL, NULL, - (GClassInitFunc) sp_tref_class_init, - NULL, NULL, - sizeof(SPTRef), - 16, - (GInstanceInitFunc) sp_tref_init, - NULL, /* value_table */ - }; - tref_type = g_type_register_static(SP_TYPE_ITEM, "SPTRef", &tref_info, (GTypeFlags)0); - } - return tref_type; -} +G_DEFINE_TYPE(SPTRef, sp_tref, SP_TYPE_ITEM); static void sp_tref_class_init(SPTRefClass *tref_class) @@ -98,8 +75,6 @@ sp_tref_class_init(SPTRefClass *tref_class) GObjectClass *gobject_class = (GObjectClass *) tref_class; SPObjectClass *sp_object_class = (SPObjectClass *)tref_class; - tref_parent_class = (SPObjectClass*)g_type_class_peek_parent(tref_class); - sp_object_class->build = sp_tref_build; sp_object_class->release = sp_tref_release; sp_object_class->write = sp_tref_write; @@ -148,8 +123,8 @@ sp_tref_finalize(GObject *obj) static void sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) tref_parent_class)->build) { - ((SPObjectClass *) tref_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_tref_parent_class)->build) { + ((SPObjectClass *) sp_tref_parent_class)->build(object, document, repr); } object->readAttr( "xlink:href" ); @@ -178,8 +153,8 @@ sp_tref_release(SPObject *object) tref->uriOriginalRef->detach(); - if (((SPObjectClass *) tref_parent_class)->release) - ((SPObjectClass *) tref_parent_class)->release(object); + if (((SPObjectClass *) sp_tref_parent_class)->release) + ((SPObjectClass *) sp_tref_parent_class)->release(object); } /** @@ -225,8 +200,8 @@ sp_tref_set(SPObject *object, unsigned int key, gchar const *value) } } else { // default - if (((SPObjectClass *) tref_parent_class)->set) { - ((SPObjectClass *) tref_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_tref_parent_class)->set) { + ((SPObjectClass *) sp_tref_parent_class)->set(object, key, value); } } @@ -243,8 +218,8 @@ sp_tref_update(SPObject *object, SPCtx *ctx, guint flags) SPTRef *tref = SP_TREF(object); - if (((SPObjectClass *) tref_parent_class)->update) { - ((SPObjectClass *) tref_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_tref_parent_class)->update) { + ((SPObjectClass *) sp_tref_parent_class)->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -307,8 +282,8 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: g_free(uri_string); } - if (((SPObjectClass *) tref_parent_class)->write) { - ((SPObjectClass *) tref_parent_class)->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) sp_tref_parent_class)->write) { + ((SPObjectClass *) sp_tref_parent_class)->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 1b1ae3d52..09429df6f 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -48,9 +48,6 @@ # SPTSPAN #####################################################*/ -static void sp_tspan_class_init(SPTSpanClass *classname); -static void sp_tspan_init(SPTSpan *tspan); - static void sp_tspan_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); static void sp_tspan_release(SPObject *object); static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value); @@ -60,43 +57,13 @@ static Geom::OptRect sp_tspan_bbox(SPItem const *item, Geom::Affine const &trans static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static char *sp_tspan_description (SPItem *item); -static SPItemClass *tspan_parent_class; - -/** - * - */ -GType -sp_tspan_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTSpanClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_tspan_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPTSpan), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_tspan_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_ITEM, "SPTSpan", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPTSpan, sp_tspan, SP_TYPE_ITEM); static void sp_tspan_class_init(SPTSpanClass *classname) { - SPObjectClass * sp_object_class; - SPItemClass * item_class; - - sp_object_class = (SPObjectClass *) classname; - item_class = (SPItemClass *) classname; - - tspan_parent_class = (SPItemClass*)g_type_class_ref(SP_TYPE_ITEM); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(classname); + SPItemClass *item_class = SP_ITEM_CLASS(classname); sp_object_class->build = sp_tspan_build; sp_object_class->release = sp_tspan_release; @@ -123,15 +90,13 @@ sp_tspan_release(SPObject *object) tspan->attributes.~TextTagAttributes(); - if (((SPObjectClass *) tspan_parent_class)->release) - ((SPObjectClass *) tspan_parent_class)->release(object); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->release) + (SP_OBJECT_CLASS(sp_tspan_parent_class))->release(object); } static void sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - //SPTSpan *tspan = SP_TSPAN(object); - object->readAttr( "x" ); object->readAttr( "y" ); object->readAttr( "dx" ); @@ -139,8 +104,8 @@ sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) object->readAttr( "rotate" ); object->readAttr( "sodipodi:role" ); - if (((SPObjectClass *) tspan_parent_class)->build) - ((SPObjectClass *) tspan_parent_class)->build(object, doc, repr); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->build) + (SP_OBJECT_CLASS(sp_tspan_parent_class))->build(object, doc, repr); } static void @@ -160,8 +125,8 @@ sp_tspan_set(SPObject *object, unsigned key, gchar const *value) } break; default: - if (((SPObjectClass *) tspan_parent_class)->set) - (((SPObjectClass *) tspan_parent_class)->set)(object, key, value); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->set) + (SP_OBJECT_CLASS(sp_tspan_parent_class))->set(object, key, value); break; } } @@ -169,8 +134,8 @@ sp_tspan_set(SPObject *object, unsigned key, gchar const *value) static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) { - if (((SPObjectClass *) tspan_parent_class)->update) { - ((SPObjectClass *) tspan_parent_class)->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->update) { + (SP_OBJECT_CLASS(sp_tspan_parent_class))->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -187,8 +152,8 @@ static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) static void sp_tspan_modified(SPObject *object, unsigned flags) { - if (((SPObjectClass *) tspan_parent_class)->modified) { - ((SPObjectClass *) tspan_parent_class)->modified(object, flags); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->modified) { + (SP_OBJECT_CLASS(sp_tspan_parent_class))->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -272,8 +237,8 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML } } - if (((SPObjectClass *) tspan_parent_class)->write) { - ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_tspan_parent_class))->write) { + (SP_OBJECT_CLASS(sp_tspan_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -292,8 +257,6 @@ sp_tspan_description(SPItem *item) # SPTEXTPATH #####################################################*/ -static void sp_textpath_class_init(SPTextPathClass *classname); -static void sp_textpath_init(SPTextPath *textpath); static void sp_textpath_finalize(GObject *obj); static void sp_textpath_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); @@ -303,42 +266,15 @@ static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_textpath_modified(SPObject *object, unsigned flags); static Inkscape::XML::Node *sp_textpath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPItemClass *textpath_parent_class; - void refresh_textpath_source(SPTextPath* offset); +G_DEFINE_TYPE(SPTextPath, sp_textpath, SP_TYPE_ITEM); -/** - * - */ -GType -sp_textpath_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTextPathClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_textpath_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPTextPath), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_textpath_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_ITEM, "SPTextPath", &info, (GTypeFlags)0); - } - return type; -} - -static void sp_textpath_class_init(SPTextPathClass *classname) +static void +sp_textpath_class_init(SPTextPathClass *classname) { - GObjectClass *gobject_class = reinterpret_cast<GObjectClass *>(classname); - SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(classname); - - textpath_parent_class = reinterpret_cast<SPItemClass*>(g_type_class_ref(SP_TYPE_ITEM)); + GObjectClass *gobject_class = G_OBJECT_CLASS(classname); + SPObjectClass *sp_object_class = SP_OBJECT_CLASS(classname); gobject_class->finalize = sp_textpath_finalize; @@ -381,11 +317,12 @@ sp_textpath_release(SPObject *object) if (textpath->originalPath) delete textpath->originalPath; textpath->originalPath = NULL; - if (((SPObjectClass *) textpath_parent_class)->release) - ((SPObjectClass *) textpath_parent_class)->release(object); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->release) + (SP_OBJECT_CLASS(sp_textpath_parent_class))->release(object); } -static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) +static void +sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { object->readAttr( "x" ); object->readAttr( "y" ); @@ -410,8 +347,8 @@ static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML:: repr->addChild(rch, NULL); } - if (((SPObjectClass *) textpath_parent_class)->build) { - ((SPObjectClass *) textpath_parent_class)->build(object, doc, repr); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->build) { + (SP_OBJECT_CLASS(sp_textpath_parent_class))->build(object, doc, repr); } } @@ -432,8 +369,8 @@ sp_textpath_set(SPObject *object, unsigned key, gchar const *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) textpath_parent_class)->set) - (((SPObjectClass *) textpath_parent_class)->set)(object, key, value); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->set) + (SP_OBJECT_CLASS(sp_textpath_parent_class))->set(object, key, value); break; } } @@ -449,8 +386,8 @@ static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) } textpath->isUpdating = false; - if (((SPObjectClass *) textpath_parent_class)->update) { - ((SPObjectClass *) textpath_parent_class)->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->update) { + (SP_OBJECT_CLASS(sp_textpath_parent_class))->update(object, ctx, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -486,10 +423,11 @@ void refresh_textpath_source(SPTextPath* tp) } } -static void sp_textpath_modified(SPObject *object, unsigned flags) +static void +sp_textpath_modified(SPObject *object, unsigned flags) { - if (((SPObjectClass *) textpath_parent_class)->modified) { - ((SPObjectClass *) textpath_parent_class)->modified(object, flags); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->modified) { + (SP_OBJECT_CLASS(sp_textpath_parent_class))->modified(object, flags); } if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -503,6 +441,7 @@ static void sp_textpath_modified(SPObject *object, unsigned flags) } } } + static Inkscape::XML::Node * sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { @@ -559,8 +498,8 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: } } - if (((SPObjectClass *) textpath_parent_class)->write) { - ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_textpath_parent_class))->write) { + (SP_OBJECT_CLASS(sp_textpath_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-tspan.h b/src/sp-tspan.h index 3672fd3b5..794e71039 100644 --- a/src/sp-tspan.h +++ b/src/sp-tspan.h @@ -9,6 +9,7 @@ #include "sp-item.h" #include "text-tag-attributes.h" +G_BEGIN_DECLS #define SP_TYPE_TSPAN (sp_tspan_get_type()) #define SP_TSPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_TSPAN, SPTSpan)) @@ -16,7 +17,6 @@ #define SP_IS_TSPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_TSPAN)) #define SP_IS_TSPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_TSPAN)) - enum { SP_TSPAN_ROLE_UNSPECIFIED, SP_TSPAN_ROLE_PARAGRAPH, @@ -32,8 +32,9 @@ struct SPTSpanClass { SPItemClass parent_class; }; -GType sp_tspan_get_type(); +GType sp_tspan_get_type() G_GNUC_CONST; +G_END_DECLS #endif /* !INKSCAPE_SP_TSPAN_H */ diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 0f45f5444..d5b3c004a 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -38,8 +38,6 @@ /* fixme: */ -static void sp_use_class_init(SPUseClass *classname); -static void sp_use_init(SPUse *use); static void sp_use_finalize(GObject *obj); static void sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -60,32 +58,10 @@ static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); static void sp_use_delete_self(SPObject *deleted, SPUse *self); -static SPItemClass *parent_class; - //void m_print(gchar *say, Geom::Affine m) //{ g_print("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); } -GType -sp_use_get_type(void) -{ - static GType use_type = 0; - if (!use_type) { - GTypeInfo use_info = { - sizeof(SPUseClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_use_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPUse), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_use_init, - NULL, /* value_table */ - }; - use_type = g_type_register_static(SP_TYPE_ITEM, "SPUse", &use_info, (GTypeFlags)0); - } - return use_type; -} +G_DEFINE_TYPE(SPUse, sp_use, SP_TYPE_ITEM); static void sp_use_class_init(SPUseClass *classname) @@ -94,8 +70,6 @@ sp_use_class_init(SPUseClass *classname) SPObjectClass *sp_object_class = (SPObjectClass *) classname; SPItemClass *item_class = (SPItemClass *) classname; - parent_class = (SPItemClass*) g_type_class_ref(SP_TYPE_ITEM); - gobject_class->finalize = sp_use_finalize; sp_object_class->build = sp_use_build; @@ -155,8 +129,8 @@ sp_use_finalize(GObject *obj) static void sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) { - (* ((SPObjectClass *) parent_class)->build)(object, document, repr); + if (((SPObjectClass *) sp_use_parent_class)->build) { + (* ((SPObjectClass *) sp_use_parent_class)->build)(object, document, repr); } object->readAttr( "x" ); @@ -189,8 +163,8 @@ sp_use_release(SPObject *object) use->ref->detach(); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) sp_use_parent_class)->release) { + ((SPObjectClass *) sp_use_parent_class)->release(object); } } @@ -242,8 +216,8 @@ sp_use_set(SPObject *object, unsigned key, gchar const *value) } default: - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_use_parent_class)->set) { + ((SPObjectClass *) sp_use_parent_class)->set(object, key, value); } break; } @@ -258,8 +232,8 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:: repr = xml_doc->createElement("svg:use"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_use_parent_class))->write) { + ((SPObjectClass *) (sp_use_parent_class))->write(object, xml_doc, repr, flags); } sp_repr_set_svg_double(repr, "x", use->x.computed); @@ -380,8 +354,8 @@ sp_use_hide(SPItem *item, unsigned key) SP_ITEM(use->child)->invoke_hide(key); } - if (((SPItemClass *) parent_class)->hide) { - ((SPItemClass *) parent_class)->hide(item, key); + if (((SPItemClass *) sp_use_parent_class)->hide) { + ((SPItemClass *) sp_use_parent_class)->hide(item, key); } } @@ -585,8 +559,8 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; - if (((SPObjectClass *) (parent_class))->update) - ((SPObjectClass *) (parent_class))->update(object, ctx, flags); + if (((SPObjectClass *) (sp_use_parent_class))->update) + ((SPObjectClass *) (sp_use_parent_class))->update(object, ctx, flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 404b0ec1c..459a56161 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -46,8 +46,6 @@ using Inkscape::DocumentUndo; -static void sp_spiral_context_class_init(SPSpiralContextClass * klass); -static void sp_spiral_context_init(SPSpiralContext *spiral_context); static void sp_spiral_context_dispose(GObject *object); static void sp_spiral_context_setup(SPEventContext *ec); static void sp_spiral_context_finish(SPEventContext *ec); @@ -59,27 +57,7 @@ static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point const &p, guint stat static void sp_spiral_finish(SPSpiralContext *sc); static void sp_spiral_cancel(SPSpiralContext *sc); -static SPEventContextClass *parent_class; - -GType -sp_spiral_context_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPSpiralContextClass), - NULL, NULL, - (GClassInitFunc) sp_spiral_context_class_init, - NULL, NULL, - sizeof(SPSpiralContext), - 4, - (GInstanceInitFunc) sp_spiral_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPSpiralContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPSpiralContext, sp_spiral_context, SP_TYPE_EVENT_CONTEXT); static void sp_spiral_context_class_init(SPSpiralContextClass *klass) @@ -87,8 +65,6 @@ sp_spiral_context_class_init(SPSpiralContextClass *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_spiral_context_dispose; event_context_class->setup = sp_spiral_context_setup; @@ -129,8 +105,8 @@ static void sp_spiral_context_finish(SPEventContext *ec) sp_spiral_finish(sc); sc->sel_changed_connection.disconnect(); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->finish(ec); } } @@ -155,7 +131,7 @@ sp_spiral_context_dispose(GObject *object) delete sc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_spiral_context_parent_class)->dispose(object); } /** @@ -177,8 +153,8 @@ sp_spiral_context_setup(SPEventContext *ec) { SPSpiralContext *sc = SP_SPIRAL_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->setup(ec); sp_event_context_read(ec, "expansion"); sp_event_context_read(ec, "revolution"); @@ -398,8 +374,8 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->root_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_spiral_context_parent_class))->root_handler(event_context, event); } return ret; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index f04d92616..7cbd92eeb 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1002,8 +1002,8 @@ sp_selected_path_outline(SPDesktop *desktop) break; } - if (o_width < 0.1) - o_width = 0.1; + if (o_width < 0.032) + o_width = 0.032; o_miter = i_style->stroke_miterlimit.value * o_width; } diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8d74477c3..694e3a500 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -78,16 +78,13 @@ using namespace std; #define DDC_RED_RGBA 0xff0000ff #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_spray_context_class_init(SPSprayContextClass *klass); -static void sp_spray_context_init(SPSprayContext *ddc); static void sp_spray_context_dispose(GObject *object); static void sp_spray_context_setup(SPEventContext *ec); static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); static gint sp_spray_context_root_handler(SPEventContext *ec, GdkEvent *event); -static SPEventContextClass *parent_class = 0; - +G_DEFINE_TYPE(SPSprayContext, sp_spray_context, SP_TYPE_EVENT_CONTEXT); /** * This function returns pseudo-random numbers from a normal distribution @@ -100,32 +97,11 @@ inline double NormalDistribution(double mu, double sigma) return mu + sigma * sqrt( -2.0 * log(g_random_double_range(0, 1)) ) * cos( 2.0*M_PI*g_random_double_range(0, 1) ); } -GType sp_spray_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPSprayContextClass), - NULL, NULL, - (GClassInitFunc) sp_spray_context_class_init, - NULL, NULL, - sizeof(SPSprayContext), - 4, - (GInstanceInitFunc) sp_spray_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPSprayContext", &info, (GTypeFlags)0); - } - return type; -} - static void sp_spray_context_class_init(SPSprayContextClass *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_spray_context_dispose; event_context_class->setup = sp_spray_context_setup; @@ -204,7 +180,7 @@ static void sp_spray_context_dispose(GObject *object) delete tc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_spray_context_parent_class)->dispose(object); } static bool is_transform_modes(gint mode) @@ -251,8 +227,8 @@ static void sp_spray_context_setup(SPEventContext *ec) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->setup(ec); } { @@ -926,8 +902,8 @@ gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *even } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/star-context.cpp b/src/star-context.cpp index ae12e8c35..e2d6961f0 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -50,8 +50,6 @@ using Inkscape::DocumentUndo; -static void sp_star_context_class_init (SPStarContextClass * klass); -static void sp_star_context_init (SPStarContext * star_context); static void sp_star_context_dispose (GObject *object); static void sp_star_context_setup (SPEventContext *ec); @@ -63,27 +61,7 @@ static void sp_star_drag (SPStarContext * sc, Geom::Point p, guint state); static void sp_star_finish (SPStarContext * sc); static void sp_star_cancel(SPStarContext * sc); -static SPEventContextClass * parent_class; - -GType -sp_star_context_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPStarContextClass), - NULL, NULL, - (GClassInitFunc) sp_star_context_class_init, - NULL, NULL, - sizeof (SPStarContext), - 4, - (GInstanceInitFunc) sp_star_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_EVENT_CONTEXT, "SPStarContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPStarContext, sp_star_context, SP_TYPE_EVENT_CONTEXT); static void sp_star_context_class_init (SPStarContextClass * klass) @@ -91,8 +69,6 @@ sp_star_context_class_init (SPStarContextClass * 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_star_context_dispose; event_context_class->setup = sp_star_context_setup; @@ -134,8 +110,8 @@ static void sp_star_context_finish(SPEventContext *ec) sp_star_finish(sc); sc->sel_changed_connection.disconnect(); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->finish(ec); } } @@ -161,7 +137,7 @@ sp_star_context_dispose (GObject *object) delete sc->_message_context; } - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (sp_star_context_parent_class)->dispose (object); } /** @@ -187,8 +163,8 @@ sp_star_context_setup (SPEventContext *ec) { SPStarContext *sc = SP_STAR_CONTEXT (ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup (ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->setup) + (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->setup (ec); sp_event_context_read (ec, "magnitude"); sp_event_context_read (ec, "proportion"); @@ -413,8 +389,8 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler (event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->root_handler) + ret = (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->root_handler (event_context, event); } return ret; diff --git a/src/syseq.h b/src/syseq.h index 5c7702268..029f27a91 100644 --- a/src/syseq.h +++ b/src/syseq.h @@ -279,7 +279,7 @@ template <int S, int T> SolutionKind gaussjord_solve (double A[S][T], double x[T // we need to adapt the value if we we are in the "projective case" (see above) double val_new = (proj ? projectify<S,T>(cols, B, x, index, val) : val); - if (index != -1 && index >= 0 && index < T) { + if (index >= 0 && index < T) { // we want the specified coefficient of the solution vector to have a given value x[index] = val_new; } 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 } diff --git a/src/trace/filterset.cpp b/src/trace/filterset.cpp index 908985225..f6c025956 100644 --- a/src/trace/filterset.cpp +++ b/src/trace/filterset.cpp @@ -365,41 +365,6 @@ grayMapCanny(GrayMap *gm, double lowThreshold, double highThreshold) - - - - -/** - * - */ -GdkPixbuf * -gdkCanny(GdkPixbuf *img, double lowThreshold, double highThreshold) -{ - if (!img) - return NULL; - - - GrayMap *grayMap = gdkPixbufToGrayMap(img); - if (!grayMap) - return NULL; - - /*grayMap->writePPM(grayMap, "gbefore.ppm");*/ - - GrayMap *cannyGm = grayMapCanny(grayMap,lowThreshold, highThreshold); - - grayMap->destroy(grayMap); - - if (!cannyGm) - return NULL; - - /*grayMap->writePPM(grayMap, "gafter.ppm");*/ - - GdkPixbuf *newImg = grayMapToGdkPixbuf(cannyGm); - - - return newImg; -} - /*######################################################################### ### Q U A N T I Z A T I O N #########################################################################*/ diff --git a/src/trace/filterset.h b/src/trace/filterset.h index eeafc079f..820d225c3 100644 --- a/src/trace/filterset.h +++ b/src/trace/filterset.h @@ -40,12 +40,6 @@ GrayMap *grayMapCanny(GrayMap *gmap, /** * */ -GdkPixbuf *gdkCanny(GdkPixbuf *img, - double lowThreshold, double highThreshold); - -/** - * - */ GrayMap *quantizeBand(RgbMap *rgbmap, int nrColors); diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index e5ff23ad0..7c7139002 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -58,7 +58,7 @@ GdkPixbuf *grayMapToGdkPixbuf(GrayMap *grayMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, grayMap->width, grayMap->height, - rowstride, NULL, NULL); + rowstride, (GdkPixbufDestroyNotify)g_free, NULL); //### Fill in the odd cells with RGB values int x,y; @@ -122,44 +122,6 @@ PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf) return ppMap; } -GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) -{ - if (!ppMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * ppMap->width * ppMap->height * 3); - if (!pixdata) - return NULL; - - int n_channels = 3; - int rowstride = ppMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, ppMap->width, ppMap->height, - rowstride, NULL, NULL); - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; y<ppMap->height ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; x<ppMap->width ; x++) - { - unsigned long rgb = ppMap->getPixel(ppMap, x, y); - p[0] = (rgb >> 16) & 0xff; - p[1] = (rgb >> 8) & 0xff; - p[2] = (rgb ) & 0xff; - p += n_channels; - } - row += rowstride; - } - - return buf; -} - - /*######################################################################### ## R G B M A P @@ -203,42 +165,7 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) return rgbMap; } -GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) -{ - if (!rgbMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * rgbMap->width * rgbMap->height * 3); - if (!pixdata) - return NULL; - int n_channels = 3; - int rowstride = rgbMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, rgbMap->width, rgbMap->height, - rowstride, NULL, NULL); - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; y<rgbMap->height ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; x<rgbMap->width ; x++) - { - RGB rgb = rgbMap->getPixel(rgbMap, x, y); - p[0] = rgb.r & 0xff; - p[1] = rgb.g & 0xff; - p[2] = rgb.b & 0xff; - p += n_channels; - } - row += rowstride; - } - - return buf; -} /*######################################################################### ## I N D E X E D M A P @@ -260,7 +187,7 @@ GdkPixbuf *indexedMapToGdkPixbuf(IndexedMap *iMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, iMap->width, iMap->height, - rowstride, NULL, NULL); + rowstride, (GdkPixbufDestroyNotify)g_free, NULL); //### Fill in the cells with RGB values int x,y; diff --git a/src/trace/imagemap-gdk.h b/src/trace/imagemap-gdk.h index d04a84d8e..63281658a 100644 --- a/src/trace/imagemap-gdk.h +++ b/src/trace/imagemap-gdk.h @@ -24,17 +24,9 @@ extern "C" { #endif GrayMap *gdkPixbufToGrayMap(GdkPixbuf *buf); - GdkPixbuf *grayMapToGdkPixbuf(GrayMap *grayMap); - PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf); - -GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap); - RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf); - -GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap); - GdkPixbuf *indexedMapToGdkPixbuf(IndexedMap *iMap); diff --git a/src/trace/imagemap.cpp b/src/trace/imagemap.cpp index c5a6bc2b5..a8d8a8c8f 100644 --- a/src/trace/imagemap.cpp +++ b/src/trace/imagemap.cpp @@ -192,16 +192,18 @@ PackedPixelMap *PackedPixelMapCreate(int width, int height) /** fields **/ me->width = width; me->height = height; - me->pixels = (unsigned long *) - malloc(sizeof(unsigned long) * width * height); - me->rows = (unsigned long **) - malloc(sizeof(unsigned long *) * height); - if (!me->pixels) - { + me->pixels = (unsigned long *) malloc(sizeof(unsigned long) * width * height); + if (!me->pixels){ free(me); return NULL; - } - + } + me->rows = (unsigned long **) malloc(sizeof(unsigned long *) * height); + if (!me->rows){ + free(me->pixels); //allocated as me->pixels is not NULL here: see previous check + free(me); + return NULL; + } + unsigned long *row = me->pixels; for (int i=0 ; i<height ; i++) { @@ -270,10 +272,12 @@ static int rWritePPM(RgbMap *me, char *fileName) static void rDestroy(RgbMap *me) { - if (me->pixels) + if (me->pixels){ free(me->pixels); - if (me->rows) + } + if (me->rows){ free(me->rows); + } free(me); } @@ -283,9 +287,10 @@ RgbMap *RgbMapCreate(int width, int height) { RgbMap *me = (RgbMap *)malloc(sizeof(RgbMap)); - if (!me) + if (!me){ return NULL; - + } + /** methods **/ me->setPixel = rSetPixel; me->setPixelRGB = rSetPixelRGB; @@ -297,22 +302,23 @@ RgbMap *RgbMapCreate(int width, int height) /** fields **/ me->width = width; me->height = height; - me->pixels = (RGB *) - malloc(sizeof(RGB) * width * height); - me->rows = (RGB **) - malloc(sizeof(RGB *) * height); - if (!me->pixels) - { + me->pixels = (RGB *) malloc(sizeof(RGB) * width * height); + if (!me->pixels){ free(me); return NULL; - } + } + me->rows = (RGB **) malloc(sizeof(RGB *) * height); + if (!me->rows){ + free(me->pixels); //allocated as me->pixels is not NULL here: see previous check + free(me); + return NULL; + } RGB *row = me->pixels; - for (int i=0 ; i<height ; i++) - { + for (int i=0 ; i<height ; i++){ me->rows[i] = row; row += width; - } + } return me; } @@ -376,10 +382,12 @@ static int iWritePPM(IndexedMap *me, char *fileName) static void iDestroy(IndexedMap *me) { - if (me->pixels) + if (me->pixels){ free(me->pixels); - if (me->rows) + } + if (me->rows){ free(me->rows); + } free(me); } @@ -403,31 +411,31 @@ IndexedMap *IndexedMapCreate(int width, int height) /** fields **/ me->width = width; me->height = height; - me->pixels = (unsigned int *) - malloc(sizeof(unsigned int) * width * height); - me->rows = (unsigned int **) - malloc(sizeof(unsigned int *) * height); - if (!me->pixels) - { + me->pixels = (unsigned int *) malloc(sizeof(unsigned int) * width * height); + if (!me->pixels){ free(me); return NULL; - } + } + me->rows = (unsigned int **) malloc(sizeof(unsigned int *) * height); + if (!me->rows){ + free(me->pixels); //allocated as me->pixels is not NULL here: see previous check + free(me); + return NULL; + } unsigned int *row = me->pixels; - for (int i=0 ; i<height ; i++) - { + for (int i=0 ; i<height ; i++){ me->rows[i] = row; row += width; - } + } me->nrColors = 0; RGB rgb; rgb.r = rgb.g = rgb.b = 0; - for (int i=0; i<256 ; i++) - { + for (int i=0; i<256 ; i++){ me->clut[i] = rgb; - } + } return me; } diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 870b9cce1..28e4c1629 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -81,35 +81,13 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_tweak_context_class_init(SPTweakContextClass *klass); -static void sp_tweak_context_init(SPTweakContext *ddc); static void sp_tweak_context_dispose(GObject *object); static void sp_tweak_context_setup(SPEventContext *ec); static void sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); static gint sp_tweak_context_root_handler(SPEventContext *ec, GdkEvent *event); -static SPEventContextClass *parent_class; - -GType -sp_tweak_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPTweakContextClass), - NULL, NULL, - (GClassInitFunc) sp_tweak_context_class_init, - NULL, NULL, - sizeof(SPTweakContext), - 4, - (GInstanceInitFunc) sp_tweak_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPTweakContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPTweakContext, sp_tweak_context, SP_TYPE_EVENT_CONTEXT); static void sp_tweak_context_class_init(SPTweakContextClass *klass) @@ -117,8 +95,6 @@ sp_tweak_context_class_init(SPTweakContextClass *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_tweak_context_dispose; event_context_class->setup = sp_tweak_context_setup; @@ -173,7 +149,7 @@ sp_tweak_context_dispose(GObject *object) delete tc->_message_context; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_tweak_context_parent_class)->dispose(object); } static bool is_transform_mode (gint mode) @@ -290,8 +266,8 @@ sp_tweak_context_setup(SPEventContext *ec) { SPTweakContext *tc = SP_TWEAK_CONTEXT(ec); - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup(ec); } { @@ -1535,8 +1511,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler(event_context, event); } } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index f267c5ae9..ecdfd3346 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -63,7 +63,12 @@ #include "helper/png-write.h" +#if WITH_EXT_GDL +#include <gdl/gdl-dock-item.h> +#else #include "libgdl/gdl-dock-item.h" +#endif + // required to set status message after export #include "desktop.h" diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 6425d9fee..496836c4d 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -26,6 +26,9 @@ #include <gdk/gdkwin32.h> #include <glib/gstdio.h> #include <glibmm/i18n.h> +#if GLIB_CHECK_VERSION(2,32,0) +#include <glibmm/thread.h> +#endif #include <gtkmm/window.h> //Inkscape includes @@ -133,7 +136,11 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent, Glib::RefPtr<const Gdk::Window> parentWindow = parent.get_window(); g_assert(parentWindow->gobj() != NULL); +#if WITH_GTKMM_3_0 + _ownerHwnd = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); +#else _ownerHwnd = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); +#endif } FileDialogBaseWin32::~FileDialogBaseWin32() @@ -1576,16 +1583,23 @@ FileOpenDialogImplWin32::show() // We can only run one worker thread at a time if(_mutex != NULL) return false; +#if !GLIB_CHECK_VERSION(2,32,0) if(!Glib::thread_supported()) Glib::thread_init(); +#endif _result = false; _finished = false; _file_selected = false; - _mutex = new Glib::Mutex(); _main_loop = g_main_loop_new(g_main_context_default(), FALSE); +#if GLIB_CHECK_VERSION(2,32,0) + _mutex = new Glib::Threads::Mutex(); + if(Glib::Threads::Thread::create(sigc::mem_fun(*this, &FileOpenDialogImplWin32::GetOpenFileName_thread))) +#else + _mutex = new Glib::Mutex(); if(Glib::Thread::create(sigc::mem_fun(*this, &FileOpenDialogImplWin32::GetOpenFileName_thread), true)) +#endif { while(1) { @@ -1870,15 +1884,21 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() bool FileSaveDialogImplWin32::show() { +#if !GLIB_CHECK_VERSION(2,32,0) if(!Glib::thread_supported()) Glib::thread_init(); +#endif _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); if(_main_loop != NULL) { +#if GLIB_CHECK_VERSION(2,32,0) + if(Glib::Threads::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread))) +#else if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) +#endif g_main_loop_run(_main_loop); if(_result && _extension) diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index 15953f9d8..e9d8829f7 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -226,7 +226,11 @@ private: /// This mutex is used to ensure that the worker thread /// that calls GetOpenFileName cannot collide with the /// main Inkscape thread +#if GLIB_CHECK_VERSION(2,32,0) + Glib::Threads::Mutex *_mutex; +#else Glib::Mutex *_mutex; +#endif /// The controller function for the thread which calls diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 418132abb..50f30e8f4 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1730,8 +1730,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair (bg_color_active.green + fg_color_active.green)/2.0, (bg_color_active.blue + fg_color_active.blue)/2.0, (bg_color_active.alpha + fg_color_active.alpha)/2.0}; - - GdkRGBA black = {0,0,0,1}; #else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); #endif @@ -1902,11 +1900,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair // Draw drag connection if(row_prim == prim && _in_drag) { cr->save(); -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr->cobj(), &black); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); -#endif + cr->set_source_rgb(0.0, 0.0, 0.0); cr->move_to(outline_x, con_drag_y); cr->line_to(mx, con_drag_y); cr->line_to(mx, my); @@ -1936,8 +1930,6 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai (bg_color.green + fg_color.green)/2.0, (bg_color.blue + fg_color.blue)/2.0, (bg_color.alpha + fg_color.alpha)/2.0}; - - GdkRGBA black = {0,0,0,1}; #else GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); #endif @@ -1955,17 +1947,14 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai const int tw = get_input_type_width(); gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1; -#if GTK_CHECK_VERSION(3,0,0) if(use_default && is_first) - gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); - else - gdk_cairo_set_source_rgba(cr->cobj(), &black); +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); #else - if(use_default && is_first) - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); - else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); + gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); #endif + else + cr->set_source_rgb(0.0, 0.0, 0.0); cr->rectangle(end_x-2, y1-2, 5, 5); cr->fill_preserve(); @@ -1993,11 +1982,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai const int y2 = rct.get_y() + rct.get_height(); // Draw a bevelled 'L'-shaped connection -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr->cobj(), &black); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->black)); -#endif + cr->set_source_rgb(0.0, 0.0, 0.0); cr->move_to(x1, y1); cr->line_to(x2-fheight/4, y1); cr->line_to(x2, y1-fheight/4); diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 24588946e..07e73cec8 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -260,7 +260,7 @@ Glib::ustring FontSubstitution::getSubstituteFontName (Glib::ustring font) font_instance *res = (font_factory::Default())->Face(descr); if (res->pFont) { PangoFontDescription *nFaceDesc = pango_font_describe(res->pFont); - out = pango_font_description_get_family(nFaceDesc); + out = sp_font_description_get_family(nFaceDesc); } pango_font_description_free(descr); diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 6aff67f69..1df0d606e 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -999,7 +999,7 @@ InputDialogImpl::ConfPanel::ConfPanel() : titleLabel(""), axisFrame(_("Axes")), keysFrame(_("Keys")), - modeLabel(_("Mode")), + modeLabel(_("Mode:")), modeBox(false, 4) { diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index f0801734a..0800346f7 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -69,15 +69,25 @@ ObjectProperties::ObjectProperties (void) : subselChangedConn() { //initialize labels for the table at the bottom of the dialog - int_labels.push_back("onclick"); - int_labels.push_back("onmouseover"); - int_labels.push_back("onmouseout"); - int_labels.push_back("onmousedown"); - int_labels.push_back("onmouseup"); - int_labels.push_back("onmousemove"); - int_labels.push_back("onfocusin"); - int_labels.push_back("onfocusout"); - int_labels.push_back("onload"); + int_attrs.push_back("onclick"); + int_attrs.push_back("onmouseover"); + int_attrs.push_back("onmouseout"); + int_attrs.push_back("onmousedown"); + int_attrs.push_back("onmouseup"); + int_attrs.push_back("onmousemove"); + int_attrs.push_back("onfocusin"); + int_attrs.push_back("onfocusout"); + int_attrs.push_back("onload"); + + int_labels.push_back("onclick:"); + int_labels.push_back("onmouseover:"); + int_labels.push_back("onmouseout:"); + int_labels.push_back("onmousedown:"); + int_labels.push_back("onmouseup:"); + int_labels.push_back("onmousemove:"); + int_labels.push_back("onfocusin:"); + int_labels.push_back("onfocusout:"); + int_labels.push_back("onload:"); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -291,7 +301,7 @@ void ObjectProperties::widget_setup(void) if (CurrentItem == NULL) { - attrTable.set_object(obj, int_labels, int_labels, (GtkWidget*)EInteractivity.gobj()); + attrTable.set_object(obj, int_labels, int_attrs, (GtkWidget*)EInteractivity.gobj()); } else { diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index 0bf622ce4..a04c62bec 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -67,6 +67,7 @@ public: private: bool blocked; SPItem *CurrentItem; //to store the current item, for not wasting resources + std::vector<Glib::ustring> int_attrs; std::vector<Glib::ustring> int_labels; Gtk::Table TopTable; //the table with the object properties diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 71674368b..97d8b0523 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -432,6 +432,9 @@ void SymbolsDialog::get_symbols() { GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) { + if (!r) { + return l; + } // Stop multiple counting of same symbol if( SP_IS_USE(r) ) { diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 7b6502ec3..e743e0efc 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -107,8 +107,6 @@ using Inkscape::ControlManager; namespace { SPCanvasGroup *create_control_group(SPDesktop *d); -void ink_node_tool_class_init(InkNodeToolClass *klass); -void ink_node_tool_init(InkNodeTool *node_context); void ink_node_tool_dispose(GObject *object); void ink_node_tool_setup(SPEventContext *ec); @@ -126,39 +124,10 @@ void handleControlUiStyleChange(InkNodeTool *nt); } // anonymous namespace -GType ink_node_tool_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(InkNodeToolClass), - NULL, NULL, - (GClassInitFunc) ink_node_tool_class_init, - NULL, NULL, - sizeof(InkNodeTool), - 4, - (GInstanceInitFunc) ink_node_tool_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "InkNodeTool", &info, (GTypeFlags)0); - } - return type; -} - -namespace { - -SPCanvasGroup *create_control_group(SPDesktop *d) -{ - return reinterpret_cast<SPCanvasGroup*>(sp_canvas_item_new( - sp_desktop_controls(d), SP_TYPE_CANVAS_GROUP, NULL)); -} - -void destroy_group(SPCanvasGroup *g) -{ - sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); -} +G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); -void ink_node_tool_class_init(InkNodeToolClass *klass) +static void +ink_node_tool_class_init(InkNodeToolClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; @@ -171,7 +140,8 @@ void ink_node_tool_class_init(InkNodeToolClass *klass) event_context_class->item_handler = ink_node_tool_item_handler; } -void ink_node_tool_init(InkNodeTool *nt) +static void +ink_node_tool_init(InkNodeTool *nt) { SPEventContext *event_context = SP_EVENT_CONTEXT(nt); @@ -191,6 +161,19 @@ void ink_node_tool_init(InkNodeTool *nt) new (&nt->_shape_editors) ShapeEditors(); } +namespace { + +SPCanvasGroup *create_control_group(SPDesktop *d) +{ + return reinterpret_cast<SPCanvasGroup*>(sp_canvas_item_new( + sp_desktop_controls(d), SP_TYPE_CANVAS_GROUP, NULL)); +} + +void destroy_group(SPCanvasGroup *g) +{ + sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); +} + void ink_node_tool_dispose(GObject *object) { InkNodeTool *nt = INK_NODE_TOOL(object); @@ -228,15 +211,15 @@ void ink_node_tool_dispose(GObject *object) delete nt->_node_message_context; } - G_OBJECT_CLASS(g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)))->dispose(object); + G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); } void ink_node_tool_setup(SPEventContext *ec) { InkNodeTool *nt = INK_NODE_TOOL(ec); - SPEventContextClass *parent = (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent->setup) parent->setup(ec); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) + SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); @@ -372,10 +355,8 @@ void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) nt->edit_masks = value->getBool(); ink_node_tool_selection_changed(nt, nt->desktop->selection); } else { - SPEventContextClass *parent_class = - (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->set) - parent_class->set(ec, value); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) + SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); } } @@ -556,9 +537,9 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) default: break; } - SPEventContextClass *parent_class = (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->root_handler) - return parent_class->root_handler(event_context, event); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) + return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler(event_context, event); + return FALSE; } @@ -622,10 +603,9 @@ void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event) gint ink_node_tool_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { - SPEventContextClass *parent_class = - (SPEventContextClass *) g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)); - if (parent_class->item_handler) - return parent_class->item_handler(event_context, item, event); + if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) + return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); + return FALSE; } diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 412c7ff8c..26e47abbb 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -101,9 +101,6 @@ struct EditWidgetInterface /// Update the "inactive desktop" indicator virtual void deactivateDesktop() = 0; - /// Set rulers to position - virtual void viewSetPosition (Geom::Point p) = 0; - /// Update rulers from current values virtual void updateRulers() = 0; diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index e13976cc4..72548e213 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -27,12 +27,6 @@ namespace UI { namespace View { static void -_onPositionSet (double x, double y, View* v) -{ - v->onPositionSet (x,y); -} - -static void _onResized (double x, double y, View* v) { v->onResized (x,y); @@ -69,7 +63,6 @@ View::View() _message_stack = GC::release(new Inkscape::MessageStack()); _tips_message_context = new Inkscape::MessageContext(_message_stack); - _position_set_connection = _position_set_signal.connect (sigc::bind (sigc::ptr_fun (&_onPositionSet), this)); _resized_connection = _resized_signal.connect (sigc::bind (sigc::ptr_fun (&_onResized), this)); _redraw_requested_connection = _redraw_requested_signal.connect (sigc::bind (sigc::ptr_fun (&_onRedrawRequested), this)); @@ -102,16 +95,6 @@ void View::_close() { Inkscape::Verb::delete_all_view (this); } -void View::setPosition (double x, double y) -{ - _position_set_signal.emit (x,y); -} - -void View::setPosition(Geom::Point const &p) -{ - setPosition (double(p[Geom::X]), double(p[Geom::Y])); -} - void View::emitResized (double width, double height) { _resized_signal.emit (width, height); diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 6ed9f476c..48f4d2549 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -90,8 +90,6 @@ public: Inkscape::MessageContext *tipsMessageContext() const { return _tips_message_context; } - void setPosition(gdouble x, gdouble y); - void setPosition(Geom::Point const &p); void emitResized(gdouble width, gdouble height); void requestRedraw(); @@ -101,7 +99,6 @@ public: virtual void mouseover() = 0; virtual void mouseout() = 0; - virtual void onPositionSet (double, double) = 0; virtual void onResized (double, double) = 0; virtual void onRedrawRequested() = 0; virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) = 0; @@ -126,13 +123,11 @@ protected: */ virtual void setDocument(SPDocument *doc); - sigc::signal<void,double,double> _position_set_signal; sigc::signal<void,double,double> _resized_signal; sigc::signal<void,gchar const*> _document_uri_set_signal; sigc::signal<void> _redraw_requested_signal; private: - sigc::connection _position_set_connection; sigc::connection _resized_connection; sigc::connection _redraw_requested_connection; sigc::connection _message_changed_connection; // foreign diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index d7be6c9f0..467f0d70e 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -25,8 +25,6 @@ #include "button.h" -static void sp_button_class_init (SPButtonClass *klass); -static void sp_button_init (SPButton *button); static void sp_button_dispose(GObject *object); #if GTK_CHECK_VERSION(3,0,0) @@ -50,28 +48,7 @@ static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action static void sp_button_action_set_active (SPButton *button, bool active); static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); -static GtkToggleButtonClass *parent_class; - -GType sp_button_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPButtonClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_button_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPButton), - 0, // n_preallocs - (GInstanceInitFunc)sp_button_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TOGGLE_BUTTON, "SPButton", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); static void sp_button_class_init (SPButtonClass *klass) @@ -80,8 +57,6 @@ sp_button_class_init (SPButtonClass *klass) GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - parent_class = GTK_TOGGLE_BUTTON_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_button_dispose; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_button_get_preferred_width; @@ -120,10 +95,10 @@ static void sp_button_dispose(GObject *object) sp_button_set_doubleclick_action (button, NULL); } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } @@ -185,7 +160,7 @@ sp_button_clicked (GtkButton *button) SPButton *sp_button=SP_BUTTON (button); if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(parent_class))->clicked (button); + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); } } @@ -340,3 +315,13 @@ sp_button_new_from_data( Inkscape::IconSize size, return button; } +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index a7432c32a..9e078cabb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -313,6 +313,22 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) } /** + * Callback for changes in size of the canvas table (i.e. the container for + * the canvas, the rulers etc). + * + * This adjusts the range of the rulers when the dock container is adjusted + * (fixes lp:950552) + */ +static void +canvas_tbl_size_allocate(GtkWidget *widget, + GdkRectangle *allocation, + gpointer data) +{ + SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); + sp_desktop_widget_update_rulers (dtw); +} + +/** * Callback for SPDesktopWidget object initialization. */ void SPDesktopWidget::init( SPDesktopWidget *dtw ) @@ -385,14 +401,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) GtkWidget *tbl = gtk_grid_new(); - GtkWidget *canvas_tbl = gtk_grid_new(); + dtw->canvas_tbl = gtk_grid_new(); - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1); #else GtkWidget *tbl = gtk_table_new(2, 3, FALSE); - GtkWidget *canvas_tbl = gtk_table_new(3, 3, FALSE); + dtw->canvas_tbl = gtk_table_new(3, 3, FALSE); - gtk_table_attach(GTK_TABLE(canvas_tbl), + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), eventbox, 1, 2, 0, 1, GTK_FILL, GTK_FILL, @@ -410,9 +426,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 0, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 0, 1, 1, 1); #else - gtk_table_attach(GTK_TABLE (canvas_tbl), + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), eventbox, 0, 1, 1, 2, GTK_FILL, GTK_FILL, @@ -428,11 +444,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj)); - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #else dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); - gtk_table_attach(GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, + gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0); dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0); @@ -460,9 +476,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0); #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); #else - gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, + gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, GTK_SHRINK, GTK_FILL, 0, 0); #endif @@ -498,9 +514,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach( GTK_GRID(canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); + gtk_grid_attach( GTK_GRID(dtw->canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); #else - gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, + gtk_table_attach( GTK_TABLE(dtw->canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0); @@ -520,6 +536,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE); + sp_ruler_add_track_widget (SP_RULER(dtw->hruler), GTK_WIDGET(dtw->canvas)); + sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas)); + #if GTK_CHECK_VERSION(3,0,0) GdkRGBA white = {1,1,1,1}; gtk_widget_override_background_color(GTK_WIDGET(dtw->canvas), @@ -541,9 +560,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); - gtk_grid_attach(GTK_GRID(canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); + gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); + gtk_table_attach (GTK_TABLE (dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0); #endif /* Dock */ @@ -560,7 +579,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Gtk::HPaned *paned = new Gtk::HPaned(); #endif - paned->pack1(*Glib::wrap(canvas_tbl)); + paned->pack1(*Glib::wrap(dtw->canvas_tbl)); paned->pack2(dtw->dock->getWidget(), Gtk::FILL); /* Prevent the paned from catching F6 and F8 by unsetting the default callbacks */ @@ -580,11 +599,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } else { #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_widget_set_vexpand(GTK_WIDGET(canvas_tbl), TRUE); - gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (canvas_tbl), 1, 1, 1, 1); + gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); + gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1); #else - gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), + gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); #endif } @@ -740,6 +759,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } overallTimer = 0; } + + // Ensure that ruler ranges are updated correctly whenever the canvas table + // is resized + g_signal_connect (G_OBJECT (dtw->canvas_tbl), + "size-allocate", + G_CALLBACK (canvas_tbl_size_allocate), + dtw); } /** @@ -761,6 +787,8 @@ static void sp_desktop_widget_dispose(GObject *object) g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); + g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw); + dtw->layer_selector->setDesktop(NULL); dtw->layer_selector->unreference(); @@ -970,12 +998,13 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt if (GTK_WIDGET_CLASS (dtw_parent_class)->event) { return (* GTK_WIDGET_CLASS (dtw_parent_class)->event) (widget, event); } else { - // The keypress events need to be passed to desktop handler explicitly, - // because otherwise the event contexts only receive keypresses when the mouse cursor - // is over the canvas. This redirection is only done for keypresses and only if there's no + // The key press/release events need to be passed to desktop handler explicitly, + // because otherwise the event contexts only receive key events when the mouse cursor + // is over the canvas. This redirection is only done for key events and only if there's no // current item on the canvas, because item events and all mouse events are caught // and passed on by the canvas acetate (I think). --bb - if (event->type == GDK_KEY_PRESS && !dtw->canvas->current_item) { + if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) + && !dtw->canvas->current_item) { return sp_desktop_root_handler (NULL, event, dtw->desktop); } } @@ -1685,13 +1714,6 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) return dtw; } -void -SPDesktopWidget::viewSetPosition (Geom::Point p) -{ - Geom::Point const origin = ( p - ruler_origin ); - sp_ruler_set_position(SP_RULER(hruler), origin[Geom::X]); - sp_ruler_set_position(SP_RULER(vruler), origin[Geom::Y]); -} void sp_desktop_widget_update_rulers (SPDesktopWidget *dtw) diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 73194304f..0ffedd112 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -105,7 +105,11 @@ struct SPDesktopWidget { unsigned int _interaction_disabled_counter; - SPCanvas *canvas; + SPCanvas *canvas; + + /** A table for displaying the canvas, rulers etc */ + GtkWidget *canvas_tbl; + Geom::Point ruler_origin; double dt2r; @@ -168,8 +172,6 @@ struct SPDesktopWidget { { sp_dtw_desktop_activate (_dtw); } virtual void deactivateDesktop() { sp_dtw_desktop_deactivate (_dtw); } - virtual void viewSetPosition (Geom::Point p) - { _dtw->viewSetPosition (p); } virtual void updateRulers() { sp_desktop_widget_update_rulers (_dtw); } virtual void updateScrollbars (double scale) diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index b17dcf470..b0b4b5504 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -442,6 +442,10 @@ GtkWidget *sp_font_selector_new() */ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) { + if ( !font || !list) { + return 0; + } + font_instance *tempFont = NULL; unsigned int currentStyleNumber = 0; unsigned int bestStyleNumber = 0; @@ -462,7 +466,9 @@ unsigned int sp_font_selector_get_best_style (font_instance *font, GList *list) tempFont = NULL; } - pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + if( bestMatchForFont != NULL ) { + pango_font_description_unset_fields(bestMatchForFont, PANGO_FONT_MASK_SIZE); + } list = list->next; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7866989b1..8470e93db 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -41,9 +41,6 @@ #include "icon.h" struct IconImpl { - static void classInit(SPIconClass *klass); - static void init(SPIcon *icon); - static GtkWidget *newFull( Inkscape::IconSize lsize, gchar const *name ); static void dispose(GObject *object); @@ -104,12 +101,10 @@ struct IconImpl { private: static const std::string magicNumber; - static GtkWidgetClass *parent_class; static std::map<Glib::ustring, Glib::ustring> legacyNames; }; const std::string IconImpl::magicNumber = "1.0"; -GtkWidgetClass *IconImpl::parent_class = 0; std::map<Glib::ustring, Glib::ustring> IconImpl::legacyNames; @@ -141,34 +136,14 @@ public: static std::map<Glib::ustring, std::vector<IconCacheItem> > iconSetCache; static std::set<Glib::ustring> internalNames; -GType SPIcon::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPIconClass), - NULL, - NULL, - reinterpret_cast<GClassInitFunc>(IconImpl::classInit), - NULL, - NULL, - sizeof(SPIcon), - 0, - reinterpret_cast<GInstanceInitFunc>(IconImpl::init), - NULL - }; - type = g_type_register_static(GTK_TYPE_WIDGET, "SPIcon", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPIcon, sp_icon, GTK_TYPE_WIDGET); -void IconImpl::classInit(SPIconClass *klass) +static void +sp_icon_class_init(SPIconClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = IconImpl::dispose; #if GTK_CHECK_VERSION(3,0,0) @@ -184,7 +159,8 @@ void IconImpl::classInit(SPIconClass *klass) widget_class->style_set = IconImpl::styleSet; } -void IconImpl::init(SPIcon *icon) +static void +sp_icon_init(SPIcon *icon) { gtk_widget_set_has_window (GTK_WIDGET (icon), FALSE); icon->lsize = Inkscape::ICON_SIZE_BUTTON; @@ -202,7 +178,7 @@ void IconImpl::dispose(GObject *object) icon->name = 0; } - (G_OBJECT_CLASS(parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_icon_parent_class))->dispose(object); } void IconImpl::reset( SPIcon *icon ) @@ -375,8 +351,8 @@ GdkPixbuf* IconImpl::renderup( gchar const* name, Inkscape::IconSize lsize, unsi void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) { - if ( GTK_WIDGET_CLASS( parent_class )->screen_changed ) { - GTK_WIDGET_CLASS( parent_class )->screen_changed( widget, previous_screen ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->screen_changed( widget, previous_screen ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); @@ -384,8 +360,8 @@ void IconImpl::screenChanged( GtkWidget *widget, GdkScreen *previous_screen ) void IconImpl::styleSet( GtkWidget *widget, GtkStyle *previous_style ) { - if ( GTK_WIDGET_CLASS( parent_class )->style_set ) { - GTK_WIDGET_CLASS( parent_class )->style_set( widget, previous_style ); + if ( GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set ) { + GTK_WIDGET_CLASS( sp_icon_parent_class )->style_set( widget, previous_style ); } SPIcon *icon = SP_ICON(widget); themeChanged(icon); diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 3f6aa2455..6bce2e330 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -17,7 +17,7 @@ #include <gtkmm/widget.h> #include "icon-size.h" -#define SP_TYPE_ICON SPIcon::getType() +#define SP_TYPE_ICON sp_icon_get_type() #define SP_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_ICON, SPIcon)) #define SP_IS_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_ICON)) @@ -29,6 +29,8 @@ struct SPIconClass { GtkWidgetClass parent_class; }; +GType sp_icon_get_type() G_GNUC_CONST; + struct SPIcon { GtkWidget widget; @@ -38,8 +40,6 @@ struct SPIcon { GdkPixbuf *pb; - static GType getType(void); - friend class SPIconImpl; }; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 37cccda9f..471ee3852 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -642,49 +642,26 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr) gint x = (int)(slider->value * (carea.width - 1) - ARROW_SIZE / 2 + carea.x); gint y1 = carea.y; gint y2 = carea.y + carea.height - 1; - gint w = ARROW_SIZE; cairo_set_line_width(cr, 1.0); -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA white = {1,1,1,1}; - GdkRGBA black = {0,0,0,1}; -#else - GdkColor white, black; - gdk_color_parse("#fff", &white); - gdk_color_parse("#000", &black); -#endif - - while ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &white); -#else - gdk_cairo_set_source_color(cr, &white); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - w -=2; - x++; - if ( w > 0 ) - { -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba(cr, &black); -#else - gdk_cairo_set_source_color(cr, &black); -#endif - cairo_move_to(cr, x - 0.5, y1 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5); - cairo_move_to(cr, x - 0.5, y2 + 0.5); - cairo_line_to(cr, x + w - 1 + 0.5, y2 + 0.5); - cairo_stroke(cr); - } - y1++; - y2--; - } - + // Define top arrow + cairo_move_to(cr, x - 0.5, y1 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y1 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y1 + ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y1 + 0.5); + + // Define bottom arrow + cairo_move_to(cr, x - 0.5, y2 + 0.5); + cairo_line_to(cr, x + ARROW_SIZE - 0.5, y2 + 0.5); + cairo_line_to(cr, x + (ARROW_SIZE-1)/2.0, y2 - ARROW_SIZE/2.0 + 0.5); + cairo_line_to(cr, x - 0.5, y2 + 0.5); + + // Render both arrows + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_stroke_preserve(cr); + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + cairo_fill(cr); + return FALSE; } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index ede98a48a..0f79a609b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -549,8 +549,9 @@ gboolean StrokeStyle::setStrokeWidthUnit(SPUnitSelector *, gdouble average = stroke_average_width (objects); - if (average == Geom::infinity() || average == 0) + if ((average == Geom::infinity()) || (average < 1e-8)){ //less than 1e-8: to campare against zero, while taking numeric accuracy into account return FALSE; + } #if WITH_GTKMM_3_0 (*spw->widthAdj)->set_value(100.0 * w / average); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6c22c81e3..3eccf1d2f 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -178,6 +178,11 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) return; } + // If font list, take only first font in list + gchar** tokens = g_strsplit( current_font, ",", 0 ); + g_strstrip( tokens[0] ); + current_font = tokens[0]; + // Get an iter to the selected font from the model data // We cant get it from the combo, cause it might not have been created yet gboolean found = false; @@ -197,13 +202,7 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) valid = gtk_tree_model_iter_next( model, &iter ); } - if (!found) { - return; - } - - // Get the list of styles from the selected font - GList *list = NULL; - gtk_tree_model_get (model, &iter, 1, &list, -1); + g_strfreev( tokens ); Ink_ComboBoxEntry_Action* fontStyleAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) ); @@ -212,7 +211,27 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) GtkListStore *store = GTK_LIST_STORE( ink_comboboxentry_action_get_model( fontStyleAction ) ); gtk_list_store_clear ( store ); - // Add list of styles to the style combo + // Get the list of styles from the selected font. + GList *list = NULL; + + if (found) { + + // Use precompiled list if font-family on system. + gtk_tree_model_get (model, &iter, 1, &list, -1); + + } else { + + // Use generic list if font-family not on system. + static GList *glist = NULL; + if( glist == NULL ) { + glist = g_list_append (glist, (void*)"Normal"); + glist = g_list_append (glist, (void*)"Italic"); + glist = g_list_append (glist, (void*)"Bold"); + glist = g_list_append (glist, (void*)"Bold Italic"); + } + list = glist; + } + for (GList *l=list; l; l = l->next) { gtk_list_store_append (store, &iter); @@ -220,7 +239,7 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL) } // Select the style in the combo that best matches font - if (font) { + if (font && list) { unsigned int index = sp_font_selector_get_best_style(font, list); @@ -519,7 +538,7 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj SPCSSAttr *css = sp_repr_css_attr_new (); - gchar *current_style = ink_comboboxentry_action_get_active_text( act ); + Glib::ustring current_style = ink_comboboxentry_action_get_active_text( act ); Glib::ustring fontFamily = ""; if (query->text->font_family.set) { @@ -530,9 +549,10 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj fontFamily = ink_comboboxentry_action_get_active_text( act ); } - font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style); + font_instance *font = (font_factory::Default())->FaceFromUIStrings (fontFamily.c_str(), current_style.c_str()); if (font) { + gchar c[256]; font->Attribute( "weight", c, 256); @@ -549,6 +569,19 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj font->Unref(); font = NULL; + + } else { + + // Font not found on system, blindly update style + // Options match choices in sp_text_fontstyle_populate + sp_repr_css_set_property (css, "font-weight", "normal"); + sp_repr_css_set_property (css, "font-style", "normal" ); + if( current_style.find("Bold") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-weight", "bold"); + } + if( current_style.find("Italic") != Glib::ustring::npos ) { + sp_repr_css_set_property (css, "font-style", "italic"); + } } // If querying returned nothing, update default style. @@ -1203,7 +1236,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ return; } - g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + // To ensure the value of the combobox is properly set on start-up, only mark + // the prefs set if the combobox has already been constructed. + Ink_ComboBoxEntry_Action* fontFamilyAction = + INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) ); + if( fontFamilyAction->combobox != NULL ) { + g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE)); + } } else { g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE)); } diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 9311901d3..7a5e4f90e 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -26,48 +26,23 @@ #include "zoom-context.h" -static void sp_zoom_context_class_init(SPZoomContextClass *klass); -static void sp_zoom_context_init(SPZoomContext *zoom_context); static void sp_zoom_context_setup(SPEventContext *ec); static void sp_zoom_context_finish (SPEventContext *ec); static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent *event); static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -static SPEventContextClass *parent_class; - static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; static bool escaped; -GType sp_zoom_context_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPZoomContextClass), - NULL, NULL, - (GClassInitFunc) sp_zoom_context_class_init, - NULL, NULL, - sizeof(SPZoomContext), - 4, - (GInstanceInitFunc) sp_zoom_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPZoomContext", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPZoomContext, sp_zoom_context, SP_TYPE_EVENT_CONTEXT); static void sp_zoom_context_class_init(SPZoomContextClass *klass) { SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - event_context_class->setup = sp_zoom_context_setup; event_context_class->finish = sp_zoom_context_finish; @@ -107,8 +82,8 @@ static void sp_zoom_context_setup(SPEventContext *ec) ec->enableGrDrag(); } - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup(ec); } } @@ -116,8 +91,8 @@ static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem * { gint ret = FALSE; - 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_zoom_context_parent_class))->item_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->item_handler (event_context, item, event); } return ret; @@ -264,8 +239,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event); + if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler) { + ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler(event_context, event); } } |
