diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-04-20 19:16:13 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-04-20 19:16:13 +0000 |
| commit | 1227ca0189590b281116fcc808bdd8c674b2196c (patch) | |
| tree | 9ce1978824c1baaba62865364c7e45aee7b42cd9 /src | |
| parent | Replaced casting macros for EventContext tree; added contructors. (diff) | |
| download | inkscape-1227ca0189590b281116fcc808bdd8c674b2196c.tar.gz inkscape-1227ca0189590b281116fcc808bdd8c674b2196c.zip | |
Further changes to EventContexts; they work without GObject
(bzr r11608.1.97)
Diffstat (limited to 'src')
| -rw-r--r-- | src/arc-context.cpp | 22 | ||||
| -rw-r--r-- | src/arc-context.h | 1 | ||||
| -rw-r--r-- | src/desktop.cpp | 94 | ||||
| -rw-r--r-- | src/desktop.h | 7 | ||||
| -rw-r--r-- | src/event-context.cpp | 106 | ||||
| -rw-r--r-- | src/event-context.h | 28 | ||||
| -rw-r--r-- | src/rect-context.cpp | 25 | ||||
| -rw-r--r-- | src/rect-context.h | 1 | ||||
| -rw-r--r-- | src/select-context.cpp | 36 | ||||
| -rw-r--r-- | src/select-context.h | 1 | ||||
| -rw-r--r-- | src/spiral-context.cpp | 34 | ||||
| -rw-r--r-- | src/spiral-context.h | 10 | ||||
| -rw-r--r-- | src/tools-switch.cpp | 46 | ||||
| -rw-r--r-- | src/tools-switch.h | 1 | ||||
| -rw-r--r-- | src/ui/tool/node-tool.cpp | 91 | ||||
| -rw-r--r-- | src/ui/tool/node-tool.h | 16 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 3 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 96 |
18 files changed, 414 insertions, 204 deletions
diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 21fd41a49..31e05a6ca 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -149,6 +149,28 @@ void CArcContext::finish() { CEventContext::finish(); } +SPArcContext::~SPArcContext() { + SPEventContext *ec = SP_EVENT_CONTEXT(this); + SPArcContext *ac = SP_ARC_CONTEXT(this); + + ec->enableGrDrag(false); + + ac->sel_changed_connection.disconnect(); + ac->sel_changed_connection.~connection(); + + delete ec->shape_editor; + ec->shape_editor = NULL; + + /* fixme: This is necessary because we do not grab */ + if (ac->item) { + sp_arc_finish(ac); + } + + delete ac->_message_context; + + //G_OBJECT_CLASS(sp_arc_context_parent_class)->dispose(object); +} + static void sp_arc_context_dispose(GObject *object) { SPEventContext *ec = SP_EVENT_CONTEXT(object); diff --git a/src/arc-context.h b/src/arc-context.h index c7ff339f4..1774b8636 100644 --- a/src/arc-context.h +++ b/src/arc-context.h @@ -34,6 +34,7 @@ class CArcContext; class SPArcContext : public SPEventContext { public: SPArcContext(); + virtual ~SPArcContext(); CArcContext* carccontext; SPItem *item; diff --git a/src/desktop.cpp b/src/desktop.cpp index 17787e912..3ef668f5f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -228,7 +228,8 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid * context ever? */ //push_event_context (SP_TYPE_SELECT_CONTEXT, "/tools/select", SP_EVENT_CONTEXT_STATIC); - set_event_context(SP_TYPE_SELECT_CONTEXT, "/tools/select"); + //set_event_context(SP_TYPE_SELECT_CONTEXT, "/tools/select"); + set_event_context2("/tools/select"); // display rect and zoom are now handled in sp_desktop_widget_realize() @@ -684,38 +685,75 @@ SPDesktop::change_document (SPDocument *theDocument) _document_replaced_signal.emit (this, theDocument); } -/** - * Make desktop switch event contexts. - */ -void -SPDesktop::set_event_context (GType type, const gchar *config) -{ - //SPEventContext *ec; - //while (event_context) { - //ec = event_context; - sp_event_context_deactivate (event_context); - // we have to keep event_context valid during destruction - otherwise writing - // destructors is next to impossible - // SPEventContext *next = ec->next; - sp_event_context_finish (event_context); - g_object_unref (G_OBJECT (event_context)); - // event_context = next; + +#include "sp-factory.h" + +void SPDesktop::set_event_context2(const std::string& toolName) { + if (event_context) { + sp_event_context_deactivate(event_context); + sp_event_context_finish(event_context); + //g_object_unref(G_OBJECT(event_context)); + delete event_context; + } + + event_context = ToolFactory::instance().createObject(toolName); + SPEventContext* ec = event_context; + SPDesktop* desktop = this; + + ec->desktop = desktop; + ec->_message_context + = new Inkscape::MessageContext(desktop->messageStack()); + //ec->key = key; + ec->key = 0; + ec->pref_observer = NULL; + + const std::string& pref_path = toolName; + //if (pref_path) { + ec->pref_observer = new ToolPrefObserver(pref_path, ec); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->addObserver(*(ec->pref_observer)); //} - // The event_context will be null. This means that it will be impossible - // to process any event invoked by the lines below. See for example bug - // LP #622350. Cutting and undoing again in the node tool resets the event - // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY - // events which cannot be handled and must be discarded. - event_context = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC); - // ec->next = event_context; - //event_context = ec; - // Now the event_context has been set again and we can process all events again - sp_event_context_activate (event_context); - _event_context_changed_signal.emit (this, event_context); + ec->ceventcontext->setup(); + + + sp_event_context_activate(event_context); + _event_context_changed_signal.emit(this, event_context); } /** + * Make desktop switch event contexts. + */ +//void +//SPDesktop::set_event_context (GType type, const gchar *config) +//{ +// //SPEventContext *ec; +// //while (event_context) { +// //ec = event_context; +// sp_event_context_deactivate (event_context); +// // we have to keep event_context valid during destruction - otherwise writing +// // destructors is next to impossible +// // SPEventContext *next = ec->next; +// sp_event_context_finish (event_context); +// g_object_unref (G_OBJECT (event_context)); +// // event_context = next; +// //} +// +// // The event_context will be null. This means that it will be impossible +// // to process any event invoked by the lines below. See for example bug +// // LP #622350. Cutting and undoing again in the node tool resets the event +// // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY +// // events which cannot be handled and must be discarded. +// event_context = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC); +// // ec->next = event_context; +// //event_context = ec; +// // Now the event_context has been set again and we can process all events again +// sp_event_context_activate (event_context); +// _event_context_changed_signal.emit (this, event_context); +//} + +/** * Push event context onto desktop's context stack. */ //void diff --git a/src/desktop.h b/src/desktop.h index 56de56c65..bf1e19904 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -281,8 +281,11 @@ public: void activate_guides (bool activate); void change_document (SPDocument *document); - void set_event_context (GType type, const gchar *config); - void push_event_context (GType type, const gchar *config, unsigned int key); + + void set_event_context2(const std::string& toolName); + + //void set_event_context (GType type, const gchar *config); + //void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const; diff --git a/src/event-context.cpp b/src/event-context.cpp index 3257a2a82..c10711497 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -148,6 +148,39 @@ static void sp_event_context_init(SPEventContext *event_context) { new (event_context) SPEventContext(); } +SPEventContext::~SPEventContext() { + SPEventContext *ec; + + ec = SP_EVENT_CONTEXT(this); + + if (ec->_message_context) { + delete ec->_message_context; + } + + if (ec->cursor != NULL) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(ec->cursor); +#else + gdk_cursor_unref(ec->cursor); +#endif + ec->cursor = NULL; + } + + if (ec->desktop) { + ec->desktop = NULL; + } + + if (ec->pref_observer) { + delete ec->pref_observer; + } + + if (ec->_delayed_snap_event) { + delete ec->_delayed_snap_event; + } + + //G_OBJECT_CLASS(sp_event_context_parent_class)->dispose(object); +} + /** * Callback to free and null member variables of SPEventContext object. */ @@ -896,55 +929,36 @@ bool sp_event_context_knot_mouseover(SPEventContext *ec) } /** - * An observer that relays pref changes to the derived classes. - */ -class ToolPrefObserver: public Inkscape::Preferences::Observer { -public: - ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) : - Inkscape::Preferences::Observer(path), _ec(ec) { - } - virtual void notify(Inkscape::Preferences::Entry const &val) { -// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set) { -// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set(_ec, -// const_cast<Inkscape::Preferences::Entry*> (&val)); -// } - _ec->ceventcontext->set(const_cast<Inkscape::Preferences::Entry*>(&val)); - } -private: - SPEventContext * const _ec; -}; - -/** * Creates new SPEventContext object and calls its virtual setup() function. * @todo This is bogus. pref_path should be a private property of the inheriting objects. */ -SPEventContext * -sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, - unsigned int key) { - g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL); - g_return_val_if_fail(desktop != NULL, NULL); - - SPEventContext * const ec = static_cast<SPEventContext*>(g_object_new(type, NULL)); - - ec->desktop = desktop; - ec->_message_context - = new Inkscape::MessageContext(desktop->messageStack()); - ec->key = key; - ec->pref_observer = NULL; - - if (pref_path) { - ec->pref_observer = new ToolPrefObserver(pref_path, ec); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->addObserver(*(ec->pref_observer)); - } - -// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup) -// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup(ec); - ec->ceventcontext->setup(); - - return ec; -} +//SPEventContext * +//sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, +// unsigned int key) { +// g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL); +// g_return_val_if_fail(desktop != NULL, NULL); +// +// SPEventContext * const ec = static_cast<SPEventContext*>(g_object_new(type, NULL)); +// +// ec->desktop = desktop; +// ec->_message_context +// = new Inkscape::MessageContext(desktop->messageStack()); +// ec->key = key; +// ec->pref_observer = NULL; +// +// if (pref_path) { +// ec->pref_observer = new ToolPrefObserver(pref_path, ec); +// +// Inkscape::Preferences *prefs = Inkscape::Preferences::get(); +// prefs->addObserver(*(ec->pref_observer)); +// } +// +//// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup) +//// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup(ec); +// ec->ceventcontext->setup(); +// +// return ec; +//} /** * Finishes SPEventContext. diff --git a/src/event-context.h b/src/event-context.h index 9f55fd8de..a4494a5cf 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -33,7 +33,6 @@ namespace Inkscape { } } - #define SP_TYPE_EVENT_CONTEXT (sp_event_context_get_type()) //#define SP_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_EVENT_CONTEXT, SPEventContext)) #define SP_EVENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_EVENT_CONTEXT, SPEventContextClass)) @@ -111,13 +110,14 @@ class CEventContext; * plus few abstract base classes. Writing a new tool involves * subclassing SPEventContext. */ -class SPEventContext : public GObject { +class SPEventContext { //: public GObject { public: void enableSelectionCue (bool enable=true); void enableGrDrag (bool enable=true); bool deleteSelectedDrag(bool just_one); SPEventContext(); + virtual ~SPEventContext(); CEventContext* ceventcontext; std::set<TypeInfo> types; @@ -194,7 +194,7 @@ protected: #define SP_EVENT_CONTEXT_STATIC 0 -SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned key); +//SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned key); void sp_event_context_finish(SPEventContext *ec); void sp_event_context_read(SPEventContext *ec, gchar const *key); void sp_event_context_activate(SPEventContext *ec); @@ -231,6 +231,28 @@ void ec_shape_event_attr_changed(Inkscape::XML::Node *shape_repr, void event_context_print_event_info(GdkEvent *event, bool print_return = true); + +/** + * An observer that relays pref changes to the derived classes. + */ +class ToolPrefObserver: public Inkscape::Preferences::Observer { +public: + ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) : + Inkscape::Preferences::Observer(path), _ec(ec) { + } + virtual void notify(Inkscape::Preferences::Entry const &val) { +// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set) { +// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set(_ec, +// const_cast<Inkscape::Preferences::Entry*> (&val)); +// } + _ec->ceventcontext->set(const_cast<Inkscape::Preferences::Entry*>(&val)); + } +private: + SPEventContext * const _ec; +}; + + + #endif // SEEN_SP_EVENT_CONTEXT_H diff --git a/src/rect-context.cpp b/src/rect-context.cpp index e0c0af2c9..2a1dfcd55 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -155,6 +155,31 @@ void CRectContext::finish() { CEventContext::finish(); } + +SPRectContext::~SPRectContext() { + SPRectContext *rc = SP_RECT_CONTEXT(this); + SPEventContext *ec = SP_EVENT_CONTEXT(this); + + ec->enableGrDrag(false); + + rc->sel_changed_connection.disconnect(); + rc->sel_changed_connection.~connection(); + + delete ec->shape_editor; + ec->shape_editor = NULL; + + /* fixme: This is necessary because we do not grab */ + if (rc->item) { + sp_rect_finish(rc); + } + + if (rc->_message_context) { + delete rc->_message_context; + } + + //G_OBJECT_CLASS(sp_rect_context_parent_class)->dispose(object); +} + static void sp_rect_context_dispose(GObject *object) { SPRectContext *rc = SP_RECT_CONTEXT(object); diff --git a/src/rect-context.h b/src/rect-context.h index 41fa64b59..627e0b942 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -32,6 +32,7 @@ class CRectContext; class SPRectContext : public SPEventContext { public: SPRectContext(); + virtual ~SPRectContext(); CRectContext* crectcontext; SPItem *item; diff --git a/src/select-context.cpp b/src/select-context.cpp index 604b4c7cc..085ac1532 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -155,6 +155,42 @@ sp_select_context_init(SPSelectContext *sc) new (sc) SPSelectContext(); } +SPSelectContext::~SPSelectContext() { + SPSelectContext *sc = SP_SELECT_CONTEXT(this); + SPEventContext * ec = SP_EVENT_CONTEXT (this); + + ec->enableGrDrag(false); + + if (sc->grabbed) { + sp_canvas_item_ungrab(sc->grabbed, GDK_CURRENT_TIME); + sc->grabbed = NULL; + } + + delete sc->_seltrans; + sc->_seltrans = NULL; + delete sc->_describer; + sc->_describer = NULL; + + if (CursorSelectDragging) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(CursorSelectDragging); +#else + gdk_cursor_unref (CursorSelectDragging); +#endif + CursorSelectDragging = NULL; + } + if (CursorSelectMouseover) { +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(CursorSelectMouseover); +#else + gdk_cursor_unref (CursorSelectMouseover); +#endif + CursorSelectMouseover = NULL; + } + + //G_OBJECT_CLASS(sp_select_context_parent_class)->dispose(object); +} + static void sp_select_context_dispose(GObject *object) { diff --git a/src/select-context.h b/src/select-context.h index 705f1ad7d..6c31cbd18 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -36,6 +36,7 @@ class CSelectContext; class SPSelectContext : public SPEventContext { public: SPSelectContext(); + virtual ~SPSelectContext(); CSelectContext* cselectcontext; guint dragging : 1; diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 2f171ddde..c8faa5e9e 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -46,8 +46,6 @@ using Inkscape::DocumentUndo; -static void sp_spiral_context_dispose(GObject *object); - static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point const &p, guint state); static void sp_spiral_finish(SPSpiralContext *sc); static void sp_spiral_cancel(SPSpiralContext *sc); @@ -68,22 +66,6 @@ const std::string& CSpiralContext::getPrefsPath() { const std::string SPSpiralContext::prefsPath = "/tools/shapes/spiral"; -G_DEFINE_TYPE(SPSpiralContext, sp_spiral_context, SP_TYPE_EVENT_CONTEXT); - -static void -sp_spiral_context_class_init(SPSpiralContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - - object_class->dispose = sp_spiral_context_dispose; - -// event_context_class->setup = sp_spiral_context_setup; -// event_context_class->finish = sp_spiral_context_finish; -// event_context_class->set = sp_spiral_context_set; -// event_context_class->root_handler = sp_spiral_context_root_handler; -} - CSpiralContext::CSpiralContext(SPSpiralContext* spiralcontext) : CEventContext(spiralcontext) { this->spspiralcontext = spiralcontext; } @@ -118,12 +100,6 @@ SPSpiralContext::SPSpiralContext() : SPEventContext() { new (&spiral_context->sel_changed_connection) sigc::connection(); } -static void -sp_spiral_context_init(SPSpiralContext *spiral_context) -{ - new (spiral_context) SPSpiralContext(); -} - void CSpiralContext::finish() { SPEventContext* ec = this->speventcontext; @@ -140,11 +116,9 @@ void CSpiralContext::finish() { CEventContext::finish(); } -static void -sp_spiral_context_dispose(GObject *object) -{ - SPSpiralContext *sc = SP_SPIRAL_CONTEXT(object); - SPEventContext *ec = SP_EVENT_CONTEXT(object); +SPSpiralContext::~SPSpiralContext() { + SPSpiralContext *sc = SP_SPIRAL_CONTEXT(this); + SPEventContext *ec = SP_EVENT_CONTEXT(this); ec->enableGrDrag(false); @@ -161,7 +135,7 @@ sp_spiral_context_dispose(GObject *object) delete sc->_message_context; } - G_OBJECT_CLASS(sp_spiral_context_parent_class)->dispose(object); + //G_OBJECT_CLASS(sp_spiral_context_parent_class)->dispose(object); } /** diff --git a/src/spiral-context.h b/src/spiral-context.h index b71135800..a4d4e3ac4 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -21,19 +21,21 @@ #include <2geom/point.h> #include "event-context.h" -#define SP_TYPE_SPIRAL_CONTEXT (sp_spiral_context_get_type ()) +//#define SP_TYPE_SPIRAL_CONTEXT (sp_spiral_context_get_type ()) //#define SP_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContext)) -#define SP_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContextClass)) +//#define SP_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SPIRAL_CONTEXT, SPSpiralContextClass)) //#define SP_IS_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL_CONTEXT)) -#define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) +//#define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) #define SP_SPIRAL_CONTEXT(obj) ((SPSpiralContext*)obj) -#define SP_IS_SPIRAL_CONTEXT(obj) (((SPEventContext*)obj)->types.count(typeid(SPSpiralContext))) +//#define SP_IS_SPIRAL_CONTEXT(obj) (((SPEventContext*)obj)->types.count(typeid(SPSpiralContext))) +#define SP_IS_SPIRAL_CONTEXT(obj) (dynamic_cast<const SPSpiralContext*>((const SPEventContext*)obj)) class CSpiralContext; class SPSpiralContext : public SPEventContext { public: SPSpiralContext(); + virtual ~SPSpiralContext(); CSpiralContext* cspiralcontext; SPItem * item; diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 9e7dfa3f9..ec917f331 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -122,134 +122,136 @@ tools_switch(SPDesktop *dt, int num) dt->_tool_changed.emit(num); } + dt->set_event_context2(tool_names[num]); + switch (num) { case TOOLS_SELECT: - dt->set_event_context(SP_TYPE_SELECT_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_SELECT_CONTEXT, tool_names[num]); /* fixme: This is really ugly hack. We should bind and unbind class methods */ dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); break; case TOOLS_NODES: - dt->set_event_context(INK_TYPE_NODE_TOOL, tool_names[num]); + //dt->set_event_context(INK_TYPE_NODE_TOOL, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); break; case TOOLS_TWEAK: - dt->set_event_context(SP_TYPE_TWEAK_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_TWEAK_CONTEXT, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To tweak a path by pushing, select it and drag over it.")); break; case TOOLS_SPRAY: - dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b>, <b>click</b> or <b>click and scroll</b> to spray the selected objects.")); break; case TOOLS_SHAPES_RECT: - dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a rectangle. <b>Drag controls</b> to round corners and resize. <b>Click</b> to select.")); break; case TOOLS_SHAPES_3DBOX: - dt->set_event_context(SP_TYPE_BOX3D_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_BOX3D_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a 3D box. <b>Drag controls</b> to resize in perspective. <b>Click</b> to select (with <b>Ctrl+Alt</b> for single faces).")); break; case TOOLS_SHAPES_ARC: - dt->set_event_context(SP_TYPE_ARC_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_ARC_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create an ellipse. <b>Drag controls</b> to make an arc or segment. <b>Click</b> to select.")); break; case TOOLS_SHAPES_STAR: - dt->set_event_context(SP_TYPE_STAR_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_STAR_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a star. <b>Drag controls</b> to edit the star shape. <b>Click</b> to select.")); break; case TOOLS_SHAPES_SPIRAL: - dt->set_event_context(SP_TYPE_SPIRAL_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_SPIRAL_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a spiral. <b>Drag controls</b> to edit the spiral shape. <b>Click</b> to select.")); break; case TOOLS_FREEHAND_PENCIL: - dt->set_event_context(SP_TYPE_PENCIL_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_PENCIL_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a freehand line. <b>Shift</b> appends to selected path, <b>Alt</b> activates sketch mode.")); break; case TOOLS_FREEHAND_PEN: - dt->set_event_context(SP_TYPE_PEN_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_PEN_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to start a path; with <b>Shift</b> to append to selected path. <b>Ctrl+click</b> to create single dots (straight line modes only).")); break; case TOOLS_CALLIGRAPHIC: - dt->set_event_context(SP_TYPE_DYNA_DRAW_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_DYNA_DRAW_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to draw a calligraphic stroke; with <b>Ctrl</b> to track a guide path. <b>Arrow keys</b> adjust width (left/right) and angle (up/down).")); break; case TOOLS_TEXT: - dt->set_event_context(SP_TYPE_TEXT_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_TEXT_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to select or create text, <b>drag</b> to create flowed text; then type.")); break; case TOOLS_GRADIENT: - dt->set_event_context(SP_TYPE_GRADIENT_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_GRADIENT_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> or <b>double click</b> to create a gradient on selected objects, <b>drag handles</b> to adjust gradients.")); break; case TOOLS_MESH: - dt->set_event_context(SP_TYPE_MESH_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_MESH_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> or <b>double click</b> to create a mesh on selected objects, <b>drag handles</b> to adjust meshes.")); break; case TOOLS_ZOOM: - dt->set_event_context(SP_TYPE_ZOOM_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_ZOOM_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>drag around an area</b> to zoom in, <b>Shift+click</b> to zoom out.")); break; case TOOLS_MEASURE: - dt->set_event_context(SP_TYPE_MEASURE_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_MEASURE_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to measure the dimensions of objects.")); break; case TOOLS_DROPPER: - dt->set_event_context(SP_TYPE_DROPPER_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_DROPPER_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard")); break; case TOOLS_CONNECTOR: - dt->set_event_context(SP_TYPE_CONNECTOR_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_CONNECTOR_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click and drag</b> between shapes to create a connector.")); break; case TOOLS_PAINTBUCKET: - dt->set_event_context(SP_TYPE_FLOOD_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_FLOOD_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to paint a bounded area, <b>Shift+click</b> to union the new fill with the current selection, <b>Ctrl+click</b> to change the clicked object's fill and stroke to the current setting.")); break; case TOOLS_ERASER: - dt->set_event_context(SP_TYPE_ERASER_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_ERASER_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to erase.")); break; case TOOLS_LPETOOL: - dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]); + //dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar")); diff --git a/src/tools-switch.h b/src/tools-switch.h index 77fe370c6..280837e87 100644 --- a/src/tools-switch.h +++ b/src/tools-switch.h @@ -18,6 +18,7 @@ namespace Geom { class Point; } + enum { TOOLS_INVALID, TOOLS_SELECT, diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e30dde1ae..a3449d0ce 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -191,16 +191,22 @@ InkNodeTool::InkNodeTool() : SPEventContext() { event_context->hot_x = 1; event_context->hot_y = 1; - new (&nt->_selection_changed_connection) sigc::connection(); - new (&nt->_selection_modified_connection) sigc::connection(); - new (&nt->_mouseover_changed_connection) sigc::connection(); - new (&nt->_sizeUpdatedConn) sigc::connection(); - //new (&nt->_mgroup) Inkscape::UI::ManipulatorGroup(nt->desktop); - new (&nt->_selected_nodes) CSelPtr(); - new (&nt->_multipath) MultiPathPtr(); - new (&nt->_selector) SelectorPtr(); - new (&nt->_path_data) PathSharedDataPtr(); - new (&nt->_shape_editors) ShapeEditors(); +// new (&nt->_selection_changed_connection) sigc::connection(); +// new (&nt->_selection_modified_connection) sigc::connection(); +// new (&nt->_mouseover_changed_connection) sigc::connection(); +// new (&nt->_sizeUpdatedConn) sigc::connection(); +// //new (&nt->_mgroup) Inkscape::UI::ManipulatorGroup(nt->desktop); +// new (&nt->_selected_nodes) CSelPtr(); +// new (&nt->_multipath) MultiPathPtr(); +// new (&nt->_selector) SelectorPtr(); +// new (&nt->_path_data) PathSharedDataPtr(); +// new (&nt->_shape_editors) ShapeEditors(); + + nt->_selected_nodes = 0; + nt->_multipath = 0; + nt->_selector = 0; + nt->_path_data = 0; + //nt->_shape_editors = 0; } static void @@ -222,6 +228,50 @@ void destroy_group(SPCanvasGroup *g) sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); } +InkNodeTool::~InkNodeTool() { + InkNodeTool *nt = INK_NODE_TOOL(this); + + nt->enableGrDrag(false); + + if (nt->flash_tempitem) { + nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem); + } + + nt->_selection_changed_connection.disconnect(); + nt->_selection_modified_connection.disconnect(); + nt->_mouseover_changed_connection.disconnect(); + nt->_sizeUpdatedConn.disconnect(); + +// nt->_multipath.~MultiPathPtr(); +// nt->_selected_nodes.~CSelPtr(); +// nt->_selector.~SelectorPtr(); +// nt->_shape_editors.~ShapeEditors(); + + delete nt->_multipath; + delete nt->_selected_nodes; + delete nt->_selector; + + Inkscape::UI::PathSharedData &data = *nt->_path_data; + destroy_group(data.node_data.node_group); + destroy_group(data.node_data.handle_group); + destroy_group(data.node_data.handle_line_group); + destroy_group(data.outline_group); + destroy_group(data.dragpoint_group); + destroy_group(nt->_transform_handle_group); + +// nt->_path_data.~PathSharedDataPtr(); +// nt->_selection_changed_connection.~connection(); +// nt->_selection_modified_connection.~connection(); +// nt->_mouseover_changed_connection.~connection(); +// nt->_sizeUpdatedConn.~connection(); + + if (nt->_node_message_context) { + delete nt->_node_message_context; + } + + //G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); +} + void ink_node_tool_dispose(GObject *object) { InkNodeTool *nt = INK_NODE_TOOL(object); @@ -278,12 +328,14 @@ void CInkNodeTool::setup() { nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); - nt->_path_data.reset(new Inkscape::UI::PathSharedData()); + //nt->_path_data.reset(new Inkscape::UI::PathSharedData()); + nt->_path_data = new Inkscape::UI::PathSharedData(); Inkscape::UI::PathSharedData &data = *nt->_path_data; data.node_data.desktop = nt->desktop; // selector has to be created here, so that its hidden control point is on the bottom - nt->_selector.reset(new Inkscape::UI::Selector(nt->desktop)); + //nt->_selector.reset(new Inkscape::UI::Selector(nt->desktop)); + nt->_selector = new Inkscape::UI::Selector(nt->desktop); // Prepare canvas groups for controls. This guarantees correct z-order, so that // for example a dragpoint won't obscure a node @@ -316,11 +368,16 @@ void CInkNodeTool::setup() { nt->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(sigc::bind(sigc::ptr_fun(&handleControlUiStyleChange), nt)); - nt->_selected_nodes.reset( - new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group)); - data.node_data.selection = nt->_selected_nodes.get(); - nt->_multipath.reset(new Inkscape::UI::MultiPathManipulator(data, - nt->_selection_changed_connection)); +// nt->_selected_nodes.reset( +// new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group)); + nt->_selected_nodes = new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group); + + //data.node_data.selection = nt->_selected_nodes.get(); + data.node_data.selection = nt->_selected_nodes; + + //nt->_multipath.reset(new Inkscape::UI::MultiPathManipulator(data, + // nt->_selection_changed_connection)); + nt->_multipath = new Inkscape::UI::MultiPathManipulator(data, nt->_selection_changed_connection); nt->_selector->signal_point.connect( sigc::bind<0>( diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 3de68d535..43c1f3cdf 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -37,10 +37,17 @@ struct PathSharedData; } // namespace UI } // namespace Inkscape -typedef std::auto_ptr<Inkscape::UI::MultiPathManipulator> MultiPathPtr; -typedef std::auto_ptr<Inkscape::UI::ControlPointSelection> CSelPtr; -typedef std::auto_ptr<Inkscape::UI::Selector> SelectorPtr; -typedef std::auto_ptr<Inkscape::UI::PathSharedData> PathSharedDataPtr; +//typedef std::auto_ptr<Inkscape::UI::MultiPathManipulator> MultiPathPtr; +//typedef std::auto_ptr<Inkscape::UI::ControlPointSelection> CSelPtr; +//typedef std::auto_ptr<Inkscape::UI::Selector> SelectorPtr; +//typedef std::auto_ptr<Inkscape::UI::PathSharedData> PathSharedDataPtr; + + +typedef Inkscape::UI::MultiPathManipulator* MultiPathPtr; +typedef Inkscape::UI::ControlPointSelection* CSelPtr; +typedef Inkscape::UI::Selector* SelectorPtr; +typedef Inkscape::UI::PathSharedData* PathSharedDataPtr; + typedef boost::ptr_map<SPItem*, ShapeEditor> ShapeEditors; class CInkNodeTool; @@ -49,6 +56,7 @@ class InkNodeTool : public SPEventContext { public: InkNodeTool(); + virtual ~InkNodeTool(); CInkNodeTool* cinknodetool; sigc::connection _selection_changed_connection; diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..479a29d1f 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -129,7 +129,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); + //ControlPointSelection *selection = nt->_selected_nodes.get(); + ControlPointSelection* selection = nt->_selected_nodes; selection->setOriginalPoints(); selection->getOriginalPoints(_snap_points); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f03835e17..6ef5a276e 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -93,6 +93,8 @@ #include "toolbox.h" #include <gtk/gtk.h> +#include "event-context.h" + //#define DEBUG_TEXT using Inkscape::UnitTracker; @@ -134,29 +136,29 @@ static struct { sp_verb_t verb; sp_verb_t doubleclick_verb; } const tools[] = { - { "SPSelectContext", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS}, - { "InkNodeTool", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS }, - { "SPTweakContext", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS }, - { "SPSprayContext", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS }, - { "SPZoomContext", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS }, - { "SPMeasureContext", "measure_tool", SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_MEASURE_PREFS }, - { "SPRectContext", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS }, - { "Box3DContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS }, - { "SPArcContext", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS }, - { "SPStarContext", "star_tool", SP_VERB_CONTEXT_STAR, SP_VERB_CONTEXT_STAR_PREFS }, - { "SPSpiralContext", "spiral_tool", SP_VERB_CONTEXT_SPIRAL, SP_VERB_CONTEXT_SPIRAL_PREFS }, - { "SPPencilContext", "pencil_tool", SP_VERB_CONTEXT_PENCIL, SP_VERB_CONTEXT_PENCIL_PREFS }, - { "SPPenContext", "pen_tool", SP_VERB_CONTEXT_PEN, SP_VERB_CONTEXT_PEN_PREFS }, - { "SPDynaDrawContext", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS }, - { "SPLPEToolContext", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS }, - { "SPEraserContext", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS }, - { "SPFloodContext", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS }, - { "SPTextContext", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS }, - { "SPConnectorContext","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS }, - { "SPGradientContext", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS }, - { "SPMeshContext", "mesh_tool", SP_VERB_CONTEXT_MESH, SP_VERB_CONTEXT_MESH_PREFS }, - { "SPDropperContext", "dropper_tool", SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_DROPPER_PREFS }, - { NULL, NULL, 0, 0 } + { "/tools/select", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS}, + { "/tools/nodes", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS }, + { "/tools/tweak", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS }, + { "/tools/spray", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS }, + { "/tools/zoom", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS }, + { "/tools/measure", "measure_tool", SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_MEASURE_PREFS }, + { "/tools/shapes/rect", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS }, + { "/tools/shapes/3dbox", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS }, + { "/tools/shapes/arc", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS }, + { "/tools/shapes/star", "star_tool", SP_VERB_CONTEXT_STAR, SP_VERB_CONTEXT_STAR_PREFS }, + { "/tools/shapes/spiral", "spiral_tool", SP_VERB_CONTEXT_SPIRAL, SP_VERB_CONTEXT_SPIRAL_PREFS }, + { "/tools/freehand/pencil", "pencil_tool", SP_VERB_CONTEXT_PENCIL, SP_VERB_CONTEXT_PENCIL_PREFS }, + { "/tools/freehand/pen", "pen_tool", SP_VERB_CONTEXT_PEN, SP_VERB_CONTEXT_PEN_PREFS }, + { "/tools/calligraphic", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS }, + { "/tools/lpetool", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS }, + { "/tools/eraser", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS }, + { "/tools/paintbucket", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS }, + { "/tools/text", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS }, + { "/tools/connector","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS }, + { "/tools/gradient", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS }, + { "/tools/mesh", "mesh_tool", SP_VERB_CONTEXT_MESH, SP_VERB_CONTEXT_MESH_PREFS }, + { "/tools/dropper", "dropper_tool", SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_DROPPER_PREFS }, + { NULL, NULL, 0, 0 } }; static struct { @@ -169,49 +171,49 @@ static struct { gchar const *swatch_tool; gchar const *swatch_tip; } const aux_toolboxes[] = { - { "SPSelectContext", "select_toolbox", 0, sp_select_toolbox_prep, "SelectToolbar", + { "/tools/select", "select_toolbox", 0, sp_select_toolbox_prep, "SelectToolbar", SP_VERB_INVALID, 0, 0}, - { "InkNodeTool", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar", + { "/tools/nodes", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar", SP_VERB_INVALID, 0, 0}, - { "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar", + { "/tools/tweak", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar", SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")}, - { "SPSprayContext", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar", + { "/tools/spray", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar", SP_VERB_INVALID, 0, 0}, - { "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar", + { "/tools/zoom", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar", SP_VERB_INVALID, 0, 0}, - { "SPMeasureContext", "measure_toolbox", 0, sp_measure_toolbox_prep, "MeasureToolbar", + { "/tools/measure", "measure_toolbox", 0, sp_measure_toolbox_prep, "MeasureToolbar", SP_VERB_INVALID, 0, 0}, - { "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar", + { "/tools/shapes/star", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar", SP_VERB_CONTEXT_STAR_PREFS, "/tools/shapes/star", N_("Style of new stars")}, - { "SPRectContext", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar", + { "/tools/shapes/rect", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar", SP_VERB_CONTEXT_RECT_PREFS, "/tools/shapes/rect", N_("Style of new rectangles")}, - { "Box3DContext", "3dbox_toolbox", 0, box3d_toolbox_prep, "3DBoxToolbar", + { "/tools/shapes/3dbox", "3dbox_toolbox", 0, box3d_toolbox_prep, "3DBoxToolbar", SP_VERB_CONTEXT_3DBOX_PREFS, "/tools/shapes/3dbox", N_("Style of new 3D boxes")}, - { "SPArcContext", "arc_toolbox", 0, sp_arc_toolbox_prep, "ArcToolbar", + { "/tools/shapes/arc", "arc_toolbox", 0, sp_arc_toolbox_prep, "ArcToolbar", SP_VERB_CONTEXT_ARC_PREFS, "/tools/shapes/arc", N_("Style of new ellipses")}, - { "SPSpiralContext", "spiral_toolbox", 0, sp_spiral_toolbox_prep, "SpiralToolbar", + { "/tools/shapes/spiral", "spiral_toolbox", 0, sp_spiral_toolbox_prep, "SpiralToolbar", SP_VERB_CONTEXT_SPIRAL_PREFS, "/tools/shapes/spiral", N_("Style of new spirals")}, - { "SPPencilContext", "pencil_toolbox", 0, sp_pencil_toolbox_prep, "PencilToolbar", + { "/tools/freehand/pencil", "pencil_toolbox", 0, sp_pencil_toolbox_prep, "PencilToolbar", SP_VERB_CONTEXT_PENCIL_PREFS, "/tools/freehand/pencil", N_("Style of new paths created by Pencil")}, - { "SPPenContext", "pen_toolbox", 0, sp_pen_toolbox_prep, "PenToolbar", + { "/tools/freehand/pen", "pen_toolbox", 0, sp_pen_toolbox_prep, "PenToolbar", SP_VERB_CONTEXT_PEN_PREFS, "/tools/freehand/pen", N_("Style of new paths created by Pen")}, - { "SPDynaDrawContext", "calligraphy_toolbox", 0, sp_calligraphy_toolbox_prep,"CalligraphyToolbar", + { "/tools/calligraphic", "calligraphy_toolbox", 0, sp_calligraphy_toolbox_prep,"CalligraphyToolbar", SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "/tools/calligraphic", N_("Style of new calligraphic strokes")}, - { "SPEraserContext", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar", + { "/tools/eraser", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar", SP_VERB_CONTEXT_ERASER_PREFS, "/tools/eraser", _("TBD")}, - { "SPLPEToolContext", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar", + { "/tools/lpetool", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar", SP_VERB_CONTEXT_LPETOOL_PREFS, "/tools/lpetool", _("TBD")}, - { "SPTextContext", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar", + { "/tools/text", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar", SP_VERB_INVALID, 0, 0}, - { "SPDropperContext", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar", + { "/tools/dropper", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar", SP_VERB_INVALID, 0, 0}, - { "SPConnectorContext", "connector_toolbox", 0, sp_connector_toolbox_prep, "ConnectorToolbar", + { "/tools/connector", "connector_toolbox", 0, sp_connector_toolbox_prep, "ConnectorToolbar", SP_VERB_INVALID, 0, 0}, - { "SPGradientContext", "gradient_toolbox", 0, sp_gradient_toolbox_prep, "GradientToolbar", + { "/tools/gradient", "gradient_toolbox", 0, sp_gradient_toolbox_prep, "GradientToolbar", SP_VERB_INVALID, 0, 0}, - { "SPMeshContext", "mesh_toolbox", 0, sp_mesh_toolbox_prep, "MeshToolbar", + { "/tools/mesh", "mesh_toolbox", 0, sp_mesh_toolbox_prep, "MeshToolbar", SP_VERB_INVALID, 0, 0}, - { "SPFloodContext", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar", + { "/tools/paintbucket", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar", SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")}, { NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL } }; @@ -1311,7 +1313,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) void update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget * /*toolbox*/ ) { gchar const *const tname = ( eventcontext - ? g_type_name(G_OBJECT_TYPE(eventcontext)) + ? eventcontext->ceventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext)) : NULL ); Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop ); @@ -1433,7 +1435,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) void update_aux_toolbox(SPDesktop * /*desktop*/, SPEventContext *eventcontext, GtkWidget *toolbox) { gchar const *tname = ( eventcontext - ? g_type_name(G_OBJECT_TYPE(eventcontext)) + ? eventcontext->ceventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext)) : NULL ); for (int i = 0 ; aux_toolboxes[i].type_name ; i++ ) { GtkWidget *sub_toolbox = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbox), aux_toolboxes[i].data_name)); |
