summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:07:14 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:07:14 +0000
commite77956b4dbd029c9f6949f81fe083606f995c624 (patch)
tree74adda4df8986d65f70efb341c6235277361fd35 /src/ui
parentupdated code to work on 0.92 code (diff)
parentLatvian translation update (diff)
downloadinkscape-e77956b4dbd029c9f6949f81fe083606f995c624.tar.gz
inkscape-e77956b4dbd029c9f6949f81fe083606f995c624.zip
update to trunk
(bzr r12588.1.39)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt5
-rw-r--r--src/ui/Makefile_insert1
-rw-r--r--src/ui/clipboard.cpp58
-rw-r--r--src/ui/clipboard.h2
-rw-r--r--src/ui/dialog-events.cpp9
-rw-r--r--src/ui/dialog-events.h12
-rw-r--r--src/ui/dialog/aboutbox.cpp6
-rw-r--r--src/ui/dialog/align-and-distribute.cpp61
-rw-r--r--src/ui/dialog/align-and-distribute.h3
-rw-r--r--src/ui/dialog/clonetiler.cpp85
-rw-r--r--src/ui/dialog/clonetiler.h5
-rw-r--r--src/ui/dialog/color-item.cpp6
-rw-r--r--src/ui/dialog/desktop-tracker.cpp17
-rw-r--r--src/ui/dialog/desktop-tracker.h4
-rw-r--r--src/ui/dialog/dialog.cpp42
-rw-r--r--src/ui/dialog/dialog.h1
-rw-r--r--src/ui/dialog/document-metadata.cpp16
-rw-r--r--src/ui/dialog/document-metadata.h5
-rw-r--r--src/ui/dialog/document-properties.cpp116
-rw-r--r--src/ui/dialog/document-properties.h4
-rw-r--r--src/ui/dialog/export.cpp59
-rw-r--r--src/ui/dialog/filedialog.cpp2
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp7
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp10
-rw-r--r--src/ui/dialog/filedialogimpl-win32.h2
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp2
-rw-r--r--src/ui/dialog/fill-and-stroke.h3
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp18
-rw-r--r--src/ui/dialog/find.cpp18
-rw-r--r--src/ui/dialog/font-substitution.cpp4
-rw-r--r--src/ui/dialog/glyphs.cpp9
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp21
-rw-r--r--src/ui/dialog/guides.cpp2
-rw-r--r--src/ui/dialog/icon-preview.cpp4
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp28
-rw-r--r--src/ui/dialog/layer-properties.cpp8
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp62
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp19
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h6
-rw-r--r--src/ui/dialog/lpe-powerstroke-properties.cpp2
-rw-r--r--src/ui/dialog/memory.cpp2
-rw-r--r--src/ui/dialog/object-attributes.cpp4
-rw-r--r--src/ui/dialog/object-properties.cpp12
-rw-r--r--src/ui/dialog/objects.cpp68
-rw-r--r--src/ui/dialog/ocaldialogs.cpp2
-rw-r--r--src/ui/dialog/panel-dialog.h33
-rw-r--r--src/ui/dialog/polar-arrange-tab.cpp22
-rw-r--r--src/ui/dialog/print.cpp21
-rw-r--r--src/ui/dialog/spellcheck.cpp8
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp39
-rw-r--r--src/ui/dialog/swatches.cpp30
-rw-r--r--src/ui/dialog/symbols.cpp16
-rw-r--r--src/ui/dialog/tags.cpp33
-rw-r--r--src/ui/dialog/tags.h2
-rw-r--r--src/ui/dialog/template-load-tab.cpp2
-rw-r--r--src/ui/dialog/template-widget.cpp6
-rw-r--r--src/ui/dialog/text-edit.cpp47
-rw-r--r--src/ui/dialog/transformation.cpp45
-rw-r--r--src/ui/dialog/transformation.h3
-rw-r--r--src/ui/dialog/undo-history.cpp2
-rw-r--r--src/ui/dialog/xml-tree.cpp30
-rw-r--r--src/ui/draw-anchor.cpp3
-rw-r--r--src/ui/interface.cpp22
-rw-r--r--src/ui/object-edit.cpp122
-rw-r--r--src/ui/shape-editor.cpp4
-rw-r--r--src/ui/tool-factory.cpp102
-rw-r--r--src/ui/tool-factory.h10
-rw-r--r--src/ui/tool/control-point.cpp6
-rw-r--r--src/ui/tool/curve-drag-point.cpp18
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp8
-rw-r--r--src/ui/tool/node.cpp2
-rw-r--r--src/ui/tool/path-manipulator.cpp10
-rw-r--r--src/ui/tool/selector.cpp6
-rw-r--r--src/ui/tool/transform-handle-set.cpp4
-rw-r--r--src/ui/tools-switch.cpp6
-rw-r--r--src/ui/tools/arc-tool.cpp26
-rw-r--r--src/ui/tools/box3d-tool.cpp30
-rw-r--r--src/ui/tools/calligraphic-tool.cpp34
-rw-r--r--src/ui/tools/connector-tool.cpp32
-rw-r--r--src/ui/tools/dropper-tool.cpp40
-rw-r--r--src/ui/tools/eraser-tool.cpp26
-rw-r--r--src/ui/tools/flood-tool.cpp38
-rw-r--r--src/ui/tools/freehand-base.cpp37
-rw-r--r--src/ui/tools/gradient-tool.cpp30
-rw-r--r--src/ui/tools/lpe-tool.cpp31
-rw-r--r--src/ui/tools/measure-tool.cpp44
-rw-r--r--src/ui/tools/mesh-tool.cpp46
-rw-r--r--src/ui/tools/node-tool.cpp24
-rw-r--r--src/ui/tools/node-tool.h2
-rw-r--r--src/ui/tools/pen-tool.cpp233
-rw-r--r--src/ui/tools/pen-tool.h1
-rw-r--r--src/ui/tools/pencil-tool.cpp15
-rw-r--r--src/ui/tools/rect-tool.cpp26
-rw-r--r--src/ui/tools/select-tool.cpp73
-rw-r--r--src/ui/tools/spiral-tool.cpp26
-rw-r--r--src/ui/tools/spray-tool.cpp88
-rw-r--r--src/ui/tools/star-tool.cpp26
-rw-r--r--src/ui/tools/text-tool.cpp85
-rw-r--r--src/ui/tools/tool-base.cpp20
-rw-r--r--src/ui/tools/tweak-tool.cpp42
-rw-r--r--src/ui/tools/zoom-tool.cpp9
-rw-r--r--src/ui/view/view.cpp8
-rw-r--r--src/ui/view/view.h2
-rw-r--r--src/ui/widget/addtoicon.cpp17
-rw-r--r--src/ui/widget/addtoicon.h2
-rw-r--r--src/ui/widget/color-picker.cpp4
-rw-r--r--src/ui/widget/dock.cpp5
-rw-r--r--src/ui/widget/filter-effect-chooser.cpp2
-rw-r--r--src/ui/widget/imageicon.cpp5
-rw-r--r--src/ui/widget/layer-selector.cpp6
-rw-r--r--src/ui/widget/licensor.cpp2
-rw-r--r--src/ui/widget/object-composite-settings.cpp51
-rw-r--r--src/ui/widget/object-composite-settings.h4
-rw-r--r--src/ui/widget/page-sizer.cpp139
-rw-r--r--src/ui/widget/page-sizer.h21
-rw-r--r--src/ui/widget/panel.cpp11
-rw-r--r--src/ui/widget/panel.h9
-rw-r--r--src/ui/widget/preferences-widget.cpp2
-rw-r--r--src/ui/widget/registered-widget.cpp39
-rw-r--r--src/ui/widget/registered-widget.h18
-rw-r--r--src/ui/widget/selected-style.cpp107
-rw-r--r--src/ui/widget/style-subject.cpp6
-rw-r--r--src/ui/widget/style-swatch.cpp9
-rw-r--r--src/ui/widget/tolerance-slider.cpp7
124 files changed, 1511 insertions, 1543 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index e5c605889..674254686 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -4,10 +4,11 @@ set(ui_SRC
control-manager.cpp
dialog-events.cpp
draw-anchor.cpp
- interface.cpp
- object-edit.cpp
+ interface.cpp
+ object-edit.cpp
previewholder.cpp
shape-editor.cpp
+ tool-factory.cpp
tools-switch.cpp
uxmanager.cpp
diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert
index 7aeb4a83d..f94cba4e9 100644
--- a/src/ui/Makefile_insert
+++ b/src/ui/Makefile_insert
@@ -21,6 +21,7 @@ ink_common_sources += \
ui/previewholder.h \
ui/shape-editor.cpp \
ui/shape-editor.h \
+ ui/tool-factory.cpp \
ui/tool-factory.h \
ui/tools-switch.cpp \
ui/tools-switch.h \
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 153ed9830..f1d0ff576 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -32,12 +32,12 @@
#include <glibmm/ustring.h>
#include <glibmm/i18n.h>
#include <glib/gstdio.h> // for g_file_set_contents etc., used in _onGet and paste
-#include "gc-core.h"
+#include "inkgc/gc-core.h"
#include "xml/repr.h"
#include "inkscape.h"
#include "io/stringstream.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h" // for sp_desktop_set_style, used in _pasteStyle
#include "document.h"
#include "document-private.h"
@@ -107,7 +107,7 @@ class ClipboardManagerImpl : public ClipboardManager {
public:
virtual void copy(SPDesktop *desktop);
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *);
- virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style);
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol);
virtual bool paste(SPDesktop *desktop, bool in_place);
virtual bool pasteStyle(SPDesktop *desktop);
virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y);
@@ -201,7 +201,7 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop)
if ( desktop == NULL ) {
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// Special case for when the gradient dragger is active - copies gradient color
if (desktop->event_context->get_drag()) {
@@ -303,7 +303,7 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam
* Copy a symbol from the symbol dialog.
* @param symbol The Inkscape::XML::Node for the symbol.
*/
-void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style)
+void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol)
{
//std::cout << "ClipboardManagerImpl::copySymbol" << std::endl;
if ( symbol == NULL ) {
@@ -326,17 +326,28 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const*
Glib::ustring id("#");
id += symbol->attribute("id");
+ gdouble scale_units = 1; // scale from "px" to "document-units"
+ Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr();
+ if (nv_repr->attribute("inkscape:document-units"))
+ scale_units = Inkscape::Util::Quantity::convert(1, "px", nv_repr->attribute("inkscape:document-units"));
+ SPObject *cmobj = _clipboardSPDoc->getObjectByRepr(repr);
+ if (cmobj && !user_symbol) { // convert only stock symbols
+ if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
+ dynamic_cast<SPGroup *>(cmobj)->scaleChildItemsRec(Geom::Scale(scale_units),
+ Geom::Point(0, SP_ACTIVE_DESKTOP->getDocument()->getHeight().value("px")),
+ false);
+ }
+ }
+
Inkscape::XML::Node *use = _doc->createElement("svg:use");
use->setAttribute("xlink:href", id.c_str() );
// Set a default style in <use> rather than <symbol> so it can be changed.
use->setAttribute("style", style );
-
- Inkscape::XML::Node *nv_repr = sp_desktop_namedview(inkscape_active_desktop())->getRepr();
- gdouble scale_units = Inkscape::Util::Quantity::convert(1, nv_repr->attribute("inkscape:document-units"), "px");
- gchar *transform_str = sp_svg_transform_write(Geom::Scale(scale_units, scale_units));
- use->setAttribute("transform", transform_str);
- g_free(transform_str);
-
+ if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
+ gchar *transform_str = sp_svg_transform_write(Geom::Scale(1.0/scale_units));
+ use->setAttribute("transform", transform_str);
+ g_free(transform_str);
+ }
_root->appendChild(use);
// This min and max sets offsets, we don't have any so set to zero.
@@ -435,7 +446,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
}
// check whether something is selected
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
_userWarn(desktop, _("Select <b>object(s)</b> to paste style to."));
return false;
@@ -488,7 +499,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
if ( desktop == NULL ) {
return false;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
_userWarn(desktop, _("Select <b>object(s)</b> to paste size to."));
return false;
@@ -551,7 +562,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
return false;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection && selection->isEmpty()) {
_userWarn(desktop, _("Select <b>object(s)</b> to paste live path effect to."));
return false;
@@ -674,10 +685,18 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
sp_repr_css_set(obj_copy, css, "style");
sp_repr_css_attr_unref(css);
+ Geom::Affine transform=item->i2doc_affine();
+
// write the complete accumulated transform passed to us
// (we're dealing with unattached representations, so we write to their attributes
// instead of using sp_item_set_transform)
- gchar *transform_str = sp_svg_transform_write(item->i2doc_affine());
+ SPUse *use=dynamic_cast<SPUse *>(item);
+ if( use && selection->includes(use->get_original()) ){//we are copying something whose parent is also copied (!)
+ transform = ((SPItem*)(use->get_original()->parent))->i2doc_affine().inverse() * transform;
+ }
+ gchar *transform_str = sp_svg_transform_write(transform );
+
+
obj_copy->setAttribute("transform", transform_str);
g_free(transform_str);
}
@@ -925,15 +944,18 @@ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc)
}
Inkscape::Extension::Extension *png = *i;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring attr = prefs->getString("/dialogs/import/link");
+ Glib::ustring attr_saved = prefs->getString("/dialogs/import/link");
+ bool ask_saved = prefs->getBool("/dialogs/import/ask");
prefs->setString("/dialogs/import/link", "embed");
+ prefs->setBool("/dialogs/import/ask", false);
png->set_gui(false);
gchar *filename = g_build_filename( g_get_tmp_dir(), "inkscape-clipboard-import", NULL );
img->save(filename, "png");
file_import(doc, filename, png);
g_free(filename);
- prefs->setString("/dialogs/import/link", attr);
+ prefs->setString("/dialogs/import/link", attr_saved);
+ prefs->setBool("/dialogs/import/ask", ask_saved);
png->set_gui(true);
return true;
diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h
index b565740c3..9f3b6cbdb 100644
--- a/src/ui/clipboard.h
+++ b/src/ui/clipboard.h
@@ -44,7 +44,7 @@ class ClipboardManager {
public:
virtual void copy(SPDesktop *desktop) = 0;
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0;
- virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style) = 0;
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol = true) = 0;
virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0;
virtual bool pasteStyle(SPDesktop *desktop) = 0;
virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0;
diff --git a/src/ui/dialog-events.cpp b/src/ui/dialog-events.cpp
index 6bd93bbc3..5bc8088a1 100644
--- a/src/ui/dialog-events.cpp
+++ b/src/ui/dialog-events.cpp
@@ -6,7 +6,7 @@
* bulia byak <bulia@dr.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
- * Copyright (C) 2003-2007 Authors
+ * Copyright (C) 2003-2014 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -25,7 +25,7 @@
#include "macros.h"
#include <gtk/gtk.h>
#include "desktop.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "preferences.h"
#include "ui/tools/tool-base.h"
@@ -183,12 +183,11 @@ void sp_transientize(GtkWidget *dialog)
void on_transientize (SPDesktop *desktop, win_data *wd )
{
- sp_transientize_callback (0, desktop, wd);
+ sp_transientize_callback (desktop, wd);
}
void
-sp_transientize_callback ( InkscapeApplication * /*inkscape*/,
- SPDesktop *desktop, win_data *wd )
+sp_transientize_callback ( SPDesktop *desktop, win_data *wd )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2);
diff --git a/src/ui/dialog-events.h b/src/ui/dialog-events.h
index b33eb3f38..b4a5d7c35 100644
--- a/src/ui/dialog-events.h
+++ b/src/ui/dialog-events.h
@@ -4,7 +4,7 @@
/* Authors:
* bulia byak <bulia@dr.com>
*
- * Copyright (C) 2003 authors
+ * Copyright (C) 2003-2014 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -28,8 +28,6 @@ class Entry;
}
class SPDesktop;
-
-struct InkscapeApplication;
typedef struct {
GtkWidget *win;
@@ -53,14 +51,14 @@ void sp_transientize ( GtkWidget *win );
void on_transientize ( SPDesktop *desktop,
win_data *wd );
-void sp_transientize_callback ( InkscapeApplication *inkscape,
- SPDesktop *desktop,
+void sp_transientize_callback ( SPDesktop *desktop,
win_data *wd );
void on_dialog_hide (GtkWidget *w);
void on_dialog_unhide (GtkWidget *w);
-gboolean sp_dialog_hide (GObject *object, gpointer data);
-gboolean sp_dialog_unhide (GObject *object, gpointer data);
+
+//gboolean sp_dialog_hide (GObject *object, gpointer data);
+//gboolean sp_dialog_unhide (GObject *object, gpointer data);
#endif
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 50b35ca2f..81f48e6ef 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -470,6 +470,7 @@ void AboutBox::initStrings() {
"Arman Aksoy <armish@linux-sevenler.de>, 2003.\n"
"Arpad Biro <biro_arpad@yahoo.com>, 2004, 2005.\n"
"Benedikt Roth <Benedikt.Roth@gmx.net>, 2000.\n"
+"Benjamin Weis <benjamin.weis@gmx.com>, 2014.\n"
"Benno Schulenberg <benno@vertaalt.nl>, 2008.\n"
"Boštjan Špetič <igzebedze@cyberpipe.org>, 2004, 2005.\n"
"Brisa Francesco <fbrisa@yahoo.it>, 2000.\n"
@@ -492,7 +493,7 @@ void AboutBox::initStrings() {
"Elias Norberg <elno0959 at student.su.se>, 2009.\n"
"Equipe de Tradução Inkscape Brasil <www.inkscapebrasil.org>, 2007.\n"
"Fatih Demir <kabalak@gtranslator.org>, 2000.\n"
-"Firas Hanife <FirasHanife@gmail.com>, 2014.\n"
+"Firas Hanife <FirasHanife@gmail.com>, 2014-2015.\n"
"Foppe Benedictus <foppe.benedictus@gmail.com>, 2007-2009.\n"
"Francesc Dorca <f.dorca@filnet.es>, 2003. Traducció sodipodi.\n"
"Francisco Javier F. Serrador <serrador@arrakis.es>, 2003.\n"
@@ -500,6 +501,7 @@ void AboutBox::initStrings() {
"Frederic Rodrigo <f.rodrigo free.fr>, 2004-2005.\n"
"Ge'ez Frontier Foundation <locales@geez.org>, 2002.\n"
"George Boukeas <boukeas@gmail.com>, 2011.\n"
+"Heiko Wöhrle <mail@heikowoehrle.de>, 2014.\n"
"Hleb Valoshka <375gnu@gmail.com>, 2008-2009.\n"
"Hizkuntza Politikarako Sailburuordetza <hizkpol@ej-gv.es>, 2005.\n"
"Ilia Penev <lichopicho@gmail.com>, 2006.\n"
@@ -564,7 +566,7 @@ void AboutBox::initStrings() {
"Stefan Graubner <pflaumenmus92@gmx.net>, 2005.\n"
"Supranee Thirawatthanasuk <supranee@opentle.org>, 2006.\n"
"Takeshi Aihana <aihana@muc.biglobe.ne.jp>, 2000, 2001.\n"
-"Tim Sheridan <tim.sheridan@gmail.com>, 2007-2011.\n"
+"Tim Sheridan <tghs@tghs.net>, 2007-2014.\n"
"Theppitak Karoonboonyanan <thep@linux.thai.net>, 2006.\n"
"Thiago Pimentel <thiago.merces@gmail.com>, 2006.\n"
"Toshifumi Sato <sato@centrosystem.com>, 2005.\n"
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 431da7ad1..65bc94011 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -24,7 +24,7 @@
#include "align-and-distribute.h"
#include <2geom/transforms.h>
#include "ui/widget/spinbutton.h"
-#include "desktop-handles.h"
+
#include "unclump.h"
#include "document.h"
#include "enums.h"
@@ -91,7 +91,7 @@ Action::Action(const Glib::ustring &id,
void ActionAlign::do_action(SPDesktop *desktop, int index)
{
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -123,10 +123,10 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
focus = selection->smallestItem(horiz);
break;
case PAGE:
- b = sp_desktop_document(desktop)->preferredBounds();
+ b = desktop->getDocument()->preferredBounds();
break;
case DRAWING:
- b = sp_desktop_document(desktop)->getRoot()->desktopPreferredBounds();
+ b = desktop->getDocument()->getRoot()->desktopPreferredBounds();
break;
case SELECTION:
b = selection->preferredBounds();
@@ -152,7 +152,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
for (std::list<SPItem *>::iterator it(selected.begin());
it != selected.end(); ++it)
{
- sp_desktop_document (desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
if (!sel_as_group)
b = (*it)->desktopPreferredBounds();
if (b && (!focus || (*it) != focus)) {
@@ -167,7 +167,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
}
if (changed) {
- DocumentUndo::done( sp_desktop_document(desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done( desktop->getDocument() , SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Align"));
}
}
@@ -247,7 +247,7 @@ private :
SPDesktop *desktop = _dialog.getDesktop();
if (!desktop) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
@@ -337,7 +337,7 @@ private :
prefs->setInt("/options/clonecompensation/value", saved_compensation);
if (changed) {
- DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done( desktop->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Distribute"));
}
}
@@ -458,13 +458,12 @@ private :
// xGap and yGap are the minimum space required between bounding rectangles.
double const xGap = removeOverlapXGap.get_value();
double const yGap = removeOverlapYGap.get_value();
- removeoverlap(sp_desktop_selection(_dialog.getDesktop())->itemList(),
- xGap, yGap);
+ removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(_dialog.getDesktop()->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Remove overlaps"));
}
};
@@ -490,12 +489,12 @@ private :
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- graphlayout(sp_desktop_selection(_dialog.getDesktop())->itemList());
+ graphlayout(_dialog.getDesktop()->getSelection()->itemList());
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(_dialog.getDesktop()->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Arrange connector network"));
}
};
@@ -547,7 +546,7 @@ private :
SPDesktop *desktop = _dialog.getDesktop();
if (!desktop) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
@@ -588,7 +587,7 @@ private :
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(_dialog.getDesktop()->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Exchange Positions"));
}
};
@@ -617,12 +616,12 @@ private :
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- unclump ((GSList *) sp_desktop_selection(_dialog.getDesktop())->itemList());
+ unclump ((GSList *) _dialog.getDesktop()->getSelection()->itemList());
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(_dialog.getDesktop()->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Unclump"));
}
};
@@ -644,7 +643,7 @@ private :
SPDesktop *desktop = _dialog.getDesktop();
if (!desktop) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
@@ -677,7 +676,7 @@ private :
it != selected.end();
++it)
{
- sp_desktop_document (desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
Geom::OptRect item_box = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds();
if (item_box) {
// find new center, staying within bbox
@@ -694,7 +693,7 @@ private :
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Randomize positions"));
}
};
@@ -743,7 +742,7 @@ private :
SPDesktop *desktop = _dialog.getDesktop();
if (!desktop) return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
using Inkscape::Util::GSListConstIterator;
@@ -797,7 +796,7 @@ private :
}
if (changed) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Distribute text baselines"));
}
@@ -820,7 +819,7 @@ private :
}
if (changed) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Align text baselines"));
}
}
@@ -829,14 +828,14 @@ private :
-static void on_tool_changed(InkscapeApplication */*inkscape*/, Inkscape::UI::Tools::ToolBase */*context*/, AlignAndDistribute *daad)
+static void on_tool_changed(AlignAndDistribute *daad)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop && desktop->getEventContext())
daad->setMode(tools_active(desktop) == TOOLS_NODES);
}
-static void on_selection_changed(InkscapeApplication */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad)
+static void on_selection_changed(AlignAndDistribute *daad)
{
daad->randomize_bbox = Geom::OptRect();
}
@@ -1044,10 +1043,10 @@ AlignAndDistribute::AlignAndDistribute()
contents->pack_start(_nodesFrame, true, true);
//Connect to the global tool change signal
- g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this);
+ _toolChangeConn = INKSCAPE.signal_eventcontext_set.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_tool_changed), this)));
// Connect to the global selection change, to invalidate cached randomize_bbox
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
+ _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::bind(sigc::ptr_fun(&on_selection_changed), this)));
randomize_bbox = Geom::OptRect();
_desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) );
@@ -1055,18 +1054,18 @@ AlignAndDistribute::AlignAndDistribute()
show_all_children();
- on_tool_changed (NULL, NULL, this); // set current mode
+ on_tool_changed (this); // set current mode
}
AlignAndDistribute::~AlignAndDistribute()
{
- sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
-
for (std::list<Action *>::iterator it = _actionList.begin();
it != _actionList.end(); ++it) {
delete *it;
}
+ _toolChangeConn.disconnect();
+ _selChangeConn.disconnect();
_desktopChangeConn.disconnect();
_deskTrack.disconnect();
}
@@ -1075,7 +1074,7 @@ void AlignAndDistribute::setTargetDesktop(SPDesktop *desktop)
{
if (_desktop != desktop) {
_desktop = desktop;
- on_tool_changed (NULL, NULL, this);
+ on_tool_changed (this);
}
}
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index dfd84535b..eecc30ff8 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -127,7 +127,8 @@ protected:
SPDesktop *_desktop;
DesktopTracker _deskTrack;
sigc::connection _desktopChangeConn;
-
+ sigc::connection _toolChangeConn;
+ sigc::connection _selChangeConn;
private:
AlignAndDistribute(AlignAndDistribute const &d);
AlignAndDistribute& operator=(AlignAndDistribute const &d);
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 7a776a9b8..bd3ad0254 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -27,7 +27,7 @@
#include <gtkmm/adjustment.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/cairo-utils.h"
#include "display/drawing.h"
#include "display/drawing-context.h"
@@ -76,15 +76,12 @@ static gdouble trace_zoom;
static SPDocument *trace_doc = NULL;
-CloneTiler::CloneTiler (void) :
+CloneTiler::CloneTiler () :
UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER),
dlg(NULL),
desktop(NULL),
deskTrack(),
- table_row_labels(NULL),
- selectChangedConn(),
- subselChangedConn(),
- selectModifiedConn()
+ table_row_labels(NULL)
{
Gtk::Box *contents = _getContents();
contents->set_spacing(0);
@@ -1096,7 +1093,7 @@ CloneTiler::CloneTiler (void) :
// unitmenu
unit_menu = new Inkscape::UI::Widget::UnitMenu();
unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR);
- unit_menu->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->display_units->abbr);
+ unit_menu->setUnit(SP_ACTIVE_DESKTOP->getNamedView()->display_units->abbr);
unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed));
{
@@ -1273,12 +1270,13 @@ CloneTiler::CloneTiler (void) :
// connect to global selection changed signal (so we can change desktops) and
// external_change (so we're not fooled by undo)
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
- g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
- g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
+ selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg));
+ externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg));
+
+ g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this);
// update now
- clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
+ clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg);
}
{
@@ -1350,7 +1348,7 @@ void CloneTiler::on_picker_color_changed(guint rgba)
is_updating = false;
}
-void CloneTiler::clonetiler_change_selection(InkscapeApplication * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
+void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg)
{
GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles"));
GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status"));
@@ -1379,16 +1377,18 @@ void CloneTiler::clonetiler_change_selection(InkscapeApplication * /*inkscape*/,
}
}
-void CloneTiler::clonetiler_external_change(InkscapeApplication * /*inkscape*/, GtkWidget *dlg)
+void CloneTiler::clonetiler_external_change(GtkWidget *dlg)
{
- clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
+ clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg);
}
-void CloneTiler::clonetiler_disconnect_gsignal(GObject *widget, gpointer source)
+void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source)
{
- if (source && G_IS_OBJECT(source)) {
- sp_signal_disconnect_by_data (source, widget);
- }
+ g_return_if_fail(source != NULL);
+
+ CloneTiler* dlg = reinterpret_cast<CloneTiler*>(source);
+ dlg->selectChangedConn.disconnect();
+ dlg->externChangedConn.disconnect();
}
Geom::Affine CloneTiler::clonetiler_get_transform(
@@ -2093,11 +2093,11 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
- sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
+ desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
return;
}
@@ -2112,13 +2112,13 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
}
}
- sp_desktop_document(desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
unclump (to_unclump);
g_slist_free (to_unclump);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
_("Unclump tiled clones"));
}
@@ -2144,11 +2144,11 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
- sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
+ desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
@@ -2169,10 +2169,10 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
}
g_slist_free (to_delete);
- clonetiler_change_selection (NULL, selection, dlg);
+ clonetiler_change_selection (selection, dlg);
if (do_undo) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
_("Delete tiled clones"));
}
}
@@ -2216,17 +2216,17 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
return;
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
if (selection->isEmpty()) {
- sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
+ desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
return;
}
// Check if more than one object is selected.
if (g_slist_length((GSList *) selection->itemList()) > 1) {
- sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
+ desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
return;
}
@@ -2251,7 +2251,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
clonetiler_remove (NULL, dlg, false);
- double scale_units = Inkscape::Util::Quantity::convert(1, "px", &sp_desktop_document(desktop)->getSVGUnit());
+ double scale_units = Inkscape::Util::Quantity::convert(1, "px", &desktop->getDocument()->getSVGUnit());
double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000);
double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000);
@@ -2337,7 +2337,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
SPItem *item = dynamic_cast<SPItem *>(obj);
if (dotrace) {
- clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, item);
+ clonetiler_trace_setup (desktop->getDocument(), 1.0, item);
}
Geom::Point center;
@@ -2409,7 +2409,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
// Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
// Get transform from symmetry, shift, scale, rotation
- Geom::Affine t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h,
+ Geom::Affine orig_t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h,
shiftx_per_i, shifty_per_i,
shiftx_per_j, shifty_per_j,
shiftx_rand, shifty_rand,
@@ -2428,7 +2428,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
rotate_rand,
rotate_alternatei, rotate_alternatej,
rotate_cumulatei, rotate_cumulatej );
-
+ Geom::Affine parent_transform = (((SPItem*)item->parent)->i2doc_affine())*(item->document->getRoot()->c2p.inverse());
+ Geom::Affine t = parent_transform*orig_t*parent_transform.inverse();
cur = center * t - center;
if (fillrect) {
if ((cur[Geom::X] > fillwidth) || (cur[Geom::Y] > fillheight)) { // off limits
@@ -2562,7 +2563,9 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
}
}
if (pick_to_size) {
- t = Geom::Translate(-center[Geom::X], -center[Geom::Y]) * Geom::Scale (val, val) * Geom::Translate(center[Geom::X], center[Geom::Y]) * t;
+ t = parent_transform * Geom::Translate(-center[Geom::X], -center[Geom::Y])
+ * Geom::Scale (val, val) * Geom::Translate(center[Geom::X], center[Geom::Y])
+ * parent_transform.inverse() * t;
}
if (pick_to_opacity) {
opacity *= val;
@@ -2590,7 +2593,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
Geom::Point new_center;
bool center_set = false;
if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) {
- new_center = scale_units*desktop->dt2doc(item->getCenter()) * t;
+ new_center = scale_units*desktop->dt2doc(item->getCenter()) * orig_t;
center_set = true;
}
@@ -2611,21 +2614,21 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
parent->getRepr()->appendChild(clone);
if (blur > 0.0) {
- SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
+ SPObject *clone_object = desktop->getDocument()->getObjectByRepr(clone);
double perimeter = perimeter_original * t.descrim();
double radius = blur * perimeter;
// this is necessary for all newly added clones to have correct bboxes,
// otherwise filters won't work:
- sp_desktop_document(desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
// it's hard to figure out exact width/height of the tile without having an object
// that we can take bbox of; however here we only need a lower bound so that blur
// margins are not too small, and the perimeter should work
- SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.descrim(), t.expansionX(), t.expansionY(), perimeter, perimeter);
+ SPFilter *constructed = new_filter_gaussian_blur(desktop->getDocument(), radius, t.descrim(), t.expansionX(), t.expansionY(), perimeter, perimeter);
sp_style_set_property_url (clone_object, "filter", constructed, false);
}
if (center_set) {
- SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
+ SPObject *clone_object = desktop->getDocument()->getObjectByRepr(clone);
SPItem *item = dynamic_cast<SPItem *>(clone_object);
if (clone_object && item) {
clone_object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -2643,11 +2646,11 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
clonetiler_trace_finish ();
}
- clonetiler_change_selection (NULL, selection, dlg);
+ clonetiler_change_selection (selection, dlg);
desktop->clearWaitingCursor();
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
_("Create tiled clones"));
}
diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h
index 70da86338..e5f5638b2 100644
--- a/src/ui/dialog/clonetiler.h
+++ b/src/ui/dialog/clonetiler.h
@@ -57,8 +57,8 @@ protected:
static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/);
static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg);
static void clonetiler_unclump(GtkWidget */*widget*/, void *);
- static void clonetiler_change_selection(InkscapeApplication * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg);
- static void clonetiler_external_change(InkscapeApplication * /*inkscape*/, GtkWidget *dlg);
+ static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg);
+ static void clonetiler_external_change(GtkWidget *dlg);
static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source);
static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg);
static guint clonetiler_number_of_clones(SPObject *obj);
@@ -129,6 +129,7 @@ private:
sigc::connection desktopChangeConn;
sigc::connection selectChangedConn;
+ sigc::connection externChangedConn;
sigc::connection subselChangedConn;
sigc::connection selectModifiedConn;
sigc::connection color_changed_connection;
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
index bab7e18e1..a49a47d5c 100644
--- a/src/ui/dialog/color-item.cpp
+++ b/src/ui/dialog/color-item.cpp
@@ -29,7 +29,7 @@
#include "color-item.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "display/cairo-utils.h"
#include "document.h"
@@ -476,7 +476,7 @@ void ColorItem::_updatePreviews()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if ( desktop ) {
- SPDocument* document = sp_desktop_document( desktop );
+ SPDocument* document = desktop->getDocument();
Inkscape::XML::Node *rroot = document->getReprRoot();
if ( rroot ) {
@@ -706,7 +706,7 @@ void ColorItem::buttonClicked(bool secondary)
sp_desktop_set_style(desktop, css);
sp_repr_css_attr_unref(css);
- DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() );
+ DocumentUndo::done( desktop->getDocument(), SP_VERB_DIALOG_SWATCHES, descr.c_str() );
}
}
diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp
index 3ed998252..0659de67b 100644
--- a/src/ui/dialog/desktop-tracker.cpp
+++ b/src/ui/dialog/desktop-tracker.cpp
@@ -22,7 +22,6 @@ DesktopTracker::DesktopTracker() :
desktop(0),
widget(0),
hierID(0),
- inkID(0),
trackActive(false),
desktopChangedSig()
{
@@ -41,7 +40,10 @@ void DesktopTracker::connect(GtkWidget *widget)
// Use C/gobject callbacks to avoid gtkmm rewrap-during-destruct issues:
hierID = g_signal_connect( G_OBJECT(widget), "hierarchy-changed", G_CALLBACK(hierarchyChangeCB), this );
- inkID = g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(activateDesktopCB), this );
+ inkID = INKSCAPE.signal_activate_desktop.connect(
+ sigc::bind(
+ sigc::ptr_fun(&DesktopTracker::activateDesktopCB), this)
+ );
GtkWidget *wdgt = gtk_widget_get_ancestor(widget, SP_TYPE_DESKTOP_WIDGET);
if (wdgt && !base) {
@@ -60,11 +62,8 @@ void DesktopTracker::disconnect()
}
hierID = 0;
}
- if (inkID) {
- if (INKSCAPE) {
- g_signal_handler_disconnect(G_OBJECT(INKSCAPE), inkID);
- }
- inkID = 0;
+ if (inkID.connected()) {
+ inkID.disconnect();
}
}
@@ -94,12 +93,12 @@ sigc::connection DesktopTracker::connectDesktopChanged( const sigc::slot<void, S
return desktopChangedSig.connect(slot);
}
-gboolean DesktopTracker::activateDesktopCB(InkscapeApplication */*inkscape*/, SPDesktop *desktop, DesktopTracker *self )
+void DesktopTracker::activateDesktopCB(SPDesktop *desktop, DesktopTracker *self )
{
if (self && self->trackActive) {
self->setDesktop(desktop);
}
- return FALSE;
+ //return FALSE;
}
bool DesktopTracker::hierarchyChangeCB(GtkWidget * /*widget*/, GtkWidget* /*prev*/, DesktopTracker *self)
diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h
index 7b944ddfa..8cb205a35 100644
--- a/src/ui/dialog/desktop-tracker.h
+++ b/src/ui/dialog/desktop-tracker.h
@@ -36,7 +36,7 @@ public:
sigc::connection connectDesktopChanged( const sigc::slot<void, SPDesktop*> & slot );
private:
- static gboolean activateDesktopCB(InkscapeApplication *inkscape, SPDesktop *desktop, DesktopTracker *self );
+ static void activateDesktopCB(SPDesktop *desktop, DesktopTracker *self );
static bool hierarchyChangeCB(GtkWidget *widget, GtkWidget* prev, DesktopTracker *self);
void handleHierarchyChange();
@@ -46,7 +46,7 @@ private:
SPDesktop *desktop;
GtkWidget *widget;
gulong hierID;
- gulong inkID;
+ sigc::connection inkID;
bool trackActive;
sigc::signal<void, SPDesktop*> desktopChangedSig;
};
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 213965a18..27d88bae7 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -25,7 +25,7 @@
#include "inkscape.h"
#include "ui/tools/tool-base.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "shortcuts.h"
#include "preferences.h"
#include "ui/interface.h"
@@ -41,12 +41,6 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-void sp_retransientize(InkscapeApplication */*inkscape*/, SPDesktop *desktop, gpointer dlgPtr)
-{
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onDesktopActivated (desktop);
-}
-
gboolean sp_retransientize_again(gpointer dlgPtr)
{
Dialog *dlg = static_cast<Dialog *>(dlgPtr);
@@ -54,30 +48,6 @@ gboolean sp_retransientize_again(gpointer dlgPtr)
return FALSE; // so that it is only called once
}
-void sp_dialog_shutdown(GObject * /*object*/, gpointer dlgPtr)
-{
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onShutdown();
-}
-
-
-static void hideCallback(GObject * /*object*/, gpointer dlgPtr)
-{
- g_return_if_fail( dlgPtr != NULL );
-
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onHideF12();
-}
-
-static void unhideCallback(GObject * /*object*/, gpointer dlgPtr)
-{
- g_return_if_fail( dlgPtr != NULL );
-
- Dialog *dlg = static_cast<Dialog *>(dlgPtr);
- dlg->onShowF12();
-}
-
-
//=====================================================================
Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path, int verb_num,
@@ -103,10 +73,10 @@ Dialog::Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_pat
_behavior = behavior_factory(*this);
_desktop = SP_ACTIVE_DESKTOP;
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_retransientize), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_dialog_shutdown), (void *)this);
+ INKSCAPE.signal_activate_desktop.connect(sigc::mem_fun(*this, &Dialog::onDesktopActivated));
+ INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dialog::onHideF12));
+ INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dialog::onShowF12));
+ INKSCAPE.signal_shut_down.connect(sigc::mem_fun(*this, &Dialog::onShutdown));
Glib::wrap(gobj())->signal_event().connect(sigc::mem_fun(*this, &Dialog::_onEvent));
Glib::wrap(gobj())->signal_key_press_event().connect(sigc::mem_fun(*this, &Dialog::_onKeyPress));
@@ -340,7 +310,7 @@ void Dialog::_defocus()
Inkscape::Selection*
Dialog::_getSelection()
{
- return sp_desktop_selection(SP_ACTIVE_DESKTOP);
+ return SP_ACTIVE_DESKTOP->getSelection();
}
} // namespace Dialog
diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h
index ccff43a56..9c7efd47b 100644
--- a/src/ui/dialog/dialog.h
+++ b/src/ui/dialog/dialog.h
@@ -30,7 +30,6 @@ namespace Dialog {
enum BehaviorType { FLOATING, DOCK };
-void sp_retransientize(InkscapeApplication *inkscape, SPDesktop *desktop, gpointer dlgPtr);
gboolean sp_retransientize_again(gpointer dlgPtr);
void sp_dialog_shutdown(GObject *object, gpointer dlgPtr);
diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp
index 77ea175d9..da1facc08 100644
--- a/src/ui/dialog/document-metadata.cpp
+++ b/src/ui/dialog/document-metadata.cpp
@@ -20,7 +20,7 @@
#include "document-metadata.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "inkscape.h"
#include "rdf.h"
#include "sp-namedview.h"
@@ -100,7 +100,7 @@ DocumentMetadata::init()
{
update();
- Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr();
repr->addListener (&_repr_events, this);
show_all_children();
@@ -108,7 +108,7 @@ DocumentMetadata::init()
DocumentMetadata::~DocumentMetadata()
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr();
repr->removeListenerByData (this);
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it)
@@ -217,23 +217,23 @@ void DocumentMetadata::update()
void
DocumentMetadata::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->addListener (&_repr_events, this);
update();
}
void
-DocumentMetadata::_handleActivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+DocumentMetadata::_handleActivateDesktop(SPDesktop *desktop)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->addListener(&_repr_events, this);
update();
}
void
-DocumentMetadata::_handleDeactivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+DocumentMetadata::_handleDeactivateDesktop(SPDesktop *desktop)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->removeListenerByData(this);
}
diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h
index 77084bc3d..cde5d92fd 100644
--- a/src/ui/dialog/document-metadata.h
+++ b/src/ui/dialog/document-metadata.h
@@ -28,6 +28,7 @@
# include <gtkmm/table.h>
#endif
+#include "inkscape.h"
#include "ui/widget/licensor.h"
#include "ui/widget/registry.h"
@@ -56,8 +57,8 @@ protected:
void init();
void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- void _handleActivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
- void _handleDeactivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
+ void _handleActivateDesktop(SPDesktop *desktop);
+ void _handleDeactivateDesktop(SPDesktop *desktop);
Gtk::Notebook _notebook;
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index f7701655c..c381ed755 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -26,7 +26,7 @@
#include "document-properties.h"
#include "display/canvas-grid.h"
#include "document.h"
-#include "desktop-handles.h"
+
#include "desktop.h"
#include "inkscape.h"
#include "io/sys.h"
@@ -87,6 +87,13 @@ static Inkscape::XML::NodeEventVector const _repr_events = {
NULL // order_changed
};
+static void docprops_style_button(Gtk::Button& btn, char const* iconName)
+{
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show( child );
+ btn.add(*Gtk::manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
+}
DocumentProperties& DocumentProperties::getInstance()
{
@@ -186,9 +193,9 @@ void DocumentProperties::init()
{
update();
- Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr();
repr->addListener (&_repr_events, this);
- Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr();
+ Inkscape::XML::Node *root = getDesktop()->getDocument()->getRoot()->getRepr();
root->addListener (&_repr_events, this);
show_all_children();
@@ -197,9 +204,9 @@ void DocumentProperties::init()
DocumentProperties::~DocumentProperties()
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr();
repr->removeListenerByData (this);
- Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr();
+ Inkscape::XML::Node *root = getDesktop()->getDocument()->getRoot()->getRepr();
root->removeListenerByData (this);
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it)
@@ -615,22 +622,10 @@ void DocumentProperties::build_cms()
label_avail->set_markup (_("<b>Available Color Profiles:</b>"));
_link_btn.set_tooltip_text(_("Link Profile"));
-#if WITH_GTKMM_3_10
- _link_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_link = Gtk::manage(new Gtk::Image());
- image_link->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _link_btn.set_image(*image_link);
-#endif
+ docprops_style_button(_link_btn, INKSCAPE_ICON("list-add"));
_unlink_btn.set_tooltip_text(_("Unlink Profile"));
-#if WITH_GTKMM_3_10
- _unlink_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_unlink = Gtk::manage(new Gtk::Image());
- image_unlink->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _unlink_btn.set_image(*image_unlink);
-#endif
+ docprops_style_button(_unlink_btn, INKSCAPE_ICON("list-remove"));
_page_cms->set_spacing(4);
gint row = 0;
@@ -752,22 +747,10 @@ void DocumentProperties::build_scripting()
label_external->set_markup (_("<b>External script files:</b>"));
_external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file"));
-#if WITH_GTKMM_3_10
- _external_add_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_ext_add = Gtk::manage(new Gtk::Image());
- image_ext_add->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _external_add_btn.set_image(*image_ext_add);
-#endif
+ docprops_style_button(_external_add_btn, INKSCAPE_ICON("list-add"));
_external_remove_btn.set_tooltip_text(_("Remove"));
-#if WITH_GTKMM_3_10
- _external_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_ext_rm = Gtk::manage(new Gtk::Image());
- image_ext_rm->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _external_remove_btn.set_image(*image_ext_rm);
-#endif
+ docprops_style_button(_external_remove_btn, INKSCAPE_ICON("list-remove"));
_page_external_scripts->set_spacing(4);
gint row = 0;
@@ -841,22 +824,10 @@ void DocumentProperties::build_scripting()
label_embedded->set_markup (_("<b>Embedded script files:</b>"));
_embed_new_btn.set_tooltip_text(_("New"));
-#if WITH_GTKMM_3_10
- _embed_new_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_embed_new = Gtk::manage(new Gtk::Image());
- image_embed_new->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _embed_new_btn.set_image(*image_embed_new);
-#endif
+ docprops_style_button(_embed_new_btn, INKSCAPE_ICON("list-add"));
_embed_remove_btn.set_tooltip_text(_("Remove"));
-#if WITH_GTKMM_3_10
- _embed_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_embed_rm = Gtk::manage(new Gtk::Image());
- image_embed_rm->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- _embed_remove_btn.set_image(*image_embed_rm);
-#endif
+ docprops_style_button(_embed_remove_btn, INKSCAPE_ICON("list-remove"));
#if !WITH_GTKMM_3_0
// TODO: This has been removed from Gtkmm 3.0. Check that
@@ -1384,7 +1355,7 @@ void DocumentProperties::populate_script_lists(){
void DocumentProperties::update_gridspage()
{
SPDesktop *dt = getDesktop();
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
//remove all tabs
while (_grids_notebook.get_n_pages() != 0) {
@@ -1428,7 +1399,7 @@ void DocumentProperties::build_gridspage()
/// Dissenting view: you want snapping without grid.
SPDesktop *dt = getDesktop();
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
(void)nv;
_grids_label_crea.set_markup(_("<b>Creation</b>"));
@@ -1464,7 +1435,7 @@ void DocumentProperties::update()
if (_wr.isUpdating()) return;
SPDesktop *dt = getDesktop();
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
_wr.setUpdating (true);
set_sensitive (true);
@@ -1484,24 +1455,25 @@ void DocumentProperties::update()
_rum_deflt.setUnit (nv->display_units->abbr);
}
- double doc_w = sp_desktop_document(dt)->getRoot()->width.value;
- Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr;
+ double doc_w = dt->getDocument()->getRoot()->width.value;
+ Glib::ustring doc_w_unit = unit_table.getUnit(dt->getDocument()->getRoot()->width.unit)->abbr;
if (doc_w_unit == "") {
doc_w_unit = "px";
- } else if (doc_w_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) {
+ } else if (doc_w_unit == "%" && dt->getDocument()->getRoot()->viewBox_set) {
doc_w_unit = "px";
- doc_w = sp_desktop_document(dt)->getRoot()->viewBox.width();
+ doc_w = dt->getDocument()->getRoot()->viewBox.width();
}
- double doc_h = sp_desktop_document(dt)->getRoot()->height.value;
- Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit)->abbr;
+ double doc_h = dt->getDocument()->getRoot()->height.value;
+ Glib::ustring doc_h_unit = unit_table.getUnit(dt->getDocument()->getRoot()->height.unit)->abbr;
if (doc_h_unit == "") {
doc_h_unit = "px";
- } else if (doc_h_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) {
+ } else if (doc_h_unit == "%" && dt->getDocument()->getRoot()->viewBox_set) {
doc_h_unit = "px";
- doc_h = sp_desktop_document(dt)->getRoot()->viewBox.height();
+ doc_h = dt->getDocument()->getRoot()->viewBox.height();
}
_page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit));
_page_sizer.updateFitMarginsUI(nv->getRepr());
+ _page_sizer.updateScaleUI();
//-----------------------------------------------------------guide page
@@ -1592,27 +1564,27 @@ void DocumentProperties::save_default_metadata()
void DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->addListener(&_repr_events, this);
Inkscape::XML::Node *root = document->getRoot()->getRepr();
root->addListener(&_repr_events, this);
update();
}
-void DocumentProperties::_handleActivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+void DocumentProperties::_handleActivateDesktop(SPDesktop *desktop)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->addListener(&_repr_events, this);
- Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr();
+ Inkscape::XML::Node *root = desktop->getDocument()->getRoot()->getRepr();
root->addListener(&_repr_events, this);
update();
}
-void DocumentProperties::_handleDeactivateDesktop(InkscapeApplication *, SPDesktop *desktop)
+void DocumentProperties::_handleDeactivateDesktop(SPDesktop *desktop)
{
- Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr();
+ Inkscape::XML::Node *repr = desktop->getNamedView()->getRepr();
repr->removeListenerByData(this);
- Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr();
+ Inkscape::XML::Node *root = desktop->getDocument()->getRoot()->getRepr();
root->removeListenerByData(this);
}
@@ -1647,8 +1619,8 @@ static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar con
void DocumentProperties::onNewGrid()
{
SPDesktop *dt = getDesktop();
- Inkscape::XML::Node *repr = sp_desktop_namedview(dt)->getRepr();
- SPDocument *doc = sp_desktop_document(dt);
+ Inkscape::XML::Node *repr = dt->getNamedView()->getRepr();
+ SPDocument *doc = dt->getDocument();
Glib::ustring typestring = _grids_combo_gridtype.get_active_text();
CanvasGrid::writeNewGridToRepr(repr, doc, CanvasGrid::getGridTypeFromName(typestring.c_str()));
@@ -1665,7 +1637,7 @@ void DocumentProperties::onRemoveGrid()
return;
SPDesktop *dt = getDesktop();
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
Inkscape::CanvasGrid * found_grid = NULL;
int i = 0;
for (GSList const * l = nv->grids; l != NULL; l = l->next, i++) { // not a very nice fix, but works.
@@ -1679,11 +1651,13 @@ void DocumentProperties::onRemoveGrid()
// delete the grid that corresponds with the selected tab
// when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer!
found_grid->repr->parent()->removeChild(found_grid->repr);
- DocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid"));
+ DocumentUndo::done(dt->getDocument(), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid"));
}
}
/** Callback for document unit change. */
+/* This should not effect anything in the SVG tree (other than "inkscape:document-units").
+ This should only effect values displayed in the GUI. */
void DocumentProperties::onDocUnitChange()
{
SPDocument *doc = SP_ACTIVE_DOCUMENT;
@@ -1697,7 +1671,7 @@ void DocumentProperties::onDocUnitChange()
}
- Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
+ Inkscape::XML::Node *repr = getDesktop()->getNamedView()->getRepr();
Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px");
if(repr->attribute("inkscape:document-units")) {
old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units"));
@@ -1709,6 +1683,8 @@ void DocumentProperties::onDocUnitChange()
os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
+ _page_sizer.updateScaleUI();
+
// Disable changing of SVG Units. The intent here is to change the units in the UI, not the units in SVG.
// This code should be moved (and fixed) once we have an "SVG Units" setting that sets what units are used in SVG data.
#if 0
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index ee7e88b18..b1f90b4b7 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -94,8 +94,8 @@ protected:
void save_default_metadata();
void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- void _handleActivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
- void _handleDeactivateDesktop(InkscapeApplication *application, SPDesktop *desktop);
+ void _handleActivateDesktop(SPDesktop *desktop);
+ void _handleDeactivateDesktop(SPDesktop *desktop);
Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer;
Gtk::Notebook _notebook;
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 37022a186..6d90c792e 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -51,10 +51,10 @@
#include "ui/widget/unit-menu.h"
#include "util/units.h"
#include "helper/window.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "document.h"
#include "document-undo.h"
-#include "desktop-handles.h"
+
#include "sp-item.h"
#include "selection.h"
#include "file.h"
@@ -101,7 +101,6 @@
#define EXPORT_COORD_PRECISION 3
-#include "../../desktop-handles.h"
#include "../../document.h"
#include "../../document-undo.h"
#include "verbs.h"
@@ -206,7 +205,7 @@ Export::Export (void) :
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop) {
- unit_selector.setUnit(sp_desktop_namedview(desktop)->display_units->abbr);
+ unit_selector.setUnit(desktop->getNamedView()->display_units->abbr);
}
unitChangedConn = unit_selector.signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged));
unitbox.pack_end(unit_selector, false, false, 0);
@@ -588,7 +587,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust
}
if (directory.empty()) {
- directory = homedir_path(NULL);
+ directory = INKSCAPE.homedir_path(NULL);
}
Glib::ustring filename = Glib::build_filename(directory, id+".png");
@@ -606,7 +605,7 @@ void Export::onBatchClicked ()
void Export::updateCheckbuttons ()
{
- gint num = g_slist_length((GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList());
+ gint num = g_slist_length((GSList *) SP_ACTIVE_DESKTOP->getSelection()->itemList());
if (num >= 2) {
batch_export.set_sensitive(true);
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
@@ -622,7 +621,7 @@ inline void Export::findDefaultSelection()
{
selection_type key = SELECTION_NUMBER_OF;
- if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
+ if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
key = SELECTION_SELECTION;
}
@@ -660,15 +659,15 @@ inline void Export::findDefaultSelection()
*/
void Export::onSelectionChanged()
{
- Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
if ((current_key == SELECTION_DRAWING || current_key == SELECTION_PAGE) &&
- (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false &&
+ (SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false &&
was_empty) {
current_key = SELECTION_SELECTION;
selectiontype_buttons[current_key]->set_active(true);
}
- was_empty = (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty();
+ was_empty = (SP_ACTIVE_DESKTOP->getSelection())->isEmpty();
if ( selection &&
SELECTION_CUSTOM != current_key) {
@@ -685,7 +684,7 @@ void Export::onSelectionModified ( guint /*flags*/ )
case SELECTION_DRAWING:
if ( SP_ACTIVE_DESKTOP ) {
SPDocument *doc;
- doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
+ doc = SP_ACTIVE_DESKTOP->getDocument();
Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds();
if (bbox) {
setArea ( bbox->left(),
@@ -696,7 +695,7 @@ void Export::onSelectionModified ( guint /*flags*/ )
}
break;
case SELECTION_SELECTION:
- Sel = sp_desktop_selection(SP_ACTIVE_DESKTOP);
+ Sel = SP_ACTIVE_DESKTOP->getSelection();
if (Sel->isEmpty() == false) {
Geom::OptRect bbox = Sel->visualBounds();
if (bbox)
@@ -736,16 +735,16 @@ void Export::onAreaToggled ()
SPDocument *doc;
Geom::OptRect bbox;
bbox = Geom::Rect(Geom::Point(0.0, 0.0),Geom::Point(0.0, 0.0));
- doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
+ doc = SP_ACTIVE_DESKTOP->getDocument();
/* Notice how the switch is used to 'fall through' here to get
various backups. If you modify this without noticing you'll
probabaly screw something up. */
switch (key) {
case SELECTION_SELECTION:
- if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
+ if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false)
{
- bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds();
+ bbox = SP_ACTIVE_DESKTOP->getSelection()->visualBounds();
/* Only if there is a selection that we can set
do we break, otherwise we fall through to the
drawing */
@@ -810,15 +809,15 @@ void Export::onAreaToggled ()
break;
}
case SELECTION_SELECTION:
- if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
+ if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
- sp_selection_get_export_hints (sp_desktop_selection(SP_ACTIVE_DESKTOP), filename, &xdpi, &ydpi);
+ sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi);
/* If we still don't have a filename -- let's build
one that's nice */
if (filename.empty()) {
const gchar * id = "object";
- const GSList * reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
+ const GSList * reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList();
for(; reprlst != NULL; reprlst = reprlst->next) {
Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data;
if (repr->attribute("id")) {
@@ -1002,8 +1001,8 @@ void Export::onExport ()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (!desktop) return;
- SPNamedView *nv = sp_desktop_namedview(desktop);
- SPDocument *doc = sp_desktop_document (desktop);
+ SPNamedView *nv = desktop->getNamedView();
+ SPDocument *doc = desktop->getDocument();
bool exportSuccessful = false;
@@ -1011,7 +1010,7 @@ void Export::onExport ()
if (batch_export.get_active ()) {
// Batch export of selected objects
- gint num = g_slist_length(const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()));
+ gint num = g_slist_length(const_cast<GSList *>(desktop->getSelection()->itemList()));
gint n = 0;
if (num < 1) {
@@ -1025,7 +1024,7 @@ void Export::onExport ()
gint export_count = 0;
- for (GSList *i = const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()); i && !interrupted; i = i->next) {
+ for (GSList *i = const_cast<GSList *>(desktop->getSelection()->itemList()); i && !interrupted; i = i->next) {
SPItem *item = reinterpret_cast<SPItem *>(i->data);
prog_dlg->set_data("current", GINT_TO_POINTER(n));
@@ -1070,7 +1069,7 @@ void Export::onExport ()
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
TRUE, // overwrite without asking
- hide ? const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()) : NULL
+ hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL
)) {
gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
@@ -1154,12 +1153,12 @@ void Export::onExport ()
prog_dlg->set_data("total", GINT_TO_POINTER(0));
/* Do export */
- ExportResult status = sp_export_png_file(sp_desktop_document(desktop), path.c_str(),
+ ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(),
Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
FALSE,
- hide ? const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()) : NULL
+ hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL
);
if (status == EXPORT_ERROR) {
gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
@@ -1231,7 +1230,7 @@ void Export::onExport ()
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false);
- reprlst = sp_desktop_selection(desktop)->reprList();
+ reprlst = desktop->getSelection()->reprList();
for(; reprlst != NULL; reprlst = reprlst->next) {
Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data);
@@ -1463,8 +1462,8 @@ void Export::detectSize() {
i++) {
switch (this_test[i]) {
case SELECTION_SELECTION:
- if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::VISUAL_BBOX);
+ if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
+ Geom::OptRect bbox = (SP_ACTIVE_DESKTOP->getSelection())->bounds(SPItem::VISUAL_BBOX);
if ( bbox && bbox_equal(*bbox,current_bbox)) {
key = SELECTION_SELECTION;
@@ -1472,7 +1471,7 @@ void Export::detectSize() {
}
break;
case SELECTION_DRAWING: {
- SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
+ SPDocument *doc = SP_ACTIVE_DESKTOP->getDocument();
Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds();
@@ -1485,7 +1484,7 @@ void Export::detectSize() {
case SELECTION_PAGE: {
SPDocument *doc;
- doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
+ doc = SP_ACTIVE_DESKTOP->getDocument();
Geom::Point x(0.0, 0.0);
Geom::Point y(doc->getWidth().value("px"),
diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp
index 00ed09551..4e4b0278a 100644
--- a/src/ui/dialog/filedialog.cpp
+++ b/src/ui/dialog/filedialog.cpp
@@ -19,7 +19,7 @@
#include "filedialogimpl-gtkmm.h"
#include "filedialog.h"
-#include "gc-core.h"
+#include "inkgc/gc-core.h"
#include "ui/dialog-events.h"
#include "extension/output.h"
#include "preferences.h"
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 5d330f7f0..17cf835cd 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -577,8 +577,9 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
SVGPreview::SVGPreview()
{
- if (!INKSCAPE)
- inkscape_application_init("", false);
+ // \FIXME Why?!!??
+ if (!Inkscape::Application::exists())
+ Inkscape::Application::create("", false);
document = NULL;
viewerGtk = NULL;
set_size_request(150, 150);
@@ -1083,7 +1084,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl
}
// allow easy access to the user's own templates folder
- gchar *templates = profile_path("templates");
+ gchar *templates = Inkscape::Application::profile_path("templates");
if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) &&
Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) {
add_shortcut_folder(templates);
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index ee6a0ef3a..cafc3be4f 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -44,6 +44,7 @@
#include "filedialog.h"
#include "sp-root.h"
+#include "preferences.h"
#include <zlib.h>
#include <cairomm/win32_surface.h>
@@ -272,6 +273,9 @@ void FileOpenDialogImplWin32::createFilterMenu()
}
if (dialogType != EXE_TYPES) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _show_preview = prefs->getBool("/dialogs/open/enable_preview", true);
+
// Compose the filter string
Inkscape::Extension::DB::InputList extension_list;
Inkscape::Extension::db.get_input_list(extension_list);
@@ -842,6 +846,10 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg,
void FileOpenDialogImplWin32::enable_preview(bool enable)
{
+ if (_show_preview != enable) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/dialogs/open/enable_preview", enable);
+ }
_show_preview = enable;
// Relayout the dialog
@@ -1949,7 +1957,7 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
pImpl = reinterpret_cast<FileSaveDialogImplWin32*>(ofn->lCustData);
// Create the Title label and edit control
- pImpl->_title_label = CreateWindowEx(0, "STATIC", "Title:",
+ pImpl->_title_label = CreateWindowEx(0, "STATIC", _("Title:"),
WS_VISIBLE|WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, rCB1.left-rST.left, rST.bottom-rST.top,
hParentWnd, NULL, hInstance, NULL);
diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h
index f77249abd..8c3b6bad6 100644
--- a/src/ui/dialog/filedialogimpl-win32.h
+++ b/src/ui/dialog/filedialogimpl-win32.h
@@ -24,7 +24,7 @@
#include "filedialogimpl-gtkmm.h"
-#include "gc-core.h"
+#include "inkgc/gc-core.h"
// define WINVER high enough so we get the correct OPENFILENAMEW size
#ifndef WINVER
#define WINVER 0x0500
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index c55d55cda..8141f7696 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -16,7 +16,7 @@
*/
#include "ui/widget/notebook-page.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "document.h"
#include "fill-and-stroke.h"
diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h
index 35c98ef9c..f2a6bf39d 100644
--- a/src/ui/dialog/fill-and-stroke.h
+++ b/src/ui/dialog/fill-and-stroke.h
@@ -41,8 +41,7 @@ public:
virtual void setDesktop(SPDesktop *desktop);
- void selectionChanged(InkscapeApplication *inkscape,
- Inkscape::Selection *selection);
+ //void selectionChanged(Inkscape::Selection *selection);
void showPageFill();
void showPageStrokePaint();
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index bd44846a3..3da0e0043 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -33,7 +33,7 @@
#include <glibmm/stringutils.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "dir-util.h"
#include "document.h"
#include "document-undo.h"
@@ -688,7 +688,7 @@ public:
private:
void select_svg_element(){
- Inkscape::Selection* sel = sp_desktop_selection(_desktop);
+ Inkscape::Selection* sel = _desktop->getSelection();
if (sel->isEmpty()) return;
Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0);
if (!node || !node->matchAttributeName("id")) return;
@@ -1416,7 +1416,7 @@ void FilterEffectsDialog::FilterModifier::setTargetDesktop(SPDesktop *desktop)
_selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &FilterModifier::on_modified_selection)));
}
_doc_replaced = desktop->connectDocumentReplaced( sigc::mem_fun(*this, &FilterModifier::on_document_replaced));
- _resource_changed = sp_desktop_document(desktop)->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters));
+ _resource_changed = desktop->getDocument()->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters));
_dialog.setDesktop(desktop);
update_filters();
@@ -1441,7 +1441,7 @@ void FilterEffectsDialog::FilterModifier::on_document_replaced(SPDesktop * /*des
// When the selection changes, show the active filter(s) in the dialog
void FilterEffectsDialog::FilterModifier::on_change_selection()
{
- Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
update_selection(selection);
}
@@ -1537,9 +1537,9 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
if(iter) {
SPDesktop *desktop = _dialog.getDesktop();
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
SPFilter* filter = (*iter)[_columns.filter];
- Inkscape::Selection *sel = sp_desktop_selection(desktop);
+ Inkscape::Selection *sel = desktop->getSelection();
/* If this filter is the only one used in the selection, unset it */
if((*iter)[_columns.sel] == 1)
@@ -1571,7 +1571,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
void FilterEffectsDialog::FilterModifier::update_filters()
{
SPDesktop* desktop = _dialog.getDesktop();
- SPDocument* document = sp_desktop_document(desktop);
+ SPDocument* document = desktop->getDocument();
const GSList* filters = document->getResourceList("filter");
_model->clear();
@@ -1627,7 +1627,7 @@ void FilterEffectsDialog::FilterModifier::filter_list_button_release(GdkEventBut
void FilterEffectsDialog::FilterModifier::add_filter()
{
- SPDocument* doc = sp_desktop_document(_dialog.getDesktop());
+ SPDocument* doc = _dialog.getDesktop()->getDocument();
SPFilter* filter = new_filter(doc);
const int count = _model->children().size();
@@ -1937,7 +1937,7 @@ void FilterEffectsDialog::PrimitiveList::remove_selected()
//XML Tree being used directly here while it shouldn't be.
sp_repr_unparent(prim->getRepr());
- DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS,
+ DocumentUndo::done(_dialog.getDesktop()->getDocument(), SP_VERB_DIALOG_FILTER_EFFECTS,
_("Remove filter primitive"));
update();
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 1a7832688..951cb01ea 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -29,7 +29,7 @@
#include "document.h"
#include "document-undo.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "ui/dialog-events.h"
#include "verbs.h"
@@ -37,6 +37,7 @@
#include "preferences.h"
#include "sp-text.h"
#include "sp-flowtext.h"
+#include "sp-flowdiv.h"
#include "text-editing.h"
#include "sp-tspan.h"
#include "sp-tref.h"
@@ -238,7 +239,7 @@ Find::Find()
show_all_children();
- Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
SPItem *item = selection->singleItem();
if (item) {
if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) {
@@ -693,7 +694,10 @@ bool Find::item_type_match (SPItem *item)
} else if (dynamic_cast<SPPath *>(item) || dynamic_cast<SPLine *>(item) || dynamic_cast<SPPolyLine *>(item)) {
return (all || check_paths.get_active());
- } else if (dynamic_cast<SPText *>(item) || dynamic_cast<SPTSpan *>(item) || dynamic_cast<SPTRef *>(item) || dynamic_cast<SPString *>(item)) {
+ } else if (dynamic_cast<SPText *>(item) || dynamic_cast<SPTSpan *>(item) ||
+ dynamic_cast<SPTRef *>(item) || dynamic_cast<SPString *>(item) ||
+ dynamic_cast<SPFlowtext *>(item) || dynamic_cast<SPFlowdiv *>(item) ||
+ dynamic_cast<SPFlowtspan *>(item) || dynamic_cast<SPFlowpara *>(item)) {
return (all || check_texts.get_active());
} else if (dynamic_cast<SPGroup *>(item) && !desktop->isLayer(item) ) { // never select layers!
@@ -824,7 +828,7 @@ void Find::onAction()
if (check_scope_layer.get_active()) {
l = all_items (desktop->currentLayer(), l, hidden, locked);
} else {
- l = all_items(sp_desktop_document(desktop)->getRoot(), l, hidden, locked);
+ l = all_items(desktop->getDocument()->getRoot(), l, hidden, locked);
}
}
guint all = g_slist_length (l);
@@ -850,7 +854,7 @@ void Find::onAction()
button_replace.set_sensitive(attributenameyok);
}
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection->clear();
selection->setList(n);
SPObject *obj = reinterpret_cast<SPObject *>(n->data);
@@ -859,13 +863,13 @@ void Find::onAction()
scroll_to_show_item(desktop, item);
if (_action_replace) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Replace text or property"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Replace text or property"));
}
} else {
status.set_text(_("Nothing found"));
if (!check_scope_selection.get_active()) {
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection->clear();
}
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No objects found"));
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index db7bdf222..ae03bdf0e 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -28,7 +28,7 @@
#include "selection.h"
#include "ui/dialog-events.h"
-#include "desktop-handles.h"
+
#include "selection-chemistry.h"
#include "preferences.h"
@@ -134,7 +134,7 @@ FontSubstitution::show(Glib::ustring out, GSList *l)
if (cbSelect->get_active()) {
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection->clear();
selection->setList(l);
}
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp
index 9bad90e7c..2b9053da9 100644
--- a/src/ui/dialog/glyphs.cpp
+++ b/src/ui/dialog/glyphs.cpp
@@ -709,13 +709,12 @@ void GlyphsPanel::readSelection( bool updateStyle, bool /*updateContent*/ )
calcCanInsert();
if (targetDesktop && updateStyle) {
- //SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT);
+ //SPStyle query(SP_ACTIVE_DOCUMENT);
- //int result_family = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
- //int result_style = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
- //int result_numbers = sp_desktop_query_style(targetDesktop, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ //int result_family = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ //int result_style = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ //int result_numbers = sp_desktop_query_style(targetDesktop, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
- //sp_style_unref(query);
}
}
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index 1417b39fa..d3ccb9bde 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -31,7 +31,7 @@
#include "verbs.h"
#include "preferences.h"
#include "inkscape.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "document.h"
#include "document-undo.h"
@@ -165,9 +165,9 @@ void GridArrangeTab::arrange()
grid_top = 99999;
SPDesktop *desktop = Parent->getDesktop();
- sp_desktop_document(desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
const GSList *items = selection ? selection->itemList() : 0;
cnt=0;
for (; items != NULL; items = items->next) {
@@ -347,7 +347,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h
g_slist_free (current_row);
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_ARRANGE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_ARRANGE,
_("Arrange in a grid"));
}
@@ -567,17 +567,6 @@ void GridArrangeTab::updateSelection()
}
-
-/*##########################
-## Experimental
-##########################*/
-
-static void updateSelectionCallback(InkscapeApplication */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg)
-{
- dlg->updateSelection();
-}
-
-
//#########################################################################
//## C O N S T R U C T O R / D E S T R U C T O R
//#########################################################################
@@ -605,7 +594,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
{
// Selection Change signal
- g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this);
+ INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)));
}
Gtk::Box *contents = this;
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index 221f9a1c0..af8e2cc31 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -24,7 +24,7 @@
#include "document-undo.h"
#include "sp-guide.h"
#include "sp-namedview.h"
-#include "desktop-handles.h"
+
#include "ui/tools/tool-base.h"
#include "widgets/desktop-widget.h"
#include <glibmm/i18n.h>
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 468e85d36..b908a90cb 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -35,7 +35,7 @@
#include "ui/widget/frame.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/drawing.h"
#include "document.h"
#include "inkscape.h"
@@ -362,7 +362,7 @@ void IconPreviewPanel::refreshPreview()
target = (hold && !targetId.empty()) ? desktop->doc()->getObjectById( targetId.c_str() ) : 0;
if ( !target ) {
targetId.clear();
- Inkscape::Selection * sel = sp_desktop_selection(desktop);
+ Inkscape::Selection * sel = desktop->getSelection();
if ( sel ) {
//g_message("found a selection to play with");
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 75cfe5bfe..3b0731953 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -32,7 +32,7 @@
#include "util/units.h"
#include <iostream>
#include "enums.h"
-#include "desktop-handles.h"
+
#include "extension/internal/gdkpixbuf-input.h"
#include "message-stack.h"
#include "style.h"
@@ -213,10 +213,10 @@ static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatc
if (desktop == NULL)
return;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
- sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE,
+ desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE,
_("<b>No objects selected</b> to take the style from."));
return;
}
@@ -225,7 +225,7 @@ static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatc
/* TODO: If each item in the selection has the same style then don't consider it an error.
* Maybe we should try to handle multiple selections anyway, e.g. the intersection of the
* style attributes for the selected items. */
- sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE,
+ desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE,
_("<b>More than one object selected.</b> Cannot take style from multiple objects."));
return;
}
@@ -279,10 +279,14 @@ void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const
p.add_line( true, "", *hb, "", "");
// style swatch
- Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"),true));
+ Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"), true));
StyleSwatch *swatch = 0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getInt(prefs_path + "/usecurrent")) {
+ button->set_sensitive(false);
+ }
+
SPCSSAttr *css = prefs->getStyle(prefs_path + "/style");
swatch = new StyleSwatch(css, _("This tool's style of new objects"));
hb->add(*swatch);
@@ -461,7 +465,7 @@ void InkscapePreferences::initPageTools()
_page_text.add_line( false, _("Text size unit type:"), _font_unit_type, "",
_("Set the type of unit used in the text toolbar and text dialogs"), false);
_font_output_px.init ( _("Always output text size in pixels (px)"), "/options/font/textOutputPx", true);
- _page_text.add_line( false, "", _font_output_px, "", _("Always convert the text size units above into pixels (px) before saving to file"));
+// _page_text.add_line( false, "", _font_output_px, "", _("Always convert the text size units above into pixels (px) before saving to file"));
this->AddNewObjectsStyle(_page_text, "/tools/text");
@@ -525,14 +529,14 @@ void InkscapePreferences::initPageUI()
_("English/Canada (en_CA)"), _("English/Great Britain (en_GB)"), _("Pig Latin (en_US@piglatin)"),
_("Esperanto (eo)"), _("Estonian (et)"), _("Farsi (fa)"), _("Finnish (fi)"),
_("French (fr)"), _("Irish (ga)"), _("Galician (gl)"), _("Hebrew (he)"), _("Hungarian (hu)"),
- _("Indonesian (id)"), _("Italian (it)"), _("Japanese (ja)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Korean (ko)"), _("Lithuanian (lt)"), _("Latvian (lv)"), _("Macedonian (mk)"),
+ _("Indonesian (id)"), _("Icelandic (is)"), _("Italian (it)"), _("Japanese (ja)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Korean (ko)"), _("Lithuanian (lt)"), _("Latvian (lv)"), _("Macedonian (mk)"),
_("Mongolian (mn)"), _("Nepali (ne)"), _("Norwegian Bokmål (nb)"), _("Norwegian Nynorsk (nn)"), _("Panjabi (pa)"),
_("Polish (pl)"), _("Portuguese (pt)"), _("Portuguese/Brazil (pt_BR)"), _("Romanian (ro)"), _("Russian (ru)"),
_("Serbian (sr)"), _("Serbian in Latin script (sr@latin)"), _("Slovak (sk)"), _("Slovenian (sl)"), _("Spanish (es)"), _("Spanish/Mexico (es_MX)"),
_("Swedish (sv)"),_("Telugu (te)"), _("Thai (th)"), _("Turkish (tr)"), _("Ukrainian (uk)"), _("Vietnamese (vi)")};
Glib::ustring langValues[] = {"", "sq", "am", "ar", "hy", "az", "eu", "be", "bg", "bn", "bn_BD", "br", "ca", "ca@valencia", "zh_CN", "zh_TW", "hr", "cs", "da", "nl",
"dz", "de", "el", "en", "en_AU", "en_CA", "en_GB", "en_US@piglatin", "eo", "et", "fa", "fi", "fr", "ga",
- "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "lv", "mk", "mn", "ne", "nb", "nn", "pa",
+ "gl", "he", "hu", "id", "is", "it", "ja", "km", "rw", "ko", "lt", "lv", "mk", "mn", "ne", "nb", "nn", "pa",
"pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te", "th", "tr", "uk", "vi" };
{
@@ -1487,7 +1491,7 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui
_kb_filelist.init( "/options/kbshortcuts/shortcutfile", &fileLabels[0], &fileNames[0], fileLabels.size(), fileNames[0]);
- Glib::ustring tooltip(_("Select a file of predefined shortcuts to use. Any customized shortcuts you create will be added seperately to "));
+ Glib::ustring tooltip(_("Select a file of predefined shortcuts to use. Any customized shortcuts you create will be added separately to "));
tooltip += Glib::ustring(IO::Resource::get_path(IO::Resource::USER, IO::Resource::KEYS, "default.xml"));
_page_keyshortcuts.add_line( false, _("Shortcut file:"), _kb_filelist, "", tooltip.c_str(), false);
@@ -1742,6 +1746,10 @@ void InkscapePreferences::onKBListKeyboardShortcuts()
// Find this group in the tree
Glib::ustring group = verb->get_group() ? _(verb->get_group()) : _("Misc");
+ Glib::ustring verb_id = verb->get_id();
+ if (verb_id .compare(0,26,"org.inkscape.effect.filter") == 0) {
+ group = _("Filters");
+ }
Gtk::TreeStore::iterator iter_group;
bool found = false;
while (path) {
@@ -1913,7 +1921,7 @@ void InkscapePreferences::initPageSystem()
_page_system.add_group_header( _("System info"));
- _sys_user_config.set_text((char const *)profile_path(""));
+ _sys_user_config.set_text((char const *)Inkscape::Application::profile_path(""));
_sys_user_config.set_editable(false);
_page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true);
diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp
index d5540b88a..1b8fbb3f7 100644
--- a/src/ui/dialog/layer-properties.cpp
+++ b/src/ui/dialog/layer-properties.cpp
@@ -23,7 +23,7 @@
#include "document-undo.h"
#include "layer-manager.h"
#include "message-stack.h"
-#include "desktop-handles.h"
+
#include "sp-object.h"
#include "sp-item.h"
#include "verbs.h"
@@ -132,7 +132,7 @@ LayerPropertiesDialog::_apply()
g_assert(_strategy != NULL);
_strategy->perform(*this);
- DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE,
+ DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_NONE,
_("Add layer"));
_close();
@@ -364,7 +364,7 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) {
(gchar *)name.c_str(),
FALSE
);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE,
_("Rename layer"));
// TRANSLATORS: This means "The layer has been renamed"
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Renamed layer"));
@@ -399,7 +399,7 @@ void LayerPropertiesDialog::Create::perform(LayerPropertiesDialog &dialog) {
if (!name.empty()) {
desktop->layer_manager->renameLayer( new_layer, (gchar *)name.c_str(), TRUE );
}
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
desktop->setCurrentLayer(new_layer);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("New layer created."));
}
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index eb3857ee7..422ec10ae 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -23,10 +23,11 @@
#include <vector>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "gtkmm/widget.h"
+#include "helper/action.h"
#include "inkscape.h"
#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
@@ -44,6 +45,7 @@
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
+#include "widgets/icon.h"
#include "xml/node.h"
#include "livepatheffect-add.h"
@@ -68,6 +70,14 @@ static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint
lpeeditor->onSelectionChanged(selection);
}
+static void lpe_style_button(Gtk::Button& btn, char const* iconName)
+{
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show( child );
+ btn.add(*Gtk::manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
+}
+
/*
* LivePathEffectEditor
@@ -107,43 +117,19 @@ LivePathEffectEditor::LivePathEffectEditor()
effectcontrol_frame.add(effectcontrol_vbox);
button_add.set_tooltip_text(_("Add path effect"));
-#if WITH_GTKMM_3_10
- button_add.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_add = Gtk::manage(new Gtk::Image());
- image_add->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- button_add.set_image(*image_add);
-#endif
+ lpe_style_button(button_add, INKSCAPE_ICON("list-add"));
button_add.set_relief(Gtk::RELIEF_NONE);
button_remove.set_tooltip_text(_("Delete current path effect"));
-#if WITH_GTKMM_3_10
- button_remove.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- button_remove.set_image(*image_remove);
-#endif
+ lpe_style_button(button_remove, INKSCAPE_ICON("list-remove"));
button_remove.set_relief(Gtk::RELIEF_NONE);
button_up.set_tooltip_text(_("Raise the current path effect"));
-#if WITH_GTKMM_3_10
- button_up.set_image_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_up = Gtk::manage(new Gtk::Image());
- image_up->set_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- button_up.set_image(*image_up);
-#endif
+ lpe_style_button(button_up, INKSCAPE_ICON("go-up"));
button_up.set_relief(Gtk::RELIEF_NONE);
button_down.set_tooltip_text(_("Lower the current path effect"));
-#if WITH_GTKMM_3_10
- button_down.set_image_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_down = Gtk::manage(new Gtk::Image());
- image_down->set_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- button_down.set_image(*image_down);
-#endif
+ lpe_style_button(button_down, INKSCAPE_ICON("go-down"));
button_down.set_relief(Gtk::RELIEF_NONE);
// Add toolbar items to toolbar
@@ -398,7 +384,7 @@ LivePathEffectEditor::setDesktop(SPDesktop *desktop)
lpe_list_locked = false;
current_desktop = desktop;
if (desktop) {
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection_changed_connection = selection->connectChanged(
sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
selection_modified_connection = selection->connectModified(
@@ -475,9 +461,13 @@ LivePathEffectEditor::onAdd()
// run sp_selection_clone_original_path_lpe
sp_selection_clone_original_path_lpe(current_desktop);
+
SPItem *new_item = sel->singleItem();
- new_item->getRepr()->setAttribute("id", id);
- new_item->getRepr()->setAttribute("transform", transform);
+ // Check that the cloning was successful. We don't want to change the ID of the original referenced path!
+ if (new_item && (new_item != orig)) {
+ new_item->getRepr()->setAttribute("id", id);
+ new_item->getRepr()->setAttribute("transform", transform);
+ }
g_free(id);
g_free(transform);
@@ -506,7 +496,7 @@ LivePathEffectEditor::onRemove()
if ( lpeitem ) {
lpeitem->removeCurrentPathEffect(false);
- DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Remove path effect") );
effect_list_reload(lpeitem);
@@ -524,7 +514,7 @@ void LivePathEffectEditor::onUp()
if ( lpeitem ) {
lpeitem->upCurrentPathEffect();
- DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Move path effect up") );
effect_list_reload(lpeitem);
@@ -541,7 +531,7 @@ void LivePathEffectEditor::onDown()
if ( lpeitem ) {
lpeitem->downCurrentPathEffect();
- DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Move path effect down") );
effect_list_reload(lpeitem);
@@ -580,7 +570,7 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
/* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
* So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
- DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
newValue ? _("Activate path effect") : _("Deactivate path effect"));
}
}
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index 55a19fc51..7e5c17133 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -23,7 +23,7 @@
#include "document-undo.h"
#include "layer-manager.h"
#include "message-stack.h"
-#include "desktop-handles.h"
+
#include "sp-object.h"
#include "sp-item.h"
#include "verbs.h"
@@ -129,7 +129,7 @@ void FilletChamferPropertiesDialog::showDialog(
const gchar *unit,
bool use_distance,
bool aprox_radius,
- Glib::ustring const * documentUnit)
+ Glib::ustring documentUnit)
{
FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog();
@@ -172,7 +172,7 @@ void FilletChamferPropertiesDialog::_apply()
}
d_pos = _index + (d_pos / 100);
} else {
- d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, *document_unit);
+ d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, document_unit);
d_pos = d_pos * -1;
}
_knotpoint->knot_set_offset(Geom::Point(d_pos, d_width));
@@ -207,12 +207,12 @@ void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event)
void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint)
{
double position;
- std::string distance_or_radius = std::string(_("Radius "));
+ std::string distance_or_radius = std::string(_("Radius"));
if(aprox){
- distance_or_radius = std::string(_("Radius approximated "));
+ distance_or_radius = std::string(_("Radius approximated"));
}
if(use_distance){
- distance_or_radius = std::string(_("Knot distance "));
+ distance_or_radius = std::string(_("Knot distance"));
}
if (knotpoint.x() > 0) {
double intpart;
@@ -222,12 +222,11 @@ void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint)
_fillet_chamfer_position_label.set_label(_("Position (%):"));
} else {
_flexible = false;
- std::string posConcat = distance_or_radius +
- std::string(_("(")) + std::string(unit) + std::string(")");
+ std::string posConcat = Glib::ustring::compose (_("%1 (%2):"), distance_or_radius, unit);
_fillet_chamfer_position_label.set_label(_(posConcat.c_str()));
position = knotpoint[Geom::X] * -1;
- position = Inkscape::Util::Quantity::convert(position, *document_unit, unit);
+ position = Inkscape::Util::Quantity::convert(position, document_unit, unit);
}
_fillet_chamfer_position_numeric.set_value(position);
if (knotpoint.y() == 1) {
@@ -257,7 +256,7 @@ void FilletChamferPropertiesDialog::_set_unit(const gchar *abbr)
unit = abbr;
}
-void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring const *abbr)
+void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring abbr)
{
document_unit = abbr;
}
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 3807e98c8..870a1734f 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -33,7 +33,7 @@ public:
const gchar *unit,
bool use_distance,
bool aprox_radius,
- Glib::ustring const * documentUnit);
+ Glib::ustring documentUnit);
protected:
@@ -69,14 +69,14 @@ protected:
void _set_pt(const Inkscape::LivePathEffect::
FilletChamferPointArrayParamKnotHolderEntity *pt);
void _set_unit(const gchar *abbr);
- void _set_document_unit(Glib::ustring const * abbr);
+ void _set_document_unit(Glib::ustring abbr);
void _set_use_distance(bool use_knot_distance);
void _set_aprox(bool aprox_radius);
void _apply();
void _close();
bool _flexible;
const gchar *unit;
- Glib::ustring const * document_unit;
+ Glib::ustring document_unit;
bool use_distance;
bool aprox;
void _set_knot_point(Geom::Point knotpoint);
diff --git a/src/ui/dialog/lpe-powerstroke-properties.cpp b/src/ui/dialog/lpe-powerstroke-properties.cpp
index 55f938a48..a9e57970d 100644
--- a/src/ui/dialog/lpe-powerstroke-properties.cpp
+++ b/src/ui/dialog/lpe-powerstroke-properties.cpp
@@ -32,7 +32,7 @@
#include "document-undo.h"
#include "layer-manager.h"
#include "message-stack.h"
-#include "desktop-handles.h"
+
#include "sp-object.h"
#include "sp-item.h"
#include "verbs.h"
diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp
index 0008eb284..c0bc884fa 100644
--- a/src/ui/dialog/memory.cpp
+++ b/src/ui/dialog/memory.cpp
@@ -20,7 +20,7 @@
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
-#include "gc-core.h"
+#include "inkgc/gc-core.h"
#include "debug/heap.h"
#include "verbs.h"
diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp
index cfa5c6182..f43a15225 100644
--- a/src/ui/dialog/object-attributes.cpp
+++ b/src/ui/dialog/object-attributes.cpp
@@ -22,7 +22,7 @@
#include "ui/dialog/dialog-manager.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "macros.h"
#include "sp-anchor.h"
#include "sp-image.h"
@@ -113,7 +113,7 @@ void ObjectAttributes::widget_setup (void)
return;
}
- Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
SPItem *item = selection->singleItem();
if (!item)
{
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 28e9b360b..dfe211e94 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -28,7 +28,7 @@
#include "object-properties.h"
#include "widgets/sp-attribute-widget.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "verbs.h"
@@ -353,7 +353,7 @@ void ObjectProperties::update()
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(SP_ACTIVE_DESKTOP);
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
Gtk::Box *contents = _getContents();
if (!selection->singleItem()) {
@@ -458,7 +458,7 @@ void ObjectProperties::_labelChanged()
return;
}
- SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
g_return_if_fail (item != NULL);
_blocked = true;
@@ -518,7 +518,7 @@ void ObjectProperties::_imageRenderingChanged()
return;
}
- SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
g_return_if_fail (item != NULL);
_blocked = true;
@@ -543,7 +543,7 @@ void ObjectProperties::_sensitivityToggled()
return;
}
- SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
g_return_if_fail(item != NULL);
_blocked = true;
@@ -559,7 +559,7 @@ void ObjectProperties::_hiddenToggled()
return;
}
- SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
g_return_if_fail(item != NULL);
_blocked = true;
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index c95529a56..9db0285d7 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -231,15 +231,13 @@ public:
/**
* Stylizes a button using the given icon name and tooltip
*/
-void ObjectsPanel::_styleButton( Gtk::Button& btn, char const* iconName, char const* tooltip )
+void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip)
{
GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName );
gtk_widget_show( child );
btn.add( *Gtk::manage(Glib::wrap(child)) );
btn.set_relief(Gtk::RELIEF_NONE);
-
btn.set_tooltip_text (tooltip);
-
}
/**
@@ -1799,29 +1797,14 @@ ObjectsPanel::ObjectsPanel() :
//Add object/layer
Gtk::Button* btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Add layer..."));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_add = Gtk::manage(new Gtk::Image());
- image_add->set_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_add);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("list-add"), _("Add layer..."));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_NEW) );
_buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
-
//Remove object
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Remove object"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- Gtk::Image *image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("list-remove"), _("Remove object"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_DELETE) );
_watching.push_back( btn );
@@ -1829,14 +1812,7 @@ ObjectsPanel::ObjectsPanel() :
//Move to bottom
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Move To Bottom"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("go-bottom"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("go-bottom"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("go-bottom"), _("Move To Bottom"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_BOTTOM) );
_watchingNonBottom.push_back( btn );
@@ -1844,14 +1820,7 @@ ObjectsPanel::ObjectsPanel() :
//Move down
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Move Down"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("go-down"), _("Move Down"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_DOWN) );
_watchingNonBottom.push_back( btn );
@@ -1859,14 +1828,7 @@ ObjectsPanel::ObjectsPanel() :
//Move up
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Move Up"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("go-up"), _("Move Up"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_UP) );
_watchingNonTop.push_back( btn );
@@ -1874,14 +1836,7 @@ ObjectsPanel::ObjectsPanel() :
//Move to top
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Move To Top"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("go-top"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("go-top"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("go-top"), _("Move To Top"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_TOP) );
_watchingNonTop.push_back( btn );
@@ -1889,14 +1844,7 @@ ObjectsPanel::ObjectsPanel() :
//Collapse all
btn = Gtk::manage( new Gtk::Button() );
- btn->set_tooltip_text(_("Collapse All"));
-#if GTK_CHECK_VERSION(3,10,0)
- btn->set_image_from_icon_name(INKSCAPE_ICON("gtk-unindent-ltr"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
-#else
- image_remove = Gtk::manage(new Gtk::Image());
- image_remove->set_from_icon_name(INKSCAPE_ICON("gtk-unindent-ltr"), Gtk::ICON_SIZE_SMALL_TOOLBAR);
- btn->set_image(*image_remove);
-#endif
+ _styleButton(*btn, INKSCAPE_ICON("format-indent-less"), _("Collapse All"));
btn->set_relief(Gtk::RELIEF_NONE);
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_takeAction), (int)BUTTON_COLLAPSE_ALL) );
_watchingNonBottom.push_back( btn );
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index c4dd9df98..a1c7d41bd 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -26,7 +26,7 @@
#include "path-prefix.h"
#include "filedialogimpl-gtkmm.h"
#include "ui/interface.h"
-#include "gc-core.h"
+#include "inkgc/gc-core.h"
#include "ui/dialog-events.h"
#include "io/sys.h"
#include "preferences.h"
diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h
index b4a355083..39110f47a 100644
--- a/src/ui/dialog/panel-dialog.h
+++ b/src/ui/dialog/panel-dialog.h
@@ -49,19 +49,10 @@ public:
virtual UI::Widget::Panel &getPanel() { return _panel; }
protected:
- static void handle_deactivate_desktop(InkscapeApplication *application, SPDesktop *desktop, void *data) {
- g_return_if_fail(data != NULL);
- static_cast<PanelDialogBase *>(data)->_propagateDesktopDeactivated(application, desktop);
- }
-
- static void _handle_activate_desktop(InkscapeApplication *application, SPDesktop *desktop, void *data) {
- g_return_if_fail(data != NULL);
- static_cast<PanelDialogBase *>(data)->_propagateDesktopActivated(application, desktop);
- }
inline virtual void _propagateDocumentReplaced(SPDesktop* desktop, SPDocument *document);
- inline virtual void _propagateDesktopActivated(InkscapeApplication *, SPDesktop *);
- inline virtual void _propagateDesktopDeactivated(InkscapeApplication *, SPDesktop *);
+ inline virtual void _propagateDesktopActivated(SPDesktop *);
+ inline virtual void _propagateDesktopDeactivated(SPDesktop *);
UI::Widget::Panel &_panel;
sigc::connection _document_replaced_connection;
@@ -134,17 +125,17 @@ void PanelDialogBase::_propagateDocumentReplaced(SPDesktop *desktop, SPDocument
_panel.signalDocumentReplaced().emit(desktop, document);
}
-void PanelDialogBase::_propagateDesktopActivated(InkscapeApplication *application, SPDesktop *desktop)
+void PanelDialogBase::_propagateDesktopActivated(SPDesktop *desktop)
{
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialogBase::_propagateDocumentReplaced));
- _panel.signalActivateDesktop().emit(application, desktop);
+ _panel.signalActivateDesktop().emit(desktop);
}
-void PanelDialogBase::_propagateDesktopDeactivated(InkscapeApplication *application, SPDesktop *desktop)
+void PanelDialogBase::_propagateDesktopDeactivated(SPDesktop *desktop)
{
_document_replaced_connection.disconnect();
- _panel.signalDeactiveDesktop().emit(application, desktop);
+ _panel.signalDeactiveDesktop().emit(desktop);
}
@@ -162,7 +153,7 @@ PanelDialog<B>::PanelDialog(Widget::Panel &panel, char const *prefs_path, int co
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- _propagateDesktopActivated(INKSCAPE, desktop);
+ _propagateDesktopActivated(desktop);
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
@@ -211,7 +202,7 @@ PanelDialog<Behavior::FloatingBehavior>::PanelDialog(UI::Widget::Panel &panel, c
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- _propagateDesktopActivated(INKSCAPE, desktop);
+ _propagateDesktopActivated(desktop);
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
@@ -247,8 +238,12 @@ PanelDialog<Behavior::FloatingBehavior> *PanelDialog<Behavior::FloatingBehavior>
new PanelDialog<Behavior::FloatingBehavior>(panel, panel.getPrefsPath(),
panel.getVerb(), panel.getApplyLabel());
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(_handle_activate_desktop), instance);
- g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK(handle_deactivate_desktop), instance);
+ INKSCAPE.signal_activate_desktop.connect(
+ sigc::mem_fun(*instance, &PanelDialog<Behavior::FloatingBehavior>::_propagateDesktopActivated)
+ );
+ INKSCAPE.signal_deactivate_desktop.connect(
+ sigc::mem_fun(*instance, &PanelDialog<Behavior::FloatingBehavior>::_propagateDesktopDeactivated)
+ );
return instance;
}
diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp
index 80579c9d3..281958998 100644
--- a/src/ui/dialog/polar-arrange-tab.cpp
+++ b/src/ui/dialog/polar-arrange-tab.cpp
@@ -16,7 +16,7 @@
#include "verbs.h"
#include "preferences.h"
#include "inkscape.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "document.h"
#include "document-undo.h"
@@ -38,12 +38,12 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
#else
parametersTable(3, 3, false),
#endif
- centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR),
- centerX("", "X coordinate of the center", centerY),
- radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR),
- radiusX("", "X coordinate of the radius", radiusY),
- angleY("", "Starting angle", UNIT_TYPE_RADIAL),
- angleX("", "End angle", angleY)
+ centerY("", C_("Polar arrange tab", "Y coordinate of the center"), UNIT_TYPE_LINEAR),
+ centerX("", C_("Polar arrange tab", "X coordinate of the center"), centerY),
+ radiusY("", C_("Polar arrange tab", "Y coordinate of the radius"), UNIT_TYPE_LINEAR),
+ radiusX("", C_("Polar arrange tab", "X coordinate of the radius"), radiusY),
+ angleY("", C_("Polar arrange tab", "Starting angle"), UNIT_TYPE_RADIAL),
+ angleX("", C_("Polar arrange tab", "End angle"), angleY)
{
anchorPointLabel.set_text(C_("Polar arrange tab", "Anchor point:"));
anchorPointLabel.set_alignment(Gtk::ALIGN_START);
@@ -80,7 +80,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed));
pack_start(arrangeOnParametersRadio, false, false);
- centerLabel.set_text(_("Center X/Y:"));
+ centerLabel.set_text(C_("Polar arrange tab", "Center X/Y:"));
#if WITH_GTKMM_3_0
parametersTable.attach(centerLabel, 0, 0, 1, 1);
#else
@@ -102,7 +102,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL);
#endif
- radiusLabel.set_text(_("Radius X/Y:"));
+ radiusLabel.set_text(C_("Polar arrange tab", "Radius X/Y:"));
#if WITH_GTKMM_3_0
parametersTable.attach(radiusLabel, 0, 1, 1, 1);
#else
@@ -296,7 +296,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p)
void PolarArrangeTab::arrange()
{
- Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop());
+ Inkscape::Selection *selection = parent->getDesktop()->getSelection();
const GSList *items, *tmp;
tmp = items = selection->itemList();
SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection
@@ -399,7 +399,7 @@ void PolarArrangeTab::arrange()
tmp = tmp->next;
}
- DocumentUndo::done(sp_desktop_document(parent->getDesktop()), SP_VERB_SELECTION_ARRANGE,
+ DocumentUndo::done(parent->getDesktop()->getDocument(), SP_VERB_SELECTION_ARRANGE,
_("Arrange on ellipse"));
}
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index a015d28f9..ad979b570 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -126,30 +126,13 @@ static void draw_page(
cairo_surface_t *surface = cairo_get_target(cr);
cairo_matrix_t ctm;
cairo_get_matrix(cr, &ctm);
-#ifdef WIN32
- //Gtk+ does not take the non printable area into account
- //http://bugzilla.gnome.org/show_bug.cgi?id=381371
- //
- // This workaround translates the origin from the top left of the
- // printable area to the top left of the page.
- GtkPrintSettings *settings = gtk_print_operation_get_print_settings(operation);
- const gchar *printerName = gtk_print_settings_get_printer(settings);
- HDC hdc = CreateDC("WINSPOOL", printerName, NULL, NULL);
- if (hdc) {
- cairo_matrix_t mat;
- int x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX);
- int y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY);
- cairo_matrix_init_translate(&mat, -x_off, -y_off);
- cairo_matrix_multiply (&ctm, &ctm, &mat);
- DeleteDC(hdc);
- }
-#endif
+
bool ret = ctx->setSurfaceTarget (surface, true, &ctm);
if (ret) {
ret = renderer.setupDocument (ctx, junk->_doc, TRUE, 0., NULL);
if (ret) {
renderer.renderItem(ctx, junk->_base);
- ret = ctx->finish();
+ ctx->finish();
}
else {
g_warning("%s", _("Could not set up Document"));
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 9faa8a2cb..6da8acb20 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -22,7 +22,7 @@
#include "document.h"
#include "selection.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "ui/tools-switch.h"
#include "ui/tools/text-tool.h"
#include "ui/interface.h"
@@ -407,7 +407,7 @@ SpellCheck::init(SPDesktop *d)
}
#endif /* HAVE_ASPELL */
- _root = sp_desktop_document(desktop)->getRoot();
+ _root = desktop->getDocument()->getRoot();
// empty the list of objects we've checked
g_slist_free (_seen_objects);
@@ -612,7 +612,7 @@ SpellCheck::nextWord()
area.expandBy(MAX(0.05 * mindim, 1));
// create canvas path rectangle, red stroke
- SPCanvasItem *rect = sp_canvas_bpath_new(sp_desktop_sketch(desktop), NULL);
+ SPCanvasItem *rect = sp_canvas_bpath_new(desktop->getSketch(), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(rect), 0xff0000ff, 3.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(rect), 0, SP_WIND_RULE_NONZERO);
SPCurve *curve = new SPCurve();
@@ -792,7 +792,7 @@ void SpellCheck::onAccept ()
// find the end of the word anew
_end_w = _begin_w;
_end_w.nextEndOfWord();
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Fix spelling"));
}
}
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 56ecfdecc..bc228633d 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -29,7 +29,8 @@
#include "xml/node.h"
#include "xml/repr.h"
#include "sp-font-face.h"
-#include "desktop-handles.h"
+#include "desktop.h"
+
#include "display/nr-svgfonts.h"
#include "verbs.h"
#include "sp-glyph.h"
@@ -181,7 +182,7 @@ void SvgFontsDialog::on_kerning_value_changed(){
return;
}
- SPDocument* document = sp_desktop_document(this->getDesktop());
+ SPDocument* document = this->getDesktop()->getDocument();
//TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done
Glib::ustring undokey = "svgfonts:hkern:k:";
@@ -264,7 +265,7 @@ void SvgFontsDialog::update_sensitiveness(){
void SvgFontsDialog::update_fonts()
{
SPDesktop* desktop = this->getDesktop();
- SPDocument* document = sp_desktop_document(desktop);
+ SPDocument* document = desktop->getDocument();
const GSList* fonts = document->getResourceList("font");
_model->clear();
@@ -481,7 +482,7 @@ void SvgFontsDialog::update_glyphs(){
void SvgFontsDialog::add_glyph(){
const int count = _GlyphsListStore->children().size();
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
/* SPGlyph* glyph =*/ new_glyph(doc, get_selected_spfont(), count+1);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph"));
@@ -514,9 +515,9 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
return;
}
- Inkscape::MessageStack *msgStack = sp_desktop_message_stack(desktop);
- SPDocument* doc = sp_desktop_document(desktop);
- Inkscape::Selection* sel = sp_desktop_selection(desktop);
+ Inkscape::MessageStack *msgStack = desktop->getMessageStack();
+ SPDocument* doc = desktop->getDocument();
+ Inkscape::Selection* sel = desktop->getSelection();
if (sel->isEmpty()){
char *msg = _("Select a <b>path</b> to define the curves of a glyph");
msgStack->flash(Inkscape::ERROR_MESSAGE, msg);
@@ -556,9 +557,9 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
return;
}
- Inkscape::MessageStack *msgStack = sp_desktop_message_stack(desktop);
- SPDocument* doc = sp_desktop_document(desktop);
- Inkscape::Selection* sel = sp_desktop_selection(desktop);
+ Inkscape::MessageStack *msgStack = desktop->getMessageStack();
+ SPDocument* doc = desktop->getDocument();
+ Inkscape::Selection* sel = desktop->getSelection();
if (sel->isEmpty()){
char *msg = _("Select a <b>path</b> to define the curves of a glyph");
msgStack->flash(Inkscape::ERROR_MESSAGE, msg);
@@ -597,7 +598,7 @@ void SvgFontsDialog::reset_missing_glyph_description(){
return;
}
- SPDocument* doc = sp_desktop_document(desktop);
+ SPDocument* doc = desktop->getDocument();
SPObject* obj;
for (obj = get_selected_spfont()->children; obj; obj=obj->next){
if (SP_IS_MISSING_GLYPH(obj)){
@@ -618,7 +619,7 @@ void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring&
//XML Tree being directly used here while it shouldn't be.
glyph->getRepr()->setAttribute("glyph-name", str.c_str());
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name"));
update_glyphs();
@@ -632,7 +633,7 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin
//XML Tree being directly used here while it shouldn't be.
glyph->getRepr()->setAttribute("unicode", str.c_str());
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode"));
update_glyphs();
@@ -644,7 +645,7 @@ void SvgFontsDialog::remove_selected_font(){
//XML Tree being directly used here while it shouldn't be.
sp_repr_unparent(font->getRepr());
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font"));
update_fonts();
@@ -661,7 +662,7 @@ void SvgFontsDialog::remove_selected_glyph(){
//XML Tree being directly used here while it shouldn't be.
sp_repr_unparent(glyph->getRepr());
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph"));
update_glyphs();
@@ -678,7 +679,7 @@ void SvgFontsDialog::remove_selected_kerning_pair(){
//XML Tree being directly used here while it shouldn't be.
sp_repr_unparent(pair->getRepr());
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair"));
update_glyphs();
@@ -749,7 +750,7 @@ void SvgFontsDialog::add_kerning_pair(){
if (this->kerning_pair) return; //We already have this kerning pair
- SPDocument* document = sp_desktop_document(this->getDesktop());
+ SPDocument* document = this->getDesktop()->getDocument();
Inkscape::XML::Document *xml_doc = document->getReprDoc();
// create a new hkern node
@@ -863,7 +864,7 @@ void set_font_family(SPFont* font, char* str){
}
void SvgFontsDialog::add_font(){
- SPDocument* doc = sp_desktop_document(this->getDesktop());
+ SPDocument* doc = this->getDesktop()->getDocument();
SPFont* font = new_font(doc);
const int count = _model->children().size();
@@ -937,7 +938,7 @@ SvgFontsDialog::SvgFontsDialog()
_FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release));
create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font));
- _defs_observer.set(sp_desktop_document(this->getDesktop())->getDefs());
+ _defs_observer.set(this->getDesktop()->getDocument()->getDefs());
_defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts));
_getContents()->show_all();
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index a3cfeeba8..8759039c3 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -28,7 +28,7 @@
#include "color-item.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "document.h"
#include "document-private.h"
@@ -122,15 +122,15 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
if ( gr ) {
bool shown = false;
if ( desktop && desktop->doc() ) {
- Inkscape::Selection *selection = sp_desktop_selection( desktop );
+ Inkscape::Selection *selection = desktop->getSelection();
GSList const *items = selection->itemList();
if (items) {
- SPStyle *query = sp_style_new( desktop->doc() );
- int result = objects_query_fillstroke(const_cast<GSList *>(items), query, true);
+ SPStyle query( desktop->doc() );
+ int result = objects_query_fillstroke(const_cast<GSList *>(items), &query, true);
if ( (result == QUERY_STYLE_MULTIPLE_SAME) || (result == QUERY_STYLE_SINGLE) ) {
// could be pertinent
- if (query->fill.isPaintserver()) {
- SPPaintServer* server = query->getFillPaintServer();
+ if (query.fill.isPaintserver()) {
+ SPPaintServer* server = query.getFillPaintServer();
if ( SP_IS_GRADIENT(server) ) {
SPGradient* grad = SP_GRADIENT(server);
if ( grad->isSwatch() && grad->getId() == gr->getId()) {
@@ -140,7 +140,6 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
}
}
}
- sp_style_unref(query);
}
}
@@ -527,7 +526,7 @@ static void loadEmUp()
beenHere = true;
std::list<gchar *> sources;
- sources.push_back( profile_path("palettes") );
+ sources.push_back( Inkscape::Application::profile_path("palettes") );
sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
sources.push_back( g_strdup(CREATE_PALETTESDIR) );
@@ -1061,15 +1060,15 @@ void SwatchesPanel::_updateFromSelection()
Glib::ustring fillId;
Glib::ustring strokeId;
- SPStyle *tmpStyle = sp_style_new( sp_desktop_document(_currentDesktop) );
- int result = sp_desktop_query_style( _currentDesktop, tmpStyle, QUERY_STYLE_PROPERTY_FILL );
+ SPStyle tmpStyle(_currentDesktop->getDocument());
+ int result = sp_desktop_query_style( _currentDesktop, &tmpStyle, QUERY_STYLE_PROPERTY_FILL );
switch (result) {
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
{
- if (tmpStyle->fill.set && tmpStyle->fill.isPaintserver()) {
- SPPaintServer* server = tmpStyle->getFillPaintServer();
+ if (tmpStyle.fill.set && tmpStyle.fill.isPaintserver()) {
+ SPPaintServer* server = tmpStyle.getFillPaintServer();
if ( SP_IS_GRADIENT(server) ) {
SPGradient* target = 0;
SPGradient* grad = SP_GRADIENT(server);
@@ -1095,14 +1094,14 @@ void SwatchesPanel::_updateFromSelection()
}
}
- result = sp_desktop_query_style( _currentDesktop, tmpStyle, QUERY_STYLE_PROPERTY_STROKE );
+ result = sp_desktop_query_style( _currentDesktop, &tmpStyle, QUERY_STYLE_PROPERTY_STROKE );
switch (result) {
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
{
- if (tmpStyle->stroke.set && tmpStyle->stroke.isPaintserver()) {
- SPPaintServer* server = tmpStyle->getStrokePaintServer();
+ if (tmpStyle.stroke.set && tmpStyle.stroke.isPaintserver()) {
+ SPPaintServer* server = tmpStyle.getStrokePaintServer();
if ( SP_IS_GRADIENT(server) ) {
SPGradient* target = 0;
SPGradient* grad = SP_GRADIENT(server);
@@ -1126,7 +1125,6 @@ void SwatchesPanel::_updateFromSelection()
break;
}
}
- sp_style_unref(tmpStyle);
for ( boost::ptr_vector<ColorItem>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) {
ColorItem* item = &*it;
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index a17a03861..eeb4d6cbe 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -52,7 +52,7 @@
#include "selection.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "inkscape.h"
#include "sp-root.h"
@@ -287,8 +287,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
++row;
/**********************************************************/
- currentDesktop = inkscape_active_desktop();
- currentDocument = sp_desktop_document(currentDesktop);
+ currentDesktop = SP_ACTIVE_DESKTOP;
+ currentDocument = currentDesktop->getDocument();
previewDocument = symbols_preview_doc(); /* Template to render symbols in */
previewDocument->ensureUpToDate(); /* Necessary? */
@@ -498,7 +498,7 @@ void SymbolsDialog::iconChanged() {
}
ClipboardManager *cm = ClipboardManager::get();
- cm->copySymbol(symbol->getRepr(), style);
+ cm->copySymbol(symbol->getRepr(), style, symbolDocument == currentDocument);
}
}
@@ -585,13 +585,15 @@ void SymbolsDialog::get_symbols() {
std::list<Glib::ustring> directories;
+// \TODO optimize this
+
if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
directories.push_back( INKSCAPE_SYMBOLSDIR );
}
- if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( profile_path("symbols") );
+ if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
+ Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
+ directories.push_back( Inkscape::Application::profile_path("symbols") );
}
std::list<Glib::ustring>::iterator it;
diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp
index 8a104d137..7d3edaffb 100644
--- a/src/ui/dialog/tags.cpp
+++ b/src/ui/dialog/tags.cpp
@@ -145,31 +145,12 @@ public:
int _actionCode;
};
-void TagsPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* tooltip )
+void TagsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip)
{
- bool set = false;
-
- if ( iconName ) {
- GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName );
- gtk_widget_show( child );
- btn.add( *manage(Glib::wrap(child)) );
- btn.set_relief(Gtk::RELIEF_NONE);
- set = true;
- }
-
- if ( desktop ) {
- Verb *verb = Verb::get( code );
- if ( verb ) {
- SPAction *action = verb->get_action(desktop);
- if ( !set && action && action->image ) {
- GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image );
- gtk_widget_show( child );
- btn.add( *manage(Glib::wrap(child)) );
- set = true;
- }
- }
- }
-
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show(child);
+ btn.add(*manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
btn.set_tooltip_text (tooltip);
}
@@ -1013,7 +994,7 @@ TagsPanel::TagsPanel() :
SPDesktop* targetDesktop = getDesktop();
Gtk::Button* btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_TAG_NEW, GTK_STOCK_ADD, _("Add a new selection set") );
+ _styleButton(*btn, "list-add", _("Add a new selection set") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &TagsPanel::_takeAction), (int)BUTTON_NEW) );
_buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
@@ -1022,7 +1003,7 @@ TagsPanel::TagsPanel() :
// _buttonsRow.add( *btn );
btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, GTK_STOCK_REMOVE, _("Remove Item/Set") );
+ _styleButton( *btn, "list-remove", _("Remove Item/Set") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &TagsPanel::_takeAction), (int)BUTTON_DELETE) );
_watching.push_back( btn );
_buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
diff --git a/src/ui/dialog/tags.h b/src/ui/dialog/tags.h
index d35dfba01..3576bd111 100644
--- a/src/ui/dialog/tags.h
+++ b/src/ui/dialog/tags.h
@@ -62,7 +62,7 @@ private:
TagsPanel(TagsPanel const &); // no copy
TagsPanel &operator=(TagsPanel const &); // no assign
- void _styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* tooltip );
+ void _styleButton( Gtk::Button& btn, char const* iconName, char const* tooltip );
void _fireAction( unsigned int code );
Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index 13cb01eef..fca1f7b30 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -194,7 +194,7 @@ void TemplateLoadTab::_refreshTemplatesList()
void TemplateLoadTab::_loadTemplates()
{
// user's local dir
- _getTemplatesFromDir(profile_path("templates") + _loading_path);
+ _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path);
// system templates dir
_getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path);
diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp
index f79d166f2..eff75b311 100644
--- a/src/ui/dialog/template-widget.cpp
+++ b/src/ui/dialog/template-widget.cpp
@@ -20,7 +20,7 @@
#include "template-load-tab.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "file.h"
@@ -68,8 +68,8 @@ void TemplateWidget::create()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
SPDesktop *desc = sp_file_new_default();
_current_template.tpl_effect->effect(desc);
- DocumentUndo::clearUndo(sp_desktop_document(desc));
- sp_desktop_document(desc)->setModifiedSinceSave(false);
+ DocumentUndo::clearUndo(desc->getDocument());
+ desc->getDocument()->setModifiedSinceSave(false);
// Apply cx,cy etc. from document
sp_namedview_window_from_document( desc );
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 0f4a6f7f1..a8be8b543 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -41,7 +41,7 @@ extern "C" {
#include "document.h"
#include "desktop.h"
#include "desktop-style.h"
-#include "desktop-handles.h"
+
#include "document-undo.h"
#include "selection.h"
#include "style.h"
@@ -325,18 +325,18 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
if (dostyle) {
// create temporary style
- SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ SPStyle query(SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
- //int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
- int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
- int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
- int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+ //int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+ int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+ int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
// (Ok to not get a font specification - must just rely on the family and style in that case)
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING
|| result_numbers == QUERY_STYLE_NOTHING) {
- sp_style_read_from_prefs(query, "/tools/text");
+ query.readFromPrefs("/tools/text");
}
// FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists
@@ -344,47 +344,46 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
// This is normally done for us by text-toolbar but only when we are in text editing context
- fontlister->update_font_list(sp_desktop_document(this->desktop));
+ fontlister->update_font_list(this->desktop->getDocument());
fontlister->selection_update();
Glib::ustring fontspec = fontlister->get_fontspec();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
- double size = sp_style_css_size_px_to_units(query->font_size.computed, unit);
+ double size = sp_style_css_size_px_to_units(query.font_size.computed, unit);
sp_font_selector_set_fontspec(fsel, fontspec, size );
setPreviewText (fontspec, phrase);
- if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) {
- if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) {
+ if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) {
+ if (query.text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) {
align_justify.set_active();
} else {
align_left.set_active();
}
- } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) {
+ } else if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) {
align_center.set_active();
} else {
align_right.set_active();
}
- if (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) {
+ if (query.writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) {
text_horizontal.set_active();
} else {
text_vertical.set_active();
}
double height;
- if (query->line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- else if (query->line_height.unit == SP_CSS_UNIT_PERCENT)
- height = query->line_height.value;
- else height = query->line_height.computed;
+ if (query.line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ else if (query.line_height.unit == SP_CSS_UNIT_PERCENT)
+ height = query.line_height.value;
+ else height = query.line_height.computed;
gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5));
gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) spacing_combo), sstr);
g_free(sstr);
- sp_style_unref(query);
}
blocked = false;
}
@@ -419,7 +418,7 @@ SPItem *TextEdit::getSelectedTextItem (void)
if (!SP_ACTIVE_DESKTOP)
return NULL;
- for (const GSList *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList();
+ for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList();
item != NULL;
item = item->next)
{
@@ -438,7 +437,7 @@ unsigned TextEdit::getSelectedTextCount (void)
unsigned int items = 0;
- for (const GSList *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList();
+ for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList();
item != NULL;
item = item->next)
{
@@ -543,7 +542,7 @@ void TextEdit::onApply()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
unsigned items = 0;
- const GSList *item_list = sp_desktop_selection(desktop)->itemList();
+ const GSList *item_list = desktop->getSelection()->itemList();
SPCSSAttr *css = fillTextStyle ();
sp_desktop_set_style(desktop, css, true);
@@ -569,7 +568,7 @@ void TextEdit::onApply()
} else if (items == 1) {
// exactly one text object; now set its text, too
- SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT(item)) {
updateObjectText (item);
}
@@ -583,7 +582,7 @@ void TextEdit::onApply()
}
// complete the transaction
- DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Set text style"));
apply_button.set_sensitive ( false );
@@ -658,7 +657,7 @@ void TextEdit::onStartOffsetChange(GtkTextBuffer * /*text_buffer*/, TextEdit *se
const gchar *sstr = gtk_combo_box_text_get_active_text(reinterpret_cast<GtkComboBoxText *>(self->startOffset));
tp->setAttribute("startOffset", sstr);
- DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "startOffset", SP_VERB_CONTEXT_TEXT, _("Set text style"));
+ DocumentUndo::maybeDone(SP_ACTIVE_DESKTOP->getDocument(), "startOffset", SP_VERB_CONTEXT_TEXT, _("Set text style"));
}
}
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 6dbcf4a05..233d99750 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -25,7 +25,8 @@
#include "document.h"
#include "document-undo.h"
-#include "desktop-handles.h"
+#include "desktop.h"
+
#include "transformation.h"
#include "align-and-distribute.h"
#include "inkscape.h"
@@ -47,16 +48,13 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-static void on_selection_changed(InkscapeApplication */*inkscape*/, Inkscape::Selection *selection, Transformation *daad)
+static void on_selection_changed(Inkscape::Selection *selection, Transformation *daad)
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
}
-static void on_selection_modified( InkscapeApplication */*inkscape*/,
- Inkscape::Selection *selection,
- guint /*flags*/,
- Transformation *daad )
+static void on_selection_modified(Inkscape::Selection *selection, Transformation *daad)
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
@@ -159,8 +157,8 @@ Transformation::Transformation()
}
// Connect to the global selection changed & modified signals
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
- g_signal_connect (G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (on_selection_modified), this);
+ _selChangeConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&on_selection_changed), this));
+ _selModifyConn = INKSCAPE.signal_selection_modified.connect(sigc::hide<1>(sigc::bind(sigc::ptr_fun(&on_selection_modified), this)));
_desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Transformation::setDesktop) );
_deskTrack.connect(GTK_WIDGET(gobj()));
@@ -170,7 +168,8 @@ Transformation::Transformation()
Transformation::~Transformation()
{
- sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
+ _selModifyConn.disconnect();
+ _selChangeConn.disconnect();
_desktopChangeConn.disconnect();
_deskTrack.disconnect();
}
@@ -207,7 +206,7 @@ void Transformation::layoutPageMove()
// Setting default unit to document unit
SPDesktop *dt = getDesktop();
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
if (nv->display_units) {
_units_move.setUnit(nv->display_units->abbr);
}
@@ -580,7 +579,7 @@ void Transformation::onSwitchPage(Gtk::Widget * /*page*/, guint pagenum)
void Transformation::onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum)
#endif
{
- updateSelection((PageType)pagenum, sp_desktop_selection(getDesktop()));
+ updateSelection((PageType)pagenum, getDesktop()->getSelection());
}
@@ -803,7 +802,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
}
}
- DocumentUndo::done( sp_desktop_document(selection->desktop()) , SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done( selection->desktop()->getDocument() , SP_VERB_DIALOG_TRANSFORM,
_("Move"));
}
@@ -865,7 +864,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
}
}
- DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
_("Scale"));
}
@@ -890,7 +889,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection)
}
}
- DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
_("Rotate"));
}
@@ -905,7 +904,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
double skewX = _scalar_skew_horizontal.getValue("%");
double skewY = _scalar_skew_vertical.getValue("%");
if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_item_skew_rel (item, 0.01*skewX, 0.01*skewY);
@@ -916,7 +915,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
|| (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON)
|| (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON)
|| (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
double skewX = tan(-angleX);
@@ -930,7 +929,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
double width = bbox->dimensions()[Geom::X];
double height = bbox->dimensions()[Geom::Y];
if (fabs(skewX*skewY - width*height) < Geom::EPSILON) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_item_skew_rel (item, skewX/height, skewY/width);
@@ -949,7 +948,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
double skewX = _scalar_skew_horizontal.getValue("%");
double skewY = _scalar_skew_vertical.getValue("%");
if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY);
@@ -960,7 +959,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
|| (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON)
|| (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON)
|| (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
double skewX = tan(-angleX);
@@ -970,7 +969,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
if (fabs(skewX*skewY - width*height) < Geom::EPSILON) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
sp_selection_skew_relative(selection, *center, skewX/height, skewY/width);
@@ -978,7 +977,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
}
}
- DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
_("Skew"));
}
@@ -994,7 +993,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
Geom::Affine displayed(a, b, c, d, e, f);
if (displayed.isSingular()) {
- sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
+ getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
@@ -1008,7 +1007,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform
}
- DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
_("Edit transformation matrix"));
}
diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h
index 1d24a0c94..89aa95d90 100644
--- a/src/ui/dialog/transformation.h
+++ b/src/ui/dialog/transformation.h
@@ -232,6 +232,9 @@ private:
Gtk::Button *applyButton;
Gtk::Button *resetButton;
Gtk::Button *cancelButton;
+
+ sigc::connection _selChangeConn;
+ sigc::connection _selModifyConn;
};
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index 53691cd37..a50a169eb 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -24,7 +24,7 @@
#include "document-undo.h"
#include "inkscape.h"
#include "verbs.h"
-#include "desktop-handles.h"
+
#include "util/signal-blocker.h"
#include "desktop.h"
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index 7ab6c78ba..99a4acc69 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -23,7 +23,7 @@
#include <gtkmm/stock.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "ui/dialog-events.h"
#include "document.h"
#include "document-undo.h"
@@ -71,10 +71,10 @@ XmlTree::XmlTree (void) :
xml_text_new_button ( _("New text node")),
xml_node_delete_button ( Q_("nodeAsInXMLdialogTooltip|Delete node")),
xml_node_duplicate_button ( _("Duplicate node")),
- unindent_node_button (Gtk::Stock::UNINDENT),
- indent_node_button (Gtk::Stock::INDENT),
- raise_node_button (Gtk::Stock::GO_UP),
- lower_node_button (Gtk::Stock::GO_DOWN),
+ unindent_node_button(),
+ indent_node_button(),
+ raise_node_button(),
+ lower_node_button(),
attr_toolbar(),
xml_attribute_delete_button (_("Delete attribute")),
text_container (),
@@ -149,21 +149,29 @@ XmlTree::XmlTree (void) :
tree_toolbar.add(separator2);
+ unindent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
+ sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-less")))));
unindent_node_button.set_label(_("Unindent node"));
unindent_node_button.set_tooltip_text(_("Unindent node"));
unindent_node_button.set_sensitive(false);
tree_toolbar.add(unindent_node_button);
+ indent_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
+ sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("format-indent-more")))));
indent_node_button.set_label(_("Indent node"));
indent_node_button.set_tooltip_text(_("Indent node"));
indent_node_button.set_sensitive(false);
tree_toolbar.add(indent_node_button);
+ raise_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
+ sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-up")))));
raise_node_button.set_label(_("Raise node"));
raise_node_button.set_tooltip_text(_("Raise node"));
raise_node_button.set_sensitive(false);
tree_toolbar.add(raise_node_button);
+ lower_node_button.set_icon_widget(*Gtk::manage(Glib::wrap(
+ sp_icon_new (Inkscape::ICON_SIZE_LARGE_TOOLBAR, INKSCAPE_ICON("go-down")))));
lower_node_button.set_label(_("Lower node"));
lower_node_button.set_tooltip_text(_("Lower node"));
lower_node_button.set_sensitive(false);
@@ -360,10 +368,10 @@ void XmlTree::set_tree_desktop(SPDesktop *desktop)
}
current_desktop = desktop;
if (desktop) {
- sel_changed_connection = sp_desktop_selection(desktop)->connectChanged(sigc::hide(sigc::mem_fun(this, &XmlTree::on_desktop_selection_changed)));
+ sel_changed_connection = desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &XmlTree::on_desktop_selection_changed)));
document_replaced_connection = desktop->connectDocumentReplaced(sigc::mem_fun(this, &XmlTree::on_document_replaced));
- set_tree_document(sp_desktop_document(desktop));
+ set_tree_document(desktop->getDocument());
} else {
set_tree_document(NULL);
}
@@ -472,7 +480,7 @@ Inkscape::XML::Node *XmlTree::get_dt_select()
if (!current_desktop) {
return NULL;
}
- return sp_desktop_selection(current_desktop)->singleRepr();
+ return current_desktop->getSelection()->singleRepr();
}
@@ -483,7 +491,7 @@ void XmlTree::set_dt_select(Inkscape::XML::Node *repr)
return;
}
- Inkscape::Selection *selection = sp_desktop_selection(current_desktop);
+ Inkscape::Selection *selection = current_desktop->getSelection();
SPObject *object;
if (repr) {
@@ -493,7 +501,7 @@ void XmlTree::set_dt_select(Inkscape::XML::Node *repr)
repr = repr->parent();
} // end of while loop
- object = sp_desktop_document(current_desktop)->getObjectByRepr(repr);
+ object = current_desktop->getDocument()->getObjectByRepr(repr);
} else {
object = NULL;
}
@@ -827,7 +835,7 @@ void XmlTree::on_document_replaced(SPDesktop *dt, SPDocument *doc)
if (current_desktop)
sel_changed_connection.disconnect();
- sel_changed_connection = sp_desktop_selection(dt)->connectChanged(sigc::hide(sigc::mem_fun(this, &XmlTree::on_desktop_selection_changed)));
+ sel_changed_connection = dt->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &XmlTree::on_desktop_selection_changed)));
set_tree_document(doc);
}
diff --git a/src/ui/draw-anchor.cpp b/src/ui/draw-anchor.cpp
index 84c919018..6b9a88ed7 100644
--- a/src/ui/draw-anchor.cpp
+++ b/src/ui/draw-anchor.cpp
@@ -15,7 +15,6 @@
#include "ui/draw-anchor.h"
#include "desktop.h"
-#include "desktop-handles.h"
#include "ui/tools/tool-base.h"
#include "ui/tools/lpe-tool.h"
#include "display/sodipodi-ctrl.h"
@@ -45,7 +44,7 @@ SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve
a->start = start;
a->active = FALSE;
a->dp = delta;
- a->ctrl = ControlManager::getManager().createControl(sp_desktop_controls(&dc->getDesktop()), Inkscape::CTRL_TYPE_ANCHOR);
+ a->ctrl = ControlManager::getManager().createControl(dc->getDesktop().getControls(), Inkscape::CTRL_TYPE_ANCHOR);
SP_CTRL(a->ctrl)->moveto(delta);
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 7830a8de1..87438ac01 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -29,7 +29,7 @@
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "extension/db.h"
#include "extension/effect.h"
#include "extension/input.h"
@@ -38,7 +38,7 @@
#include "path-prefix.h"
#include "shortcuts.h"
#include "document.h"
-#include "desktop-handles.h"
+
#include "ui/interface.h"
#include "desktop.h"
#include "selection.h"
@@ -270,7 +270,7 @@ sp_create_window(SPViewWidget *vw, bool editable)
// needed because the first ACTIVATE_DESKTOP was sent when there was no window yet
if ( SP_IS_DESKTOP_WIDGET(vw) ) {
- inkscape_reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop);
+ INKSCAPE.reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop);
}
}
@@ -318,13 +318,13 @@ sp_ui_close_view(GtkWidget */*widget*/)
// If closing the last document, open a new document so Inkscape doesn't quit.
std::list<SPDesktop *> desktops;
- inkscape_get_all_desktops(desktops);
+ INKSCAPE.get_all_desktops(desktops);
if (desktops.size() == 1) {
Glib::ustring templateUri = sp_file_default_template_uri();
SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true );
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
}
dt->change_document(doc);
sp_namedview_window_from_document(dt);
@@ -921,7 +921,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I
GtkWidget *sp_ui_main_menubar(Inkscape::UI::View::View *view)
{
GtkWidget *mbar = gtk_menu_bar_new();
- sp_ui_build_dyn_menus(inkscape_get_menus(INKSCAPE), mbar, view);
+ sp_ui_build_dyn_menus(INKSCAPE.get_menus(), mbar, view);
return mbar;
}
@@ -1232,12 +1232,12 @@ sp_ui_drag_data_received(GtkWidget *widget,
SPObject *new_obj = NULL;
new_obj = desktop->currentLayer()->appendChildRepr(newgroup);
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection->set(SP_ITEM(new_obj));
// move to mouse pointer
{
- sp_desktop_document(desktop)->ensureUpToDate();
+ desktop->getDocument()->ensureUpToDate();
Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
@@ -1815,7 +1815,7 @@ void ContextMenu::SelectSameStrokeColor(void)
void ContextMenu::SelectSameStrokeStyle(void)
{
- sp_select_same_stroke_style(_desktop);
+ sp_select_same_fill_stroke_style(_desktop, false, false, true);
}
void ContextMenu::SelectSameObjectType(void)
@@ -2117,13 +2117,13 @@ void ContextMenu::ImageEdit(void)
void ContextMenu::ImageTraceBitmap(void)
{
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
_desktop->_dlg_mgr->showDialog("Trace");
}
void ContextMenu::ImageTracePixelArt(void)
{
- inkscape_dialogs_unhide();
+ INKSCAPE.dialogs_unhide();
_desktop->_dlg_mgr->showDialog("PixelArt");
}
diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp
index ca550502d..0a6c792dc 100644
--- a/src/ui/object-edit.cpp
+++ b/src/ui/object-edit.cpp
@@ -28,7 +28,7 @@
#include "preferences.h"
#include "style.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "sp-namedview.h"
#include "live_effects/effect.h"
#include "sp-pattern.h"
@@ -154,12 +154,9 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp);
- rect->rx._set = rect->ry._set = true;
-
+ rect->rx = rect->ry = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp);
} else {
- rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0);
- rect->rx._set = true;
+ rect->rx = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0);
}
update_knot();
@@ -207,20 +204,17 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry,
// resulting in a perfect circle (and not an ellipse)
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp);
- rect->ry._set = rect->rx._set = true;
+ rect->rx = rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp);
} else {
if (!rect->rx._set || rect->rx.computed == 0) {
- rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed,
- 0.0,
- MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
+ rect->ry = CLAMP(s[Geom::Y] - rect->y.computed,
+ 0.0,
+ MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
} else {
- rect->ry.computed = CLAMP(s[Geom::Y] - rect->y.computed,
- 0.0,
- rect->height.computed / 2.0);
+ rect->ry = CLAMP(s[Geom::Y] - rect->y.computed,
+ 0.0,
+ rect->height.computed / 2.0);
}
-
- rect->ry._set = true;
}
update_knot();
@@ -250,12 +244,10 @@ static void sp_rect_clamp_radii(SPRect *rect)
{
// clamp rounding radii so that they do not exceed width/height
if (2 * rect->rx.computed > rect->width.computed) {
- rect->rx.computed = 0.5 * rect->width.computed;
- rect->rx._set = true;
+ rect->rx = 0.5 * rect->width.computed;
}
if (2 * rect->ry.computed > rect->height.computed) {
- rect->ry.computed = 0.5 * rect->height.computed;
- rect->ry._set = true;
+ rect->ry = 0.5 * rect->height.computed;
}
}
@@ -296,44 +288,45 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
- miny = s[Geom::Y] - origin[Geom::Y];
- rect->height.computed = MAX(h_orig + minx / ratio, 0);
+ // Dead assignment: Value stored to 'miny' is never read
+ //miny = s[Geom::Y] - origin[Geom::Y];
+ rect->height = MAX(h_orig + minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
- miny = s[Geom::Y] - origin[Geom::Y];
- rect->height.computed = MAX(h_orig, 0);
+ // Dead assignment: Value stored to 'miny' is never read
+ //miny = s[Geom::Y] - origin[Geom::Y];
+ rect->height = MAX(h_orig, 0);
}
- rect->width.computed = MAX(w_orig + minx, 0);
+ rect->width = MAX(w_orig + minx, 0);
} else {
// snap to vertical or diagonal
if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
- minx = s[Geom::X] - origin[Geom::X];
+ // Dead assignment: Value stored to 'minx' is never read
+ //minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->width.computed = MAX(w_orig + miny * ratio, 0);
+ rect->width = MAX(w_orig + miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
- minx = s[Geom::X] - origin[Geom::X];
+ // Dead assignment: Value stored to 'minx' is never read
+ //minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->width.computed = MAX(w_orig, 0);
+ rect->width = MAX(w_orig, 0);
}
- rect->height.computed = MAX(h_orig + miny, 0);
+ rect->height = MAX(h_orig + miny, 0);
}
- rect->width._set = rect->height._set = true;
-
} else {
// move freely
s = snap_knot_position(p, state);
- rect->width.computed = MAX(s[Geom::X] - rect->x.computed, 0);
- rect->height.computed = MAX(s[Geom::Y] - rect->y.computed, 0);
- rect->width._set = rect->height._set = true;
+ rect->width = MAX(s[Geom::X] - rect->x.computed, 0);
+ rect->height = MAX(s[Geom::Y] - rect->y.computed, 0);
}
sp_rect_clamp_radii(rect);
@@ -388,53 +381,54 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
- miny = s[Geom::Y] - origin[Geom::Y];
- rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
- rect->height.computed = MAX(h_orig - minx / ratio, 0);
+ // Dead assignment: Value stored to 'miny' is never read
+ //miny = s[Geom::Y] - origin[Geom::Y];
+ rect->y = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
+ rect->height = MAX(h_orig - minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
- miny = s[Geom::Y] - origin[Geom::Y];
- rect->y.computed = MIN(origin[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig, 0);
+ // Dead assignment: Value stored to 'miny' is never read
+ //miny = s[Geom::Y] - origin[Geom::Y];
+ rect->y = MIN(origin[Geom::Y], opposite_y);
+ rect->height = MAX(h_orig, 0);
}
- rect->x.computed = MIN(s[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig - minx, 0);
+ rect->x = MIN(s[Geom::X], opposite_x);
+ rect->width = MAX(w_orig - minx, 0);
} else {
// snap to vertical or diagonal
if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
- minx = s[Geom::X] - origin[Geom::X];
+ // Dead assignment: Value stored to 'minx' is never read
+ //minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x);
- rect->width.computed = MAX(w_orig - miny * ratio, 0);
+ rect->x = MIN(origin[Geom::X] + miny * ratio, opposite_x);
+ rect->width = MAX(w_orig - miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
- minx = s[Geom::X] - origin[Geom::X];
+ // Dead assignment: Value stored to 'minx' is never read
+ //minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(origin[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig, 0);
+ rect->x = MIN(origin[Geom::X], opposite_x);
+ rect->width = MAX(w_orig, 0);
}
- rect->y.computed = MIN(s[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig - miny, 0);
+ rect->y = MIN(s[Geom::Y], opposite_y);
+ rect->height = MAX(h_orig - miny, 0);
}
- rect->width._set = rect->height._set = rect->x._set = rect->y._set = true;
-
} else {
// move freely
s = snap_knot_position(p, state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
- rect->x.computed = MIN(s[Geom::X], opposite_x);
- rect->width.computed = MAX(w_orig - minx, 0);
- rect->y.computed = MIN(s[Geom::Y], opposite_y);
- rect->height.computed = MAX(h_orig - miny, 0);
- rect->width._set = rect->height._set = rect->x._set = rect->y._set = true;
+ rect->x = MIN(s[Geom::X], opposite_x);
+ rect->y = MIN(s[Geom::Y], opposite_y);
+ rect->width = MAX(w_orig - minx, 0);
+ rect->height = MAX(h_orig - miny, 0);
}
sp_rect_clamp_radii(rect);
@@ -909,10 +903,10 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p, state);
- ge->rx.computed = fabs( ge->cx.computed - s[Geom::X] );
+ ge->rx = fabs( ge->cx.computed - s[Geom::X] );
if ( state & GDK_CONTROL_MASK ) {
- ge->ry.computed = ge->rx.computed;
+ ge->ry = ge->rx.computed;
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -934,7 +928,7 @@ ArcKnotHolderEntityRX::knot_click(unsigned int state)
g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
- ge->ry.computed = ge->rx.computed;
+ ge->ry = ge->rx.computed;
ge->updateRepr();
}
}
@@ -947,10 +941,10 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p, state);
- ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] );
+ ge->ry = fabs( ge->cy.computed - s[Geom::Y] );
if ( state & GDK_CONTROL_MASK ) {
- ge->rx.computed = ge->ry.computed;
+ ge->rx = ge->ry.computed;
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -972,7 +966,7 @@ ArcKnotHolderEntityRY::knot_click(unsigned int state)
g_assert(ge != NULL);
if (state & GDK_CONTROL_MASK) {
- ge->rx.computed = ge->ry.computed;
+ ge->rx = ge->ry.computed;
ge->updateRepr();
}
}
diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp
index 0b9fc24c5..aec5cde27 100644
--- a/src/ui/shape-editor.cpp
+++ b/src/ui/shape-editor.cpp
@@ -14,7 +14,7 @@
#include <string.h>
#include <glibmm/i18n.h>
-#include "desktop-handles.h"
+#include "desktop.h"
#include "document.h"
#include "gc-anchored.h"
#include "knotholder.h"
@@ -146,7 +146,7 @@ void ShapeEditor::set_item(SPItem *item, bool keep_knotholder) {
void ShapeEditor::reset_item(bool keep_knotholder)
{
if (knotholder) {
- SPObject *obj = sp_desktop_document(desktop)->getObjectByRepr(knotholder_listener_attached_for); /// note that it is not certain that this is an SPItem; it could be a LivePathEffectObject.
+ SPObject *obj = desktop->getDocument()->getObjectByRepr(knotholder_listener_attached_for); /// note that it is not certain that this is an SPItem; it could be a LivePathEffectObject.
set_item(SP_ITEM(obj), keep_knotholder);
}
}
diff --git a/src/ui/tool-factory.cpp b/src/ui/tool-factory.cpp
new file mode 100644
index 000000000..700bd40ce
--- /dev/null
+++ b/src/ui/tool-factory.cpp
@@ -0,0 +1,102 @@
+/*
+ * Factory for ToolBase tree
+ *
+ * Authors:
+ * Markus Engel
+ *
+ * Copyright (C) 2013 Authors
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "tool-factory.h"
+
+#include "ui/tools/arc-tool.h"
+#include "ui/tools/box3d-tool.h"
+#include "ui/tools/calligraphic-tool.h"
+#include "ui/tools/connector-tool.h"
+#include "ui/tools/dropper-tool.h"
+#include "ui/tools/eraser-tool.h"
+#include "ui/tools/flood-tool.h"
+#include "ui/tools/gradient-tool.h"
+#include "ui/tools/lpe-tool.h"
+#include "ui/tools/measure-tool.h"
+#include "ui/tools/mesh-tool.h"
+#include "ui/tools/node-tool.h"
+#include "ui/tools/pencil-tool.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/rect-tool.h"
+#include "ui/tools/select-tool.h"
+#include "ui/tools/spiral-tool.h"
+#include "ui/tools/spray-tool.h"
+#include "ui/tools/star-tool.h"
+#include "ui/tools/text-tool.h"
+#include "ui/tools/tool-base.h"
+#include "ui/tools/tweak-tool.h"
+#include "ui/tools/zoom-tool.h"
+
+using namespace Inkscape::UI::Tools;
+
+ToolBase *ToolFactory::createObject(std::string const& id)
+{
+ ToolBase *tool = NULL;
+
+ if (id == "/tools/shapes/arc")
+ tool = new ArcTool;
+ else if (id == "/tools/shapes/3dbox")
+ tool = new Box3dTool;
+ else if (id == "/tools/calligraphic")
+ tool = new CalligraphicTool;
+ else if (id == "/tools/connector")
+ tool = new ConnectorTool;
+ else if (id == "/tools/dropper")
+ tool = new DropperTool;
+ else if (id == "/tools/eraser")
+ tool = new EraserTool;
+ else if (id == "/tools/paintbucket")
+ tool = new FloodTool;
+ else if (id == "/tools/gradient")
+ tool = new GradientTool;
+ else if (id == "/tools/lpetool")
+ tool = new LpeTool;
+ else if (id == "/tools/measure")
+ tool = new MeasureTool;
+ else if (id == "/tools/mesh")
+ tool = new MeshTool;
+ else if (id == "/tools/nodes")
+ tool = new NodeTool;
+ else if (id == "/tools/freehand/pencil")
+ tool = new PencilTool;
+ else if (id == "/tools/freehand/pen")
+ tool = new PenTool;
+ else if (id == "/tools/shapes/rect")
+ tool = new RectTool;
+ else if (id == "/tools/select")
+ tool = new SelectTool;
+ else if (id == "/tools/shapes/spiral")
+ tool = new SpiralTool;
+ else if (id == "/tools/spray")
+ tool = new SprayTool;
+ else if (id == "/tools/shapes/star")
+ tool = new StarTool;
+ else if (id == "/tools/text")
+ tool = new TextTool;
+ else if (id == "/tools/tweak")
+ tool = new TweakTool;
+ else if (id == "/tools/zoom")
+ tool = new ZoomTool;
+ else
+ fprintf(stderr, "WARNING: unknown tool: %s", id.c_str());
+
+ return tool;
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/tool-factory.h b/src/ui/tool-factory.h
index 726706732..3b041fec5 100644
--- a/src/ui/tool-factory.h
+++ b/src/ui/tool-factory.h
@@ -1,6 +1,6 @@
-/** @file
+/*
* Factory for ToolBase tree
- *//*
+ *
* Authors:
* Markus Engel
*
@@ -11,7 +11,7 @@
#ifndef TOOL_FACTORY_SEEN
#define TOOL_FACTORY_SEEN
-#include "factory.h"
+#include <string>
namespace Inkscape {
namespace UI {
@@ -23,7 +23,9 @@ class ToolBase;
}
}
-typedef Singleton< Factory<Inkscape::UI::Tools::ToolBase> > ToolFactory;
+struct ToolFactory {
+ static Inkscape::UI::Tools::ToolBase *createObject(std::string const& id);
+};
#endif
diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp
index e98c7b2a2..bcf5c9fce 100644
--- a/src/ui/tool/control-point.cpp
+++ b/src/ui/tool/control-point.cpp
@@ -11,7 +11,7 @@
#include <gdkmm.h>
#include <2geom/point.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/sp-canvas.h"
#include "display/snap-indicator.h"
#include "ui/tools/tool-base.h"
@@ -74,7 +74,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAncho
_lurking(false)
{
_canvas_item = sp_canvas_item_new(
- group ? group : sp_desktop_controls(_desktop), SP_TYPE_CTRL,
+ group ? group : _desktop->getControls(), SP_TYPE_CTRL,
"anchor", (SPAnchorType) anchor, "size", (gdouble) pixbuf->get_width(),
"shape", SP_CTRL_SHAPE_BITMAP, "pixbuf", pixbuf->gobj(),
"filled", TRUE, "fill_color", _cset.normal.fill,
@@ -93,7 +93,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAncho
_position(initial_pos),
_lurking(false)
{
- _canvas_item = ControlManager::getManager().createControl(group ? group : sp_desktop_controls(_desktop), type);
+ _canvas_item = ControlManager::getManager().createControl(group ? group : _desktop->getControls(), type);
g_object_set(_canvas_item,
"anchor", anchor,
"filled", TRUE, "fill_color", _cset.normal.fill,
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index 013553410..49c949107 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -94,8 +94,22 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event)
if(!_pm.isBSpline(false)){
first->front()->move(first->front()->position() + offset0);
second->back()->move(second->back()->position() + offset1);
- }else if(weight>=0.8 && held_shift(*event))second->back()->move(new_pos);
- else if(weight<=0.2 && held_shift(*event))first->front()->move(new_pos);
+ }else if(weight>=0.8){
+ if(held_shift(*event)){
+ second->back()->move(new_pos);
+ } else {
+ second->move(second->position() + delta);
+ }
+ }else if(weight<=0.2){
+ if(held_shift(*event)){
+ first->back()->move(new_pos);
+ } else {
+ first->move(first->position() + delta);
+ }
+ }else{
+ first->move(first->position() + delta);
+ second->move(second->position() + delta);
+ }
_pm.update();
}
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index d7b35c974..f53cef5f4 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -14,7 +14,7 @@
#include "node.h"
#include <glibmm/i18n.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "live_effects/lpeobject.h"
@@ -820,9 +820,9 @@ void MultiPathManipulator::_commit(CommitEvent cps)
_selection.signal_update.emit();
invokeForAll(&PathManipulator::writeXML);
if (key) {
- DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason);
+ DocumentUndo::maybeDone(_desktop->getDocument(), key, SP_VERB_CONTEXT_NODE, reason);
} else {
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason);
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_NODE, reason);
}
signal_coords_changed.emit();
}
@@ -831,7 +831,7 @@ void MultiPathManipulator::_commit(CommitEvent cps)
void MultiPathManipulator::_done(gchar const *reason, bool alert_LPE) {
invokeForAll(&PathManipulator::update, alert_LPE);
invokeForAll(&PathManipulator::writeXML);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason);
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_NODE, reason);
signal_coords_changed.emit();
}
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 8c22f7c6e..eeea47e4d 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -17,7 +17,7 @@
#include "display/sp-canvas.h"
#include "display/sp-canvas-util.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "preferences.h"
#include "snap.h"
#include "snap-preferences.h"
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 8b99c33b8..c8b986824 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -23,7 +23,7 @@
#include <glibmm/i18n.h>
#include "ui/tool/path-manipulator.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/sp-canvas.h"
#include "display/sp-canvas-util.h"
#include "display/curve.h"
@@ -972,6 +972,10 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d
NodeList &list = NodeList::get(first);
NodeList::iterator second = first.next();
if (!second) throw std::invalid_argument("Subdivide after last node in open path");
+ if (first->type() == NODE_SYMMETRIC)
+ first->setType(NODE_SMOOTH, false);
+ if (second->type() == NODE_SYMMETRIC)
+ second->setType(NODE_SMOOTH, false);
// We need to insert the segment after 'first'. We can't simply use 'second'
// as the point of insertion, because when 'first' is the last node of closed path,
@@ -1617,13 +1621,13 @@ void PathManipulator::_removeNodesFromSelection()
void PathManipulator::_commit(Glib::ustring const &annotation)
{
writeXML();
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data());
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_NODE, annotation.data());
}
void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key)
{
writeXML();
- DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE,
+ DocumentUndo::maybeDone(_desktop->getDocument(), key, SP_VERB_CONTEXT_NODE,
annotation.data());
}
diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp
index bdeacadc9..e4e701785 100644
--- a/src/ui/tool/selector.cpp
+++ b/src/ui/tool/selector.cpp
@@ -11,7 +11,7 @@
#include "control-point.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/sodipodi-ctrlrect.h"
#include "ui/tools/tool-base.h"
#include "preferences.h"
@@ -37,7 +37,7 @@ public:
_cancel(false)
{
setVisible(false);
- _rubber = static_cast<CtrlRect*>(sp_canvas_item_new(sp_desktop_controls(_desktop),
+ _rubber = static_cast<CtrlRect*>(sp_canvas_item_new(_desktop->getControls(),
SP_TYPE_CTRLRECT, NULL));
sp_canvas_item_hide(_rubber);
}
@@ -100,7 +100,7 @@ private:
Selector::Selector(SPDesktop *d)
: Manipulator(d)
- , _dragger(new SelectorPoint(d, sp_desktop_controls(d), this))
+ , _dragger(new SelectorPoint(d, d->getControls(), this))
{
_dragger->setVisible(false);
}
diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp
index 7d5c9bf0c..da2a54989 100644
--- a/src/ui/tool/transform-handle-set.cpp
+++ b/src/ui/tool/transform-handle-set.cpp
@@ -15,7 +15,7 @@
#include <glib/gi18n.h>
#include <2geom/transforms.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/sodipodi-ctrlrect.h"
#include "preferences.h"
#include "snap.h"
@@ -686,7 +686,7 @@ TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group)
, _in_transform(false)
, _visible(true)
{
- _trans_outline = static_cast<CtrlRect*>(sp_canvas_item_new(sp_desktop_controls(_desktop),
+ _trans_outline = static_cast<CtrlRect*>(sp_canvas_item_new(_desktop->getControls(),
SP_TYPE_CTRLRECT, NULL));
sp_canvas_item_hide(_trans_outline);
_trans_outline->setDashed(true);
diff --git a/src/ui/tools-switch.cpp b/src/ui/tools-switch.cpp
index 47b9d2832..11313f550 100644
--- a/src/ui/tools-switch.cpp
+++ b/src/ui/tools-switch.cpp
@@ -16,9 +16,9 @@
#include <cstring>
#include <string>
-#include "inkscape-private.h"
+#include "inkscape.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include <glibmm/i18n.h>
#include <xml/repr.h>
@@ -159,7 +159,7 @@ tools_switch(SPDesktop *dt, int num)
/* fixme: This is really ugly hack. We should bind and unbind class methods */
/* First 4 tools use guides, first is undefined but we don't care */
dt->activate_guides(num < 5);
- inkscape_eventcontext_set(dt->getEventContext());
+ INKSCAPE.eventcontext_set(dt->getEventContext());
}
void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p)
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index 9c3195a42..c6a9bb23a 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -29,7 +29,7 @@
#include "document-undo.h"
#include "sp-namedview.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "snap.h"
#include "pixmaps/cursor-ellipse.xpm"
#include "xml/repr.h"
@@ -48,20 +48,10 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createArcContext() {
- return new ArcTool();
- }
-
- bool arcContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/arc", createArcContext);
-}
-
const std::string& ArcTool::getPrefsPath() {
return ArcTool::prefsPath;
}
@@ -109,11 +99,11 @@ void ArcTool::selection_changed(Inkscape::Selection* selection) {
void ArcTool::setup() {
ToolBase::setup();
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
@@ -151,7 +141,7 @@ bool ArcTool::item_handler(SPItem* item, GdkEvent* event) {
bool ArcTool::root_handler(GdkEvent* event) {
static bool dragging;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -442,16 +432,16 @@ void ArcTool::finishItem() {
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(this->arc);
+ desktop->getSelection()->set(this->arc);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, _("Create ellipse"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ARC, _("Create ellipse"));
this->arc = NULL;
}
}
void ArcTool::cancel() {
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
if (this->arc != NULL) {
@@ -466,7 +456,7 @@ void ArcTool::cancel() {
desktop->canvas->endForcedFullRedraws();
- DocumentUndo::cancel(sp_desktop_document(desktop));
+ DocumentUndo::cancel(desktop->getDocument());
}
}
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 0a20a0842..538e0c7e2 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -26,7 +26,7 @@
#include "sp-namedview.h"
#include "selection.h"
#include "selection-chemistry.h"
-#include "desktop-handles.h"
+
#include "snap.h"
#include "display/curve.h"
#include "display/sp-canvas-item.h"
@@ -52,20 +52,10 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createBox3dTool() {
- return new Box3dTool();
- }
-
- bool Box3dToolRegistered = ToolFactory::instance().registerObject("/tools/shapes/3dbox", createBox3dTool);
-}
-
const std::string& Box3dTool::getPrefsPath() {
return Box3dTool::prefsPath;
}
@@ -145,17 +135,17 @@ void Box3dTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
this->sel_changed_connection.disconnect();
- this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
+ this->sel_changed_connection = this->desktop->getSelection()->connectChanged(
sigc::mem_fun(this, &Box3dTool::selection_changed)
);
- this->_vpdrag = new Box3D::VPDrag(sp_desktop_document(this->desktop));
+ this->_vpdrag = new Box3D::VPDrag(this->desktop->getDocument());
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -195,8 +185,8 @@ bool Box3dTool::item_handler(SPItem* item, GdkEvent* event) {
bool Box3dTool::root_handler(GdkEvent* event) {
static bool dragging;
- SPDocument *document = sp_desktop_document (desktop);
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ SPDocument *document = desktop->getDocument();
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
@@ -466,7 +456,7 @@ bool Box3dTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
//TODO: make dragging escapable by Esc
break;
@@ -589,7 +579,7 @@ void Box3dTool::finishItem() {
this->extruded = false;
if (this->box3d != NULL) {
- SPDocument *doc = sp_desktop_document(this->desktop);
+ SPDocument *doc = this->desktop->getDocument();
if (!doc || !doc->getCurrentPersp3D()) {
return;
@@ -604,8 +594,8 @@ void Box3dTool::finishItem() {
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(this->box3d);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
+ desktop->getSelection()->set(this->box3d);
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_3DBOX,
_("Create 3D box"));
this->box3d = NULL;
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index d297fe5e1..15e6527a3 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -47,7 +47,7 @@
#include "selection.h"
#include "desktop.h"
#include "desktop-events.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "message-context.h"
#include "preferences.h"
@@ -82,22 +82,12 @@ using Inkscape::DocumentUndo;
#define DYNA_MIN_WIDTH 1.0e-6
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding);
-namespace {
- ToolBase* createCalligraphicContext() {
- return new CalligraphicTool();
- }
-
- bool calligraphicContextRegistered = ToolFactory::instance().registerObject("/tools/calligraphic", createCalligraphicContext);
-}
-
const std::string& CalligraphicTool::getPrefsPath() {
return CalligraphicTool::prefsPath;
}
@@ -141,7 +131,7 @@ void CalligraphicTool::setup() {
this->cal1 = new SPCurve();
this->cal2 = new SPCurve();
- this->currentshape = sp_canvas_item_new(sp_desktop_sketch(this->desktop), SP_TYPE_CANVAS_BPATH, NULL);
+ this->currentshape = sp_canvas_item_new(this->desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->currentshape), DDC_RED_RGBA, SP_WIND_RULE_EVENODD);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->currentshape), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -155,7 +145,7 @@ void CalligraphicTool::setup() {
SPCurve *c = new SPCurve(path);
- this->hatch_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
+ this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c);
c->unref();
@@ -373,7 +363,7 @@ void CalligraphicTool::brush() {
double R, G, B, A;
Geom::IntRect area = Geom::IntRect::from_xywh(brush_w.floor(), Geom::IntPoint(1, 1));
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
- sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(this)->desktop)), s, area);
+ sp_canvas_arena_render_surface(SP_CANVAS_ARENA(this->desktop->getDrawing()), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
cairo_surface_destroy(s);
double max = MAX (MAX (R, G), B);
@@ -506,7 +496,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
if (event->motion.state & GDK_CONTROL_MASK) { // hatching - sense the item
- SPItem *selected = sp_desktop_selection(desktop)->singleItem();
+ SPItem *selected = desktop->getSelection()->singleItem();
if (selected && (SP_IS_SHAPE(selected) || SP_IS_TEXT(selected))) {
// One item selected, and it's a path;
// let's try to track it as a guide
@@ -940,14 +930,14 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
g_free(str);
if (unionize) {
- sp_desktop_selection(desktop)->add(this->repr);
- sp_selected_path_union_skip_undo(sp_desktop_selection(desktop), desktop);
+ desktop->getSelection()->add(this->repr);
+ sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
} else if (subtract) {
- sp_desktop_selection(desktop)->add(this->repr);
- sp_selected_path_diff_skip_undo(sp_desktop_selection(desktop), desktop);
+ desktop->getSelection()->add(this->repr);
+ sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop);
} else {
if (this->keep_selected) {
- sp_desktop_selection(desktop)->set(this->repr);
+ desktop->getSelection()->set(this->repr);
}
}
@@ -973,7 +963,7 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
this->repr = NULL;
}
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_CALLIGRAPHIC,
_("Draw calligraphic stroke"));
}
@@ -1142,7 +1132,7 @@ void CalligraphicTool::fit_and_split(bool release) {
if (!release) {
g_assert(!this->currentcurve->is_empty());
- SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop),
+ SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(),
SP_TYPE_CANVAS_BPATH,
NULL);
SPCurve *curve = this->currentcurve->copy();
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 7b5c84c16..d76b0d142 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -79,7 +79,7 @@
#include "svg/svg.h"
#include "desktop.h"
#include "desktop-style.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "message-context.h"
@@ -109,8 +109,6 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
@@ -147,14 +145,6 @@ static Inkscape::XML::NodeEventVector layer_repr_events = {
NULL /* order_changed */
};
-namespace {
- ToolBase* createConnectorContext() {
- return new ConnectorTool();
- }
-
- bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext);
-}
-
const std::string& ConnectorTool::getPrefsPath() {
return ConnectorTool::prefsPath;
}
@@ -223,7 +213,7 @@ ConnectorTool::~ConnectorTool() {
void ConnectorTool::setup() {
ToolBase::setup();
- this->selection = sp_desktop_selection(this->desktop);
+ this->selection = this->desktop->getSelection();
this->sel_changed_connection.disconnect();
this->sel_changed_connection = this->selection->connectChanged(
@@ -231,7 +221,7 @@ void ConnectorTool::setup() {
);
/* Create red bpath */
- this->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL);
+ this->red_bpath = sp_canvas_bpath_new(this->desktop->getSketch(), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color,
1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->red_bpath), 0x00000000,
@@ -659,7 +649,7 @@ bool ConnectorTool::_handleButtonRelease(GdkEventButton const &revent) {
bool ret = false;
if ( revent.button == 1 && !this->space_panning ) {
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
SnapManager &m = desktop->namedview->snap_manager;
Geom::Point const event_w(revent.x, revent.y);
@@ -729,7 +719,7 @@ bool ConnectorTool::_handleKeyPress(guint const keyval) {
break;
case GDK_KEY_Escape:
if (this->state == SP_CONNECTOR_CONTEXT_REROUTING) {
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
this->_reroutingFinish(NULL);
@@ -754,7 +744,7 @@ bool ConnectorTool::_handleKeyPress(guint const keyval) {
}
void ConnectorTool::_reroutingFinish(Geom::Point *const p) {
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
// Clear the temporary path:
this->red_curve->reset();
@@ -812,7 +802,7 @@ void ConnectorTool::_setSubsequentPoint(Geom::Point const p) {
Avoid::Point dst(d[Geom::X], d[Geom::Y]);
if (!this->newConnRef) {
- Avoid::Router *router = sp_desktop_document(desktop)->router;
+ Avoid::Router *router = desktop->getDocument()->router;
this->newConnRef = new Avoid::ConnRef(router);
this->newConnRef->setEndpoint(Avoid::VertID::src, src);
if (this->isOrthogonal)
@@ -876,7 +866,7 @@ void ConnectorTool::_flushWhite(SPCurve *gc) {
/* Now we have to go back to item coordinates at last */
c->transform(this->desktop->dt2doc());
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
if ( c && !c->is_empty() ) {
@@ -1304,14 +1294,14 @@ bool cc_item_is_connector(SPItem *item)
void cc_selection_set_avoid(bool const set_avoid)
{
- SPDesktop *desktop = inkscape_active_desktop();
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL) {
return;
}
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *document = desktop->getDocument();
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
GSList *l = const_cast<GSList *>(selection->itemList());
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 6c55f7484..bda9d8e8a 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -34,7 +34,7 @@
#include "sp-namedview.h"
#include "sp-cursor.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "document.h"
#include "document-undo.h"
@@ -52,20 +52,10 @@ using Inkscape::DocumentUndo;
static GdkCursor *cursor_dropper_fill = NULL;
static GdkCursor *cursor_dropper_stroke = NULL;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createDropperContext() {
- return new DropperTool();
- }
-
- bool dropperContextRegistered = ToolFactory::instance().registerObject("/tools/dropper", createDropperContext);
-}
-
const std::string& DropperTool::getPrefsPath() {
return DropperTool::prefsPath;
}
@@ -73,7 +63,7 @@ const std::string& DropperTool::getPrefsPath() {
const std::string DropperTool::prefsPath = "/tools/dropper";
DropperTool::DropperTool()
- : ToolBase(cursor_dropper_f_xpm, 7, 7)
+ : ToolBase(cursor_dropper_f_xpm, 5, 5)
, R(0)
, G(0)
, B(0)
@@ -83,8 +73,8 @@ DropperTool::DropperTool()
, area(NULL)
, centre(0, 0)
{
- cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7);
- cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7);
+ cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 5, 5);
+ cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 5, 5);
}
DropperTool::~DropperTool() {
@@ -99,7 +89,7 @@ void DropperTool::setup() {
SPCurve *c = new SPCurve(path);
- this->area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
+ this->area = sp_canvas_bpath_new(this->desktop->getControls(), c);
c->unref();
@@ -200,7 +190,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
// If one time pick with stroke set the pixmap
if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) {
//TODO Only set when not set already
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
gdk_window_set_cursor(window, cursor_dropper_stroke);
}
@@ -230,7 +220,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
if (!r.hasZeroArea()) {
Geom::IntRect area = r.roundOutwards();
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height());
- sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
+ sp_canvas_arena_render_surface(SP_CANVAS_ARENA(desktop->getDrawing()), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
cairo_surface_destroy(s);
}
@@ -238,14 +228,14 @@ bool DropperTool::root_handler(GdkEvent* event) {
// pick single pixel
Geom::IntRect area = Geom::IntRect::from_xywh(floor(event->button.x), floor(event->button.y), 1, 1);
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
- sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
+ sp_canvas_arena_render_surface(SP_CANVAS_ARENA(desktop->getDrawing()), s, area);
ink_cairo_surface_average_color_premul(s, R, G, B, A);
cairo_surface_destroy(s);
}
if (pick == SP_DROPPER_PICK_VISIBLE) {
// compose with page color
- guint32 bg = sp_desktop_namedview(desktop)->pagecolor;
+ guint32 bg = desktop->getNamedView()->pagecolor;
R = R + (SP_RGBA32_R_F(bg)) * (1 - A);
G = G + (SP_RGBA32_G_F(bg)) * (1 - A);
B = B + (SP_RGBA32_B_F(bg)) * (1 - A);
@@ -324,12 +314,12 @@ bool DropperTool::root_handler(GdkEvent* event) {
// REJON: set aux. toolbar input to hex color!
if (event->button.state & GDK_SHIFT_MASK) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
gdk_window_set_cursor(window, cursor_dropper_stroke);
}
- if (!(sp_desktop_selection(desktop)->isEmpty())) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER,
+ if (!(desktop->getSelection()->isEmpty())) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_DROPPER,
_("Set picked color"));
}
@@ -359,11 +349,11 @@ bool DropperTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
gdk_window_set_cursor(window, cursor_dropper_stroke);
}
@@ -378,7 +368,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
gdk_window_set_cursor(window, cursor_dropper_fill);
}
break;
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index bf4015b4c..af0cbcb78 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -44,7 +44,7 @@
#include "selection.h"
#include "desktop.h"
#include "desktop-events.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "message-context.h"
#include "preferences.h"
@@ -84,20 +84,10 @@ using Inkscape::DocumentUndo;
#define DRAG_DEFAULT 1.0
#define DRAG_MAX 1.0
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createEraserContext() {
- return new EraserTool();
- }
-
- bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext);
-}
-
const std::string& EraserTool::getPrefsPath() {
return EraserTool::prefsPath;
}
@@ -121,7 +111,7 @@ void EraserTool::setup() {
this->cal1 = new SPCurve();
this->cal2 = new SPCurve();
- this->currentshape = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL);
+ this->currentshape = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->currentshape), ERC_RED_RGBA, SP_WIND_RULE_EVENODD);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->currentshape), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -666,7 +656,7 @@ void EraserTool::set_to_accumulated() {
if ( this->repr ) {
bool wasSelection = false;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
@@ -680,10 +670,10 @@ void EraserTool::set_to_accumulated() {
if (selection->isEmpty()) {
if ( eraserMode ) {
- toWorkOn = sp_desktop_document(desktop)->getItemsPartiallyInBox(desktop->dkey, bounds);
+ toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds);
} else {
Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
- toWorkOn = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints());
+ toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
}
toWorkOn = g_slist_remove( toWorkOn, acid );
@@ -767,9 +757,9 @@ void EraserTool::set_to_accumulated() {
if ( workDone ) {
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
} else {
- DocumentUndo::cancel(sp_desktop_document(desktop));
+ DocumentUndo::cancel(desktop->getDocument());
}
}
@@ -949,7 +939,7 @@ void EraserTool::fit_and_split(bool release) {
gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
g_assert(!this->currentcurve->is_empty());
- SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL);
+ SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
SPCurve *curve = this->currentcurve->copy();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
curve->unref();
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 5745fc9cc..bb8782dfa 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -31,7 +31,7 @@
#include "color.h"
#include "context-fns.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
@@ -74,20 +74,10 @@ using Inkscape::Display::ExtractARGB32;
using Inkscape::Display::ExtractRGB32;
using Inkscape::Display::AssembleARGB32;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createPaintbucketContext() {
- return new FloodTool();
- }
-
- bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext);
-}
-
const std::string& FloodTool::getPrefsPath() {
return FloodTool::prefsPath;
}
@@ -128,13 +118,13 @@ void FloodTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
this->sel_changed_connection.disconnect();
- this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
+ this->sel_changed_connection = this->desktop->getSelection()->connectChanged(
sigc::mem_fun(this, &FloodTool::selection_changed)
);
@@ -360,7 +350,7 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_
* @param union_with_selection If true, merge the final SVG path with the current selection.
*/
static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, Geom::Affine transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) {
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *document = desktop->getDocument();
unsigned char *trace_t;
@@ -467,7 +457,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
g_free(affinestr);
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
pathRepr->setPosition(-1);
@@ -476,7 +466,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",
SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() );
selection->add(reprobj);
- sp_selected_path_union_skip_undo(sp_desktop_selection(desktop), desktop);
+ sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
} else {
desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE,
ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",
@@ -621,7 +611,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<Geom::Point>
bool currently_painting_top = false;
bool currently_painting_bottom = false;
- unsigned int top_ty = bci.y - 1;
+ unsigned int top_ty = (bci.y > 0) ? bci.y - 1 : 0;
unsigned int bottom_ty = bci.y + 1;
bool can_paint_top = (top_ty > 0);
@@ -740,7 +730,7 @@ static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) {
*/
static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, bool union_with_selection, bool is_point_fill, bool is_touch_fill) {
SPDesktop *desktop = event_context->desktop;
- SPDocument *document = sp_desktop_document(desktop);
+ SPDocument *document = desktop->getDocument();
document->ensureUpToDate();
@@ -792,7 +782,7 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo
Inkscape::DrawingContext dc(s, Geom::Point(0,0));
// cairo_translate not necessary here - surface origin is at 0,0
- SPNamedView *nv = sp_desktop_namedview(desktop);
+ SPNamedView *nv = desktop->getNamedView();
bgcolor = nv->pagecolor;
// bgcolor is 0xrrggbbaa, we need 0xaarrggbb
dtc = (bgcolor >> 8) | (bgcolor << 24);
@@ -1096,9 +1086,9 @@ bool FloodTool::item_handler(SPItem* item, GdkEvent* event) {
// Set style
desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object"));
-
- ret = TRUE;
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object"));
+ // Dead assignment: Value stored to 'ret' is never read
+ //ret = TRUE;
}
break;
@@ -1229,9 +1219,9 @@ void FloodTool::finishItem() {
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(this->item);
+ desktop->getSelection()->set(this->item);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area"));
this->item = NULL;
}
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 2ef06df61..22948c7bc 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -28,7 +28,7 @@
#include <glibmm/i18n.h>
#include "display/curve.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "document.h"
#include "ui/draw-anchor.h"
@@ -118,7 +118,7 @@ FreehandBase::~FreehandBase() {
void FreehandBase::setup() {
ToolBase::setup();
- this->selection = sp_desktop_selection(desktop);
+ this->selection = desktop->getSelection();
// Connect signals to track selection changes
this->sel_changed_connection = this->selection->connectChanged(
@@ -129,14 +129,14 @@ void FreehandBase::setup() {
);
// Create red bpath
- this->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL);
+ this->red_bpath = sp_canvas_bpath_new(this->desktop->getSketch(), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
// Create red curve
this->red_curve = new SPCurve();
// Create blue bpath
- this->blue_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL);
+ this->blue_bpath = sp_canvas_bpath_new(this->desktop->getSketch(), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
// Create blue curve
@@ -248,11 +248,9 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points
char const *style_str = NULL;
style_str = repr->attribute("style");
if (style_str) {
- SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
- sp_style_merge_from_style_string(style, style_str);
- stroke_width = style->stroke_width.computed;
- style->stroke_width.computed = 0;
- sp_style_unref(style);
+ SPStyle style(SP_ACTIVE_DOCUMENT);
+ style.mergeString(style_str);
+ stroke_width = style.stroke_width.computed;
}
std::ostringstream s;
@@ -557,7 +555,7 @@ void spdc_endpoint_snap_free(ToolBase const * const ec, Geom::Point& p, boost::o
{
SPDesktop *dt = ec->desktop;
SnapManager &m = dt->namedview->snap_manager;
- Inkscape::Selection *selection = sp_desktop_selection (dt);
+ Inkscape::Selection *selection = dt->getSelection();
// selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
// TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
@@ -723,7 +721,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
: dc->desktop->dt2doc() );
SPDesktop *desktop = dc->desktop;
- SPDocument *doc = sp_desktop_document(desktop);
+ SPDocument *doc = desktop->getDocument();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
if ( c && !c->is_empty() ) {
@@ -774,7 +772,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
// results in the tool losing all of the selected path's curve except that last subpath. To
// fix this, we force the selection_modified callback now, to make sure the tool's curve is
// in sync immediately.
- spdc_selection_modified(sp_desktop_selection(desktop), 0, dc);
+ spdc_selection_modified(desktop->getSelection(), 0, dc);
}
c->unref();
@@ -880,14 +878,11 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
// find out stroke width (TODO: is there an easier way??)
double stroke_width = 3.0;
- gchar const *style_str = NULL;
- style_str = repr->attribute("style");
+ gchar const *style_str = repr->attribute("style");
if (style_str) {
- SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
- sp_style_merge_from_style_string(style, style_str);
- stroke_width = style->stroke_width.computed;
- style->stroke_width.computed = 0;
- sp_style_unref(style);
+ SPStyle style(SP_ACTIVE_DOCUMENT);
+ style.mergeString(style_str);
+ stroke_width = style.stroke_width.computed;
}
// unset stroke and set fill color to former stroke color
@@ -921,10 +916,10 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
item->updateRepr();
- sp_desktop_selection(desktop)->set(item);
+ desktop->getSelection()->set(item);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot"));
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_NONE, _("Create single dot"));
}
}
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 9c853917e..5be84eb76 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -23,7 +23,7 @@
#include "document.h"
#include "selection.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "message-context.h"
#include "message-stack.h"
#include "pixmaps/cursor-gradient.xpm"
@@ -51,22 +51,12 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint state, guint32 etime);
-namespace {
- ToolBase* createGradientContext() {
- return new GradientTool();
- }
-
- bool gradientContextRegistered = ToolFactory::instance().registerObject("/tools/gradient", createGradientContext);
-}
-
const std::string& GradientTool::getPrefsPath() {
return GradientTool::prefsPath;
}
@@ -112,7 +102,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
GradientTool *rc = (GradientTool *) this;
GrDrag *drag = rc->_grdrag;
- Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(rc)->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
if (selection == NULL) {
return;
}
@@ -167,7 +157,7 @@ void GradientTool::setup() {
}
this->enableGrDrag();
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->selcon = new sigc::connection(selection->connectChanged(
sigc::mem_fun(this, &GradientTool::selection_changed)
@@ -464,7 +454,7 @@ sp_gradient_context_add_stop_near_point (GradientTool *rc, SPItem *item, Geom::
SPStop *newstop = ec->get_drag()->addStopNearPoint (item, mouse_p, tolerance/desktop->current_zoom());
- DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_GRADIENT,
_("Add gradient stop"));
ec->get_drag()->updateDraggers();
@@ -475,7 +465,7 @@ sp_gradient_context_add_stop_near_point (GradientTool *rc, SPItem *item, Geom::
bool GradientTool::root_handler(GdkEvent* event) {
static bool dragging;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -509,13 +499,13 @@ bool GradientTool::root_handler(GdkEvent* event) {
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
- SPGradient *vector = sp_gradient_vector_for_object(sp_desktop_document(desktop), desktop, item, fsmode);
+ SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode);
SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode);
sp_gradient_reset_to_userspace(priv, item);
}
- DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_GRADIENT,
_("Create default gradient"));
}
ret = TRUE;
@@ -892,8 +882,8 @@ bool GradientTool::root_handler(GdkEvent* event) {
static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPDocument *document = sp_desktop_document(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
+ SPDocument *document = desktop->getDocument();
ToolBase *ec = SP_EVENT_CONTEXT(&rc);
if (!selection->isEmpty()) {
@@ -957,7 +947,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
n_objects);
} else {
- sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> on which to create gradient."));
+ desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> on which to create gradient."));
}
}
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 1fd1ebf8c..c0517578d 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -30,7 +30,7 @@
#include "preferences.h"
#include "ui/shape-editor.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
@@ -58,23 +58,12 @@ SubtoolEntry lpesubtools[] = {
{Inkscape::LivePathEffect::MIRROR_SYMMETRY, "draw-geometry-mirror"}
};
-
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data);
-namespace {
- ToolBase* createLPEToolContext() {
- return new LpeTool();
- }
-
- bool lpetoolContextRegistered = ToolFactory::instance().registerObject("/tools/lpetool", createLPEToolContext);
-}
-
const std::string& LpeTool::getPrefsPath() {
return LpeTool::prefsPath;
}
@@ -110,7 +99,7 @@ LpeTool::~LpeTool() {
void LpeTool::setup() {
PenTool::setup();
- Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
SPItem *item = selection->singleItem();
this->sel_changed_connection.disconnect();
@@ -164,7 +153,7 @@ bool LpeTool::item_handler(SPItem* item, GdkEvent* event) {
case GDK_BUTTON_PRESS:
{
// select the clicked item but do nothing else
- Inkscape::Selection * const selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection * const selection = this->desktop->getSelection();
selection->clear();
selection->add(item);
ret = TRUE;
@@ -186,7 +175,7 @@ bool LpeTool::item_handler(SPItem* item, GdkEvent* event) {
}
bool LpeTool::root_handler(GdkEvent* event) {
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
bool ret = false;
@@ -305,12 +294,12 @@ int lpetool_item_has_construction(LpeTool */*lc*/, SPItem *item)
bool
lpetool_try_construction(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type)
{
- Inkscape::Selection *selection = sp_desktop_selection(lc->desktop);
+ Inkscape::Selection *selection = lc->desktop->getSelection();
SPItem *item = selection->singleItem();
// TODO: should we check whether type represents a valid geometric construction?
if (item && SP_IS_LPE_ITEM(item) && Inkscape::LivePathEffect::Effect::acceptsNumClicks(type) == 0) {
- Inkscape::LivePathEffect::Effect::createAndApply(type, sp_desktop_document(lc->desktop), item);
+ Inkscape::LivePathEffect::Effect::createAndApply(type, lc->desktop->getDocument(), item);
return true;
}
return false;
@@ -360,7 +349,7 @@ lpetool_context_reset_limiting_bbox(LpeTool *lc)
if (!prefs->getBool("/tools/lpetool/show_bbox", true))
return;
- SPDocument *document = sp_desktop_document(lc->desktop);
+ SPDocument *document = lc->desktop->getDocument();
Geom::Point A, B;
lpetool_get_limiting_bbox_corners(document, A, B);
@@ -371,7 +360,7 @@ lpetool_context_reset_limiting_bbox(LpeTool *lc)
Geom::Rect rect(A, B);
SPCurve *curve = SPCurve::new_from_rect(rect);
- lc->canvas_bbox = sp_canvas_bpath_new (sp_desktop_controls(lc->desktop), curve);
+ lc->canvas_bbox = sp_canvas_bpath_new (lc->desktop->getControls(), curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(lc->canvas_bbox), 0x0000ffff, 0.8, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 5);
}
@@ -396,7 +385,7 @@ void
lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
{
if (!selection) {
- selection = sp_desktop_selection(lc->desktop);
+ selection = lc->desktop->getSelection();
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = prefs->getBool("/tools/lpetool/show_measuring_info", true);
@@ -404,7 +393,7 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
SPPath *path;
SPCurve *curve;
SPCanvasText *canvas_text;
- SPCanvasGroup *tmpgrp = sp_desktop_tempgroup(lc->desktop);
+ SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup();
gchar *arc_length;
double lengthval;
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 6b5cbeccd..0875c29e0 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -29,7 +29,7 @@
#include "pixmaps/cursor-measure.xpm"
#include "preferences.h"
#include "inkscape.h"
-#include "desktop-handles.h"
+
#include "ui/tools/measure-tool.h"
#include "ui/tools/freehand-base.h"
#include "display/canvas-text.h"
@@ -49,22 +49,12 @@ using Inkscape::ControlManager;
using Inkscape::CTLINE_SECONDARY;
using Inkscape::Util::unit_table;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items;
-namespace {
- ToolBase* createMeasureContext() {
- return new MeasureTool();
- }
-
- bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext);
-}
-
const std::string& MeasureTool::getPrefsPath() {
return MeasureTool::prefsPath;
}
@@ -228,7 +218,7 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const &center, Geom
yc + ay + (k2 * ax));
Geom::Point p3(xc + bx + (k2 * by),
yc + by - (k2 * bx));
- SPCtrlCurve *curve = ControlManager::getManager().createControlCurve(sp_desktop_tempgroup(desktop), p1, p2, p3, p4, CTLINE_SECONDARY);
+ SPCtrlCurve *curve = ControlManager::getManager().createControlCurve(desktop->getTempGroup(), p1, p2, p3, p4, CTLINE_SECONDARY);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(SP_CANVAS_ITEM(curve), 0, true));
}
@@ -291,7 +281,7 @@ static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom:
//TODO: consider only visible intersections
Geom::Point intersection = lineseg[0].pointAt((*m).ta);
double eps = 0.0001;
- SPDocument* doc = sp_desktop_document(desktop);
+ SPDocument* doc = desktop->getDocument();
if (((*m).ta > eps &&
item == doc->getItemAtPoint(desktop->dkey, lineseg[0].pointAt((*m).ta - eps), false, NULL)) ||
((*m).ta + eps < 1 &&
@@ -441,7 +431,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO switch to a different variable name. The single letter 'l' is easy to misread.
//select elements crossed by line segment:
- GSList *items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, points);
+ GSList *items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points);
std::vector<double> intersection_times;
for (GSList *l = items; l != NULL; l = l->next) {
SPItem *item = static_cast<SPItem*>(l->data);
@@ -525,7 +515,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO cleanup memory, Glib::ustring, etc.:
gchar *measure_str = g_strdup_printf("%.2f %s", place.lengthVal, unit_name.c_str());
- SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop),
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
desktop,
place.end,
measure_str);
@@ -548,7 +538,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO cleanup memory, Glib::ustring, etc.:
gchar *angle_str = g_strdup_printf("%.2f °", angle * 180/M_PI);
- SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop),
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
desktop,
angleDisplayPt,
angle_str);
@@ -569,7 +559,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO cleanup memory, Glib::ustring, etc.:
gchar *totallength_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str());
- SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop),
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
desktop,
end_point + desktop->w2d(Geom::Point(3*fontsize, -fontsize)),
totallength_str);
@@ -590,7 +580,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// TODO cleanup memory, Glib::ustring, etc.:
gchar *total_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str());
- SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop),
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
desktop,
desktop->doc2dt((intersections[0] + intersections[intersections.size()-1])/2) + normal * 60,
total_str);
@@ -609,7 +599,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
for (size_t idx = 0; idx < intersections.size(); ++idx) {
// Display the intersection indicator (i.e. the cross)
- SPCanvasItem * canvasitem = sp_canvas_item_new(sp_desktop_tempgroup(desktop),
+ SPCanvasItem * canvasitem = sp_canvas_item_new(desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
"size", 8.0,
@@ -627,7 +617,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// draw main control line
{
- SPCtrlLine *control_line = ControlManager::getManager().createControlLine(sp_desktop_tempgroup(desktop),
+ SPCtrlLine *control_line = ControlManager::getManager().createControlLine(desktop->getTempGroup(),
start_point,
end_point);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
@@ -642,7 +632,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
* Geom::Affine(Geom::Translate(start_point)));
}
- SPCtrlLine *control_line = ControlManager::getManager().createControlLine(sp_desktop_tempgroup(desktop),
+ SPCtrlLine *control_line = ControlManager::getManager().createControlLine(desktop->getTempGroup(),
start_point,
anchorEnd,
CTLINE_SECONDARY);
@@ -655,17 +645,17 @@ bool MeasureTool::root_handler(GdkEvent* event) {
if (intersections.size() > 2) {
ControlManager &mgr = ControlManager::getManager();
SPCtrlLine *control_line = 0;
- control_line = mgr.createControlLine(sp_desktop_tempgroup(desktop),
+ control_line = mgr.createControlLine(desktop->getTempGroup(),
desktop->doc2dt(intersections[0]) + normal * 60,
desktop->doc2dt(intersections[intersections.size() - 1]) + normal * 60);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
- control_line = mgr.createControlLine(sp_desktop_tempgroup(desktop),
+ control_line = mgr.createControlLine(desktop->getTempGroup(),
desktop->doc2dt(intersections[0]),
desktop->doc2dt(intersections[0]) + normal * 65);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
- control_line = mgr.createControlLine(sp_desktop_tempgroup(desktop),
+ control_line = mgr.createControlLine(desktop->getTempGroup(),
desktop->doc2dt(intersections[intersections.size() - 1]),
desktop->doc2dt(intersections[intersections.size() - 1]) + normal * 65);
measure_tmp_items.push_back(desktop->add_temporary_canvasitem(control_line, 0));
@@ -677,7 +667,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
LabelPlacement &place = *it;
ControlManager &mgr = ControlManager::getManager();
- SPCtrlLine *control_line = mgr.createControlLine(sp_desktop_tempgroup(desktop),
+ SPCtrlLine *control_line = mgr.createControlLine(desktop->getTempGroup(),
place.start,
place.end,
CTLINE_SECONDARY);
@@ -689,7 +679,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
Geom::Point measure_text_pos = (intersections[idx - 1] + intersections[idx]) / 2;
ControlManager &mgr = ControlManager::getManager();
- SPCtrlLine *control_line = mgr.createControlLine(sp_desktop_tempgroup(desktop),
+ SPCtrlLine *control_line = mgr.createControlLine(desktop->getTempGroup(),
desktop->doc2dt(measure_text_pos),
desktop->doc2dt(measure_text_pos) - (normal * DIMENSION_OFFSET),
CTLINE_SECONDARY);
@@ -699,7 +689,7 @@ bool MeasureTool::root_handler(GdkEvent* event) {
// Initial point
{
- SPCanvasItem * canvasitem = sp_canvas_item_new(sp_desktop_tempgroup(desktop),
+ SPCanvasItem * canvasitem = sp_canvas_item_new(desktop->getTempGroup(),
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
"size", 8.0,
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 8a1fb7c72..67ed7aef1 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -27,7 +27,7 @@
// General
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "macros.h"
@@ -48,27 +48,17 @@
// Mesh specific
#include "ui/tools/mesh-tool.h"
-#include "sp-mesh-gradient.h"
+#include "sp-mesh.h"
#include "display/sp-ctrlcurve.h"
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
static void sp_mesh_drag(MeshTool &rc, Geom::Point const pt, guint state, guint32 etime);
-namespace {
- ToolBase* createMeshContext() {
- return new MeshTool();
- }
-
- bool meshContextRegistered = ToolFactory::instance().registerObject("/tools/mesh", createMeshContext);
-}
-
const std::string& MeshTool::getPrefsPath() {
return MeshTool::prefsPath;
}
@@ -107,7 +97,7 @@ const gchar *ms_handle_descr [] = {
void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
GrDrag *drag = this->_grdrag;
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
if (selection == NULL) {
return;
@@ -172,9 +162,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
// if (style && (style->fill.isPaintserver())) {
// SPPaintServer *server = item->style->getFillPaintServer();
- // if ( SP_IS_MESHGRADIENT(server) ) {
+ // if ( SP_IS_MESH(server) ) {
- // SPMeshGradient *mg = SP_MESHGRADIENT(server);
+ // SPMesh *mg = SP_MESH(server);
// guint rows = 0;//mg->array.patches.size();
// for ( guint i = 0; i < rows; ++i ) {
@@ -234,7 +224,7 @@ void MeshTool::setup() {
}
this->enableGrDrag();
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->selcon = new sigc::connection(selection->connectChanged(
sigc::mem_fun(this, &MeshTool::selection_changed)
@@ -317,7 +307,7 @@ static void sp_mesh_context_split_near_point(MeshTool *rc, SPItem *item, Geom::
ec->get_drag()->addStopNearPoint (item, mouse_p, tolerance/desktop->current_zoom());
- DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_MESH,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Split mesh row/column"));
ec->get_drag()->updateDraggers();
@@ -337,8 +327,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- std::map<SPMeshGradient*, std::vector<guint> > points;
- std::map<SPMeshGradient*, SPItem*> items;
+ std::map<SPMesh*, std::vector<guint> > points;
+ std::map<SPMesh*, SPItem*> items;
// Get list of selected draggers for each mesh.
// For all selected draggers
@@ -352,7 +342,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
if( d->point_type != POINT_MG_CORNER ) continue;
// Find the gradient
- SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) );
+ SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) );
// Collect points together for same gradient
points[gradient].push_back( d->point_i );
@@ -361,8 +351,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
}
// Loop over meshes.
- for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
- SPMeshGradient *mg = SP_MESHGRADIENT( iter->first );
+ for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
+ SPMesh *mg = SP_MESH( iter->first );
if( iter->second.size() > 0 ) {
guint noperation = 0;
switch (operation) {
@@ -440,7 +430,7 @@ Handles all keyboard and mouse input for meshs.
bool MeshTool::root_handler(GdkEvent* event) {
static bool dragging;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -488,13 +478,13 @@ bool MeshTool::root_handler(GdkEvent* event) {
#ifdef DEBUG_MESH
std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl;
#endif
- SPGradient *vector = sp_gradient_vector_for_object(sp_desktop_document(desktop), desktop, item, fsmode);
+ SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode);
SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode);
sp_gradient_reset_to_userspace(priv, item);
}
- DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_MESH,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Create default mesh"));
}
@@ -933,8 +923,8 @@ bool MeshTool::root_handler(GdkEvent* event) {
static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) {
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPDocument *document = sp_desktop_document(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
+ SPDocument *document = desktop->getDocument();
ToolBase *ec = SP_EVENT_CONTEXT(&rc);
if (!selection->isEmpty()) {
@@ -994,7 +984,7 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
n_objects);
} else {
- sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> on which to create gradient."));
+ desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> on which to create gradient."));
}
}
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 838c2a884..f8045a029 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -13,7 +13,7 @@
#include "ui/tool/curve-drag-point.h"
#include <glib/gi18n.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "display/sp-canvas-group.h"
#include "display/canvas-bpath.h"
#include "display/curve.h"
@@ -107,20 +107,10 @@
using Inkscape::ControlManager;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createNodesContext() {
- return new NodeTool();
- }
-
- bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext);
-}
-
const std::string& NodeTool::getPrefsPath() {
return NodeTool::prefsPath;
}
@@ -155,7 +145,7 @@ NodeTool::NodeTool()
SPCanvasGroup *create_control_group(SPDesktop *d)
{
return reinterpret_cast<SPCanvasGroup*>(sp_canvas_item_new(
- sp_desktop_controls(d), SP_TYPE_CANVAS_GROUP, NULL));
+ d->getControls(), SP_TYPE_CANVAS_GROUP, NULL));
}
void destroy_group(SPCanvasGroup *g)
@@ -215,7 +205,7 @@ void NodeTool::setup() {
data.node_data.node_group = create_control_group(this->desktop);
data.node_data.handle_group = create_control_group(this->desktop);
- Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->_selection_changed_connection.disconnect();
this->_selection_changed_connection =
@@ -295,7 +285,7 @@ void NodeTool::setup() {
// show helper paths of the applied LPE, if any
void NodeTool::update_helperpath () {
- Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
if (this->helperpath_tmpitem) {
this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem);
@@ -324,7 +314,7 @@ void NodeTool::update_helperpath () {
cc->reset();
}
if (!c->is_empty()) {
- SPCanvasItem *helperpath = sp_canvas_bpath_new(sp_desktop_tempgroup(this->desktop), c);
+ SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath), 0x0000ff9A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_affine_absolute(helperpath, selection->singleItem()->i2dt_affine());
@@ -527,7 +517,7 @@ bool NodeTool::root_handler(GdkEvent* event) {
}
c->transform(over_item->i2dt_affine());
- SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c);
+ SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash),
//prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0,
@@ -668,7 +658,7 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) {
if (this->_multipath->empty()) {
// if multipath is empty, select rubberbanded items rather than nodes
Inkscape::Selection *selection = this->desktop->selection;
- GSList *items = sp_desktop_document(this->desktop)->getItemsInBox(this->desktop->dkey, sel);
+ GSList *items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel);
selection->setList(items);
g_slist_free(items);
} else {
diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h
index ab72f3632..20375e869 100644
--- a/src/ui/tools/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -33,6 +33,8 @@ namespace Inkscape {
}
}
+struct SPCanvasGroup;
+
#define INK_NODE_TOOL(obj) (dynamic_cast<Inkscape::UI::Tools::NodeTool*>((Inkscape::UI::Tools::ToolBase*)obj))
#define INK_IS_NODE_TOOL(obj) (dynamic_cast<const Inkscape::UI::Tools::NodeTool*>((const Inkscape::UI::Tools::ToolBase*)obj))
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index fbcdf6142..d28b7c27a 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -20,10 +20,13 @@
#include <cstring>
#include <string>
+#include "shortcuts.h"
+#include "verbs.h"
+
#include "ui/tools/pen-tool.h"
#include "sp-namedview.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "selection-chemistry.h"
#include "ui/draw-anchor.h"
@@ -70,8 +73,6 @@
#include "live_effects/lpe-bspline.h"
#include <2geom/nearest-point.h>
-#include "ui/tool-factory.h"
-
#include "live_effects/effect.h"
@@ -85,13 +86,6 @@ static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
const double handleCubicGap = 0.01;
-namespace {
- ToolBase* createPenContext() {
- return new PenTool();
- }
-
- bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
-}
const std::string& PenTool::getPrefsPath() {
return PenTool::prefsPath;
@@ -192,14 +186,14 @@ void PenTool::setup() {
ControlManager &mgr = ControlManager::getManager();
// Pen indicators
- this->c0 = mgr.createControl(sp_desktop_controls(this->desktop), Inkscape::CTRL_TYPE_ADJ_HANDLE);
+ this->c0 = mgr.createControl(this->desktop->getControls(), Inkscape::CTRL_TYPE_ADJ_HANDLE);
mgr.track(this->c0);
- this->c1 = mgr.createControl(sp_desktop_controls(this->desktop), Inkscape::CTRL_TYPE_ADJ_HANDLE);
+ this->c1 = mgr.createControl(this->desktop->getControls(), Inkscape::CTRL_TYPE_ADJ_HANDLE);
mgr.track(this->c1);
- this->cl0 = mgr.createControlLine(sp_desktop_controls(this->desktop));
- this->cl1 = mgr.createControlLine(sp_desktop_controls(this->desktop));
+ this->cl0 = mgr.createControlLine(this->desktop->getControls());
+ this->cl1 = mgr.createControlLine(this->desktop->getControls());
sp_canvas_item_hide(this->c0);
sp_canvas_item_hide(this->c1);
@@ -468,7 +462,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
// This is the first click of a new curve; deselect item so that
// this curve is not combined with it (unless it is drawn from its
// anchor, which is handled by the sibling branch above)
- Inkscape::Selection * const selection = sp_desktop_selection(desktop);
+ Inkscape::Selection * const selection = desktop->getSelection();
if (!(bevent.state & GDK_SHIFT_MASK) || this->hasWaitingLPE()) {
// if we have a waiting LPE, we need a fresh path to be created
// so don't append to an existing one
@@ -614,7 +608,12 @@ bool PenTool::_handleMotionNotify(GdkEventMotion const &mevent) {
ret = true;
break;
case PenTool::STOP:
- // This is perfectly valid
+ if (!this->sp_event_context_knot_mouseover()) {
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop);
+ m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE));
+ m.unSetup();
+ }
break;
default:
break;
@@ -685,8 +684,7 @@ bool PenTool::_handleMotionNotify(GdkEventMotion const &mevent) {
ret = true;
break;
case PenTool::STOP:
- // This is perfectly valid
- break;
+ // Don't break; fall through to default to do preSnapping
default:
if (!this->sp_event_context_knot_mouseover()) {
SnapManager &m = desktop->namedview->snap_manager;
@@ -846,7 +844,7 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
if (this->expecting_clicks_for_LPE == 0 && this->hasWaitingLPE()) {
this->setPolylineMode();
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
if (this->waiting_LPE) {
// we have an already created LPE waiting for a path
@@ -881,7 +879,7 @@ void PenTool::_redrawAll() {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), this->green_curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
@@ -1064,6 +1062,23 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px
+ // Check for undo if we have started drawing a path.
+ if (this->npoints > 0) {
+ unsigned int shortcut = Inkscape::UI::Tools::get_group0_keyval (&event->key) |
+ ( event->key.state & GDK_SHIFT_MASK ?
+ SP_SHORTCUT_SHIFT_MASK : 0 ) |
+ ( event->key.state & GDK_CONTROL_MASK ?
+ SP_SHORTCUT_CONTROL_MASK : 0 ) |
+ ( event->key.state & GDK_MOD1_MASK ?
+ SP_SHORTCUT_ALT_MASK : 0 );
+ Inkscape::Verb* verb = sp_shortcut_get_verb(shortcut);
+ if (verb) {
+ unsigned int vcode = verb->get_code();
+ if (vcode == SP_VERB_EDIT_UNDO)
+ return _undoLastPoint();
+ }
+ }
+
switch (get_group0_keyval (&event->key)) {
case GDK_KEY_Left: // move last point left
case GDK_KEY_KP_Left:
@@ -1218,14 +1233,6 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
ret = true;
}
break;
- case GDK_KEY_z:
- case GDK_KEY_Z:
- if (MOD__CTRL_ONLY(event) && this->npoints != 0) {
- // if drawing, cancel, otherwise pass it up for undo
- this->_cancel ();
- ret = true;
- }
- break;
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
@@ -1236,83 +1243,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
case GDK_KEY_BackSpace:
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
- if ( this->green_curve->is_empty() || (this->green_curve->last_segment() == NULL) ) {
- if (!this->red_curve->is_empty()) {
- this->_cancel ();
- ret = true;
- } else {
- // do nothing; this event should be handled upstream
- }
- } else {
- // Reset red curve
- this->red_curve->reset();
- // Destroy topmost green bpath
- if (this->green_bpaths) {
- if (this->green_bpaths->data) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- }
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
- }
- // Get last segment
- if ( this->green_curve->is_empty() ) {
- g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty");
- break;
- }
- // The code below assumes that this->green_curve has only ONE path !
- Geom::Curve const * crv = this->green_curve->last_segment();
- this->p[0] = crv->initialPoint();
- if ( Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>(crv)) {
- this->p[1] = (*cubic)[1];
-
- } else {
- this->p[1] = this->p[0];
- }
-
- // asign the value in a third of the distance of the last segment.
- if (this->bspline){
- this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
- }
-
- Geom::Point const pt( (this->npoints < 4) ? crv->finalPoint() : this->p[3] );
-
- this->npoints = 2;
- // delete the last segment of the green curve
- if (this->green_curve->get_segment_count() == 1) {
- this->npoints = 5;
- if (this->green_bpaths) {
- if (this->green_bpaths->data) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- }
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
- }
- this->green_curve->reset();
- } else {
- this->green_curve->backspace();
- }
-
- // assign the value of this->p[1] to the oposite of the green line last segment
- if (this->spiro){
- Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(this->green_curve->last_segment());
- if ( cubic ) {
- this->p[1] = (*cubic)[3] + (*cubic)[3] - (*cubic)[2];
- SP_CTRL(this->c1)->moveto(this->p[0]);
- } else {
- this->p[1] = this->p[0];
- }
- }
-
- sp_canvas_item_hide(this->c0);
- sp_canvas_item_hide(this->c1);
- sp_canvas_item_hide(this->cl0);
- sp_canvas_item_hide(this->cl1);
- this->state = PenTool::POINT;
- this->_setSubsequentPoint(pt, true);
- pen_last_paraxial_dir = !pen_last_paraxial_dir;
-
- //redraw
- this->_bspline_spiro_build();
- ret = true;
- }
+ ret = _undoLastPoint();
break;
default:
break;
@@ -1415,7 +1346,7 @@ void PenTool::_bspline_spiro_color()
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), this->green_curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape);
@@ -2161,7 +2092,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
curve->unref();
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -2175,6 +2106,92 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
}
}
+// Partial fix for https://bugs.launchpad.net/inkscape/+bug/171990
+// TODO: implement the redo feature
+bool PenTool::_undoLastPoint() {
+ bool ret = false;
+
+ if ( this->green_curve->is_empty() || (this->green_curve->last_segment() == NULL) ) {
+ if (!this->red_curve->is_empty()) {
+ this->_cancel ();
+ ret = true;
+ } else {
+ // do nothing; this event should be handled upstream
+ }
+ } else {
+ // Reset red curve
+ this->red_curve->reset();
+ // Destroy topmost green bpath
+ if (this->green_bpaths) {
+ if (this->green_bpaths->data) {
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
+ }
+ this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ }
+ // Get last segment
+ if ( this->green_curve->is_empty() ) {
+ g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty");
+ return false;
+ }
+ // The code below assumes that this->green_curve has only ONE path !
+ Geom::Curve const * crv = this->green_curve->last_segment();
+ this->p[0] = crv->initialPoint();
+ if ( Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>(crv)) {
+ this->p[1] = (*cubic)[1];
+
+ } else {
+ this->p[1] = this->p[0];
+ }
+
+ // asign the value in a third of the distance of the last segment.
+ if (this->bspline){
+ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
+ }
+
+ Geom::Point const pt( (this->npoints < 4) ? crv->finalPoint() : this->p[3] );
+
+ this->npoints = 2;
+ // delete the last segment of the green curve
+ if (this->green_curve->get_segment_count() == 1) {
+ this->npoints = 5;
+ if (this->green_bpaths) {
+ if (this->green_bpaths->data) {
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
+ }
+ this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ }
+ this->green_curve->reset();
+ } else {
+ this->green_curve->backspace();
+ }
+
+ // assign the value of this->p[1] to the oposite of the green line last segment
+ if (this->spiro){
+ Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(this->green_curve->last_segment());
+ if ( cubic ) {
+ this->p[1] = (*cubic)[3] + (*cubic)[3] - (*cubic)[2];
+ SP_CTRL(this->c1)->moveto(this->p[0]);
+ } else {
+ this->p[1] = this->p[0];
+ }
+ }
+
+ sp_canvas_item_hide(this->c0);
+ sp_canvas_item_hide(this->c1);
+ sp_canvas_item_hide(this->cl0);
+ sp_canvas_item_hide(this->cl1);
+ this->state = PenTool::POINT;
+ this->_setSubsequentPoint(pt, true);
+ pen_last_paraxial_dir = !pen_last_paraxial_dir;
+
+ //redraw
+ this->_bspline_spiro_build();
+ ret = true;
+ }
+
+ return ret;
+}
+
void PenTool::_finish(gboolean const closed) {
if (this->expecting_clicks_for_LPE > 1) {
// don't let the path be finished before we have collected the required number of mouse clicks
@@ -2277,7 +2294,7 @@ void PenTool::_setToNearestHorizVert(Geom::Point &pt, guint const state, bool sn
// Snap along the constraint line; if we didn't snap then still the constraint will be applied
SnapManager &m = this->desktop->namedview->snap_manager;
- Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
// selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
// TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 98fd0a43e..2208005c5 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -121,6 +121,7 @@ private:
void _setSubsequentPoint(Geom::Point const p, bool statusbar, guint status = 0);
void _setCtrl(Geom::Point const p, guint state);
void _finishSegment(Geom::Point p, guint state);
+ bool _undoLastPoint();
void _finish(gboolean closed);
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 3ea2ae843..db24c7432 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -20,7 +20,7 @@
#include "ui/tools/pencil-tool.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "selection-chemistry.h"
#include "ui/draw-anchor.h"
@@ -43,7 +43,6 @@
#include "display/sp-canvas.h"
#include "display/curve.h"
#include "livarot/Path.h"
-#include "ui/tool-factory.h"
#include "ui/tool/event-utils.h"
namespace Inkscape {
@@ -55,14 +54,6 @@ static bool pencil_within_tolerance = false;
static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; }
-namespace {
- ToolBase* createPencilContext() {
- return new PencilTool();
- }
-
- bool pencilContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pencil", createPencilContext);
-}
-
const std::string& PencilTool::getPrefsPath() {
return PencilTool::prefsPath;
}
@@ -153,7 +144,7 @@ bool PencilTool::_handleButtonPress(GdkEventButton const &bevent) {
bool ret = false;
if ( bevent.button == 1 && !this->space_panning) {
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (Inkscape::have_viable_layer(desktop, this->message_context) == false) {
return true;
@@ -853,7 +844,7 @@ void PencilTool::_fitAndSplit() {
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
curve->unref();
this->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color();
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 67df0d9a5..62a9006ea 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -28,7 +28,7 @@
#include "sp-namedview.h"
#include "selection.h"
#include "selection-chemistry.h"
-#include "desktop-handles.h"
+
#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -46,20 +46,10 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createRectContext() {
- return new RectTool();
- }
-
- bool rectContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/rect", createRectContext);
-}
-
const std::string& RectTool::getPrefsPath() {
return RectTool::prefsPath;
}
@@ -111,13 +101,13 @@ void RectTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
this->sel_changed_connection.disconnect();
- this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
+ this->sel_changed_connection = this->desktop->getSelection()->connectChanged(
sigc::mem_fun(this, &RectTool::selection_changed)
);
@@ -170,7 +160,7 @@ bool RectTool::root_handler(GdkEvent* event) {
static bool dragging;
SPDesktop *desktop = this->desktop;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -476,16 +466,16 @@ void RectTool::finishItem() {
this->desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(this->desktop)->set(this->rect);
+ this->desktop->getSelection()->set(this->rect);
- DocumentUndo::done(sp_desktop_document(this->desktop), SP_VERB_CONTEXT_RECT, _("Create rectangle"));
+ DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_RECT, _("Create rectangle"));
this->rect = NULL;
}
}
void RectTool::cancel(){
- sp_desktop_selection(this->desktop)->clear();
+ this->desktop->getSelection()->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(this->desktop->acetate), 0);
if (this->rect != NULL) {
@@ -500,7 +490,7 @@ void RectTool::cancel(){
this->desktop->canvas->endForcedFullRedraws();
- DocumentUndo::cancel(sp_desktop_document(this->desktop));
+ DocumentUndo::cancel(this->desktop->getDocument());
}
}
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index a8267ea1d..40b994968 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -38,7 +38,7 @@
#include "extension/dbus/document-interface.h"
#endif
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "sp-root.h"
#include "preferences.h"
#include "ui/tools-switch.h"
@@ -49,7 +49,6 @@
#include "display/sp-canvas.h"
#include "display/sp-canvas-item.h"
#include "display/drawing-item.h"
-#include "ui/tool-factory.h"
using Inkscape::DocumentUndo;
@@ -65,14 +64,6 @@ static GdkCursor *CursorSelectDragging = NULL;
static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect
static gint drag_escaped = 0; // if non-zero, drag was canceled by esc
-namespace {
- ToolBase* createSelectContext() {
- return new SelectTool();
- }
-
- bool selectContextRegistered = ToolFactory::instance().registerObject("/tools/select", createSelectContext);
-}
-
const std::string& SelectTool::getPrefsPath() {
return SelectTool::prefsPath;
}
@@ -208,7 +199,7 @@ bool SelectTool::sp_select_context_abort() {
if (this->item) {
// only undo if the item is still valid
if (this->item->document) {
- DocumentUndo::undo(sp_desktop_document(desktop));
+ DocumentUndo::undo(desktop->getDocument());
}
sp_object_unref( this->item, NULL);
@@ -216,7 +207,7 @@ bool SelectTool::sp_select_context_abort() {
// NOTE: This is a workaround to a bug.
// When the ctrl key is held, sc->item is not defined
// so in this case (only), we skip the object doc check
- DocumentUndo::undo(sp_desktop_document(desktop));
+ DocumentUndo::undo(desktop->getDocument());
}
this->item = NULL;
@@ -272,7 +263,7 @@ sp_select_context_up_one_layer(SPDesktop *desktop)
{
desktop->setCurrentLayer(parent);
if (current_group && (SPGroup::LAYER != current_group->layerMode())) {
- sp_desktop_selection(desktop)->set(current_layer);
+ desktop->getSelection()->set(current_layer);
}
}
}
@@ -308,7 +299,7 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
// if shift or ctrl was pressed, do not move objects;
// pass the event to root handler which will perform rubberband, shift-click, ctrl-click, ctrl-drag
} else {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
this->dragging = TRUE;
this->moved = FALSE;
@@ -353,7 +344,7 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
case GDK_ENTER_NOTIFY: {
if (!desktop->isWaitingCursor() && !this->dragging) {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, CursorSelectMouseover);
}
@@ -361,7 +352,7 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
}
case GDK_LEAVE_NOTIFY:
if (!desktop->isWaitingCursor() && !this->dragging) {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, this->cursor);
}
@@ -469,7 +460,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
SPItem *item_at_point = NULL, *group_at_point = NULL, *item_in_group = NULL;
gint ret = FALSE;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// make sure we still have valid objects to move around
@@ -485,7 +476,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
desktop->setCurrentLayer(clicked_item);
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
this->dragging = false;
sp_event_context_discard_delayed_snap_event(this);
@@ -573,7 +564,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
// but not with shift) we want to drag rather than rubberband
this->dragging = TRUE;
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, CursorSelectDragging);
@@ -702,7 +693,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
}
this->dragging = FALSE;
- window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, CursorSelectMouseover);
sp_event_context_discard_delayed_snap_event(this);
@@ -722,9 +713,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (r->getMode() == RUBBERBAND_MODE_RECT) {
Geom::OptRect const b = r->getRectangle();
- items = sp_desktop_document(desktop)->getItemsInBox(desktop->dkey, *b);
+ items = desktop->getDocument()->getItemsInBox(desktop->dkey, *b);
} else if (r->getMode() == RUBBERBAND_MODE_TOUCHPATH) {
- items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints());
+ items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
}
_seltrans->resetState();
@@ -953,7 +944,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
// if Alt and nonempty selection, show moving cursor ("move selected"):
if (alt && !selection->isEmpty() && !desktop->isWaitingCursor()) {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, CursorSelectDragging);
}
@@ -974,15 +965,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(sp_desktop_selection(desktop), mul*-10, 0); // shift
+ sp_selection_move_screen(desktop->getSelection(), mul*-10, 0); // shift
} else {
- sp_selection_move_screen(sp_desktop_selection(desktop), mul*-1, 0); // no shift
+ sp_selection_move_screen(desktop->getSelection(), mul*-1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(sp_desktop_selection(desktop), mul*-10*nudge, 0); // shift
+ sp_selection_move(desktop->getSelection(), mul*-10*nudge, 0); // shift
} else {
- sp_selection_move(sp_desktop_selection(desktop), mul*-nudge, 0); // no shift
+ sp_selection_move(desktop->getSelection(), mul*-nudge, 0); // no shift
}
}
@@ -997,15 +988,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*10); // shift
+ sp_selection_move_screen(desktop->getSelection(), 0, mul*10); // shift
} else {
- sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*1); // no shift
+ sp_selection_move_screen(desktop->getSelection(), 0, mul*1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(sp_desktop_selection(desktop), 0, mul*10*nudge); // shift
+ sp_selection_move(desktop->getSelection(), 0, mul*10*nudge); // shift
} else {
- sp_selection_move(sp_desktop_selection(desktop), 0, mul*nudge); // no shift
+ sp_selection_move(desktop->getSelection(), 0, mul*nudge); // no shift
}
}
@@ -1020,15 +1011,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(sp_desktop_selection(desktop), mul*10, 0); // shift
+ sp_selection_move_screen(desktop->getSelection(), mul*10, 0); // shift
} else {
- sp_selection_move_screen(sp_desktop_selection(desktop), mul*1, 0); // no shift
+ sp_selection_move_screen(desktop->getSelection(), mul*1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(sp_desktop_selection(desktop), mul*10*nudge, 0); // shift
+ sp_selection_move(desktop->getSelection(), mul*10*nudge, 0); // shift
} else {
- sp_selection_move(sp_desktop_selection(desktop), mul*nudge, 0); // no shift
+ sp_selection_move(desktop->getSelection(), mul*nudge, 0); // no shift
}
}
@@ -1043,15 +1034,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*-10); // shift
+ sp_selection_move_screen(desktop->getSelection(), 0, mul*-10); // shift
} else {
- sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*-1); // no shift
+ sp_selection_move_screen(desktop->getSelection(), 0, mul*-1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(sp_desktop_selection(desktop), 0, mul*-10*nudge); // shift
+ sp_selection_move(desktop->getSelection(), 0, mul*-10*nudge); // shift
} else {
- sp_selection_move(sp_desktop_selection(desktop), 0, mul*-nudge); // no shift
+ sp_selection_move(desktop->getSelection(), 0, mul*-nudge); // no shift
}
}
@@ -1155,7 +1146,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
SPGroup *clickedGroup = dynamic_cast<SPGroup *>(clicked_item);
if ( (clickedGroup && (clickedGroup->layerMode() != SPGroup::LAYER)) || dynamic_cast<SPBox3D *>(clicked_item)) { // enter group or a 3D box
desktop->setCurrentLayer(clicked_item);
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
} else {
this->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selected object is not a group. Cannot enter."));
}
@@ -1226,7 +1217,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
// set cursor to default.
if (!desktop->isWaitingCursor()) {
// Do we need to reset the cursor here on key release ?
- //GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ //GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
//gdk_window_set_cursor(window, event_context->cursor);
}
break;
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 31c4e8829..833fef18d 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -27,7 +27,7 @@
#include "document-undo.h"
#include "sp-namedview.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -45,20 +45,10 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createSpiralContext() {
- return new SpiralTool();
- }
-
- bool spiralContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/spiral", createSpiralContext);
-}
-
const std::string& SpiralTool::getPrefsPath() {
return SpiralTool::prefsPath;
}
@@ -117,12 +107,12 @@ void SpiralTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->sel_changed_connection.disconnect();
this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &SpiralTool::selection_changed));
@@ -154,7 +144,7 @@ bool SpiralTool::root_handler(GdkEvent* event) {
static gboolean dragging;
SPDesktop *desktop = this->desktop;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -417,15 +407,15 @@ void SpiralTool::finishItem() {
this->desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(this->desktop)->set(this->spiral);
- DocumentUndo::done(sp_desktop_document(this->desktop), SP_VERB_CONTEXT_SPIRAL, _("Create spiral"));
+ this->desktop->getSelection()->set(this->spiral);
+ DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_SPIRAL, _("Create spiral"));
this->spiral = NULL;
}
}
void SpiralTool::cancel() {
- sp_desktop_selection(this->desktop)->clear();
+ this->desktop->getSelection()->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(this->desktop->acetate), 0);
if (this->spiral != NULL) {
@@ -440,7 +430,7 @@ void SpiralTool::cancel() {
this->desktop->canvas->endForcedFullRedraws();
- DocumentUndo::cancel(sp_desktop_document(this->desktop));
+ DocumentUndo::cancel(this->desktop->getDocument());
}
}
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index cdc608558..ec7d10e13 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -33,7 +33,7 @@
#include "selection.h"
#include "desktop.h"
#include "desktop-events.h"
-#include "desktop-handles.h"
+
#include "message-context.h"
#include "pixmaps/cursor-spray.xpm"
#include <boost/optional.hpp>
@@ -84,20 +84,10 @@ using namespace std;
// Please enable again when working on 1.0
#define ENABLE_SPRAY_MODE_SINGLE_PATH
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createSprayContext() {
- return new SprayTool();
- }
-
- bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext);
-}
-
const std::string& SprayTool::getPrefsPath() {
return SprayTool::prefsPath;
}
@@ -222,7 +212,7 @@ void SprayTool::setup() {
SPCurve *c = new SPCurve(path);
- this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
+ this->dilate_area = sp_canvas_bpath_new(this->desktop->getControls(), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -449,39 +439,41 @@ static bool sp_spray_recursive(SPDesktop *desktop,
}
i++;
}
- SPDocument *doc = parent_item->document;
- Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = parent_item->getRepr();
- Inkscape::XML::Node *parent = old_repr->parent();
-
- Geom::OptRect a = parent_item->documentVisualBounds();
- if (a) {
- if (_fid <= population) { // Rules the population of objects sprayed
- // Duplicates the parent item
- Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
- parent->appendChild(copy);
- SPObject *new_obj = doc->getObjectByRepr(copy);
- item_copied = dynamic_cast<SPItem *>(new_obj);
-
- // Move around the cursor
- Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
-
- Geom::Point center = parent_item->getCenter();
- sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
- sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
- sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
- sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
-
- // Union and duplication
- selection->clear();
- selection->add(item_copied);
- if (unionResult) { // No need to add the very first item (initialized with NULL).
- selection->add(unionResult);
+ if (parent_item) {
+ SPDocument *doc = parent_item->document;
+ Inkscape::XML::Document* xml_doc = doc->getReprDoc();
+ Inkscape::XML::Node *old_repr = parent_item->getRepr();
+ Inkscape::XML::Node *parent = old_repr->parent();
+
+ Geom::OptRect a = parent_item->documentVisualBounds();
+ if (a) {
+ if (_fid <= population) { // Rules the population of objects sprayed
+ // Duplicates the parent item
+ Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
+ parent->appendChild(copy);
+ SPObject *new_obj = doc->getObjectByRepr(copy);
+ item_copied = dynamic_cast<SPItem *>(new_obj);
+
+ // Move around the cursor
+ Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
+
+ Geom::Point center = parent_item->getCenter();
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
+ sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
+ sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
+
+ // Union and duplication
+ selection->clear();
+ selection->add(item_copied);
+ if (unionResult) { // No need to add the very first item (initialized with NULL).
+ selection->add(unionResult);
+ }
+ sp_selected_path_union_skip_undo(selection, selection->desktop());
+ selection->add(parent_item);
+ Inkscape::GC::release(copy);
+ did = true;
}
- sp_selected_path_union_skip_undo(selection, selection->desktop());
- selection->add(parent_item);
- Inkscape::GC::release(copy);
- did = true;
}
}
#endif
@@ -527,7 +519,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
SPDesktop *desktop = tc->desktop;
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection->isEmpty()) {
return false;
@@ -735,15 +727,15 @@ bool SprayTool::root_handler(GdkEvent* event) {
this->has_dilated = false;
switch (this->mode) {
case SPRAY_MODE_COPY:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray with copies"));
break;
case SPRAY_MODE_CLONE:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
break;
case SPRAY_MODE_SINGLE_PATH:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
break;
}
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index b5544d263..9190ae57b 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -30,7 +30,7 @@
#include "document-undo.h"
#include "sp-namedview.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -49,20 +49,10 @@
using Inkscape::DocumentUndo;
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createStarContext() {
- return new StarTool();
- }
-
- bool starContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/star", createStarContext);
-}
-
const std::string& StarTool::getPrefsPath() {
return StarTool::prefsPath;
}
@@ -127,12 +117,12 @@ void StarTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item) {
this->shape_editor->set_item(item);
}
- Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+ Inkscape::Selection *selection = this->desktop->getSelection();
this->sel_changed_connection.disconnect();
@@ -168,7 +158,7 @@ bool StarTool::root_handler(GdkEvent* event) {
static bool dragging;
SPDesktop *desktop = this->desktop;
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -441,8 +431,8 @@ void StarTool::finishItem() {
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(this->star);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ desktop->getSelection()->set(this->star);
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_STAR,
_("Create star"));
this->star = NULL;
@@ -450,7 +440,7 @@ void StarTool::finishItem() {
}
void StarTool::cancel() {
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
if (this->star != NULL) {
@@ -465,7 +455,7 @@ void StarTool::cancel() {
desktop->canvas->endForcedFullRedraws();
- DocumentUndo::cancel(sp_desktop_document(desktop));
+ DocumentUndo::cancel(desktop->getDocument());
}
}
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 578add843..a2c0c81ae 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -26,7 +26,7 @@
#include <sstream>
#include "context-fns.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "desktop.h"
#include "document.h"
@@ -52,7 +52,6 @@
#include "xml/node-event-vector.h"
#include "xml/repr.h"
#include <gtk/gtk.h>
-#include "ui/tool-factory.h"
using Inkscape::ControlManager;
using Inkscape::DocumentUndo;
@@ -71,14 +70,6 @@ static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, TextTool *tc)
static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, TextTool *tc);
static void sptc_commit(GtkIMContext *imc, gchar *string, TextTool *tc);
-namespace {
- ToolBase* createTextContext() {
- return new TextTool();
- }
-
- bool textContextRegistered = ToolFactory::instance().registerObject("/tools/text", createTextContext);
-}
-
const std::string& TextTool::getPrefsPath() {
return TextTool::prefsPath;
}
@@ -131,17 +122,17 @@ void TextTool::setup() {
timeout /= 2;
}
- this->cursor = ControlManager::getManager().createControlLine(sp_desktop_controls(desktop), Geom::Point(100, 0), Geom::Point(100, 100));
+ this->cursor = ControlManager::getManager().createControlLine(desktop->getControls(), Geom::Point(100, 0), Geom::Point(100, 100));
this->cursor->setRgba32(0x000000ff);
sp_canvas_item_hide(this->cursor);
- this->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL);
+ this->indicator = sp_canvas_item_new(desktop->getControls(), SP_TYPE_CTRLRECT, NULL);
SP_CTRLRECT(this->indicator)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100)));
SP_CTRLRECT(this->indicator)->setColor(0x0000ff7f, false, 0);
SP_CTRLRECT(this->indicator)->setShadow(1, 0xffffff7f);
sp_canvas_item_hide(this->indicator);
- this->frame = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL);
+ this->frame = sp_canvas_item_new(desktop->getControls(), SP_TYPE_CTRLRECT, NULL);
SP_CTRLRECT(this->frame)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100)));
SP_CTRLRECT(this->frame)->setColor(0x0000ff7f, false, 0);
sp_canvas_item_hide(this->frame);
@@ -150,7 +141,7 @@ void TextTool::setup() {
this->imc = gtk_im_multicontext_new();
if (this->imc) {
- GtkWidget *canvas = GTK_WIDGET(sp_desktop_canvas(desktop));
+ GtkWidget *canvas = GTK_WIDGET(desktop->getCanvas());
/* im preedit handling is very broken in inkscape for
* multi-byte characters. See bug 1086769.
@@ -175,15 +166,15 @@ void TextTool::setup() {
this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ SPItem *item = this->desktop->getSelection()->singleItem();
if (item && SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) {
this->shape_editor->set_item(item);
}
- this->sel_changed_connection = sp_desktop_selection(desktop)->connectChangedFirst(
+ this->sel_changed_connection = desktop->getSelection()->connectChangedFirst(
sigc::mem_fun(*this, &TextTool::_selectionChanged)
);
- this->sel_modified_connection = sp_desktop_selection(desktop)->connectModifiedFirst(
+ this->sel_modified_connection = desktop->getSelection()->connectModifiedFirst(
sigc::mem_fun(*this, &TextTool::_selectionModified)
);
this->style_set_connection = desktop->connectSetStyle(
@@ -193,7 +184,7 @@ void TextTool::setup() {
sigc::mem_fun(*this, &TextTool::_styleQueried)
);
- _selectionChanged(sp_desktop_selection(desktop));
+ _selectionChanged(desktop->getSelection());
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/text/selcue")) {
@@ -206,7 +197,7 @@ void TextTool::setup() {
void TextTool::finish() {
if (this->desktop) {
- sp_signal_disconnect_by_data(sp_desktop_canvas(this->desktop), this);
+ sp_signal_disconnect_by_data(this->desktop->getCanvas(), this);
}
this->enableGrDrag(false);
@@ -268,7 +259,7 @@ bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
// find out clicked item, disregarding groups
item_ungrouped = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE);
if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) {
- sp_desktop_selection(desktop)->set(item_ungrouped);
+ desktop->getSelection()->set(item_ungrouped);
if (this->text) {
// find out click point in document coordinates
Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y));
@@ -425,13 +416,13 @@ static void sp_text_context_setup_text(TextTool *tc)
SPItem *text_item = SP_ITEM(ec->desktop->currentLayer()->appendChildRepr(rtext));
/* fixme: Is selection::changed really immediate? */
/* yes, it's immediate .. why does it matter? */
- sp_desktop_selection(ec->desktop)->set(text_item);
+ ec->desktop->getSelection()->set(text_item);
Inkscape::GC::release(rtext);
text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse();
text_item->updateRepr();
text_item->doWriteTransform(text_item->getRepr(), text_item->transform, NULL, true);
- DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Create text"));
}
@@ -471,7 +462,7 @@ static void insert_uni_char(TextTool *const tc)
tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, u);
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
- DocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM,
+ DocumentUndo::done(tc->desktop->getDocument(), SP_VERB_DIALOG_TRANSFORM,
_("Insert Unicode character"));
}
}
@@ -627,7 +618,7 @@ bool TextTool::root_handler(GdkEvent* event) {
if (this->creating && this->within_tolerance) {
/* Button 1, set X & Y & new item */
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
this->pdoc = desktop->dt2doc(p1);
this->show = TRUE;
this->phase = 1;
@@ -660,9 +651,9 @@ bool TextTool::root_handler(GdkEvent* event) {
SPItem *ft = create_flowtext_with_internal_frame (desktop, this->p0, p1);
/* Set style */
sp_desktop_apply_style_tool(desktop, ft->getRepr(), "/tools/text", true);
- sp_desktop_selection(desktop)->set(ft);
+ desktop->getSelection()->set(ft);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created."));
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Create flowed text"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Create flowed text"));
} else {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is <b>too small</b> for the current font size. Flowed text not created."));
}
@@ -801,7 +792,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No-break space"));
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Insert no-break space"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Insert no-break space"));
return TRUE;
}
break;
@@ -837,7 +828,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_repr_css_set_property(css, "font-weight", "normal");
sp_te_apply_style(this->text, this->text_sel_start, this->text_sel_end, css);
sp_repr_css_attr_unref(css);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Make bold"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Make bold"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
return TRUE;
@@ -854,7 +845,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_repr_css_set_property(css, "font-style", "italic");
sp_te_apply_style(this->text, this->text_sel_start, this->text_sel_end, css);
sp_repr_css_attr_unref(css);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Make italic"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Make italic"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
return TRUE;
@@ -892,7 +883,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("New line"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("New line"));
return TRUE;
}
case GDK_KEY_BackSpace:
@@ -933,7 +924,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Backspace"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Backspace"));
}
return TRUE;
case GDK_KEY_Delete:
@@ -971,7 +962,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Delete"));
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Delete"));
}
return TRUE;
case GDK_KEY_Left:
@@ -987,7 +978,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*-1, 0));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, _("Kern to the left"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "kern:left", SP_VERB_CONTEXT_TEXT, _("Kern to the left"));
} else {
if (MOD__CTRL(event))
this->text_sel_end.cursorLeftWithControl();
@@ -1011,7 +1002,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*1, 0));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, _("Kern to the right"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "kern:right", SP_VERB_CONTEXT_TEXT, _("Kern to the right"));
} else {
if (MOD__CTRL(event))
this->text_sel_end.cursorRightWithControl();
@@ -1035,7 +1026,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*-1));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, _("Kern up"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "kern:up", SP_VERB_CONTEXT_TEXT, _("Kern up"));
} else {
if (MOD__CTRL(event))
this->text_sel_end.cursorUpWithControl();
@@ -1059,7 +1050,7 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*1));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, _("Kern down"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "kern:down", SP_VERB_CONTEXT_TEXT, _("Kern down"));
} else {
if (MOD__CTRL(event))
this->text_sel_end.cursorDownWithControl();
@@ -1117,7 +1108,7 @@ bool TextTool::root_handler(GdkEvent* event) {
}
Inkscape::Rubberband::get(desktop)->stop();
} else {
- sp_desktop_selection(desktop)->clear();
+ desktop->getSelection()->clear();
}
this->nascent_object = FALSE;
return TRUE;
@@ -1134,7 +1125,7 @@ bool TextTool::root_handler(GdkEvent* event) {
} else {
sp_te_adjust_rotation(this->text, this->text_sel_start, this->text_sel_end, desktop, -90);
}
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, _("Rotate counterclockwise"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "textrot:ccw", SP_VERB_CONTEXT_TEXT, _("Rotate counterclockwise"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
return TRUE;
@@ -1154,7 +1145,7 @@ bool TextTool::root_handler(GdkEvent* event) {
} else {
sp_te_adjust_rotation(this->text, this->text_sel_start, this->text_sel_end, desktop, 90);
}
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, _("Rotate clockwise"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "textrot:cw", SP_VERB_CONTEXT_TEXT, _("Rotate clockwise"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
return TRUE;
@@ -1170,13 +1161,13 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_linespacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, -10);
else
sp_te_adjust_linespacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, -1);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract line spacing"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "linespacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract line spacing"));
} else {
if (MOD__SHIFT(event))
sp_te_adjust_tspan_letterspacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, -10);
else
sp_te_adjust_tspan_letterspacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, -1);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract letter spacing"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract letter spacing"));
}
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
@@ -1193,13 +1184,13 @@ bool TextTool::root_handler(GdkEvent* event) {
sp_te_adjust_linespacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, 10);
else
sp_te_adjust_linespacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, 1);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand line spacing"));
+ DocumentUndo::maybeDone(desktop->getDocument(), "linespacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand line spacing"));
} else {
if (MOD__SHIFT(event))
sp_te_adjust_tspan_letterspacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, 10);
else
sp_te_adjust_tspan_letterspacing_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, 1);
- DocumentUndo::maybeDone(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand letter spacing"));\
+ DocumentUndo::maybeDone(desktop->getDocument(), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand letter spacing"));\
}
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
@@ -1328,7 +1319,7 @@ bool sp_text_paste_inline(ToolBase *ec)
tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start);
begin = end + 1;
}
- DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Paste text"));
return true;
@@ -1451,7 +1442,7 @@ bool TextTool::_styleSet(SPCSSAttr const *css)
return false; // will get picked up by the parent and applied to the whole text object
sp_te_apply_style(this->text, this->text_sel_start, this->text_sel_end, css);
- DocumentUndo::done(sp_desktop_document(this->desktop), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Set text style"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
@@ -1614,7 +1605,7 @@ static void sp_text_context_update_text_selection(TextTool *tc)
quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2dt_affine());
for (unsigned i = 0 ; i < quads.size() ; i += 4) {
SPCanvasItem *quad_canvasitem;
- quad_canvasitem = sp_canvas_item_new(sp_desktop_controls(tc->desktop), SP_TYPE_CTRLQUADR, NULL);
+ quad_canvasitem = sp_canvas_item_new(tc->desktop->getControls(), SP_TYPE_CTRLQUADR, NULL);
// FIXME: make the color settable in prefs
// for now, use semitrasparent blue, as cairo cannot do inversion :(
sp_ctrlquadr_set_rgba32(SP_CTRLQUADR(quad_canvasitem), 0x00777777);
@@ -1661,7 +1652,7 @@ static void sp_text_context_forget_text(TextTool *tc)
// the XML editor
if ( text_repr && text_repr->parent() ) {
sp_repr_unparent(text_repr);
- SPDocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT,
+ SPDocumentUndo::done(tc->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Remove empty text"));
}
}
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 37ca5eeea..a07f2fb86 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -39,7 +39,7 @@
#include "xml/node-event-vector.h"
#include "sp-cursor.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-events.h"
#include "desktop-style.h"
#include "sp-namedview.h"
@@ -149,7 +149,7 @@ ToolBase::~ToolBase() {
*/
void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
- GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(this->desktop));
+ GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
GdkDisplay *display = gdk_display_get_default();
GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type);
@@ -169,7 +169,7 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
* Recreates and draws cursor on desktop related to ToolBase.
*/
void ToolBase::sp_event_context_update_cursor() {
- GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(this->desktop));
+ GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
if (gtk_widget_get_window (w)) {
GtkStyle *style = gtk_widget_get_style(w);
@@ -530,7 +530,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
if (panning_cursor == 1) {
panning_cursor = 0;
- GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(this->desktop));
+ GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
}
@@ -641,7 +641,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
case GDK_KEY_KP_4:
if (MOD__CTRL_ONLY(event)) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
- acceleration, sp_desktop_canvas(desktop)));
+ acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_world(i, 0);
@@ -654,7 +654,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
case GDK_KEY_KP_8:
if (MOD__CTRL_ONLY(event)) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
- acceleration, sp_desktop_canvas(desktop)));
+ acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_world(0, i);
@@ -667,7 +667,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
case GDK_KEY_KP_6:
if (MOD__CTRL_ONLY(event)) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
- acceleration, sp_desktop_canvas(desktop)));
+ acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_world(-i, 0);
@@ -680,7 +680,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
case GDK_KEY_KP_2:
if (MOD__CTRL_ONLY(event)) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
- acceleration, sp_desktop_canvas(desktop)));
+ acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_world(0, -i);
@@ -740,7 +740,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
if (panning_cursor == 1) {
panning_cursor = 0;
- GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(this->desktop));
+ GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
}
@@ -1083,7 +1083,7 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
/* fixme: This is not what I want but works for now (Lauris) */
if (event->type == GDK_KEY_PRESS) {
- item = sp_desktop_selection(desktop)->singleItem();
+ item = desktop->getSelection()->singleItem();
}
ContextMenu* CM = new ContextMenu(desktop, item);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index f56975de2..80b52fba6 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -28,7 +28,7 @@
#include "selection.h"
#include "desktop.h"
#include "desktop-events.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-tweak-move.xpm"
@@ -91,20 +91,10 @@ using Inkscape::DocumentUndo;
#define DYNA_MIN_WIDTH 1.0e-6
-#include "ui/tool-factory.h"
-
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createTweakContext() {
- return new TweakTool();
- }
-
- bool tweakContextRegistered = ToolFactory::instance().registerObject("/tools/tweak", createTweakContext);
-}
-
const std::string& TweakTool::getPrefsPath() {
return TweakTool::prefsPath;
}
@@ -274,7 +264,7 @@ void TweakTool::setup() {
SPCurve *c = new SPCurve(path);
- this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c);
+ this->dilate_area = sp_canvas_bpath_new(this->desktop->getControls(), c);
c->unref();
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -1032,7 +1022,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
static bool
sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse)
{
- Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
+ Inkscape::Selection *selection = tc->desktop->getSelection();
SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
if (selection->isEmpty()) {
@@ -1235,55 +1225,55 @@ bool TweakTool::root_handler(GdkEvent* event) {
this->has_dilated = false;
switch (this->mode) {
case TWEAK_MODE_MOVE:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Move tweak"));
break;
case TWEAK_MODE_MOVE_IN_OUT:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak"));
break;
case TWEAK_MODE_MOVE_JITTER:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak"));
break;
case TWEAK_MODE_SCALE:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Scale tweak"));
break;
case TWEAK_MODE_ROTATE:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Rotate tweak"));
break;
case TWEAK_MODE_MORELESS:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak"));
break;
case TWEAK_MODE_PUSH:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Push path tweak"));
break;
case TWEAK_MODE_SHRINK_GROW:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak"));
break;
case TWEAK_MODE_ATTRACT_REPEL:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak"));
break;
case TWEAK_MODE_ROUGHEN:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak"));
break;
case TWEAK_MODE_COLORPAINT:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Color paint tweak"));
break;
case TWEAK_MODE_COLORJITTER:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak"));
break;
case TWEAK_MODE_BLUR:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop),
+ DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_TWEAK, _("Blur tweak"));
break;
}
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index b3fb78c8f..6a4d4dbbd 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -25,20 +25,11 @@
#include "selection-chemistry.h"
#include "ui/tools/zoom-tool.h"
-#include "ui/tool-factory.h"
namespace Inkscape {
namespace UI {
namespace Tools {
-namespace {
- ToolBase* createZoomContext() {
- return new ZoomTool();
- }
-
- bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext);
-}
-
const std::string& ZoomTool::getPrefsPath() {
return ZoomTool::prefsPath;
}
diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp
index 72548e213..47e2a1e0d 100644
--- a/src/ui/view/view.cpp
+++ b/src/ui/view/view.cpp
@@ -20,7 +20,7 @@
#include "message-stack.h"
#include "message-context.h"
#include "verbs.h"
-#include "inkscape-private.h"
+#include "inkscape.h"
namespace Inkscape {
namespace UI {
@@ -85,7 +85,7 @@ void View::_close() {
if (_doc) {
_document_uri_set_connection.disconnect();
_document_resized_connection.disconnect();
- if (inkscape_remove_document(_doc)) {
+ if (INKSCAPE.remove_document(_doc)) {
// this was the last view of this document, so delete it
delete _doc;
}
@@ -111,13 +111,13 @@ void View::setDocument(SPDocument *doc) {
if (_doc) {
_document_uri_set_connection.disconnect();
_document_resized_connection.disconnect();
- if (inkscape_remove_document(_doc)) {
+ if (INKSCAPE.remove_document(_doc)) {
// this was the last view of this document, so delete it
delete _doc;
}
}
- inkscape_add_document(doc);
+ INKSCAPE.add_document(doc);
_doc = doc;
_document_uri_set_connection =
diff --git a/src/ui/view/view.h b/src/ui/view/view.h
index 48f4d2549..21a5d0dfc 100644
--- a/src/ui/view/view.h
+++ b/src/ui/view/view.h
@@ -15,7 +15,7 @@
#include <stddef.h>
#include <sigc++/connection.h>
#include "message.h"
-#include "gc-managed.h"
+#include "inkgc/gc-managed.h"
#include "gc-finalized.h"
#include "gc-anchored.h"
#include <2geom/forward.h>
diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp
index 0798d1c98..f15d7abf7 100644
--- a/src/ui/widget/addtoicon.cpp
+++ b/src/ui/widget/addtoicon.cpp
@@ -23,6 +23,7 @@
#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
+#include "preferences.h"
#include "layertypeicon.h"
#include "addtoicon.h"
@@ -39,6 +40,7 @@ AddToIcon::AddToIcon() :
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_BUTTON);
+
// Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
//
// if (!icon_theme->has_icon(_pixAddName)) {
@@ -50,7 +52,8 @@ AddToIcon::AddToIcon() :
//
// _property_pixbuf_add = Gtk::Widget::
- property_stock_id() = GTK_STOCK_ADD;
+ //property_stock_id() = GTK_STOCK_ADD;
+ set_pixbuf();
}
@@ -118,7 +121,7 @@ void AddToIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
Gtk::CellRendererState flags )
#endif
{
- property_stock_id() = property_active().get_value() ? GTK_STOCK_ADD : GTK_STOCK_DELETE;
+ set_pixbuf();
#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
@@ -137,6 +140,14 @@ bool AddToIcon::activate_vfunc(GdkEvent* /*event*/,
return false;
}
+void AddToIcon::set_pixbuf()
+{
+ bool active = property_active().get_value();
+
+ GdkPixbuf *pixbuf = sp_pixbuf_new(Inkscape::ICON_SIZE_BUTTON, active ? INKSCAPE_ICON("list-add") : INKSCAPE_ICON("edit-delete"));
+ property_pixbuf() = Glib::wrap(pixbuf);
+}
+
} // namespace Widget
} // namespace UI
@@ -152,5 +163,3 @@ bool AddToIcon::activate_vfunc(GdkEvent* /*event*/,
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
-
-
diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h
index 9c134d231..a8d900d1f 100644
--- a/src/ui/widget/addtoicon.h
+++ b/src/ui/widget/addtoicon.h
@@ -74,7 +74,7 @@ private:
Glib::Property<bool> _property_active;
// Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_add;
-
+ void set_pixbuf();
};
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index 6b5a351f6..d4c4d394e 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -12,7 +12,7 @@
#include "color-picker.h"
#include "inkscape.h"
-#include "desktop-handles.h"
+#include "desktop.h"
#include "document.h"
#include "document-undo.h"
#include "ui/dialog-events.h"
@@ -128,7 +128,7 @@ void sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
(ptr->_preview).setRgba32 (rgba);
if (ptr->_undo && SP_ACTIVE_DESKTOP)
- DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE,
+ DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_NONE,
/* TODO: annotate */ "color-picker.cpp:130");
ptr->on_changed (rgba);
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index 52e9ea605..c5e14d4f0 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -119,8 +119,9 @@ Dock::Dock(Gtk::Orientation orientation)
gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(hideCallback), (void *)this);
- g_signal_connect(G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(unhideCallback), (void *)this);
+
+ INKSCAPE.signal_dialogs_hide.connect(sigc::mem_fun(*this, &Dock::hide));
+ INKSCAPE.signal_dialogs_unhide.connect(sigc::mem_fun(*this, &Dock::show));
g_signal_connect(_paned->gobj(), "button-press-event", G_CALLBACK(_on_paned_button_event), (void *)this);
g_signal_connect(_paned->gobj(), "button-release-event", G_CALLBACK(_on_paned_button_event), (void *)this);
diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp
index 4754b9c23..242a99073 100644
--- a/src/ui/widget/filter-effect-chooser.cpp
+++ b/src/ui/widget/filter-effect-chooser.cpp
@@ -13,7 +13,7 @@
#include <glibmm/i18n.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "inkscape.h"
diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp
index 22abd04ba..df261b69a 100644
--- a/src/ui/widget/imageicon.cpp
+++ b/src/ui/widget/imageicon.cpp
@@ -88,8 +88,9 @@ ImageIcon::~ImageIcon()
*/
void ImageIcon::init()
{
- if (!INKSCAPE)
- inkscape_application_init("",false);
+ // \FIXME Why?
+ if (!Inkscape::Application::exists())
+ Inkscape::Application::create("", false);
document = NULL;
viewerGtkmm = NULL;
//set_size_request(150,150);
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index 7b1a8dbfb..dc89d233f 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -21,7 +21,7 @@
#include <glibmm/i18n.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "document.h"
#include "document-undo.h"
#include "layer-manager.h"
@@ -601,7 +601,7 @@ void LayerSelector::_prepareLabelRenderer(
void LayerSelector::_lockLayer(bool lock) {
if ( _layer && SP_IS_ITEM(_layer) ) {
SP_ITEM(_layer)->setLocked(lock);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_NONE,
lock? _("Lock layer") : _("Unlock layer"));
}
}
@@ -609,7 +609,7 @@ void LayerSelector::_lockLayer(bool lock) {
void LayerSelector::_hideLayer(bool hide) {
if ( _layer && SP_IS_ITEM(_layer) ) {
SP_ITEM(_layer)->setHidden(hide);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_NONE,
hide? _("Hide layer") : _("Unhide layer"));
}
}
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp
index 7429bb07e..d21e848f2 100644
--- a/src/ui/widget/licensor.cpp
+++ b/src/ui/widget/licensor.cpp
@@ -69,7 +69,7 @@ void LicenseItem::on_toggled()
SPDocument *doc = SP_ACTIVE_DOCUMENT;
rdf_set_license (doc, _lic->details ? _lic : 0);
if (doc->priv->sensitive) {
- DocumentUndo::done(doc, SP_VERB_NONE, "Document license updated");
+ DocumentUndo::done(doc, SP_VERB_NONE, _("Document license updated"));
}
_wr.setUpdating (false);
static_cast<Gtk::Entry*>(_eep->_packable)->set_text (_lic->uri);
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index e4cd76345..00a74c4fe 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -17,7 +17,7 @@
#include <glibmm/i18n.h>
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "document.h"
#include "document-undo.h"
@@ -39,26 +39,6 @@ namespace Inkscape {
namespace UI {
namespace Widget {
-/*void ObjectCompositeSettings::_on_desktop_activate(
- InkscapeApplication *application,
- SPDesktop *desktop,
- ObjectCompositeSettings *w
-) {
- if (w->_subject) {
- w->_subject->setDesktop(desktop);
- }
-}
-
-void ObjectCompositeSettings::_on_desktop_deactivate(
- InkscapeApplication *application,
- SPDesktop *desktop,
- ObjectCompositeSettings *w
-) {
- if (w->_subject) {
- w->_subject->setDesktop(NULL);
- }
-}*/
-
ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags)
: _verb_code(verb_code),
_blur_tag(Glib::ustring(history_prefix) + ":blur"),
@@ -102,7 +82,6 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co
ObjectCompositeSettings::~ObjectCompositeSettings() {
setSubject(NULL);
- g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _desktop_activated);
}
void ObjectCompositeSettings::setSubject(StyleSubject *subject) {
@@ -125,14 +104,14 @@ ObjectCompositeSettings::_blendBlurValueChanged()
if (!desktop) {
return;
}
- SPDocument *document = sp_desktop_document (desktop);
+ SPDocument *document = desktop->getDocument();
if (_blocked)
return;
_blocked = true;
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
- //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+ //sp_canvas_force_full_redraw_after_interruptions(desktop->getCanvas(), 0);
Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
double radius;
@@ -180,7 +159,7 @@ ObjectCompositeSettings::_blendBlurValueChanged()
_("Change blur"));
// resume interruptibility
- //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+ //sp_canvas_end_forced_full_redraws(desktop->getCanvas());
_blocked = false;
}
@@ -204,7 +183,7 @@ ObjectCompositeSettings::_opacityValueChanged()
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
// UPDATE: crash fixed in GTK+ 2.10.7 (bug 374378), remove this as soon as it's reasonably common
// (though this only fixes the crash, not the multiple change events)
- //sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
+ //sp_canvas_force_full_redraw_after_interruptions(desktop->getCanvas(), 0);
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -216,11 +195,11 @@ ObjectCompositeSettings::_opacityValueChanged()
sp_repr_css_attr_unref (css);
- DocumentUndo::maybeDone(sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code,
+ DocumentUndo::maybeDone(desktop->getDocument(), _opacity_tag.c_str(), _verb_code,
_("Change opacity"));
// resume interruptibility
- //sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
+ //sp_canvas_end_forced_full_redraws(desktop->getCanvas());
_blocked = false;
}
@@ -240,8 +219,8 @@ ObjectCompositeSettings::_subjectChanged() {
return;
_blocked = true;
- SPStyle *query = sp_style_new (sp_desktop_document(desktop));
- int result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
+ SPStyle query(desktop->getDocument());
+ int result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
switch (result) {
case QUERY_STYLE_NOTHING:
@@ -252,19 +231,19 @@ ObjectCompositeSettings::_subjectChanged() {
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
case QUERY_STYLE_MULTIPLE_SAME:
_opacity_vbox.set_sensitive(true);
- _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
+ _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query.opacity.value));
break;
}
//query now for current filter mode and average blurring of selection
- const int blend_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLEND);
+ const int blend_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLEND);
switch(blend_result) {
case QUERY_STYLE_NOTHING:
_fe_cb.set_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_SAME:
- _fe_cb.set_blend_mode(query->filter_blend_mode.value);
+ _fe_cb.set_blend_mode(query.filter_blend_mode.value);
_fe_cb.set_sensitive(true);
break;
case QUERY_STYLE_MULTIPLE_DIFFERENT:
@@ -274,7 +253,7 @@ ObjectCompositeSettings::_subjectChanged() {
}
if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) {
- int blur_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLUR);
+ int blur_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLUR);
switch (blur_result) {
case QUERY_STYLE_NOTHING: //no blurring
_fe_cb.set_blur_sensitive(false);
@@ -287,7 +266,7 @@ ObjectCompositeSettings::_subjectChanged() {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
_fe_cb.set_blur_sensitive(true);
//update blur widget value
- float radius = query->filter_gaussianBlur_deviation.value;
+ float radius = query.filter_gaussianBlur_deviation.value;
float percent = radius * 400 / perimeter; // so that for a square, 100% == half side
_fe_cb.set_blur_value(percent);
}
@@ -295,8 +274,6 @@ ObjectCompositeSettings::_subjectChanged() {
}
}
- sp_style_unref(query);
-
_blocked = false;
}
diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h
index e375bf24a..5a723a2fd 100644
--- a/src/ui/widget/object-composite-settings.h
+++ b/src/ui/widget/object-composite-settings.h
@@ -66,8 +66,8 @@ private:
gulong _desktop_activated;
sigc::connection _subject_changed;
- static void _on_desktop_activate(InkscapeApplication *application, SPDesktop *desktop, ObjectCompositeSettings *w);
- static void _on_desktop_deactivate(InkscapeApplication *application, SPDesktop *desktop, ObjectCompositeSettings *w);
+ static void _on_desktop_activate(SPDesktop *desktop, ObjectCompositeSettings *w);
+ static void _on_desktop_deactivate(SPDesktop *desktop, ObjectCompositeSettings *w);
void _subjectChanged();
void _blendBlurValueChanged();
void _opacityValueChanged();
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index b775b3c49..8e647ebb4 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -26,13 +26,14 @@
#include <cmath>
#include <string>
#include <string.h>
+#include <sstream>
#include <vector>
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
-#include "desktop-handles.h"
+
#include "document.h"
#include "desktop.h"
#include "helper/action.h"
@@ -240,6 +241,8 @@ PageSizer::PageSizer(Registry & _wr)
_marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr),
_marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr),
_lockMarginUpdate(false),
+ _scaleX(_("Scale _x:"), _("Scale X"), "scale-x", _wr),
+ _lockScaleUpdate(false),
_widgetRegistry(&_wr)
{
// set precision of scalar entry boxes
@@ -250,6 +253,8 @@ PageSizer::PageSizer(Registry & _wr)
_marginLeft.setDigits(5);
_marginRight.setDigits(5);
_marginBottom.setDigits(5);
+ _scaleX.setDigits(5);
+ _scaleX.setRange( 0.00001, 100000 );
_wr.setUpdating (false);
//# Set up the Paper Size combo box
@@ -309,7 +314,7 @@ PageSizer::PageSizer(Registry & _wr)
// Setting default custom unit to document unit
SPDesktop *dt = SP_ACTIVE_DESKTOP;
- SPNamedView *nv = sp_desktop_namedview(dt);
+ SPNamedView *nv = dt->getNamedView();
_wr.setUpdating (true);
if (nv->page_size_units) {
_dimensionUnits.setUnit(nv->page_size_units->abbr);
@@ -318,6 +323,7 @@ PageSizer::PageSizer(Registry & _wr)
}
_wr.setUpdating (false);
+
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
pack_start (_customFrame, false, false, 0);
@@ -419,6 +425,34 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageButton.set_label(_("_Resize page to drawing or selection"));
_fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
+ _scaleFrame.set_label(_("Scale"));
+ pack_start (_scaleFrame, false, false, 0);
+ _scaleFrame.add(_scaleTable);
+
+ _scaleTable.set_border_width(4);
+
+#if WITH_GTKMM_3_0
+ _scaleTable.set_row_spacing(4);
+ _scaleTable.set_column_spacing(4);
+
+ _dimensionWidth.set_hexpand();
+ _dimensionWidth.set_vexpand();
+ _scaleTable.attach(_scaleX, 0, 0, 1, 1);
+
+ _dimensionUnits.set_hexpand();
+ _dimensionUnits.set_vexpand();
+ _scaleTable.attach(_scaleLabel, 1, 0, 1, 1);
+#else
+ _scaleTable.resize(2, 1);
+ _scaleTable.set_row_spacings(4);
+ _scaleTable.set_col_spacings(4);
+ _scaleTable.attach(_scaleX, 0,1, 0,1);
+ _scaleTable.attach(_scaleLabel, 1,2, 0,1);
+#endif
+
+ _wr.setUpdating (true);
+ updateScaleUI();
+ _wr.setUpdating (false);
}
@@ -444,7 +478,7 @@ PageSizer::init ()
_changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed));
_changedu_connection = _dimensionUnits.getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &PageSizer::on_units_changed));
_fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing));
-
+ _changeds_connection = _scaleX.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_scale_changed));
show_all_children();
}
@@ -459,7 +493,7 @@ PageSizer::init ()
* \param changeList whether to modify the paper size list
*/
void
-PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList)
+PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList, bool changeSize)
{
static bool _called = false;
if (_called) {
@@ -477,14 +511,15 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool
_unit = w.unit->abbr;
if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) {
- SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
+ SPDocument *doc = SP_ACTIVE_DESKTOP->getDocument();
Inkscape::Util::Quantity const old_height = doc->getHeight();
- doc->setWidth (w);
- doc->setHeight (h);
+ doc->setWidthAndHeight (w, h, changeSize);
// The origin for the user is in the lower left corner; this point should remain stationary when
// changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this
- Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px"))));
- doc->getRoot()->translateChildItems(vert_offset);
+ if (changeSize) {
+ Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px"))));
+ doc->getRoot()->translateChildItems(vert_offset);
+ }
DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size"));
}
@@ -511,6 +546,7 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool
_dimensionHeight.setUnit(h.unit->abbr);
_dimensionHeight.setValue (h.quantity);
+
_paper_size_list_connection.unblock();
_landscape_connection.unblock();
_portrait_connection.unblock();
@@ -606,7 +642,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing()
SPNamedView *nv;
Inkscape::XML::Node *nv_repr;
- if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP))
+ if ((doc = SP_ACTIVE_DESKTOP->getDocument())
&& (nv = sp_document_namedview(doc, 0))
&& (nv_repr = nv->getRepr())) {
_lockMarginUpdate = true;
@@ -700,6 +736,60 @@ PageSizer::on_landscape()
}
}
+
+/**
+ * Update scale widgets
+ */
+void
+PageSizer::updateScaleUI()
+{
+
+ if (_lockScaleUpdate) {
+ return;
+ }
+
+ static bool _called = false;
+ if (_called) {
+ return;
+ }
+
+ _called = true;
+
+ _changeds_connection.block();
+
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ SPDocument *doc = dt->getDocument();
+ Geom::Scale scale = doc->getDocumentScale();
+
+ SPNamedView *nv = dt->getNamedView();
+
+ std::stringstream ss;
+ ss << _("User units per ") << nv->display_units->abbr << "." ;
+ _scaleLabel.set_text( ss.str() );
+
+ double scaleX_inv =
+ Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units );
+ if( scaleX_inv > 0 ) {
+ _scaleX.setValue(1.0/scaleX_inv);
+ } else {
+ // Should never happen
+ std::cerr << "PageSizer::updateScaleUI(): Invalid scale value: " << scaleX_inv << std::endl;
+ _scaleX.setValue(1.0);
+ }
+
+ } else {
+ // Should never happen
+ std::cerr << "PageSizer::updateScaleUI(): No active desktop." << std::endl;
+ _scaleLabel.set_text( "Unknown scale" );
+ }
+
+ _changeds_connection.unblock();
+
+ _called = false;
+}
+
+
/**
* Callback for the dimension widgets
*/
@@ -717,7 +807,34 @@ PageSizer::on_units_changed()
if (_widgetRegistry->isUpdating()) return;
_unit = _dimensionUnits.getUnit()->abbr;
setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()),
- Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit()));
+ Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit()),
+ true, false);
+}
+
+/**
+ * Callback for scale widgets
+ */
+void
+PageSizer::on_scale_changed()
+{
+ if (_widgetRegistry->isUpdating()) return;
+
+ double value = _scaleX.getValue();
+ if( value > 0 ) {
+
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ SPDocument *doc = dt->getDocument();
+ SPNamedView *nv = dt->getNamedView();
+
+ double scaleX_inv = Inkscape::Util::Quantity(1.0/value, nv->display_units ).value("px");
+
+ _lockScaleUpdate = true;
+ doc->setDocumentScale( 1.0/scaleX_inv );
+ _lockScaleUpdate = false;
+ DocumentUndo::done(doc, SP_VERB_NONE, _("Set page scale"));
+ }
+ }
}
} // namespace Widget
diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h
index f4bcae4b6..f9a72d9f3 100644
--- a/src/ui/widget/page-sizer.h
+++ b/src/ui/widget/page-sizer.h
@@ -161,7 +161,7 @@ public:
* Set the page size to the given dimensions. If 'changeList' is
* true, then reset the paper size list to the closest match
*/
- void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true);
+ void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true, bool changeSize=true);
/**
* Updates the scalar widgets for the fit margins. (Just changes the value
@@ -169,6 +169,11 @@ public:
*/
void updateFitMarginsUI(Inkscape::XML::Node *nv_repr);
+ /**
+ * Updates the scale widgets. (Just changes the values of the ui widgets.)
+ */
+ void updateScaleUI();
+
protected:
/**
@@ -250,12 +255,26 @@ protected:
Gtk::Button _fitPageButton;
bool _lockMarginUpdate;
+ // Document scale
+ Gtk::Frame _scaleFrame;
+#if WITH_GTKMM_3_0
+ Gtk::Grid _scaleTable;
+#else
+ Gtk::Table _scaleTable;
+#endif
+
+ Gtk::Label _scaleLabel;
+ RegisteredScalar _scaleX;
+ bool _lockScaleUpdate;
+
//callback
void on_value_changed();
void on_units_changed();
+ void on_scale_changed();
sigc::connection _changedw_connection;
sigc::connection _changedh_connection;
sigc::connection _changedu_connection;
+ sigc::connection _changeds_connection;
Registry *_widgetRegistry;
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index 0abd81b16..0cff25d88 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -33,7 +33,8 @@
#include "panel.h"
#include "icon-size.h"
#include "preferences.h"
-#include "desktop-handles.h"
+#include "desktop.h"
+
#include "inkscape.h"
#include "widgets/eek-preview.h"
#include "ui/previewfillable.h"
@@ -293,7 +294,7 @@ void Panel::_init()
signalResponse().connect(sigc::mem_fun(*this, &Panel::_handleResponse));
- signalActivateDesktop().connect(sigc::hide<0>(sigc::mem_fun(*this, &Panel::setDesktop)));
+ signalActivateDesktop().connect(sigc::mem_fun(*this, &Panel::setDesktop));
show_all_children();
@@ -643,13 +644,13 @@ Panel::signalDocumentReplaced()
return _signal_document_replaced;
}
-sigc::signal<void, InkscapeApplication *, SPDesktop *> &
+sigc::signal<void, SPDesktop *> &
Panel::signalActivateDesktop()
{
return _signal_activate_desktop;
}
-sigc::signal<void, InkscapeApplication *, SPDesktop *> &
+sigc::signal<void, SPDesktop *> &
Panel::signalDeactiveDesktop()
{
return _signal_deactive_desktop;
@@ -667,7 +668,7 @@ void Panel::_handleResponse(int response_id)
Inkscape::Selection *Panel::_getSelection()
{
- return sp_desktop_selection(_desktop);
+ return _desktop->getSelection();
}
} // namespace Widget
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 177314797..5680cac30 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -48,6 +48,7 @@ namespace Gtk {
struct InkscapeApplication;
namespace Inkscape {
+
class Selection;
namespace UI {
@@ -116,8 +117,8 @@ public:
void setResponseSensitive(int response_id, bool setting);
virtual sigc::signal<void, SPDesktop *, SPDocument *> &signalDocumentReplaced();
- virtual sigc::signal<void, InkscapeApplication *, SPDesktop *> &signalActivateDesktop();
- virtual sigc::signal<void, InkscapeApplication *, SPDesktop *> &signalDeactiveDesktop();
+ virtual sigc::signal<void, SPDesktop *> &signalActivateDesktop();
+ virtual sigc::signal<void, SPDesktop *> &signalDeactiveDesktop();
protected:
/**
@@ -147,8 +148,8 @@ protected:
sigc::signal<void, int> _signal_response;
sigc::signal<void> _signal_present;
sigc::signal<void, SPDesktop *, SPDocument *> _signal_document_replaced;
- sigc::signal<void, InkscapeApplication *, SPDesktop *> _signal_activate_desktop;
- sigc::signal<void, InkscapeApplication *, SPDesktop *> _signal_deactive_desktop;
+ sigc::signal<void, SPDesktop *> _signal_activate_desktop;
+ sigc::signal<void, SPDesktop *> _signal_deactive_desktop;
private:
void _init();
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 7f3e6cd47..98028ed78 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -34,7 +34,7 @@
#include "desktop.h"
#include "enums.h"
#include "inkscape.h"
-#include "desktop-handles.h"
+
#include "message-stack.h"
#include "style.h"
#include "selection.h"
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index e97285de4..298377af3 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -36,6 +36,11 @@
// for interruptability bug:
#include "display/sp-canvas.h"
+#include "desktop.h"
+
+
+#include "sp-root.h"
+
namespace Inkscape {
namespace UI {
namespace Widget {
@@ -203,7 +208,7 @@ RegisteredScalarUnit::~RegisteredScalarUnit()
_value_changed_connection.disconnect();
}
-RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in)
+RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, const RegisteredUnitMenu &rum, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument *doc_in, RSU_UserUnits user_units)
: RegisteredWidget<ScalarUnit>(label, tip, UNIT_TYPE_LINEAR, "", "", rum.getUnitMenu()),
_um(0)
{
@@ -215,6 +220,7 @@ RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Gl
setUnit (rum.getUnitMenu()->getUnitAbbr());
setDigits (2);
_um = rum.getUnitMenu();
+ _user_units = user_units;
_value_changed_connection = signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalarUnit::on_value_changed));
}
@@ -233,12 +239,31 @@ RegisteredScalarUnit::on_value_changed()
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
- os << getValue("");
- if (_um)
- os << _um->getUnitAbbr();
+ if (_user_units != RSU_none) {
+ // Output length in 'user units', taking into account scale in 'x' or 'y'.
+ double scale = 1.0;
+ if (doc) {
+ SPRoot *root = doc->getRoot();
+ if (root->viewBox_set) {
+ // check to see if scaling is uniform
+ if(Geom::are_near((root->viewBox.width() * root->height.computed) / (root->width.computed * root->viewBox.height()), 1.0, Geom::EPSILON)) {
+ scale = (root->viewBox.width() / root->width.computed + root->viewBox.height() / root->height.computed)/2.0;
+ } else if (_user_units == RSU_x) {
+ scale = root->viewBox.width() / root->width.computed;
+ } else {
+ scale = root->viewBox.height() / root->height.computed;
+ }
+ }
+ }
+ os << getValue("px") * scale;
+ } else {
+ // Output using unit identifiers.
+ os << getValue("");
+ if (_um)
+ os << _um->getUnitAbbr();
+ }
write_to_xml(os.str().c_str());
-
_wr->setUpdating (false);
}
@@ -397,8 +422,8 @@ RegisteredColorPicker::on_changed (guint32 rgba)
SPDesktop *dt = SP_ACTIVE_DESKTOP;
if (!dt)
return;
- local_repr = sp_desktop_namedview(dt)->getRepr();
- local_doc = sp_desktop_document(dt);
+ local_repr = dt->getNamedView()->getRepr();
+ local_doc = dt->getDocument();
}
gchar c[32];
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index 1f505a3cd..9d2489712 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -27,7 +27,7 @@
#include "document.h"
#include "document-undo.h"
-#include "desktop-handles.h"
+#include "desktop.h"
#include "sp-namedview.h"
#include <gtkmm/checkbutton.h>
@@ -99,8 +99,8 @@ protected:
if (!local_repr) {
// no repr specified, use active desktop's namedview's repr
SPDesktop* dt = SP_ACTIVE_DESKTOP;
- local_repr = reinterpret_cast<SPObject *>(sp_desktop_namedview(dt))->getRepr();
- local_doc = sp_desktop_document(dt);
+ local_repr = reinterpret_cast<SPObject *>(dt->getNamedView())->getRepr();
+ local_doc = dt->getDocument();
}
bool saved = DocumentUndo::getUndoSensitive(local_doc);
@@ -206,6 +206,14 @@ protected:
void on_changed();
};
+// Allow RegisteredScalarUnit to output lengths in 'user units' (which may have direction dependent
+// scale factors).
+enum RSU_UserUnits {
+ RSU_none,
+ RSU_x,
+ RSU_y
+};
+
class RegisteredScalarUnit : public RegisteredWidget<ScalarUnit> {
public:
~RegisteredScalarUnit();
@@ -215,12 +223,14 @@ public:
const RegisteredUnitMenu &rum,
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
- SPDocument *doc_in = NULL );
+ SPDocument *doc_in = NULL,
+ RSU_UserUnits _user_units = RSU_none );
protected:
sigc::connection _value_changed_connection;
UnitMenu *_um;
void on_value_changed();
+ RSU_UserUnits _user_units;
};
class RegisteredScalar : public RegisteredWidget<Scalar> {
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index aebef2c4e..9e283fc64 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -20,13 +20,13 @@
#include "ui/widget/color-preview.h"
#include "selection.h"
-#include "desktop-handles.h"
+
#include "style.h"
#include "desktop-style.h"
#include "sp-namedview.h"
#include "sp-linear-gradient.h"
-#include "sp-mesh-gradient.h"
#include "sp-radial-gradient.h"
+#include "sp-mesh.h"
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
@@ -480,7 +480,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop)
_desktop = desktop;
g_object_set_data (G_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas);
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
selection_changed_connection = new sigc::connection (selection->connectChanged(
sigc::bind (
@@ -498,7 +498,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop)
this )
));
- _sw_unit = sp_desktop_namedview(desktop)->display_units;
+ _sw_unit = desktop->getNamedView()->display_units;
// Set the doc default unit active in the units list
gint length = g_slist_length(_unit_mis);
@@ -541,8 +541,7 @@ void SelectedStyle::dragDataReceived( GtkWidget */*widget*/,
sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c );
sp_desktop_set_style( tracker->parent->_desktop, css );
sp_repr_css_attr_unref( css );
- DocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE,
- _("Drop color"));
+ DocumentUndo::done( tracker->parent->_desktop->getDocument(), SP_VERB_NONE, _("Drop color"));
}
}
break;
@@ -554,7 +553,7 @@ void SelectedStyle::on_fill_remove() {
sp_repr_css_set_property (css, "fill", "none");
sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Remove fill"));
}
@@ -563,7 +562,7 @@ void SelectedStyle::on_stroke_remove() {
sp_repr_css_set_property (css, "stroke", "none");
sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Remove stroke"));
}
@@ -572,7 +571,7 @@ void SelectedStyle::on_fill_unset() {
sp_repr_css_unset_property (css, "fill");
sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Unset fill"));
}
@@ -588,7 +587,7 @@ void SelectedStyle::on_stroke_unset() {
sp_repr_css_unset_property (css, "stroke-dasharray");
sp_desktop_set_style (_desktop, css, true, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Unset stroke"));
}
@@ -597,7 +596,7 @@ void SelectedStyle::on_fill_opaque() {
sp_repr_css_set_property (css, "fill-opacity", "1");
sp_desktop_set_style (_desktop, css, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Make fill opaque"));
}
@@ -606,7 +605,7 @@ void SelectedStyle::on_stroke_opaque() {
sp_repr_css_set_property (css, "stroke-opacity", "1");
sp_desktop_set_style (_desktop, css, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Make fill opaque"));
}
@@ -618,7 +617,7 @@ void SelectedStyle::on_fill_lastused() {
sp_repr_css_set_property (css, "fill", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last set color to fill"));
}
@@ -630,7 +629,7 @@ void SelectedStyle::on_stroke_lastused() {
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last set color to stroke"));
}
@@ -641,7 +640,7 @@ void SelectedStyle::on_fill_lastselected() {
sp_repr_css_set_property (css, "fill", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last selected color to fill"));
}
@@ -652,7 +651,7 @@ void SelectedStyle::on_stroke_lastselected() {
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Apply last selected color to stroke"));
}
@@ -678,7 +677,7 @@ void SelectedStyle::on_fill_invert() {
sp_repr_css_set_property (css, "fill", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Invert fill"));
}
@@ -702,7 +701,7 @@ void SelectedStyle::on_stroke_invert() {
sp_repr_css_set_property (css, "stroke", c);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Invert stroke"));
}
@@ -714,7 +713,7 @@ void SelectedStyle::on_fill_white() {
sp_repr_css_set_property (css, "fill-opacity", "1");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("White fill"));
}
@@ -726,7 +725,7 @@ void SelectedStyle::on_stroke_white() {
sp_repr_css_set_property (css, "stroke-opacity", "1");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("White stroke"));
}
@@ -738,7 +737,7 @@ void SelectedStyle::on_fill_black() {
sp_repr_css_set_property (css, "fill-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Black fill"));
}
@@ -750,7 +749,7 @@ void SelectedStyle::on_stroke_black() {
sp_repr_css_set_property (css, "stroke-opacity", "1.0");
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Black stroke"));
}
@@ -793,7 +792,7 @@ void SelectedStyle::on_fill_paste() {
sp_repr_css_set_property (css, "fill", text.c_str());
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Paste fill"));
}
}
@@ -811,7 +810,7 @@ void SelectedStyle::on_stroke_paste() {
sp_repr_css_set_property (css, "stroke", text.c_str());
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Paste stroke"));
}
}
@@ -865,7 +864,7 @@ void SelectedStyle::on_fillstroke_swap() {
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Swap fill and stroke"));
}
@@ -940,7 +939,7 @@ SelectedStyle::on_opacity_click(GdkEventButton *event)
sp_repr_css_set_property (css, "opacity", opacity);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
_("Change opacity"));
return true;
}
@@ -967,7 +966,7 @@ void SelectedStyle::on_popup_preset(int i) {
// FIXME: update dash patterns!
sp_desktop_set_style (_desktop, css, true);
sp_repr_css_attr_unref (css);
- DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES,
+ DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_SWATCHES,
_("Change stroke width"));
}
@@ -978,7 +977,7 @@ SelectedStyle::update()
return;
// create temporary style
- SPStyle *query = sp_style_new (sp_desktop_document(_desktop));
+ SPStyle query(_desktop->getDocument());
for (int i = SS_FILL; i <= SS_STROKE; i++) {
Gtk::EventBox *place = (i == SS_FILL)? &_fill_place : &_stroke_place;
@@ -996,7 +995,7 @@ SelectedStyle::update()
_popup_copy[i].set_sensitive(false);
// query style from desktop. This returns a result flag and fills query with the style of subselection, if any, or selection
- int result = sp_desktop_query_style (_desktop, query,
+ int result = sp_desktop_query_style (_desktop, &query,
(i == SS_FILL)? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
switch (result) {
case QUERY_STYLE_NOTHING:
@@ -1021,12 +1020,12 @@ SelectedStyle::update()
}
SPIPaint *paint;
if (i == SS_FILL) {
- paint = &(query->fill);
+ paint = &(query.fill);
} else {
- paint = &(query->stroke);
+ paint = &(query.stroke);
}
if (paint->set && paint->isPaintserver()) {
- SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
+ SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (&query) : SP_STYLE_STROKE_SERVER (&query);
if ( server ) {
Inkscape::XML::Node *srepr = server->getRepr();
_paintserver_id[i] += "url(#";
@@ -1046,7 +1045,7 @@ SelectedStyle::update()
place->set_tooltip_text(__rgradient[i]);
_mode[i] = SS_RGRADIENT;
#ifdef WITH_MESH
- } else if (SP_IS_MESHGRADIENT(server)) {
+ } else if (SP_IS_MESH(server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector);
place->add(_gradient_box_m[i]);
@@ -1063,7 +1062,7 @@ SelectedStyle::update()
}
} else if (paint->set && paint->isColor()) {
guint32 color = paint->value.color.toRGBA32(
- SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
+ SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query.fill_opacity.value : query.stroke_opacity.value));
_lastselected[i] = _thisselected[i];
_thisselected[i] = color; // include opacity
((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
@@ -1106,7 +1105,7 @@ SelectedStyle::update()
clearTooltip(_opacity_place);
clearTooltip(_opacity_sb);
- int result = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
+ int result = sp_desktop_query_style (_desktop, &query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
switch (result) {
case QUERY_STYLE_NOTHING:
@@ -1123,16 +1122,16 @@ SelectedStyle::update()
_opacity_blocked = true;
_opacity_sb.set_sensitive(true);
#if WITH_GTKMM_3_0
- _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query->opacity.value) * 100);
+ _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
#else
- _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query->opacity.value) * 100);
+ _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
#endif
_opacity_blocked = false;
break;
}
// Now query stroke_width
- int result_sw = sp_desktop_query_style (_desktop, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
+ int result_sw = sp_desktop_query_style (_desktop, &query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
switch (result_sw) {
case QUERY_STYLE_NOTHING:
_stroke_width.set_markup("");
@@ -1144,9 +1143,9 @@ SelectedStyle::update()
{
double w;
if (_sw_unit) {
- w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", _sw_unit);
+ w = Inkscape::Util::Quantity::convert(query.stroke_width.computed, "px", _sw_unit);
} else {
- w = query->stroke_width.computed;
+ w = query.stroke_width.computed;
}
current_stroke_width = w;
@@ -1169,8 +1168,6 @@ SelectedStyle::update()
default:
break;
}
-
- sp_style_unref(query);
}
void SelectedStyle::opacity_0(void) {_opacity_sb.set_value(0);}
@@ -1241,13 +1238,13 @@ void SelectedStyle::on_opacity_changed ()
// me. As a result, scrolling the spinbutton once results in runaway change until it hits 1.0
// or 0.0. (And no, this is not a race with ::update, I checked that.)
// Sigh. So we disable interruptibility while we're setting the new value.
- sp_desktop_canvas(_desktop)->forceFullRedrawAfterInterruptions(0);
+ _desktop->getCanvas()->forceFullRedrawAfterInterruptions(0);
sp_desktop_set_style (_desktop, css);
sp_repr_css_attr_unref (css);
- DocumentUndo::maybeDone(sp_desktop_document(_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
+ DocumentUndo::maybeDone(_desktop->getDocument(), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
_("Change opacity"));
// resume interruptibility
- sp_desktop_canvas(_desktop)->endForcedFullRedraws();
+ _desktop->getCanvas()->endForcedFullRedraws();
spinbutton_defocus(GTK_WIDGET(_opacity_sb.gobj()));
_opacity_blocked = false;
}
@@ -1385,25 +1382,25 @@ RotateableSwatch::do_motion(double by, guint modifier) {
diff = color_adjust(hsla, by, cc, modifier);
if (modifier == 3) { // alpha
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), 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);
} else if (modifier == 2) { // saturation
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), 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);
} else if (modifier == 1) { // lightness
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), 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);
} else { // hue
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), 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);
@@ -1440,18 +1437,18 @@ RotateableSwatch::do_release(double by, guint modifier) {
}
if (modifier == 3) { // alpha
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust alpha"));
} else if (modifier == 2) { // saturation
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
} else if (modifier == 1) { // lightness
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness"));
} else { // hue
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue"));
}
@@ -1523,7 +1520,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) {
if (modifier == 3) { // Alt, do nothing
} else {
double diff = value_adjust(startvalue, by, modifier, false);
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), 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);
}
@@ -1537,7 +1534,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
} else {
value_adjust(startvalue, by, modifier, true);
startvalue_set = false;
- DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ DocumentUndo::maybeDone(parent->getDesktop()->getDocument(), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width")));
}
diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp
index d9bf7e2aa..a48370d9b 100644
--- a/src/ui/widget/style-subject.cpp
+++ b/src/ui/widget/style-subject.cpp
@@ -11,7 +11,7 @@
#include "sp-object.h"
#include "xml/sp-css-attr.h"
#include "desktop-style.h"
-#include "desktop-handles.h"
+
#include "selection.h"
#include "style.h"
@@ -49,7 +49,7 @@ StyleSubject::Selection::~Selection() {
Inkscape::Selection *StyleSubject::Selection::_getSelection() const {
SPDesktop *desktop = getDesktop();
if (desktop) {
- return sp_desktop_selection(desktop);
+ return desktop->getSelection();
} else {
return NULL;
}
@@ -88,7 +88,7 @@ void StyleSubject::Selection::_afterDesktopSwitch(SPDesktop *desktop) {
_sel_modified.disconnect();
if (desktop) {
_subsel_changed = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &Selection::_emitChanged)));
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ Inkscape::Selection *selection = desktop->getSelection();
if (selection) {
_sel_changed = selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Selection::_emitChanged)));
_sel_modified = selection->connectModified(sigc::hide(sigc::hide(sigc::mem_fun(*this, &Selection::_emitChanged))));
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index 157fd2ad9..fa8543c46 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -260,13 +260,12 @@ void StyleSwatch::setStyle(SPCSSAttr *css)
Glib::ustring css_string;
sp_repr_css_write_string (_css, css_string);
- SPStyle *temp_spstyle = sp_style_new(SP_ACTIVE_DOCUMENT);
+
+ SPStyle style(SP_ACTIVE_DOCUMENT);
if (!css_string.empty()) {
- sp_style_merge_from_style_string (temp_spstyle, css_string.c_str());
+ style.mergeString(css_string.c_str());
}
-
- setStyle (temp_spstyle);
- sp_style_unref (temp_spstyle);
+ setStyle (&style);
}
void StyleSwatch::setStyle(SPStyle *query)
diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp
index aac7451f4..ff525c679 100644
--- a/src/ui/widget/tolerance-slider.cpp
+++ b/src/ui/widget/tolerance-slider.cpp
@@ -28,7 +28,8 @@
#include "inkscape.h"
#include "document.h"
#include "document-undo.h"
-#include "desktop-handles.h"
+#include "desktop.h"
+
#include "sp-namedview.h"
#include "registry.h"
@@ -195,10 +196,10 @@ void ToleranceSlider::update (double val)
_wr->setUpdating (true);
- SPDocument *doc = sp_desktop_document(dt);
+ SPDocument *doc = dt->getDocument();
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false);
- Inkscape::XML::Node *repr = sp_desktop_namedview(dt)->getRepr();
+ Inkscape::XML::Node *repr = dt->getNamedView()->getRepr();
repr->setAttribute(_key.c_str(), os.str().c_str());
DocumentUndo::setUndoSensitive(doc, saved);