diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-07-31 19:11:20 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-07-31 19:11:20 +0000 |
| commit | 989abbac025a8b3349748d19a613a08586c5fdcd (patch) | |
| tree | 157b5f656c6344784aea3c498fa60199bd7d2958 /src | |
| parent | Further refactoring of EventContexts. (diff) | |
| download | inkscape-989abbac025a8b3349748d19a613a08586c5fdcd.tar.gz inkscape-989abbac025a8b3349748d19a613a08586c5fdcd.zip | |
Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes.
(bzr r11608.1.110)
Diffstat (limited to 'src')
43 files changed, 161 insertions, 276 deletions
diff --git a/src/Makefile_insert b/src/Makefile_insert index d17fad8b9..0fa7069ef 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -141,7 +141,6 @@ ink_common_sources += \ seltrans-handles.cpp seltrans-handles.h \ shape-editor.cpp shape-editor.h \ shortcuts.cpp shortcuts.h \ - singleton.h \ snap.cpp snap.h \ snap-enums.h snap-candidate.h \ snapped-curve.cpp snapped-curve.h \ diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 827a0eb35..1f14bd270 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -67,7 +67,6 @@ const std::string SPArcContext::prefsPath = "/tools/shapes/arc"; SPArcContext::SPArcContext() : SPEventContext() { - this->_message_context = 0; this->cursor_shape = cursor_ellipse_xpm; this->hot_x = 4; this->hot_y = 4; @@ -101,8 +100,6 @@ SPArcContext::~SPArcContext() { if (this->arc) { this->finishItem(); } - - delete this->_message_context; } /** @@ -139,8 +136,6 @@ void SPArcContext::setup() { if (prefs->getBool("/tools/shapes/gradientdrag")) { this->enableGrDrag(); } - - this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack()); } bool SPArcContext::item_handler(SPItem* item, GdkEvent* event) { @@ -357,7 +352,7 @@ bool SPArcContext::root_handler(GdkEvent* event) { void SPArcContext::drag(Geom::Point pt, guint state) { if (!this->arc) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return; } @@ -435,9 +430,9 @@ void SPArcContext::drag(Geom::Point pt, guint state) { ratio_y = (int) rint (rdimy / rdimx); } - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); } else { - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); } g_string_free(xs, FALSE); @@ -445,7 +440,7 @@ void SPArcContext::drag(Geom::Point pt, guint state) { } void SPArcContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); if (this->arc != NULL) { if (this->arc->rx.computed == 0 || this->arc->ry.computed == 0) { diff --git a/src/arc-context.h b/src/arc-context.h index 25b8762b2..2fe6eff1e 100644 --- a/src/arc-context.h +++ b/src/arc-context.h @@ -47,8 +47,6 @@ private: sigc::connection sel_changed_connection; - Inkscape::MessageContext *_message_context; - void selection_changed(Inkscape::Selection* selection); void drag(Geom::Point pt, guint state); diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index f0bb67dcc..1e0a62a1b 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -70,8 +70,6 @@ const std::string& Box3DContext::getPrefsPath() { const std::string Box3DContext::prefsPath = "/tools/shapes/3dbox"; Box3DContext::Box3DContext() : SPEventContext() { - this->_message_context = 0; - this->cursor_shape = cursor_3dbox_xpm; this->hot_x = 4; this->hot_y = 4; @@ -113,10 +111,6 @@ Box3DContext::~Box3DContext() { if (this->box3d) { this->finishItem(); } - - if (this->_message_context) { - delete this->_message_context; - } } /** @@ -178,8 +172,6 @@ void Box3DContext::setup() { if (prefs->getBool("/tools/shapes/gradientdrag")) { this->enableGrDrag(); } - - this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack()); } bool Box3DContext::item_handler(SPItem* item, GdkEvent* event) { @@ -522,7 +514,7 @@ bool Box3DContext::root_handler(GdkEvent* event) { void Box3DContext::drag(guint state) { if (!this->box3d) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return; } @@ -594,11 +586,11 @@ void Box3DContext::drag(guint state) { box3d_position_set(this->box3d); // status text - this->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis")); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis")); } void Box3DContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); this->ctrl_dragged = false; this->extruded = false; diff --git a/src/box3d-context.h b/src/box3d-context.h index 7f910158e..164e3bde8 100644 --- a/src/box3d-context.h +++ b/src/box3d-context.h @@ -67,8 +67,6 @@ private: sigc::connection sel_changed_connection; - Inkscape::MessageContext *_message_context; - void selection_changed(Inkscape::Selection* selection); void drag(guint state); diff --git a/src/common-context.cpp b/src/common-context.cpp index e6b82cf82..fb984cbf1 100644 --- a/src/common-context.cpp +++ b/src/common-context.cpp @@ -20,7 +20,6 @@ #define DRAG_MAX 1.0 SPCommonContext::SPCommonContext() : SPEventContext() { - this->_message_context = 0; this->tremor = 0; this->usetilt = 0; this->is_drawing = false; @@ -96,13 +95,6 @@ SPCommonContext::~SPCommonContext() { sp_canvas_item_destroy(this->currentshape); this->currentshape = 0; } - - if (this->_message_context) { - delete this->_message_context; - this->_message_context = 0; - } - - //G_OBJECT_CLASS(sp_common_context_parent_class)->dispose(object); } void SPCommonContext::set(const Inkscape::Preferences::Entry& value) { diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 72a01dee9..c79c58125 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -518,7 +518,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - if (Inkscape::have_viable_layer(desktop, cc->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, cc->message_context) == false) { return TRUE; } diff --git a/src/desktop.cpp b/src/desktop.cpp index 332ae5996..a8de8ee50 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -682,7 +682,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) { event_context = ToolFactory::instance().createObject(toolName); event_context->desktop = this; - event_context->_message_context = new Inkscape::MessageContext(this->messageStack()); + event_context->message_context = new Inkscape::MessageContext(this->messageStack()); event_context->setup(); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index da90d926f..05ebc3a4a 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -102,36 +102,29 @@ const std::string& SPDynaDrawContext::getPrefsPath() { const std::string SPDynaDrawContext::prefsPath = "/tools/calligraphic"; SPDynaDrawContext::SPDynaDrawContext() : SPCommonContext() { - SPDynaDrawContext* ddc = this; + this->cursor_shape = cursor_calligraphy_xpm; + this->hot_x = 4; + this->hot_y = 4; - ddc->cursor_shape = cursor_calligraphy_xpm; - ddc->hot_x = 4; - ddc->hot_y = 4; + this->vel_thin = 0.1; + this->flatness = 0.9; + this->cap_rounding = 0.0; - ddc->vel_thin = 0.1; - ddc->flatness = 0.9; - ddc->cap_rounding = 0.0; + this->abs_width = false; + this->keep_selected = true; - ddc->abs_width = false; - ddc->keep_selected = true; + this->hatch_spacing = 0; + this->hatch_spacing_step = 0; - ddc->hatch_spacing = 0; - ddc->hatch_spacing_step = 0; + this->hatch_last_nearest = Geom::Point(0,0); + this->hatch_last_pointer = Geom::Point(0,0); + this->hatch_escaped = false; + this->hatch_area = NULL; + this->hatch_item = NULL; + this->hatch_livarot_path = NULL; -// new (&ddc->hatch_pointer_past) std::list<double>(); -// new (&ddc->hatch_nearest_past) std::list<double>(); -// new (&ddc->inertia_vectors) std::list<Geom::Point>(); -// new (&ddc->hatch_vectors) std::list<Geom::Point>(); - - ddc->hatch_last_nearest = Geom::Point(0,0); - ddc->hatch_last_pointer = Geom::Point(0,0); - ddc->hatch_escaped = false; - ddc->hatch_area = NULL; - ddc->hatch_item = NULL; - ddc->hatch_livarot_path = NULL; - - ddc->trace_bg = false; - ddc->just_started_drawing = false; + this->trace_bg = false; + this->just_started_drawing = false; } SPDynaDrawContext::~SPDynaDrawContext() { @@ -194,7 +187,6 @@ void SPDynaDrawContext::setup() { sp_event_context_read(this, "cap_rounding"); this->is_drawing = false; - this->_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/calligraphic/selcue")) { @@ -476,7 +468,7 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return TRUE; } @@ -511,7 +503,7 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { Geom::Point motion_dt(desktop->w2d(motion_w)); this->extinput(event); - this->_message_context->clear(); + this->message_context->clear(); // for hatching: double hatch_dist = 0; @@ -549,9 +541,9 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { // unit-length vector hatch_unit_vector = (pointer - nearest)/hatch_dist; - this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Guide path selected</b>; start drawing along the guide with <b>Ctrl</b>")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Guide path selected</b>; start drawing along the guide with <b>Ctrl</b>")); } else { - this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Select a guide path</b> to track with <b>Ctrl</b>")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Select a guide path</b> to track with <b>Ctrl</b>")); } } @@ -686,10 +678,10 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { this->hatch_vectors.pop_back(); } - this->_message_context->set(Inkscape::NORMAL_MESSAGE, this->hatch_escaped? _("Tracking: <b>connection to guide path lost!</b>") : _("<b>Tracking</b> a guide path")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, this->hatch_escaped? _("Tracking: <b>connection to guide path lost!</b>") : _("<b>Tracking</b> a guide path")); } else { - this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drawing</b> a calligraphic stroke")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drawing</b> a calligraphic stroke")); } if (this->just_started_drawing) { @@ -805,7 +797,7 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { this->hatch_spacing += this->hatch_spacing_step; } - this->_message_context->clear(); + this->message_context->clear(); ret = TRUE; } break; @@ -896,7 +888,7 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: - this->_message_context->clear(); + this->message_context->clear(); this->hatch_spacing = 0; this->hatch_spacing_step = 0; break; diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 6391419eb..b2df86434 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -152,8 +152,6 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { this->is_drawing = false; - this->_message_context = new Inkscape::MessageContext(desktop->messageStack()); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/eraser/selcue", 0) != 0) { this->enableSelectionCue(); @@ -383,7 +381,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return TRUE; } @@ -427,12 +425,12 @@ bool SPEraserContext::root_handler(GdkEvent* event) { ); this->extinput(event); - this->_message_context->clear(); + this->message_context->clear(); if ( this->is_drawing && (event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) { this->dragging = TRUE; - this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drawing</b> an eraser stroke")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drawing</b> an eraser stroke")); if (!this->apply(motion_dt)) { ret = TRUE; @@ -484,7 +482,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { this->repr = NULL; } - this->_message_context->clear(); + this->message_context->clear(); ret = TRUE; } @@ -603,7 +601,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: - this->_message_context->clear(); + this->message_context->clear(); break; default: diff --git a/src/event-context.cpp b/src/event-context.cpp index bea5f63f6..e5ea85818 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -104,7 +104,7 @@ SPEventContext::SPEventContext() { this->desktop = NULL; this->cursor = NULL; - this->_message_context = NULL; + this->message_context = NULL; this->_selcue = NULL; this->_grdrag = NULL; this->space_panning = false; @@ -115,8 +115,8 @@ SPEventContext::SPEventContext() { } SPEventContext::~SPEventContext() { - if (this->_message_context) { - delete this->_message_context; + if (this->message_context) { + delete this->message_context; } if (this->cursor != NULL) { @@ -704,7 +704,7 @@ bool SPEventContext::root_handler(GdkEvent* event) { panning = 4; this->space_panning = true; - this->_message_context->set(Inkscape::INFORMATION_MESSAGE, + this->message_context->set(Inkscape::INFORMATION_MESSAGE, _("<b>Space+mouse move</b> to pan canvas")); ret = TRUE; @@ -728,7 +728,7 @@ bool SPEventContext::root_handler(GdkEvent* event) { // Stop panning on any key release if (this->space_panning) { this->space_panning = false; - this->_message_context->clear(); + this->message_context->clear(); } if (panning) { diff --git a/src/event-context.h b/src/event-context.h index 38474a208..51c49b123 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -122,10 +122,10 @@ public: ///< be selected if this is a click not drag Inkscape::MessageContext *defaultMessageContext() { - return _message_context; + return message_context; } - Inkscape::MessageContext *_message_context; + Inkscape::MessageContext *message_context; Inkscape::SelCue *_selcue; diff --git a/src/factory.h b/src/factory.h index 495db5474..ca90a6e9a 100644 --- a/src/factory.h +++ b/src/factory.h @@ -1,9 +1,21 @@ -#pragma once +#ifndef FACTORY_H_SEEN +#define FACTORY_H_SEEN #include <exception> #include <map> #include <string> +/** + * A simple singleton implementation. + */ +template<class T> +struct Singleton { + static T& instance() { + static T inst; + return inst; + } +}; + namespace FactoryExceptions { class TypeNotRegistered : public std::exception { public: @@ -78,3 +90,6 @@ struct NodeTraits { return name; } }; + +#endif + diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 824c6e329..09a1d5742 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -92,7 +92,6 @@ const std::string& SPFloodContext::getPrefsPath() { const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; SPFloodContext::SPFloodContext() : SPEventContext() { - this->_message_context = 0; this->cursor_shape = cursor_paintbucket_xpm; this->hot_x = 11; this->hot_y = 30; @@ -115,10 +114,6 @@ SPFloodContext::~SPFloodContext() { if (this->item) { this->finishItem(); } - - if (this->_message_context) { - delete this->_message_context; - } } /** @@ -145,8 +140,6 @@ void SPFloodContext::setup() { sigc::mem_fun(this, &SPFloodContext::selection_changed) ); - this->_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/paintbucket/selcue")) { @@ -1231,7 +1224,7 @@ bool SPFloodContext::root_handler(GdkEvent* event) { } void SPFloodContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); if (this->item != NULL) { this->item->updateRepr(); diff --git a/src/flood-context.h b/src/flood-context.h index accfd1e40..a864f464a 100644 --- a/src/flood-context.h +++ b/src/flood-context.h @@ -36,8 +36,6 @@ public: sigc::connection sel_changed_connection; - Inkscape::MessageContext *_message_context; - static const std::string prefsPath; virtual void setup(); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 1e9bef354..5921426cf 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -74,7 +74,6 @@ const std::string SPGradientContext::prefsPath = "/tools/gradient"; SPGradientContext::SPGradientContext() : SPEventContext() { this->node_added = false; this->subselcon = 0; - this->_message_context = 0; this->selcon = 0; this->cursor_addnode = false; @@ -91,10 +90,6 @@ SPGradientContext::SPGradientContext() : SPEventContext() { SPGradientContext::~SPGradientContext() { this->enableGrDrag(false); - if (this->_message_context) { - delete this->_message_context; - } - this->selcon->disconnect(); delete this->selcon; @@ -138,7 +133,7 @@ void SPGradientContext::selection_changed(Inkscape::Selection*) { //TRANSLATORS: Mind the space in front. This is part of a compound message ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + rc->message_context->setF(Inkscape::NORMAL_MESSAGE, message,_(gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { gchar * message = g_strconcat( @@ -147,16 +142,16 @@ void SPGradientContext::selection_changed(Inkscape::Selection*) { "One handle merging %d stops (drag with <b>Shift</b> to separate) selected",drag->singleSelectedDraggerNumDraggables()), ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); + rc->message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); } } else if (n_sel > 1) { //TRANSLATORS: The plural refers to number of selected gradient handles. This is part of a compound message (part two indicates selected object count) gchar * message = g_strconcat(ngettext("<b>%d</b> gradient handle selected out of %d","<b>%d</b> gradient handles selected out of %d",n_sel), //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); + rc->message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); } else if (n_sel == 0) { - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + rc->message_context->setF(Inkscape::NORMAL_MESSAGE, //TRANSLATORS: The plural refers to number of selected objects ngettext("<b>No</b> gradient handles selected out of %d on %d selected object", "<b>No</b> gradient handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj); @@ -175,8 +170,6 @@ void SPGradientContext::setup() { this->enableGrDrag(); Inkscape::Selection *selection = sp_desktop_selection(this->desktop); - this->_message_context = new Inkscape::MessageContext(sp_desktop_message_stack(this->desktop)); - this->selcon = new sigc::connection(selection->connectChanged( sigc::mem_fun(this, &SPGradientContext::selection_changed) )); @@ -955,7 +948,7 @@ static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint // status text; we do not track coords because this branch is run once, not all the time // during drag int n_objects = g_slist_length((GSList *) selection->itemList()); - rc._message_context->setF(Inkscape::NORMAL_MESSAGE, + rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), n_objects); diff --git a/src/gradient-context.h b/src/gradient-context.h index 0c2a7eb3d..fb964f904 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -35,8 +35,6 @@ public: Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords - Inkscape::MessageContext *_message_context; - sigc::connection *selcon; sigc::connection *subselcon; diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 7ff262a3c..a1c812049 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -79,9 +79,8 @@ SPLPEToolContext::SPLPEToolContext() : SPPenContext() { lc->mode = Inkscape::LivePathEffect::BEND_PATH; lc->shape_editor = 0; - lc->_lpetool_message_context = 0; - lc->cursor_shape = cursor_crosshairs_xpm; + lc->cursor_shape = cursor_crosshairs_xpm; lc->hot_x = 7; lc->hot_y = 7; @@ -107,9 +106,6 @@ SPLPEToolContext::~SPLPEToolContext() { lc->sel_changed_connection.disconnect(); //lc->sel_changed_connection.~connection(); - if (lc->_lpetool_message_context) { - delete lc->_lpetool_message_context; - } //G_OBJECT_CLASS(sp_lpetool_context_parent_class)->dispose(object); } @@ -149,8 +145,6 @@ void SPLPEToolContext::setup() { if (prefs->getBool("/tools/lpetool/selcue")) { ec->enableSelectionCue(); } - - lc->_lpetool_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); } /** diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h index 657916342..6d36594fe 100644 --- a/src/lpe-tool-context.h +++ b/src/lpe-tool-context.h @@ -53,8 +53,6 @@ public: std::map<SPPath *, SPCanvasItem*> *measuring_items; - Inkscape::MessageContext *_lpetool_message_context; - sigc::connection sel_changed_connection; sigc::connection sel_modified_connection; diff --git a/src/mesh-context.cpp b/src/mesh-context.cpp index 915ac0f7f..ecd847fa4 100644 --- a/src/mesh-context.cpp +++ b/src/mesh-context.cpp @@ -74,7 +74,6 @@ const std::string SPMeshContext::prefsPath = "/tools/mesh"; SPMeshContext::SPMeshContext() : SPEventContext() { this->selcon = 0; - this->_message_context = 0; this->node_added = false; this->subselcon = 0; @@ -92,10 +91,6 @@ SPMeshContext::SPMeshContext() : SPEventContext() { SPMeshContext::~SPMeshContext() { this->enableGrDrag(false); - if (this->_message_context) { - delete this->_message_context; - } - this->selcon->disconnect(); delete this->selcon; @@ -135,7 +130,7 @@ void SPMeshContext::selection_changed(Inkscape::Selection* sel) { //TRANSLATORS: Mind the space in front. This is part of a compound message ngettext(" out of %d mesh handle"," out of %d mesh handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - this->_message_context->setF(Inkscape::NORMAL_MESSAGE, + this->message_context->setF(Inkscape::NORMAL_MESSAGE, message,_(ms_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { gchar * message = @@ -146,7 +141,7 @@ void SPMeshContext::selection_changed(Inkscape::Selection* sel) { drag->singleSelectedDraggerNumDraggables()), ngettext(" out of %d mesh handle"," out of %d mesh handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - this->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); + this->message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); } } else if (n_sel > 1) { //TRANSLATORS: The plural refers to number of selected mesh handles. This is part of a compound message (part two indicates selected object count) @@ -154,9 +149,9 @@ void SPMeshContext::selection_changed(Inkscape::Selection* sel) { g_strconcat(ngettext("<b>%d</b> mesh handle selected out of %d","<b>%d</b> mesh handles selected out of %d",n_sel), //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - this->_message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); + this->message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); } else if (n_sel == 0) { - this->_message_context->setF(Inkscape::NORMAL_MESSAGE, + this->message_context->setF(Inkscape::NORMAL_MESSAGE, //TRANSLATORS: The plural refers to number of selected objects ngettext("<b>No</b> mesh handles selected out of %d on %d selected object", "<b>No</b> mesh handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj); @@ -240,8 +235,6 @@ void SPMeshContext::setup() { this->enableGrDrag(); Inkscape::Selection *selection = sp_desktop_selection(this->desktop); - this->_message_context = new Inkscape::MessageContext(sp_desktop_message_stack(this->desktop)); - this->selcon = new sigc::connection(selection->connectChanged( sigc::mem_fun(this, &SPMeshContext::selection_changed) )); @@ -995,7 +988,7 @@ static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const /*pt*/, guint /*st // status text; we do not track coords because this branch is run once, not all the time // during drag int n_objects = g_slist_length((GSList *) selection->itemList()); - rc._message_context->setF(Inkscape::NORMAL_MESSAGE, + rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), n_objects); diff --git a/src/mesh-context.h b/src/mesh-context.h index 69eef1086..1d360268e 100644 --- a/src/mesh-context.h +++ b/src/mesh-context.h @@ -37,8 +37,6 @@ public: Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords - Inkscape::MessageContext *_message_context; - sigc::connection *selcon; sigc::connection *subselcon; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 690b520bc..fbcb6dae5 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -205,8 +205,8 @@ static void pen_cancel (SPPenContext *const pc) sp_canvas_item_hide(pc->c1); sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); - pc->_message_context->clear(); - pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); + pc->message_context->clear(); + pc->message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); pc->desktop->canvas->endForcedFullRedraws(); } @@ -386,7 +386,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // make sure this is not the last click for a waiting LPE (otherwise we want to finish the path) && pc->expecting_clicks_for_LPE != 1) { - if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, dc->message_context) == false) { return TRUE; } @@ -623,20 +623,20 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons } if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path.")); + pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path.")); pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { - pc->_message_context->clear(); + pc->message_context->clear(); pc->anchor_statusbar = false; } ret = TRUE; } else { if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to continue the path from this point.")); + pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to continue the path from this point.")); pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { - pc->_message_context->clear(); + pc->message_context->clear(); pc->anchor_statusbar = false; } if (!sp_event_context_knot_mouseover(pc)) { @@ -1185,7 +1185,7 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) angle = angle_to_compass (angle); - pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); + pc->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); g_string_free(dist, FALSE); } @@ -1314,7 +1314,7 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) pen_disable_events(pc); SPDesktop *const desktop = pc->desktop; - pc->_message_context->clear(); + pc->message_context->clear(); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); pc->red_curve->reset(); diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index b81580f3a..c7257ff10 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -198,7 +198,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); Inkscape::Selection *selection = sp_desktop_selection(desktop); - if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, dc->message_context) == false) { return TRUE; } @@ -359,21 +359,21 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev } if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Release</b> here to close and finish the path.")); + pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Release</b> here to close and finish the path.")); pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { - pc->_message_context->clear(); + pc->message_context->clear(); pc->anchor_statusbar = false; } else if (!anchor) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing a freehand path")); + pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing a freehand path")); } } else { if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to continue the path from this point.")); + pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to continue the path from this point.")); pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { - pc->_message_context->clear(); + pc->message_context->clear(); pc->anchor_statusbar = false; } } @@ -517,8 +517,8 @@ pencil_cancel (SPPencilContext *const pc) pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor); } - pc->_message_context->clear(); - pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); + pc->message_context->clear(); + pc->message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); pc->desktop->canvas->endForcedFullRedraws(); } diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 23c4794c1..2a3c8dd2b 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -64,8 +64,6 @@ const std::string& SPRectContext::getPrefsPath() { const std::string SPRectContext::prefsPath = "/tools/shapes/rect"; SPRectContext::SPRectContext() : SPEventContext() { - this->_message_context = 0; - this->cursor_shape = cursor_rect_xpm; this->hot_x = 4; this->hot_y = 4; @@ -102,10 +100,6 @@ SPRectContext::~SPRectContext() { if (this->rect) { this->finishItem(); } - - if (this->_message_context) { - delete this->_message_context; - } } /** @@ -143,8 +137,6 @@ void SPRectContext::setup() { if (prefs->getBool("/tools/shapes/gradientdrag")) { this->enableGrDrag(); } - - this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack()); } void SPRectContext::set(const Inkscape::Preferences::Entry& val) { @@ -396,7 +388,7 @@ void SPRectContext::drag(Geom::Point const pt, guint state) { SPDesktop *desktop = this->desktop; if (!this->rect) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return; } @@ -459,16 +451,16 @@ void SPRectContext::drag(Geom::Point const pt, guint state) { } if (!is_golden_ratio) { - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); } else { if (ratio_y == 1) { - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); } else { - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); } } } else { - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s × %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str); } g_string_free(xs, FALSE); @@ -476,7 +468,7 @@ void SPRectContext::drag(Geom::Point const pt, guint state) { } void SPRectContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); if (this->rect != NULL) { if (this->rect->width.computed == 0 || this->rect->height.computed == 0) { diff --git a/src/rect-context.h b/src/rect-context.h index 1856a3d7e..f57a1266a 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -48,8 +48,6 @@ private: sigc::connection sel_changed_connection; - Inkscape::MessageContext *_message_context; - void drag(Geom::Point const pt, guint state); void finishItem(); void cancel(); diff --git a/src/singleton.h b/src/singleton.h deleted file mode 100644 index 022e314e4..000000000 --- a/src/singleton.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -/** - * A simple singleton implementation. - */ -template<class T> -struct Singleton { - static T& instance() { - static T inst; - return inst; - } -}; diff --git a/src/sp-factory.h b/src/sp-factory.h index 50c328aa8..7a6416cad 100644 --- a/src/sp-factory.h +++ b/src/sp-factory.h @@ -1,7 +1,10 @@ -#pragma once +#ifndef SP_FACTORY_SEEN +#define SP_FACTORY_SEEN #include "factory.h" -#include "singleton.h" class SPObject; typedef Singleton< Factory<SPObject> > SPFactory; + + +#endif diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ed1a2ef79..f313ed7c1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -117,9 +117,9 @@ SPItem::SPItem() : SPObject() { avoidRef = new SPAvoidRef(this); - new (&constraints) std::vector<SPGuideConstraint>(); + //new (&constraints) std::vector<SPGuideConstraint>(); - new (&_transformed_signal) sigc::signal<void, Geom::Affine const *, SPItem *>(); + //new (&_transformed_signal) sigc::signal<void, Geom::Affine const *, SPItem *>(); } SPItem::~SPItem() { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 167d8a331..08ed9fc8d 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -128,10 +128,10 @@ SPObject::SPObject() { this->_collection_policy = SPObject::COLLECT_WITH_PARENT; - new (&this->_release_signal) sigc::signal<void, SPObject *>(); - new (&this->_modified_signal) sigc::signal<void, SPObject *, unsigned int>(); - new (&this->_delete_signal) sigc::signal<void, SPObject *>(); - new (&this->_position_changed_signal) sigc::signal<void, SPObject *>(); + //new (&this->_release_signal) sigc::signal<void, SPObject *>(); + //new (&this->_modified_signal) sigc::signal<void, SPObject *, unsigned int>(); + //new (&this->_delete_signal) sigc::signal<void, SPObject *>(); + //new (&this->_position_changed_signal) sigc::signal<void, SPObject *>(); this->_successor = NULL; // FIXME: now we create style for all objects, but per SVG, only the following can have style attribute: @@ -156,10 +156,10 @@ SPObject::~SPObject() { this->_successor = NULL; } - this->_release_signal.~signal(); - this->_modified_signal.~signal(); - this->_delete_signal.~signal(); - this->_position_changed_signal.~signal(); + //this->_release_signal.~signal(); + //this->_modified_signal.~signal(); + //this->_delete_signal.~signal(); + //this->_position_changed_signal.~signal(); } // CPPIFY: make pure virtual diff --git a/src/sp-object.h b/src/sp-object.h index c9e7bbace..449049611 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -822,7 +822,7 @@ public: friend class SPObjectImpl; -public: +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -833,12 +833,13 @@ public: virtual void set(unsigned int key, const gchar* value); - virtual void read_content(); - virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +public: + virtual void read_content(); }; diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 6b060b424..dc2bd6149 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -63,8 +63,6 @@ const std::string& SPSpiralContext::getPrefsPath() { const std::string SPSpiralContext::prefsPath = "/tools/shapes/spiral"; SPSpiralContext::SPSpiralContext() : SPEventContext() { - this->_message_context = 0; - this->cursor_shape = cursor_spiral_xpm; this->hot_x = 4; this->hot_y = 4; @@ -104,10 +102,6 @@ SPSpiralContext::~SPSpiralContext() { if (this->spiral) { this->finishItem(); } - - if (this->_message_context) { - delete this->_message_context; - } } /** @@ -147,8 +141,6 @@ void SPSpiralContext::setup() { if (prefs->getBool("/tools/shapes/gradientdrag")) { this->enableGrDrag(); } - - this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack()); } void SPSpiralContext::set(const Inkscape::Preferences::Entry& val) { @@ -362,7 +354,7 @@ void SPSpiralContext::drag(Geom::Point const &p, guint state) { int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); if (!this->spiral) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return; } @@ -408,14 +400,14 @@ void SPSpiralContext::drag(Geom::Point const &p, guint state) { /* status text */ GString *rads = SP_PX_TO_METRIC_STRING(rad, desktop->namedview->getDefaultMetric()); - this->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Spiral</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle"), rads->str, sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001)); g_string_free(rads, FALSE); } void SPSpiralContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); if (this->spiral != NULL) { if (this->spiral->rad == 0) { diff --git a/src/spiral-context.h b/src/spiral-context.h index 518d8ad41..9e3987eeb 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -49,8 +49,6 @@ private: sigc::connection sel_changed_connection; - Inkscape::MessageContext *_message_context; - void drag(Geom::Point const &p, guint state); void finishItem(); void cancel(); diff --git a/src/spray-context.cpp b/src/spray-context.cpp index c96df20b2..8256d6861 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -131,7 +131,6 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it SPSprayContext::SPSprayContext() : SPEventContext() { this->usetilt = 0; - this->message_context = 0; this->dilate_area = 0; this->usetext = false; this->population = 0; @@ -169,10 +168,6 @@ SPSprayContext::~SPSprayContext() { sp_canvas_item_destroy(this->dilate_area); this->dilate_area = NULL; } - - if (this->message_context) { - delete this->message_context; - } } static bool is_transform_modes(gint mode) @@ -237,8 +232,6 @@ void SPSprayContext::setup() { this->is_drawing = false; - this->message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); - sp_event_context_read(this, "distrib"); sp_event_context_read(this, "width"); sp_event_context_read(this, "ratio"); diff --git a/src/spray-context.h b/src/spray-context.h index 1bae7c4e4..a3bcb93de 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -77,8 +77,6 @@ public: gint mode; - Inkscape::MessageContext *message_context; - bool is_drawing; bool is_dilating; diff --git a/src/star-context.cpp b/src/star-context.cpp index 3601a4d49..d4dee3892 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -68,7 +68,6 @@ const std::string SPStarContext::prefsPath = "/tools/shapes/star"; SPStarContext::SPStarContext() : SPEventContext() { this->randomized = 0; - this->message_context = 0; this->rounded = 0; this->cursor_shape = cursor_star_xpm; @@ -109,10 +108,6 @@ SPStarContext::~SPStarContext() { if (this->star) { this->finishItem(); } - - if (this->message_context) { - delete this->message_context; - } } /** @@ -158,8 +153,6 @@ void SPStarContext::setup() { if (prefs->getBool("/tools/shapes/gradientdrag")) { this->enableGrDrag(); } - - this->message_context = new Inkscape::MessageContext(this->desktop->messageStack()); } void SPStarContext::set(const Inkscape::Preferences::Entry& val) { diff --git a/src/star-context.h b/src/star-context.h index a068e4441..af66f3201 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -57,8 +57,6 @@ private: sigc::connection sel_changed_connection; - Inkscape::MessageContext *message_context; - void drag(Geom::Point p, guint state); void finishItem(); void cancel(); diff --git a/src/text-context.cpp b/src/text-context.cpp index fea159834..1d1511470 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -646,7 +646,7 @@ bool SPTextContext::root_handler(GdkEvent* event) { // status text GString *xs = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::X]), desktop->namedview->getDefaultMetric()); GString *ys = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::Y]), desktop->namedview->getDefaultMetric()); - event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs->str, ys->str); + event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs->str, ys->str); g_string_free(xs, FALSE); g_string_free(ys, FALSE); @@ -703,7 +703,7 @@ bool SPTextContext::root_handler(GdkEvent* event) { im_cursor.height = (int) -floor(SP_EVENT_CONTEXT(tc)->desktop->d2w(cursor_size)[Geom::Y]); gtk_im_context_set_cursor_location(tc->imc, &im_cursor); } - event_context->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync + event_context->message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync event_context->within_tolerance = false; } else if (tc->creating) { @@ -1650,9 +1650,9 @@ static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see } } - SP_EVENT_CONTEXT(tc)->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit flowed text (%d characters%s); <b>Enter</b> to start new paragraph."), nChars, trunc); + SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit flowed text (%d characters%s); <b>Enter</b> to start new paragraph."), nChars, trunc); } else { - SP_EVENT_CONTEXT(tc)->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit text (%d characters%s); <b>Enter</b> to start new line."), nChars, trunc); + SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit text (%d characters%s); <b>Enter</b> to start new line."), nChars, trunc); } } else { @@ -1660,7 +1660,7 @@ static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see sp_canvas_item_hide(tc->frame); tc->show = FALSE; if (!tc->nascent_object) { - SP_EVENT_CONTEXT(tc)->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to select or create text, <b>drag</b> to create flowed text; then type.")); // FIXME: this is a copy of string from tools-switch, do not desync + SP_EVENT_CONTEXT(tc)->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to select or create text, <b>drag</b> to create flowed text; then type.")); // FIXME: this is a copy of string from tools-switch, do not desync } } diff --git a/src/tool-factory.h b/src/tool-factory.h index 3892606c6..48b277495 100644 --- a/src/tool-factory.h +++ b/src/tool-factory.h @@ -1,7 +1,10 @@ -#pragma once +#ifndef TOOL_FACTORY_SEEN +#define TOOL_FACTORY_SEEN #include "factory.h" -#include "singleton.h" class SPEventContext; typedef Singleton< Factory<SPEventContext> > ToolFactory; + + +#endif diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 74e2e12e2..3afdc177c 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -107,7 +107,6 @@ const std::string& SPTweakContext::getPrefsPath() { const std::string SPTweakContext::prefsPath = "/tools/tweak"; SPTweakContext::SPTweakContext() : SPEventContext() { - this->_message_context = 0; this->mode = 0; this->dilate_area = 0; this->usetilt = 0; @@ -144,10 +143,6 @@ SPTweakContext::~SPTweakContext() { sp_canvas_item_destroy(this->dilate_area); this->dilate_area = NULL; } - - if (this->_message_context) { - delete this->_message_context; - } } static bool is_transform_mode (gint mode) @@ -182,11 +177,11 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) switch (tc->mode) { case TWEAK_MODE_MOVE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); event_context->cursor_shape = cursor_tweak_move_xpm; break; case TWEAK_MODE_MOVE_IN_OUT: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_tweak_move_out_xpm; } else { @@ -194,11 +189,11 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_MOVE_JITTER: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); event_context->cursor_shape = cursor_tweak_move_jitter_xpm; break; case TWEAK_MODE_SCALE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_tweak_scale_up_xpm; } else { @@ -206,7 +201,7 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_ROTATE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; } else { @@ -214,7 +209,7 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_MORELESS: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_tweak_less_xpm; } else { @@ -222,11 +217,11 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_PUSH: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); event_context->cursor_shape = cursor_push_xpm; break; case TWEAK_MODE_SHRINK_GROW: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_thicken_xpm; } else { @@ -234,7 +229,7 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_ATTRACT_REPEL: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); if (with_shift) { event_context->cursor_shape = cursor_repel_xpm; } else { @@ -242,19 +237,19 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) } break; case TWEAK_MODE_ROUGHEN: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); event_context->cursor_shape = cursor_roughen_xpm; break; case TWEAK_MODE_COLORPAINT: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); event_context->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_COLORJITTER: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); event_context->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_BLUR: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); + tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); event_context->cursor_shape = cursor_color_xpm; break; } @@ -296,8 +291,6 @@ void SPTweakContext::setup() { this->is_drawing = false; - this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack()); - sp_event_context_read(this, "width"); sp_event_context_read(this, "mode"); sp_event_context_read(this, "fidelity"); @@ -1167,7 +1160,7 @@ bool SPTweakContext::root_handler(GdkEvent* event) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return TRUE; } @@ -1205,7 +1198,7 @@ bool SPTweakContext::root_handler(GdkEvent* event) { num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList())); } if (num == 0) { - this->_message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); + this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); } // dilating: @@ -1498,7 +1491,7 @@ bool SPTweakContext::root_handler(GdkEvent* event) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); - this->_message_context->clear(); + this->message_context->clear(); break; default: sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); diff --git a/src/tweak-context.h b/src/tweak-context.h index 2d3eaa1e4..ac046a875 100644 --- a/src/tweak-context.h +++ b/src/tweak-context.h @@ -56,8 +56,6 @@ public: gint mode; - Inkscape::MessageContext *_message_context; - bool is_drawing; bool is_dilating; diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index d424c1fdb..4b236e94c 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -127,7 +127,6 @@ InkNodeTool::InkNodeTool() : SPEventContext() { this->single_node_transform_handles = false; this->show_transform_handles = false; this->cursor_drag = false; - this->_node_message_context = 0; this->live_objects = false; this->edit_clipping_paths = false; this->live_outline = false; @@ -183,16 +182,11 @@ InkNodeTool::~InkNodeTool() { destroy_group(data.outline_group); destroy_group(data.dragpoint_group); destroy_group(this->_transform_handle_group); - - if (this->_node_message_context) { - delete this->_node_message_context; - } } void InkNodeTool::setup() { SPEventContext::setup(); - this->_node_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); this->_path_data = new Inkscape::UI::PathSharedData(); Inkscape::UI::PathSharedData &data = *this->_path_data; @@ -559,11 +553,11 @@ void InkNodeTool::update_tip(GdkEvent *event) { if (state_held_shift(new_state)) { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "<b>Shift</b>: drag to add nodes to the selection, " "click to toggle object selection")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "<b>Shift</b>: drag to add nodes to the selection")); } @@ -584,30 +578,30 @@ void InkNodeTool::update_tip(GdkEvent *event) { char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click to edit only this object (more: Shift)"), nodestring); - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } else { char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click clear the selection"), nodestring); - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } g_free(nodestring); } else if (!this->_multipath->empty()) { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to edit only this object")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to clear the selection")); } } else { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit, click to edit this object (more: Shift)")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit")); } } diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 313cc0561..779cf98e6 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -58,7 +58,6 @@ private: sigc::connection _mouseover_changed_connection; sigc::connection _sizeUpdatedConn; - Inkscape::MessageContext *_node_message_context; SPItem *flashed_item; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 8cb0c5588..08589a0b6 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1351,25 +1351,25 @@ RotateableSwatch::do_motion(double by, guint modifier) { DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha"))); double ch = hsla[3]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>alpha</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>alpha</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 2) { // saturation DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation"))); double ch = hsla[1]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); double ch = hsla[2]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); double ch = hsla[0]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff); } } @@ -1424,7 +1424,7 @@ RotateableSwatch::do_release(double by, guint modifier) { undokey = "ssrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); startcolor_set = false; } @@ -1490,7 +1490,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) { double diff = value_adjust(startvalue, by, modifier, false); DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff); } } @@ -1511,7 +1511,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) { } else { undokey = "swrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); } void |
