summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2008-10-27 18:03:09 +0000
committerTed Gould <ted@canonical.com>2008-10-27 18:03:09 +0000
commit7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902 (patch)
tree7d3a2b95b84a03a19cb132cdf88bea0ab6dc4773 /src
parentMerging from trunk (diff)
downloadinkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.tar.gz
inkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.zip
From trunk
(bzr r6885)
Diffstat (limited to '')
-rw-r--r--src/Makefile_insert4
-rw-r--r--src/arc-context.cpp14
-rw-r--r--src/attributes-test.h1
-rw-r--r--src/attributes.cpp1
-rw-r--r--src/attributes.h1
-rw-r--r--src/box3d-context.cpp20
-rw-r--r--src/box3d-side.cpp9
-rw-r--r--src/box3d.cpp5
-rw-r--r--src/color-profile.cpp38
-rw-r--r--src/common-context.cpp76
-rw-r--r--src/conn-avoid-ref.cpp9
-rw-r--r--src/connector-context.cpp70
-rw-r--r--src/connector-context.h4
-rw-r--r--src/context-fns.cpp12
-rw-r--r--src/debug/gdk-event-latency-tracker.cpp5
-rw-r--r--src/desktop-events.cpp7
-rw-r--r--src/desktop-handles.h4
-rw-r--r--src/desktop-style.cpp79
-rw-r--r--src/desktop-style.h9
-rw-r--r--src/desktop.cpp293
-rw-r--r--src/desktop.h2
-rw-r--r--src/dialogs/clonetiler.cpp260
-rw-r--r--src/dialogs/dialog-events.cpp10
-rw-r--r--src/dialogs/export.cpp28
-rw-r--r--src/dialogs/fill-style.cpp28
-rw-r--r--src/dialogs/find.cpp22
-rw-r--r--src/dialogs/iconpreview.cpp60
-rw-r--r--src/dialogs/input.cpp173
-rw-r--r--src/dialogs/item-properties.cpp23
-rw-r--r--src/dialogs/layers-panel.cpp7
-rw-r--r--src/dialogs/stroke-style.cpp9
-rw-r--r--src/dialogs/swatches.cpp8
-rw-r--r--src/dialogs/swatches.h2
-rw-r--r--src/dialogs/text-edit.cpp37
-rw-r--r--src/dialogs/tiledialog.cpp155
-rw-r--r--src/dialogs/xml-tree.cpp22
-rw-r--r--src/display/bezier-utils-test.cpp8
-rw-r--r--src/display/bezier-utils-test.h140
-rw-r--r--src/display/bezier-utils.cpp22
-rw-r--r--src/display/canvas-arena.h2
-rw-r--r--src/display/canvas-axonomgrid.cpp21
-rw-r--r--src/display/canvas-grid.cpp39
-rw-r--r--src/display/canvas-grid.h17
-rw-r--r--src/display/canvas-text.cpp26
-rw-r--r--src/display/canvas-text.h2
-rw-r--r--src/display/nr-arena-glyphs.cpp10
-rw-r--r--src/display/nr-arena-glyphs.h4
-rw-r--r--src/display/nr-arena-image.cpp7
-rw-r--r--src/display/nr-arena-item.cpp7
-rw-r--r--src/display/nr-arena-shape.cpp1
-rw-r--r--src/display/nr-arena-shape.h1
-rw-r--r--src/display/nr-filter-gaussian.cpp7
-rw-r--r--src/display/nr-filter-slot.cpp23
-rw-r--r--src/display/nr-filter-slot.h6
-rw-r--r--src/display/nr-filter-types.h8
-rw-r--r--src/display/nr-filter.cpp43
-rw-r--r--src/display/nr-filter.h3
-rw-r--r--src/display/nr-svgfonts.cpp50
-rw-r--r--src/display/sp-canvas.cpp107
-rw-r--r--src/display/sp-canvas.h5
-rw-r--r--src/display/sp-ctrlquadr.cpp2
-rw-r--r--src/document.cpp62
-rw-r--r--src/draw-anchor.cpp4
-rw-r--r--src/draw-anchor.h8
-rw-r--r--src/draw-context.cpp41
-rw-r--r--src/dropper-context.cpp17
-rw-r--r--src/dyna-draw-context.cpp73
-rw-r--r--src/eraser-context.cpp36
-rw-r--r--src/event-context.cpp92
-rw-r--r--src/event-context.h9
-rw-r--r--src/extension/error-file.cpp13
-rw-r--r--src/extension/implementation/script.cpp2
-rw-r--r--src/extension/init.cpp14
-rw-r--r--src/extension/internal/bluredge.cpp11
-rw-r--r--src/extension/internal/cairo-ps-out.cpp207
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp28
-rw-r--r--src/extension/internal/cairo-renderer.cpp71
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp1
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp4
-rw-r--r--src/extension/param/bool.cpp21
-rw-r--r--src/extension/param/color.cpp4
-rw-r--r--src/extension/param/color.h6
-rw-r--r--src/extension/param/description.cpp8
-rw-r--r--src/extension/param/enum.cpp20
-rw-r--r--src/extension/param/float.cpp12
-rw-r--r--src/extension/param/int.cpp25
-rw-r--r--src/extension/param/notebook.cpp14
-rw-r--r--src/extension/param/parameter.cpp12
-rw-r--r--src/extension/param/parameter.h32
-rw-r--r--src/extension/param/radiobutton.cpp10
-rw-r--r--src/extension/param/string.cpp9
-rw-r--r--src/file.cpp57
-rw-r--r--src/flood-context.cpp54
-rw-r--r--src/fontsize-expansion.cpp30
-rw-r--r--src/fontsize-expansion.h9
-rw-r--r--src/gradient-chemistry.cpp5
-rw-r--r--src/gradient-context.cpp21
-rw-r--r--src/gradient-drag.cpp11
-rw-r--r--src/graphlayout/graphlayout.cpp25
-rw-r--r--src/guide-snapper.cpp2
-rw-r--r--src/helper/png-write.cpp14
-rw-r--r--src/inkscape.cpp25
-rw-r--r--src/inkscape.h1
-rw-r--r--src/inkview.cpp1
-rw-r--r--src/interface.cpp127
-rw-r--r--src/io/sys.cpp9
-rw-r--r--src/knot-holder-entity.cpp7
-rw-r--r--src/knot.cpp5
-rw-r--r--src/layer-manager.cpp5
-rw-r--r--src/line-snapper.cpp14
-rw-r--r--src/line-snapper.h7
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/effect.h5
-rw-r--r--src/live_effects/lpe-bendpath.cpp7
-rw-r--r--src/live_effects/lpe-bendpath.h1
-rw-r--r--src/live_effects/lpe-curvestitch.cpp5
-rwxr-xr-xsrc/live_effects/lpe-envelope.cpp7
-rwxr-xr-xsrc/live_effects/lpe-envelope.h2
-rw-r--r--src/live_effects/lpe-knot.cpp18
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp7
-rw-r--r--src/live_effects/lpe-patternalongpath.h2
-rw-r--r--src/live_effects/lpe-sketch.cpp23
-rw-r--r--src/live_effects/lpe-sketch.h5
-rw-r--r--src/live_effects/lpe-vonkoch.cpp8
-rw-r--r--src/live_effects/lpe-vonkoch.h2
-rw-r--r--src/live_effects/lpegroupbbox.cpp21
-rw-r--r--src/live_effects/lpeobject-reference.cpp2
-rw-r--r--src/lpe-tool-context.cpp39
-rw-r--r--src/main.cpp157
-rw-r--r--src/marker.cpp29
-rw-r--r--src/marker.h2
-rw-r--r--src/menus-skeleton.h4
-rw-r--r--src/node-context.cpp29
-rw-r--r--src/nodepath.cpp205
-rw-r--r--src/nodepath.h2
-rw-r--r--src/object-edit.cpp14
-rw-r--r--src/object-snapper.cpp54
-rw-r--r--src/object-snapper.h20
-rw-r--r--src/path-chemistry.cpp101
-rw-r--r--src/path-chemistry.h1
-rw-r--r--src/pen-context.cpp29
-rw-r--r--src/pencil-context.cpp41
-rw-r--r--src/pencil-context.h1
-rw-r--r--src/preferences-skeleton.h1
-rw-r--r--src/preferences.cpp513
-rw-r--r--src/preferences.h489
-rw-r--r--src/prefs-utils.cpp96
-rw-r--r--src/prefs-utils.h93
-rw-r--r--src/rect-context.cpp31
-rw-r--r--src/selcue.cpp9
-rw-r--r--src/select-context.cpp27
-rw-r--r--src/selection-chemistry.cpp60
-rw-r--r--src/selection.cpp63
-rw-r--r--src/selection.h4
-rw-r--r--src/seltrans.cpp72
-rw-r--r--src/shape-editor.cpp11
-rw-r--r--src/snap-preferences.cpp124
-rw-r--r--src/snap-preferences.h81
-rw-r--r--src/snap.cpp113
-rw-r--r--src/snap.h68
-rw-r--r--src/snapper.cpp34
-rw-r--r--src/snapper.h32
-rw-r--r--src/sp-ellipse.cpp14
-rw-r--r--src/sp-flowtext.cpp32
-rw-r--r--src/sp-flowtext.h10
-rw-r--r--src/sp-guide.cpp24
-rw-r--r--src/sp-guide.h6
-rw-r--r--src/sp-image.cpp15
-rw-r--r--src/sp-item-group.cpp532
-rw-r--r--src/sp-item-notify-moveto.cpp2
-rw-r--r--src/sp-item-rm-unsatisfied-cns.cpp2
-rw-r--r--src/sp-item-update-cns.cpp2
-rw-r--r--src/sp-item.cpp37
-rw-r--r--src/sp-item.h5
-rw-r--r--src/sp-lpe-item.cpp24
-rw-r--r--src/sp-namedview.cpp43
-rw-r--r--src/sp-offset.cpp22
-rw-r--r--src/sp-offset.h78
-rw-r--r--src/sp-path.cpp39
-rw-r--r--src/sp-rect.cpp9
-rw-r--r--src/sp-shape.cpp81
-rw-r--r--src/sp-spiral.cpp6
-rw-r--r--src/sp-star.cpp6
-rw-r--r--src/sp-text.cpp4
-rw-r--r--src/sp-use-reference.cpp8
-rw-r--r--src/sp-use.cpp14
-rw-r--r--src/spiral-context.cpp44
-rw-r--r--src/splivarot.cpp134
-rw-r--r--src/star-context.cpp50
-rw-r--r--src/style.cpp36
-rw-r--r--src/style.h6
-rw-r--r--src/svg-view.cpp2
-rw-r--r--src/svg/css-ostringstream.cpp5
-rw-r--r--src/svg/path-string.cpp11
-rw-r--r--src/svg/stringstream.cpp5
-rw-r--r--src/svg/svg-affine.cpp11
-rw-r--r--src/svg/svg-color-test.h7
-rw-r--r--src/svg/svg-color.cpp5
-rw-r--r--src/svg/svg-path-geom-test.h13
-rw-r--r--src/text-context.cpp66
-rw-r--r--src/text-context.h62
-rw-r--r--src/text-editing.cpp2
-rw-r--r--src/tools-switch.cpp74
-rw-r--r--src/tweak-context.cpp112
-rw-r--r--src/ui/clipboard.cpp2
-rw-r--r--src/ui/context-menu.cpp115
-rw-r--r--src/ui/dialog/aboutbox.cpp8
-rw-r--r--src/ui/dialog/aboutbox.h8
-rw-r--r--src/ui/dialog/align-and-distribute.cpp71
-rw-r--r--src/ui/dialog/align-and-distribute.h8
-rw-r--r--src/ui/dialog/behavior.h8
-rw-r--r--src/ui/dialog/dialog-manager.cpp7
-rw-r--r--src/ui/dialog/dialog-manager.h8
-rw-r--r--src/ui/dialog/dialog.cpp29
-rw-r--r--src/ui/dialog/dialog.h18
-rw-r--r--src/ui/dialog/dock-behavior.cpp24
-rw-r--r--src/ui/dialog/dock-behavior.h8
-rw-r--r--src/ui/dialog/document-metadata.cpp18
-rw-r--r--src/ui/dialog/document-metadata.h9
-rw-r--r--src/ui/dialog/document-properties.cpp37
-rw-r--r--src/ui/dialog/document-properties.h12
-rw-r--r--src/ui/dialog/extension-editor.cpp14
-rw-r--r--src/ui/dialog/extension-editor.h8
-rw-r--r--src/ui/dialog/filedialog.cpp10
-rw-r--r--src/ui/dialog/filedialog.h14
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp57
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.h29
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp11
-rw-r--r--src/ui/dialog/filedialogimpl-win32.h10
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp15
-rw-r--r--src/ui/dialog/fill-and-stroke.h9
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp18
-rw-r--r--src/ui/dialog/filter-effects-dialog.h8
-rw-r--r--src/ui/dialog/find.cpp7
-rw-r--r--src/ui/dialog/find.h92
-rw-r--r--src/ui/dialog/floating-behavior.cpp61
-rw-r--r--src/ui/dialog/floating-behavior.h8
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp430
-rw-r--r--src/ui/dialog/inkscape-preferences.h9
-rw-r--r--src/ui/dialog/input.cpp62
-rw-r--r--src/ui/dialog/input.h11
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp13
-rw-r--r--src/ui/dialog/livepatheffect-editor.h9
-rw-r--r--src/ui/dialog/memory.cpp10
-rw-r--r--src/ui/dialog/memory.h9
-rw-r--r--src/ui/dialog/messages.cpp25
-rw-r--r--src/ui/dialog/messages.h9
-rw-r--r--src/ui/dialog/ocaldialogs.cpp12
-rw-r--r--src/ui/dialog/ocaldialogs.h16
-rw-r--r--src/ui/dialog/panel-dialog.h17
-rw-r--r--src/ui/dialog/print.cpp20
-rw-r--r--src/ui/dialog/print.h9
-rw-r--r--src/ui/dialog/scriptdialog.cpp24
-rw-r--r--src/ui/dialog/scriptdialog.h29
-rw-r--r--src/ui/dialog/session-player.cpp20
-rw-r--r--src/ui/dialog/session-player.h22
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp23
-rw-r--r--src/ui/dialog/svg-fonts-dialog.h9
-rw-r--r--src/ui/dialog/tracedialog.cpp9
-rw-r--r--src/ui/dialog/tracedialog.h29
-rw-r--r--src/ui/dialog/transformation.cpp35
-rw-r--r--src/ui/dialog/transformation.h9
-rw-r--r--src/ui/dialog/undo-history.cpp11
-rw-r--r--src/ui/dialog/undo-history.h21
-rw-r--r--src/ui/dialog/whiteboard-connect.cpp29
-rw-r--r--src/ui/dialog/whiteboard-connect.h19
-rw-r--r--src/ui/dialog/whiteboard-sharewithchat.cpp24
-rw-r--r--src/ui/dialog/whiteboard-sharewithchat.h19
-rw-r--r--src/ui/dialog/whiteboard-sharewithuser.cpp8
-rw-r--r--src/ui/dialog/whiteboard-sharewithuser.h10
-rw-r--r--src/ui/view/edit-widget.cpp20
-rw-r--r--src/ui/widget/dock-item.cpp10
-rw-r--r--src/ui/widget/dock.cpp15
-rw-r--r--src/ui/widget/dock.h8
-rw-r--r--src/ui/widget/panel.cpp115
-rw-r--r--src/ui/widget/panel.h2
-rw-r--r--src/ui/widget/preferences-widget.cpp99
-rw-r--r--src/ui/widget/preferences-widget.h30
-rw-r--r--src/ui/widget/registered-widget.cpp8
-rw-r--r--src/ui/widget/style-swatch.cpp202
-rw-r--r--src/ui/widget/style-swatch.h45
-rw-r--r--src/vanishing-point.cpp6
-rw-r--r--src/verbs.cpp53
-rw-r--r--src/widgets/dash-selector.cpp63
-rw-r--r--src/widgets/dash-selector.h17
-rw-r--r--src/widgets/desktop-widget.cpp266
-rw-r--r--src/widgets/gradient-toolbar.cpp26
-rw-r--r--src/widgets/gradient-vector.cpp142
-rw-r--r--src/widgets/icon.cpp24
-rw-r--r--src/widgets/select-toolbar.cpp56
-rw-r--r--src/widgets/sp-color-icc-selector.cpp11
-rw-r--r--src/widgets/sp-color-notebook.cpp23
-rw-r--r--src/widgets/toolbox.cpp662
-rw-r--r--src/widgets/toolbox.h2
-rw-r--r--src/xml/node-observer.h17
-rw-r--r--src/xml/repr-io.cpp7
-rw-r--r--src/zoom-context.cpp24
297 files changed, 6197 insertions, 5317 deletions
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 33e4f07f8..8244996c8 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -81,7 +81,6 @@ libinkpre_a_SOURCES = \
filter-chemistry.cpp filter-chemistry.h \
filter-enums.cpp filter-enums.h \
flood-context.cpp flood-context.h \
- fontsize-expansion.cpp fontsize-expansion.h \
forward.h \
gradient-context.cpp gradient-context.h \
gradient-drag.cpp gradient-drag.h \
@@ -131,8 +130,6 @@ libinkpre_a_SOURCES = \
menus-skeleton.h \
prefix.cpp \
prefix.h \
- prefs-utils.cpp \
- prefs-utils.h \
print.cpp print.h \
profile-manager.cpp \
profile-manager.h \
@@ -151,6 +148,7 @@ libinkpre_a_SOURCES = \
shape-editor.cpp shape-editor.h \
shortcuts.cpp shortcuts.h \
snap.cpp snap.h \
+ snap-preferences.cpp snap-preferences.h \
snapped-curve.cpp snapped-curve.h \
snapped-line.cpp snapped-line.h \
snapped-point.cpp snapped-point.h \
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index 1409d1d64..50d348e7b 100644
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
@@ -34,7 +34,7 @@
#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include "object-edit.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "message-context.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -208,11 +208,12 @@ static void sp_arc_context_setup(SPEventContext *ec)
sigc::bind(sigc::ptr_fun(&sp_arc_context_selection_changed), (gpointer) ac)
);
- if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/shapes/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
ec->enableGrDrag();
}
@@ -250,8 +251,9 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPArcContext *ac = SP_ARC_CONTEXT(event_context);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
@@ -266,7 +268,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
Geom::Point pt2g = to_2geom(ac->center);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
ac->center = from_2geom(pt2g);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -423,7 +425,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state)
repr->setAttribute("sodipodi:type", "arc");
/* Set style */
- sp_desktop_apply_style_tool(desktop, repr, "tools.shapes.arc", false);
+ sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/arc", false);
ac->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
Inkscape::GC::release(repr);
diff --git a/src/attributes-test.h b/src/attributes-test.h
index 25167e75b..89be0eb4f 100644
--- a/src/attributes-test.h
+++ b/src/attributes-test.h
@@ -352,6 +352,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:snap-nodes", true},
{"inkscape:snap-guide", true},
{"inkscape:snap-center", true},
+ {"inkscape:snap-smooth-nodes", true},
{"inkscape:snap-intersection-grid-guide", true},
{"inkscape:snap-intersection-paths", true},
{"inkscape:pageopacity", true},
diff --git a/src/attributes.cpp b/src/attributes.cpp
index e64cedf36..add2c8caf 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -92,6 +92,7 @@ static SPStyleProp const props[] = {
{SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"},
{SP_ATTR_INKSCAPE_SNAP_GUIDE, "inkscape:snap-guide"},
{SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"},
+ {SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES, "inkscape:snap-smooth-nodes"},
{SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE, "inkscape:snap-intersection-grid-guide"},
{SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, "inkscape:snap-intersection-paths"},
{SP_ATTR_INKSCAPE_OBJECT_PATHS, "inkscape:object-paths"},
diff --git a/src/attributes.h b/src/attributes.h
index 82fba18a9..e15822411 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -92,6 +92,7 @@ enum SPAttributeEnum {
SP_ATTR_INKSCAPE_SNAP_NODES,
SP_ATTR_INKSCAPE_SNAP_GUIDE,
SP_ATTR_INKSCAPE_SNAP_CENTER,
+ SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES,
SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE,
SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS,
SP_ATTR_INKSCAPE_OBJECT_PATHS,
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 03a9073b4..404723231 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -38,7 +38,7 @@
#include "object-edit.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "context-fns.h"
#include "desktop-style.h"
#include "transf_mat_3x4.h"
@@ -247,12 +247,13 @@ static void sp_box3d_context_setup(SPEventContext *ec)
);
bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
ec->enableGrDrag();
}
@@ -290,13 +291,14 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
Persp3D *cur_persp = SP_ACTIVE_DOCUMENT->current_persp3d;
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
switch (event->type) {
@@ -331,7 +333,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, bc->item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt);
bc->center = from_2geom(button_dt);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -363,7 +365,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, bc->item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt);
bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
@@ -397,7 +399,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
bc->drag_ptC_proj = cur_persp->tmat.preimage (from_2geom(motion_dt), bc->drag_ptB_proj[Proj::X], Proj::X);
}
Geom::Point pt2g = to_2geom(bc->drag_ptC);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
bc->drag_ptC = from_2geom(pt2g);
}
@@ -583,7 +585,7 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
repr->setAttribute("sodipodi:type", "inkscape:box3d");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
+ sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/3dbox", false);
bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
Inkscape::GC::release(repr);
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index cdeb001eb..866cbbca4 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -241,19 +241,20 @@ box3d_side_apply_style (Box3DSide *side) {
Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring descr = "desktop.";
+ Glib::ustring descr = "/desktop/";
descr += box3d_side_axes_string(side);
- Glib::ustring cur_style = prefs->getString(descr, "style");
+ descr += "/style";
+ Glib::ustring cur_style = prefs->getString(descr);
SPDesktop *desktop = inkscape_active_desktop();
- bool use_current = prefs->getBool("tools.shapes.3dbox", "usecurrent", false);
+ bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false);
if (use_current && !cur_style.empty()) {
/* use last used style */
repr_face->setAttribute("style", cur_style.data());
} else {
/* use default style */
GString *pstring = g_string_new("");
- g_string_printf (pstring, "tools.shapes.3dbox.%s", box3d_side_axes_string(side));
+ g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false);
}
}
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 548132bdc..057329a28 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -35,7 +35,7 @@
#include "2geom/geom.h"
#include "sp-guide.h"
#include "sp-namedview.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop.h"
#include "desktop-handles.h"
@@ -1416,8 +1416,9 @@ box3d_push_back_corner_pair(SPBox3D *box, std::list<std::pair<Geom::Point, Geom:
void
box3d_convert_to_guides(SPItem *item) {
SPBox3D *box = SP_BOX3D(item);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs_get_int_attribute("tools.shapes.3dbox", "convertguides", 1) == 0) {
+ if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) {
sp_item_convert_to_guides(SP_ITEM(box));
return;
}
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 583145c80..fbfa8efb1 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -39,9 +39,9 @@ extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
- bool dump = prefs->getBool("options.scislac", #key);\
- bool dumpD = prefs->getBool("options.scislac", #key"D");\
- bool dumpD2 = prefs->getBool("options.scislac", #key"D2");\
+ bool dump = prefs->getBool(Glib::ustring("/options/scislac/") + #key);\
+ bool dumpD = prefs->getBool(Glib::ustring("/options/scislac/") + #key"D");\
+ bool dumpD2 = prefs->getBool(Glib::ustring("/options/scislac/") + #key"D2");\
dumpD &= ( (update_in_progress == 0) || dumpD2 );\
if ( dump )\
{\
@@ -684,7 +684,7 @@ cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle()
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring uri = prefs->getString("options.displayprofile", "uri");
+ Glib::ustring uri = prefs->getString("/options/displayprofile/uri");
if ( !uri.empty() ) {
if ( uri != lastURI ) {
@@ -743,8 +743,8 @@ cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle()
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool which = prefs->getBool( "options.softproof", "enable");
- Glib::ustring uri = prefs->getString("options.softproof", "uri");
+ bool which = prefs->getBool( "/options/softproof/enable");
+ Glib::ustring uri = prefs->getString("/options/softproof/uri");
if ( which && !uri.empty() ) {
if ( lastURI != uri ) {
@@ -799,7 +799,7 @@ static void free_transforms();
cmsHTRANSFORM Inkscape::colorprofile_get_display_transform()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool fromDisplay = prefs->getBool( "options.displayprofile", "from_display");
+ bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
if ( fromDisplay ) {
if ( transf ) {
cmsDeleteTransform(transf);
@@ -808,14 +808,14 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_transform()
return 0;
}
- bool warn = prefs->getBool( "options.softproof", "gamutwarn");
- int intent = prefs->getIntLimited( "options.displayprofile", "intent", 0, 0, 3 );
- int proofIntent = prefs->getIntLimited( "options.softproof", "intent", 0, 0, 3 );
- bool bpc = prefs->getBool( "options.softproof", "bpc");
+ bool warn = prefs->getBool( "/options/softproof/gamutwarn");
+ int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
+ int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
+ bool bpc = prefs->getBool( "/options/softproof/bpc");
#if defined(cmsFLAGS_PRESERVEBLACK)
- bool preserveBlack = prefs->getBool( "options.softproof", "preserveblack");
+ bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
#endif //defined(cmsFLAGS_PRESERVEBLACK)
- Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
if ( (warn != gamutWarn)
@@ -969,14 +969,14 @@ cmsHTRANSFORM Inkscape::colorprofile_get_display_per( Glib::ustring const& id )
if ( id == it2->id ) {
MemProfile& item = *it2;
- bool warn = prefs->getBool( "options.softproof", "gamutwarn");
- int intent = prefs->getIntLimited( "options.displayprofile", "intent", 0, 0, 3 );
- int proofIntent = prefs->getIntLimited( "options.softproof", "intent", 0, 0, 3 );
- bool bpc = prefs->getBool( "options.softproof", "bpc");
+ bool warn = prefs->getBool( "/options/softproof/gamutwarn");
+ int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
+ int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
+ bool bpc = prefs->getBool( "/options/softproof/bpc");
#if defined(cmsFLAGS_PRESERVEBLACK)
- bool preserveBlack = prefs->getBool( "options.softproof", "preserveblack");
+ bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
#endif //defined(cmsFLAGS_PRESERVEBLACK)
- Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
if ( (warn != gamutWarn)
diff --git a/src/common-context.cpp b/src/common-context.cpp
index eab50b478..48a7f308c 100644
--- a/src/common-context.cpp
+++ b/src/common-context.cpp
@@ -8,6 +8,7 @@
#include "forward.h"
#include "message-context.h"
#include "streq.h"
+#include "preferences.h"
#define MIN_PRESSURE 0.0
#define MAX_PRESSURE 1.0
@@ -23,7 +24,7 @@ static void sp_common_context_init(SPCommonContext *erc);
static void sp_common_context_dispose(GObject *object);
static void sp_common_context_setup(SPEventContext *ec);
-static void sp_common_context_set(SPEventContext *ec, gchar const *key, gchar const *value);
+static void sp_common_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEvent *event);
@@ -154,51 +155,38 @@ static void sp_common_context_setup(SPEventContext *ec)
}
}
-static inline bool
-get_bool_value(char const *const val)
-{
- return ( val && *val == '1' );
- /* The only possible values if written by inkscape are NULL (attribute not present)
- * or "0" or "1".
- *
- * For other values (e.g. if modified by a human without following the above rules), the
- * current implementation does the right thing for empty string, "no", "false", "n", "f"
- * but the wrong thing for "yes", "true", "y", "t". */
-}
-
-static void sp_common_context_set(SPEventContext *ec, gchar const *key, gchar const *value)
+static void sp_common_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *value)
{
SPCommonContext *ctx = SP_COMMON_CONTEXT(ec);
-
- if (streq(key, "mass")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.2 );
- ctx->mass = CLAMP(dval, -1000.0, 1000.0);
- } else if (streq(key, "wiggle")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : (1 - DRAG_DEFAULT));
- ctx->drag = CLAMP((1 - dval), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
- } else if (streq(key, "angle")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0);
- ctx->angle = CLAMP (dval, -90, 90);
- } else if (streq(key, "width")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 );
- ctx->width = CLAMP(dval, -1000.0, 1000.0);
- } else if (streq(key, "thinning")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 );
- ctx->vel_thin = CLAMP(dval, -1.0, 1.0);
- } else if (streq(key, "tremor")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0 );
- ctx->tremor = CLAMP(dval, 0.0, 1.0);
- } else if (streq(key, "flatness")) {
- double const dval = ( value ? g_ascii_strtod (value, NULL) : 1.0 );
- ctx->flatness = CLAMP(dval, 0, 1.0);
- } else if (streq(key, "usepressure")) {
- ctx->usepressure = get_bool_value(value);
- } else if (streq(key, "usetilt")) {
- ctx->usetilt = get_bool_value(value);
- } else if (streq(key, "abs_width")) {
- ctx->abs_width = get_bool_value(value);
- } else if (streq(key, "cap_rounding")) {
- ctx->cap_rounding = ( value ? g_ascii_strtod (value, NULL) : 0.0 );
+ Glib::ustring path = value->getEntryName();
+
+ // ignore preset modifications
+ static Glib::ustring const presets_path = ec->pref_observer->observed_path + "/preset";
+ Glib::ustring const &full_path = value->getPath();
+ if (full_path.compare(0, presets_path.size(), presets_path) == 0) return;
+
+ if (path == "mass") {
+ ctx->mass = CLAMP(value->getDouble(0.2), -1000.0, 1000.0);
+ } else if (path == "wiggle") {
+ ctx->drag = CLAMP((1 - value->getDouble(1 - DRAG_DEFAULT)), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
+ } else if (path == "angle") {
+ ctx->angle = CLAMP(value->getDouble(), -90, 90);
+ } else if (path == "width") {
+ ctx->width = CLAMP(value->getDouble(0.1), -1000.0, 1000.0);
+ } else if (path == "thinning") {
+ ctx->vel_thin = CLAMP(value->getDouble(0.1), -1.0, 1.0);
+ } else if (path == "tremor") {
+ ctx->tremor = CLAMP(value->getDouble(), 0.0, 1.0);
+ } else if (path == "flatness") {
+ ctx->flatness = CLAMP(value->getDouble(1.0), 0, 1.0);
+ } else if (path == "usepressure") {
+ ctx->usepressure = value->getBool();
+ } else if (path == "usetilt") {
+ ctx->usetilt = value->getBool();
+ } else if (path == "abs_width") {
+ ctx->abs_width = value->getBool();
+ } else if (path == "cap_rounding") {
+ ctx->cap_rounding = value->getDouble();
}
}
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index 5a09f8765..ac9064713 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -15,14 +15,11 @@
#include "sp-item.h"
#include "conn-avoid-ref.h"
-#include "libnr/nr-rect-ops.h"
#include "libavoid/polyutil.h"
#include "libavoid/router.h"
#include "libavoid/connector.h"
#include "xml/simple-node.h"
#include "document.h"
-#include "prefs-utils.h"
-
#include "desktop.h"
#include "desktop-handles.h"
#include "sp-namedview.h"
@@ -206,9 +203,9 @@ static Avoid::Polygn avoid_item_poly(SPItem const *item)
poly = Avoid::newPoly(4);
for (unsigned n = 0; n < 4; ++n) {
- NR::Point hullPoint = rExpandedHull.corner(n);
- poly.ps[n].x = hullPoint[NR::X];
- poly.ps[n].y = hullPoint[NR::Y];
+ Geom::Point hullPoint = rExpandedHull.corner(n);
+ poly.ps[n].x = hullPoint[Geom::X];
+ poly.ps[n].y = hullPoint[Geom::Y];
}
return poly;
diff --git a/src/connector-context.cpp b/src/connector-context.cpp
index 527ba720f..ef89c290f 100644
--- a/src/connector-context.cpp
+++ b/src/connector-context.cpp
@@ -59,7 +59,7 @@
#include "message-stack.h"
#include "selection.h"
#include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-path.h"
#include "display/canvas-bpath.h"
#include "display/sodipodi-ctrl.h"
@@ -85,9 +85,9 @@ static gint sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *even
static gint sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
// Stuff borrowed from DrawContext
-static void spcc_connector_set_initial_point(SPConnectorContext *cc, NR::Point const p);
-static void spcc_connector_set_subsequent_point(SPConnectorContext *cc, NR::Point const p);
-static void spcc_connector_finish_segment(SPConnectorContext *cc, NR::Point p);
+static void spcc_connector_set_initial_point(SPConnectorContext *cc, Geom::Point const p);
+static void spcc_connector_set_subsequent_point(SPConnectorContext *cc, Geom::Point const p);
+static void spcc_connector_finish_segment(SPConnectorContext *cc, Geom::Point p);
static void spcc_reset_colors(SPConnectorContext *cc);
static void spcc_connector_finish(SPConnectorContext *cc);
static void spcc_concat_colors_and_flush(SPConnectorContext *cc);
@@ -103,11 +103,11 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item);
static void cc_clear_active_shape(SPConnectorContext *cc);
static void cc_set_active_conn(SPConnectorContext *cc, SPItem *item);
static void cc_clear_active_conn(SPConnectorContext *cc);
-static gchar *conn_pt_handle_test(SPConnectorContext *cc, NR::Point& w);
+static gchar *conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& w);
static bool cc_item_is_shape(SPItem *item);
static void cc_selection_changed(Inkscape::Selection *selection, gpointer data);
static void cc_connector_rerouting_finish(SPConnectorContext *const cc,
- NR::Point *const p);
+ Geom::Point *const p);
static void shape_event_attr_deleted(Inkscape::XML::Node *repr,
Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data);
@@ -116,7 +116,7 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam
gpointer data);
-static NR::Point connector_drag_origin_w(0, 0);
+static Geom::Point connector_drag_origin_w(0, 0);
static bool connector_within_tolerance = false;
static SPEventContextClass *parent_class;
@@ -283,7 +283,8 @@ sp_connector_context_setup(SPEventContext *ec)
// Notice the initial selection.
cc_selection_changed(cc->selection, (gpointer) cc);
- if (prefs_get_int_attribute("tools.connector", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/connector/selcue", 0)) {
ec->enableSelectionCue();
}
@@ -373,7 +374,7 @@ cc_clear_active_conn(SPConnectorContext *cc)
static gchar *
-conn_pt_handle_test(SPConnectorContext *cc, NR::Point& p)
+conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p)
{
// TODO: this will need to change when there are more connection
// points available for each shape.
@@ -398,7 +399,7 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G
SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(event_context);
- NR::Point p(event->button.x, event->button.y);
+ Geom::Point p(event->button.x, event->button.y);
switch (event->type) {
case GDK_BUTTON_RELEASE:
@@ -488,9 +489,9 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event)
static gint
connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const &bevent)
{
- NR::Point const event_w(bevent.x, bevent.y);
+ Geom::Point const event_w(bevent.x, bevent.y);
/* Find desktop coordinates */
- NR::Point p = cc->desktop->w2d(event_w);
+ Geom::Point p = cc->desktop->w2d(event_w);
SPEventContext *event_context = SP_EVENT_CONTEXT(cc);
gint ret = FALSE;
@@ -502,12 +503,12 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
return TRUE;
}
- NR::Point const event_w(bevent.x,
+ Geom::Point const event_w(bevent.x,
bevent.y);
connector_drag_origin_w = event_w;
connector_within_tolerance = true;
- NR::Point const event_dt = cc->desktop->w2d(event_w);
+ Geom::Point const event_dt = cc->desktop->w2d(event_w);
switch (cc->state) {
case SP_CONNECTOR_CONTEXT_STOP:
/* This is allowed, if we just cancelled curve */
@@ -520,7 +521,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
/* Set start anchor */
/* Create green anchor */
- NR::Point p = event_dt;
+ Geom::Point p = event_dt;
// Test whether we clicked on a connection point
cc->sid = conn_pt_handle_test(cc, p);
@@ -532,7 +533,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
// as there's no other points to go off.
SnapManager &m = cc->desktop->namedview->snap_manager;
m.setup(cc->desktop);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
}
spcc_connector_set_initial_point(cc, from_2geom(pt2g));
@@ -590,17 +591,17 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons
{
gint ret = FALSE;
SPEventContext *event_context = SP_EVENT_CONTEXT(cc);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
// allow middle-button scrolling
return FALSE;
}
- NR::Point const event_w(mevent.x, mevent.y);
+ Geom::Point const event_w(mevent.x, mevent.y);
if (connector_within_tolerance) {
- gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
- "value", 0, 0, 100);
+ gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if ( NR::LInfty( event_w - connector_drag_origin_w ) < tolerance ) {
return FALSE; // Do not drag if we're within tolerance from origin.
}
@@ -675,10 +676,10 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
SPDocument *doc = sp_desktop_document(desktop);
- NR::Point const event_w(revent.x, revent.y);
+ Geom::Point const event_w(revent.x, revent.y);
/* Find desktop coordinates */
- NR::Point p = cc->desktop->w2d(event_w);
+ Geom::Point p = cc->desktop->w2d(event_w);
switch (cc->state) {
//case SP_CONNECTOR_CONTEXT_POINT:
@@ -766,7 +767,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
static void
-cc_connector_rerouting_finish(SPConnectorContext *const cc, NR::Point *const p)
+cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p)
{
SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
SPDocument *doc = sp_desktop_document(desktop);
@@ -814,7 +815,7 @@ spcc_reset_colors(SPConnectorContext *cc)
static void
-spcc_connector_set_initial_point(SPConnectorContext *const cc, NR::Point const p)
+spcc_connector_set_initial_point(SPConnectorContext *const cc, Geom::Point const p)
{
g_assert( cc->npoints == 0 );
@@ -826,15 +827,15 @@ spcc_connector_set_initial_point(SPConnectorContext *const cc, NR::Point const p
static void
-spcc_connector_set_subsequent_point(SPConnectorContext *const cc, NR::Point const p)
+spcc_connector_set_subsequent_point(SPConnectorContext *const cc, Geom::Point const p)
{
g_assert( cc->npoints != 0 );
SPDesktop *dt = cc->desktop;
- NR::Point o = dt->dt2doc(cc->p[0]);
- NR::Point d = dt->dt2doc(p);
- Avoid::Point src(o[NR::X], o[NR::Y]);
- Avoid::Point dst(d[NR::X], d[NR::Y]);
+ Geom::Point o = dt->dt2doc(cc->p[0]);
+ Geom::Point d = dt->dt2doc(p);
+ Avoid::Point src(o[Geom::X], o[Geom::Y]);
+ Avoid::Point dst(d[Geom::X], d[Geom::Y]);
if (!cc->newConnRef) {
Avoid::Router *router = sp_desktop_document(dt)->router;
@@ -850,11 +851,11 @@ spcc_connector_set_subsequent_point(SPConnectorContext *const cc, NR::Point cons
cc->newConnRef->calcRouteDist();
cc->red_curve->reset();
- NR::Point pt(route.ps[0].x, route.ps[0].y);
+ Geom::Point pt(route.ps[0].x, route.ps[0].y);
cc->red_curve->moveto(pt);
for (int i = 1; i < route.pn; ++i) {
- NR::Point p(route.ps[i].x, route.ps[i].y);
+ Geom::Point p(route.ps[i].x, route.ps[i].y);
cc->red_curve->lineto(p);
}
cc->red_curve->transform(dt->doc2dt());
@@ -919,7 +920,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool(desktop, repr, "tools.connector", false);
+ sp_desktop_apply_style_tool(desktop, repr, "/tools/connector", false);
gchar *str = sp_svg_write_path( c->get_pathvector() );
g_assert( str != NULL );
@@ -966,7 +967,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
static void
-spcc_connector_finish_segment(SPConnectorContext *const cc, NR::Point const /*p*/)
+spcc_connector_finish_segment(SPConnectorContext *const cc, Geom::Point const /*p*/)
{
if (!cc->red_curve->is_empty()) {
cc->green_curve->append_continuous(cc->red_curve, 0.0625);
@@ -1068,7 +1069,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc)
unsigned ind = (cc->active_handle == cc->endpt_handle[0]) ? 0 : 1;
sp_conn_end_detach(cc->clickeditem, ind);
- NR::Point origin;
+ Geom::Point origin;
if (cc->clickedhandle == cc->endpt_handle[0]) {
origin = cc->endpt_handle[1]->pos;
}
@@ -1258,7 +1259,8 @@ static bool cc_item_is_shape(SPItem *item)
}
}
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
- if (prefs_get_int_attribute("tools.connector", "ignoretext", 1) == 1) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/connector/ignoretext", true)) {
// Don't count text as a shape we can connect connector to.
return false;
}
diff --git a/src/connector-context.h b/src/connector-context.h
index e8d9a4390..d67e12b81 100644
--- a/src/connector-context.h
+++ b/src/connector-context.h
@@ -17,7 +17,7 @@
#include "event-context.h"
#include <forward.h>
#include <display/display-forward.h>
-#include <libnr/nr-point.h>
+#include <2geom/point.h>
#include "libavoid/connector.h"
@@ -44,7 +44,7 @@ enum {
struct SPConnectorContext : public SPEventContext {
Inkscape::Selection *selection;
- NR::Point p[5];
+ Geom::Point p[5];
/** \invar npoints in {0, 2}. */
gint npoints;
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index e6ebbe337..c80def787 100644
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
@@ -132,11 +132,11 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
Inkscape::SnappedPoint s[2];
/* Try to snap p[0] (the opposite corner) along the constraint vector */
- s[0] = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[0]),
+ s[0] = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p[0]),
Inkscape::Snapper::ConstraintLine(p[0] - p[1]));
/* Try to snap p[1] (the dragged corner) along the constraint vector */
- s[1] = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]),
+ s[1] = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p[1]),
Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
/* Choose the best snap and update points accordingly */
@@ -157,7 +157,7 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
- snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]),
+ snappoint = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p[1]),
Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
if (snappoint.getSnapped()) {
p[1] = snappoint.getPoint();
@@ -175,8 +175,8 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
Inkscape::SnappedPoint s[2];
- s[0] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[0]));
- s[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]));
+ s[0] = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p[0]));
+ s[1] = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p[1]));
if (s[0].getDistance() < s[1].getDistance()) {
if (s[0].getSnapped()) {
@@ -197,7 +197,7 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
p[1] = pt;
- snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(pt));
+ snappoint = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(pt));
if (snappoint.getSnapped()) {
p[1] = snappoint.getPoint();
}
diff --git a/src/debug/gdk-event-latency-tracker.cpp b/src/debug/gdk-event-latency-tracker.cpp
index cfd5a9b71..a6baae8da 100644
--- a/src/debug/gdk-event-latency-tracker.cpp
+++ b/src/debug/gdk-event-latency-tracker.cpp
@@ -10,7 +10,7 @@
*/
#include "debug/gdk-event-latency-tracker.h"
-#include "prefs-utils.h"
+#include "preferences.h"
namespace Inkscape {
namespace Debug {
@@ -32,7 +32,8 @@ boost::optional<double> GdkEventLatencyTracker::process(GdkEvent const *event) {
if (start_seconds == 0.0) {
elapsed.start();
start_seconds = timestamp_seconds;
- skew = prefs_get_double_attribute_limited("debug.latency", "skew", 1.0, 0.5, 2.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ skew = prefs->getDoubleLimited("/debug/latency/skew", 1.0, 0.5, 2.0);
return boost::optional<double>(0.0);
} else {
last_elapsed = elapsed.elapsed();
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 726341ded..4258d1980 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -36,7 +36,7 @@
#include "snap.h"
#include "display/canvas-grid.h"
#include "display/canvas-axonomgrid.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "helper/action.h"
#include "tools-switch.h"
#include <2geom/point.h>
@@ -52,8 +52,9 @@ int sp_desktop_root_handler(SPCanvasItem */*item*/, GdkEvent *event, SPDesktop *
static bool first = true;
if ( first ) {
- if ( prefs_get_int_attribute("options.useextinput", "value", 1)
- && prefs_get_int_attribute("options.switchonextinput", "value", 0) ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if ( prefs->getBool("/options/useextinput/value", true)
+ && prefs->getBool("/options/switchonextinput/value") ) {
watch = true;
init_extended();
}
diff --git a/src/desktop-handles.h b/src/desktop-handles.h
index 72c943949..a8d0a3d1e 100644
--- a/src/desktop-handles.h
+++ b/src/desktop-handles.h
@@ -25,8 +25,8 @@ namespace Inkscape {
#define SP_DESKTOP_ZOOM_MIN 0.01
#define SP_COORDINATES_UNDERLINE_NONE (0)
-#define SP_COORDINATES_UNDERLINE_X (1 << NR::X)
-#define SP_COORDINATES_UNDERLINE_Y (1 << NR::Y)
+#define SP_COORDINATES_UNDERLINE_X (1 << Geom::X)
+#define SP_COORDINATES_UNDERLINE_Y (1 << Geom::Y)
SPEventContext * sp_desktop_event_context (SPDesktop const * desktop);
Inkscape::Selection * sp_desktop_selection (SPDesktop const * desktop);
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 23b2e07a5..07817529d 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -23,7 +23,7 @@
#include "selection.h"
#include "inkscape.h"
#include "style.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-use.h"
#include "sp-feblend.h"
#include "sp-filter.h"
@@ -159,22 +159,22 @@ void
sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
{
if (write_current) {
-// 1. Set internal value
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ // 1. Set internal value
sp_repr_css_merge(desktop->current, css);
-// 1a. Write to prefs; make a copy and unset any URIs first
+ // 1a. Write to prefs; make a copy and unset any URIs first
SPCSSAttr *css_write = sp_repr_css_attr_new();
sp_repr_css_merge(css_write, css);
sp_css_attr_unset_uris(css_write);
- sp_repr_css_change(inkscape_get_repr(INKSCAPE, "desktop"), css_write, "style");
+ prefs->mergeStyle("/desktop/style", css_write);
+
for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
/* last used styles for 3D box faces are stored separately */
if (SP_IS_BOX3D_SIDE (i->data)) {
const char * descr = box3d_side_axes_string(SP_BOX3D_SIDE(i->data));
if (descr != NULL) {
- gchar *style_grp = g_strconcat ("desktop.", descr, NULL);
- sp_repr_css_change(inkscape_get_repr(INKSCAPE, style_grp), css_write, "style");
- g_free (style_grp);
+ prefs->mergeStyle(Glib::ustring("/desktop/") + descr + "/style", css_write);
}
}
}
@@ -243,19 +243,17 @@ sp_desktop_get_color(SPDesktop *desktop, bool is_fill)
}
double
-sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool, bool *has_opacity)
+sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPCSSAttr *css = NULL;
gfloat value = 1.0; // default if nothing else found
if (has_opacity)
*has_opacity = false;
- if (prefs_get_double_attribute(tool, "usecurrent", 0) != 0) {
+ if (prefs->getBool(tool + "/usecurrent")) {
css = sp_desktop_get_style(desktop, true);
- } else {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- if (tool_repr) {
- css = sp_repr_css_attr_inherited(tool_repr, "style");
- }
+ } else {
+ css = prefs->getStyle(tool + "/style");
}
if (css) {
@@ -276,17 +274,15 @@ sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool, bool *h
return value;
}
double
-sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill)
+sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPCSSAttr *css = NULL;
gfloat value = 1.0; // default if nothing else found
- if (prefs_get_double_attribute(tool, "usecurrent", 0) != 0) {
+ if (prefs->getBool(tool + "/usecurrent")) {
css = sp_desktop_get_style(desktop, true);
} else {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- if (tool_repr) {
- css = sp_repr_css_attr_inherited(tool_repr, "style");
- }
+ css = prefs->getStyle(tool + "/style");
}
if (css) {
@@ -305,19 +301,17 @@ sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill)
}
guint32
-sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill, bool *has_color)
-{
+sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill, bool *has_color)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPCSSAttr *css = NULL;
guint32 r = 0; // if there's no color, return black
if (has_color)
*has_color = false;
- if (prefs_get_int_attribute(tool, "usecurrent", 0) != 0) {
+ if (prefs->getBool(tool + "/usecurrent")) {
css = sp_desktop_get_style(desktop, true);
} else {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- if (tool_repr) {
- css = sp_repr_css_attr_inherited(tool_repr, "style");
- }
+ css = prefs->getStyle(tool + "/style");
}
if (css) {
@@ -342,18 +336,17 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill, bo
* Apply the desktop's current style or the tool style to repr.
*/
void
-sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, char const *tool, bool with_text)
+sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool_path, bool with_text)
{
SPCSSAttr *css_current = sp_desktop_get_style(desktop, with_text);
- if ((prefs_get_int_attribute(tool, "usecurrent", 0) != 0) && css_current) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
sp_repr_css_set(repr, css_current, "style");
} else {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool);
- if (tool_repr) {
- SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style");
- sp_repr_css_set(repr, css, "style");
- sp_repr_css_attr_unref(css);
- }
+ SPCSSAttr *css = prefs->getStyle(tool_path + "/style");
+ sp_repr_css_set(repr, css, "style");
+ sp_repr_css_attr_unref(css);
}
if (css_current) {
sp_repr_css_attr_unref(css_current);
@@ -368,21 +361,19 @@ double
sp_desktop_get_font_size_tool(SPDesktop *desktop)
{
(void)desktop; // TODO cleanup
- gchar const *desktop_style = inkscape_get_repr(INKSCAPE, "desktop")->attribute("style");
- gchar const *style_str = NULL;
- if ((prefs_get_int_attribute("tools.text", "usecurrent", 0) != 0) && desktop_style) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring desktop_style = prefs->getString("/desktop/style");
+ Glib::ustring style_str;
+ if ((prefs->getBool("/tools/text/usecurrent")) && !desktop_style.empty()) {
style_str = desktop_style;
} else {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, "tools.text");
- if (tool_repr) {
- style_str = tool_repr->attribute("style");
- }
+ style_str = prefs->getString("/tools/text/style");
}
double ret = 12;
- if (style_str) {
+ if (!style_str.empty()) {
SPStyle *style = sp_style_new(SP_ACTIVE_DOCUMENT);
- sp_style_merge_from_style_string(style, style_str);
+ sp_style_merge_from_style_string(style, style_str.data());
ret = style->font_size.computed;
sp_style_unref(style);
}
diff --git a/src/desktop-style.h b/src/desktop-style.h
index 57d8e0ae1..40461da72 100644
--- a/src/desktop-style.h
+++ b/src/desktop-style.h
@@ -25,6 +25,7 @@ namespace XML {
struct Node;
}
}
+namespace Glib { class ustring; }
enum { // what kind of a style the query is returning
QUERY_STYLE_NOTHING, // nothing was queried - e.g. no selection
@@ -57,11 +58,11 @@ void sp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_re
void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true);
SPCSSAttr *sp_desktop_get_style(SPDesktop *desktop, bool with_text);
guint32 sp_desktop_get_color (SPDesktop *desktop, bool is_fill);
-double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool, bool* has_opacity = NULL);
-double sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill);
-guint32 sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill, bool* has_color = NULL);
+double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool* has_opacity = NULL);
+double sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill);
+guint32 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill, bool* has_color = NULL);
double sp_desktop_get_font_size_tool (SPDesktop *desktop);
-void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, char const *tool, bool with_text);
+void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text);
gdouble stroke_average_width (GSList const *objects);
diff --git a/src/desktop.cpp b/src/desktop.cpp
index eb4a50410..1ee24f9c6 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -70,7 +70,7 @@
#include "sp-namedview.h"
#include "color.h"
#include "sp-item-group.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "object-hierarchy.h"
#include "helper/units.h"
#include "display/canvas-arena.h"
@@ -133,7 +133,7 @@ SPDesktop::SPDesktop() :
page( 0 ),
page_border( 0 ),
current( 0 ),
- _focusMode(false),
+ _focusMode(false),
zooms_past( 0 ),
zooms_future( 0 ),
dkey( 0 ),
@@ -156,7 +156,7 @@ SPDesktop::SPDesktop() :
_active( false ),
_w2d(),
_d2w(),
- _doc2dt( NR::Matrix(Geom::Scale(1, -1)) ),
+ _doc2dt( Geom::Scale(1, -1) ),
grids_visible( false )
{
_d2w.setIdentity();
@@ -170,10 +170,11 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas)
{
// Temporary workaround for link order issues:
Inkscape::DeviceManager::getManager().getDevices();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_guides_message_context = new Inkscape::MessageContext(const_cast<Inkscape::MessageStack*>(messageStack()));
- current = sp_repr_css_attr_inherited (inkscape_get_repr (INKSCAPE, "desktop"), "style");
+ current = prefs->getStyle("/desktop/style");
namedview = nv;
canvas = aCanvas;
@@ -216,9 +217,9 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas)
drawing = sp_canvas_item_new (main, SP_TYPE_CANVAS_ARENA, NULL);
g_signal_connect (G_OBJECT (drawing), "arena_event", G_CALLBACK (_arena_handler), this);
- SP_CANVAS_ARENA (drawing)->arena->delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0); // default is 1 px
+ SP_CANVAS_ARENA (drawing)->arena->delta = prefs->getDouble("/options/cursortolerance/value", 1.0); // default is 1 px
- if (prefs_get_int_attribute("options.startmode", "outline", 0)) {
+ if (prefs->getBool("/options/startmode/outline")) {
// Start in outline mode
setDisplayModeOutline();
} else {
@@ -238,7 +239,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas)
* call "set" instead of "push". Can we assume that there is only one
* context ever?
*/
- push_event_context (SP_TYPE_SELECT_CONTEXT, "tools.select", SP_EVENT_CONTEXT_STATIC);
+ push_event_context (SP_TYPE_SELECT_CONTEXT, "/tools/select", SP_EVENT_CONTEXT_STATIC);
// display rect and zoom are now handled in sp_desktop_widget_realize()
@@ -613,8 +614,7 @@ SPDesktop::set_event_context (GtkType type, const gchar *config)
g_object_unref (G_OBJECT (ec));
}
- Inkscape::XML::Node *repr = (config) ? inkscape_get_repr (_inkscape, config) : NULL;
- ec = sp_event_context_new (type, this, repr, SP_EVENT_CONTEXT_STATIC);
+ ec = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC);
ec->next = event_context;
event_context = ec;
sp_event_context_activate (ec);
@@ -628,7 +628,6 @@ void
SPDesktop::push_event_context (GtkType type, const gchar *config, unsigned int key)
{
SPEventContext *ref, *ec;
- Inkscape::XML::Node *repr;
if (event_context && event_context->key == key) return;
ref = event_context;
@@ -641,8 +640,7 @@ SPDesktop::push_event_context (GtkType type, const gchar *config, unsigned int k
}
if (event_context) sp_event_context_deactivate (event_context);
- repr = (config) ? inkscape_get_repr (INKSCAPE, config) : NULL;
- ec = sp_event_context_new (type, this, repr, key);
+ ec = sp_event_context_new (type, this, config, key);
ec->next = event_context;
event_context = ec;
sp_event_context_activate (ec);
@@ -723,10 +721,10 @@ SPDesktop::push_current_zoom (GList **history)
Geom::Rect const area = get_display_area();
NRRect *old_zoom = g_new(NRRect, 1);
- old_zoom->x0 = area.min()[NR::X];
- old_zoom->x1 = area.max()[NR::X];
- old_zoom->y0 = area.min()[NR::Y];
- old_zoom->y1 = area.max()[NR::Y];
+ old_zoom->x0 = area.min()[Geom::X];
+ old_zoom->x1 = area.max()[Geom::X];
+ old_zoom->y0 = area.min()[Geom::Y];
+ old_zoom->y1 = area.max()[Geom::Y];
if ( *history == NULL
|| !( ( ((NRRect *) ((*history)->data))->x0 == old_zoom->x0 ) &&
( ((NRRect *) ((*history)->data))->x1 == old_zoom->x1 ) &&
@@ -773,15 +771,15 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
int clear = FALSE;
if (!NR_DF_TEST_CLOSE (newscale, scale, 1e-4 * scale)) {
/* Set zoom factors */
- _d2w = NR::Matrix(Geom::Scale(newscale, -newscale));
- _w2d = NR::Matrix(Geom::Scale(1/newscale, 1/-newscale));
+ _d2w = Geom::Scale(newscale, -newscale);
+ _w2d = Geom::Scale(1/newscale, 1/-newscale);
sp_canvas_item_affine_absolute(SP_CANVAS_ITEM(main), _d2w);
clear = TRUE;
}
/* Calculate top left corner (in document pixels) */
- x0 = cx - 0.5 * viewbox.dimensions()[NR::X] / newscale;
- y1 = cy + 0.5 * viewbox.dimensions()[NR::Y] / newscale;
+ x0 = cx - 0.5 * viewbox.dimensions()[Geom::X] / newscale;
+ y1 = cy + 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
/* Scroll */
sp_canvas_scroll_to (canvas, x0 * newscale - border, y1 * -newscale - border, clear);
@@ -868,94 +866,94 @@ SPDesktop::next_zoom()
#include "nodepath.h"
/** \brief Performs a quick zoom into what the user is working on
- \param enable Whether we're going in or out of quick zoom
+ \param enable Whether we're going in or out of quick zoom
*/
void
SPDesktop::zoom_quick (bool enable)
{
- if (enable == _quick_zoom_enabled) {
- return;
- }
-
- if (enable == true) {
- _quick_zoom_stored_area = get_display_area();
- bool zoomed = false;
-
- if (!zoomed) {
- SPItem * singleItem = selection->singleItem();
- if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) {
- SPNodeContext * ncontext = SP_NODE_CONTEXT(event_context);
-
- Inkscape::NodePath::Path * nodepath = ncontext->shape_editor->get_nodepath();
- // printf("I've got a nodepath, crazy\n");
-
- Geom::Rect nodes;
- bool firstnode = true;
-
- if (nodepath->selected) {
- for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) {
- Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data;
- for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
- Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
- if (node->selected) {
- // printf("\tSelected node\n");
- if (firstnode) {
- nodes = Geom::Rect(node->pos, node->pos);
- firstnode = false;
- } else {
- nodes.expandTo(node->pos);
- }
-
- if (node->p.other != NULL) {
- /* Include previous node pos */
- nodes.expandTo(node->p.other->pos);
-
- /* Include previous handle */
- if (!sp_node_side_is_line(node, &node->p)) {
- nodes.expandTo(node->p.pos);
- }
- }
-
- if (node->n.other != NULL) {
- /* Include previous node pos */
- nodes.expandTo(node->n.other->pos);
-
- /* Include previous handle */
- if (!sp_node_side_is_line(node, &node->n)) {
- nodes.expandTo(node->n.pos);
- }
- }
- }
- }
- }
-
- if (!firstnode && nodes.area() * 2.0 < _quick_zoom_stored_area.area()) {
- set_display_area(nodes, 10);
- zoomed = true;
- }
- }
- }
- }
-
- if (!zoomed) {
- boost::optional<Geom::Rect> const d = selection->bounds();
- if (d && !d->isEmpty() && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
- set_display_area(*d, 10);
- zoomed = true;
- }
- }
-
- if (!zoomed) {
- zoom_relative(_quick_zoom_stored_area.midpoint()[NR::X], _quick_zoom_stored_area.midpoint()[NR::Y], 2.0);
- zoomed = true;
- }
- } else {
- set_display_area(_quick_zoom_stored_area, 0);
- }
-
- _quick_zoom_enabled = enable;
- return;
+ if (enable == _quick_zoom_enabled) {
+ return;
+ }
+
+ if (enable == true) {
+ _quick_zoom_stored_area = get_display_area();
+ bool zoomed = false;
+
+ if (!zoomed) {
+ SPItem * singleItem = selection->singleItem();
+ if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) {
+ SPNodeContext * ncontext = SP_NODE_CONTEXT(event_context);
+
+ Inkscape::NodePath::Path * nodepath = ncontext->shape_editor->get_nodepath();
+ // printf("I've got a nodepath, crazy\n");
+
+ Geom::Rect nodes;
+ bool firstnode = true;
+
+ if (nodepath->selected) {
+ for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) {
+ Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data;
+ for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
+ Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
+ if (node->selected) {
+ // printf("\tSelected node\n");
+ if (firstnode) {
+ nodes = Geom::Rect(node->pos, node->pos);
+ firstnode = false;
+ } else {
+ nodes.expandTo(node->pos);
+ }
+
+ if (node->p.other != NULL) {
+ /* Include previous node pos */
+ nodes.expandTo(node->p.other->pos);
+
+ /* Include previous handle */
+ if (!sp_node_side_is_line(node, &node->p)) {
+ nodes.expandTo(node->p.pos);
+ }
+ }
+
+ if (node->n.other != NULL) {
+ /* Include previous node pos */
+ nodes.expandTo(node->n.other->pos);
+
+ /* Include previous handle */
+ if (!sp_node_side_is_line(node, &node->n)) {
+ nodes.expandTo(node->n.pos);
+ }
+ }
+ }
+ }
+ }
+
+ if (!firstnode && nodes.area() * 2.0 < _quick_zoom_stored_area.area()) {
+ set_display_area(nodes, 10);
+ zoomed = true;
+ }
+ }
+ }
+ }
+
+ if (!zoomed) {
+ boost::optional<Geom::Rect> const d = selection->bounds();
+ if (d && !d->isEmpty() && d->area() * 2.0 < _quick_zoom_stored_area.area()) {
+ set_display_area(*d, 10);
+ zoomed = true;
+ }
+ }
+
+ if (!zoomed) {
+ zoom_relative(_quick_zoom_stored_area.midpoint()[Geom::X], _quick_zoom_stored_area.midpoint()[Geom::Y], 2.0);
+ zoomed = true;
+ }
+ } else {
+ set_display_area(_quick_zoom_stored_area, 0);
+ }
+
+ _quick_zoom_enabled = enable;
+ return;
}
/**
@@ -974,8 +972,8 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py,
Geom::Rect const viewbox = canvas->getViewbox();
- double const width2 = viewbox.dimensions()[NR::X] / zoom;
- double const height2 = viewbox.dimensions()[NR::Y] / zoom;
+ double const width2 = viewbox.dimensions()[Geom::X] / zoom;
+ double const height2 = viewbox.dimensions()[Geom::Y] / zoom;
set_display_area(cx - px * width2,
cy - py * height2,
@@ -1001,22 +999,22 @@ SPDesktop::zoom_relative_keep_point (double cx, double cy, double zoom)
{
Geom::Rect const area = get_display_area();
- if (cx < area.min()[NR::X]) {
- cx = area.min()[NR::X];
+ if (cx < area.min()[Geom::X]) {
+ cx = area.min()[Geom::X];
}
- if (cx > area.max()[NR::X]) {
- cx = area.max()[NR::X];
+ if (cx > area.max()[Geom::X]) {
+ cx = area.max()[Geom::X];
}
- if (cy < area.min()[NR::Y]) {
- cy = area.min()[NR::Y];
+ if (cy < area.min()[Geom::Y]) {
+ cy = area.min()[Geom::Y];
}
- if (cy > area.max()[NR::Y]) {
- cy = area.max()[NR::Y];
+ if (cy > area.max()[Geom::Y]) {
+ cy = area.max()[Geom::Y];
}
gdouble const scale = _d2w.descrim() * zoom;
- double const px = (cx - area.min()[NR::X]) / area.dimensions()[NR::X];
- double const py = (cy - area.min()[NR::Y]) / area.dimensions()[NR::Y];
+ double const px = (cx - area.min()[Geom::X]) / area.dimensions()[Geom::X];
+ double const py = (cy - area.min()[Geom::Y]) / area.dimensions()[Geom::Y];
zoom_absolute_keep_point(cx, cy, px, py, scale);
}
@@ -1146,7 +1144,11 @@ SPDesktop::scroll_world (double dx, double dy, bool is_scrolling)
bool
SPDesktop::scroll_to_point (Geom::Point const &p, gdouble autoscrollspeed)
{
- gdouble autoscrolldistance = (gdouble) prefs_get_int_attribute_limited ("options.autoscrolldistance", "value", 0, -1000, 10000);
+ using Geom::X;
+ using Geom::Y;
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble autoscrolldistance = (gdouble) prefs->getIntLimited("/options/autoscrolldistance/value", 0, -1000, 10000);
// autoscrolldistance is in screen pixels, but the display area is in document units
autoscrolldistance /= _d2w.descrim();
@@ -1154,33 +1156,33 @@ SPDesktop::scroll_to_point (Geom::Point const &p, gdouble autoscrollspeed)
Geom::Rect dbox = get_display_area();
dbox.expandBy(-autoscrolldistance);
- if (!(p[NR::X] > dbox.min()[NR::X] && p[NR::X] < dbox.max()[NR::X]) ||
- !(p[NR::Y] > dbox.min()[NR::Y] && p[NR::Y] < dbox.max()[NR::Y]) ) {
+ if (!(p[X] > dbox.min()[X] && p[X] < dbox.max()[X]) ||
+ !(p[Y] > dbox.min()[Y] && p[Y] < dbox.max()[Y]) ) {
Geom::Point const s_w( p * (Geom::Matrix)_d2w );
gdouble x_to;
- if (p[NR::X] < dbox.min()[NR::X])
- x_to = dbox.min()[NR::X];
- else if (p[NR::X] > dbox.max()[NR::X])
- x_to = dbox.max()[NR::X];
+ if (p[X] < dbox.min()[X])
+ x_to = dbox.min()[X];
+ else if (p[X] > dbox.max()[X])
+ x_to = dbox.max()[X];
else
- x_to = p[NR::X];
+ x_to = p[X];
gdouble y_to;
- if (p[NR::Y] < dbox.min()[NR::Y])
- y_to = dbox.min()[NR::Y];
- else if (p[NR::Y] > dbox.max()[NR::Y])
- y_to = dbox.max()[NR::Y];
+ if (p[Y] < dbox.min()[Y])
+ y_to = dbox.min()[Y];
+ else if (p[Y] > dbox.max()[Y])
+ y_to = dbox.max()[Y];
else
- y_to = p[NR::Y];
+ y_to = p[Y];
Geom::Point const d_dt(x_to, y_to);
Geom::Point const d_w( d_dt * _d2w );
Geom::Point const moved_w( d_w - s_w );
if (autoscrollspeed == 0)
- autoscrollspeed = prefs_get_double_attribute_limited ("options.autoscrollspeed", "value", 1, 0, 10);
+ autoscrollspeed = prefs->getDoubleLimited("/options/autoscrollspeed/value", 1, 0, 10);
if (autoscrollspeed != 0)
scroll_world (autoscrollspeed * moved_w);
@@ -1228,29 +1230,29 @@ SPDesktop::fullscreen()
/** \brief Checks to see if the user is working in focused mode
- Returns the value of \c _focusMode
+ Returns the value of \c _focusMode
*/
bool
SPDesktop::is_focusMode()
{
- return _focusMode;
+ return _focusMode;
}
/** \brief Changes whether the user is in focus mode or not
- \param mode Which mode the view should be in
+ \param mode Which mode the view should be in
*/
void
SPDesktop::focusMode (bool mode)
{
- if (mode == _focusMode) { return; }
+ if (mode == _focusMode) { return; }
- _focusMode = mode;
+ _focusMode = mode;
- layoutWidget();
- //sp_desktop_widget_layout(SPDesktopWidget);
+ layoutWidget();
+ //sp_desktop_widget_layout(SPDesktopWidget);
- return;
+ return;
}
void
@@ -1344,7 +1346,7 @@ bool SPDesktop::onDeleteUI (GdkEventAny*)
bool
SPDesktop::onWindowStateEvent (GdkEventWindowState* event)
{
- // Record the desktop window's state
+ // Record the desktop window's state
window_state = event->new_window_state;
// Layout may differ depending on full-screen mode or not
@@ -1353,7 +1355,7 @@ SPDesktop::onWindowStateEvent (GdkEventWindowState* event)
layoutWidget();
}
- return false;
+ return false;
}
void
@@ -1383,8 +1385,8 @@ SPDesktop::isToolboxButtonActive (gchar const *id)
void
SPDesktop::emitToolSubselectionChanged(gpointer data)
{
- _tool_subselection_changed.emit(data);
- inkscape_subselection_changed (this);
+ _tool_subselection_changed.emit(data);
+ inkscape_subselection_changed (this);
}
void
@@ -1452,7 +1454,7 @@ void SPDesktop::showGrids(bool show, bool dirty_document)
void SPDesktop::toggleSnapping()
{
- bool v = namedview->snap_manager.getSnapEnabledGlobally();
+ bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally();
Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
sp_repr_set_boolean(repr, "inkscape:snap-global", !v);
}
@@ -1731,7 +1733,7 @@ _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop)
int order = sp_canvas_item_order (desktop->page_border);
int morder = sp_canvas_item_order (desktop->drawing);
if (morder > order) sp_canvas_item_raise (desktop->page_border,
- morder - order);
+ morder - order);
}
} else {
sp_canvas_item_hide (desktop->page_border);
@@ -1747,14 +1749,15 @@ _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop)
((CtrlRect *) desktop->page_border)->setShadow(0, 0x00000000);
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (SP_RGBA32_A_U(nv->pagecolor) < 128 ||
(SP_RGBA32_R_U(nv->pagecolor) +
SP_RGBA32_G_U(nv->pagecolor) +
SP_RGBA32_B_U(nv->pagecolor)) >= 384) {
// the background color is light or transparent, use black outline
- SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "onlight", 0xff);
+ SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff);
} else { // use white outline
- SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "ondark", 0xffffffff);
+ SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff);
}
}
}
diff --git a/src/desktop.h b/src/desktop.h
index fa38e1b71..ce82f4ea6 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -118,7 +118,7 @@ struct SPDesktop : public Inkscape::UI::View::View
GList *zooms_past;
GList *zooms_future;
bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode
- Geom::Rect _quick_zoom_stored_area; ///< The area of the screen before quick zoom
+ Geom::Rect _quick_zoom_stored_area; ///< The area of the screen before quick zoom
unsigned int dkey;
unsigned int number;
guint window_state;
diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp
index c27c2b666..ce0fc15df 100644
--- a/src/dialogs/clonetiler.cpp
+++ b/src/dialogs/clonetiler.cpp
@@ -68,7 +68,7 @@ static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar const *prefs_path = "dialogs.clonetiler";
+static Glib::ustring const prefs_path = "/dialogs/clonetiler/";
#define SB_MARGIN 1
#define VB_MARGIN 4
@@ -125,10 +125,10 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer
if (y<0) y=0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(prefs_path, "x", x);
- prefs->setInt(prefs_path, "y", y);
- prefs->setInt(prefs_path, "w", w);
- prefs->setInt(prefs_path, "h", h);
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
@@ -151,7 +151,7 @@ on_picker_color_changed (guint rgba)
gchar c[32];
sp_svg_write_color(c, sizeof(c), rgba);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(prefs_path, "initial_color", c);
+ prefs->setString(prefs_path + "initial_color", c);
is_updating = false;
}
@@ -1134,89 +1134,87 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
clonetiler_remove (NULL, NULL, false);
- 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);
- double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "shiftx_per_j", 0, -10000, 10000);
- double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "shifty_per_j", 0, -10000, 10000);
- double shiftx_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "shiftx_rand", 0, 0, 1000);
- double shifty_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "shifty_rand", 0, 0, 1000);
- double shiftx_exp = prefs->getDoubleLimited(prefs_path, "shiftx_exp", 1, 0, 10);
- double shifty_exp = prefs->getDoubleLimited(prefs_path, "shifty_exp", 1, 0, 10);
- bool shiftx_alternate = prefs->getBool(prefs_path, "shiftx_alternate");
- bool shifty_alternate = prefs->getBool(prefs_path, "shifty_alternate");
- bool shiftx_cumulate = prefs->getBool(prefs_path, "shiftx_cumulate");
- bool shifty_cumulate = prefs->getBool(prefs_path, "shifty_cumulate");
- bool shiftx_excludew = prefs->getBool(prefs_path, "shiftx_excludew");
- bool shifty_excludeh = prefs->getBool(prefs_path, "shifty_excludeh");
-
- double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_per_i", 0, -100, 1000);
- double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_per_i", 0, -100, 1000);
- double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_per_j", 0, -100, 1000);
- double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_per_j", 0, -100, 1000);
- double scalex_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "scalex_rand", 0, 0, 1000);
- double scaley_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "scaley_rand", 0, 0, 1000);
- double scalex_exp = prefs->getDoubleLimited(prefs_path, "scalex_exp", 1, 0, 10);
- double scaley_exp = prefs->getDoubleLimited(prefs_path, "scaley_exp", 1, 0, 10);
- double scalex_log = prefs->getDoubleLimited(prefs_path, "scalex_log", 0, 0, 10);
- double scaley_log = prefs->getDoubleLimited(prefs_path, "scaley_log", 0, 0, 10);
- bool scalex_alternate = prefs->getBool(prefs_path, "scalex_alternate");
- bool scaley_alternate = prefs->getBool(prefs_path, "scaley_alternate");
- bool scalex_cumulate = prefs->getBool(prefs_path, "scalex_cumulate");
- bool scaley_cumulate = prefs->getBool(prefs_path, "scaley_cumulate");
-
- double rotate_per_i = prefs->getDoubleLimited(prefs_path, "rotate_per_i", 0, -180, 180);
- double rotate_per_j = prefs->getDoubleLimited(prefs_path, "rotate_per_j", 0, -180, 180);
- double rotate_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "rotate_rand", 0, 0, 100);
- bool rotate_alternatei = prefs->getBool(prefs_path, "rotate_alternatei");
- bool rotate_alternatej = prefs->getBool(prefs_path, "rotate_alternatej");
- bool rotate_cumulatei = prefs->getBool(prefs_path, "rotate_cumulatei");
- bool rotate_cumulatej = prefs->getBool(prefs_path, "rotate_cumulatej");
-
- double blur_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_per_i", 0, 0, 100);
- double blur_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_per_j", 0, 0, 100);
- bool blur_alternatei = prefs->getBool(prefs_path, "blur_alternatei");
- bool blur_alternatej = prefs->getBool(prefs_path, "blur_alternatej");
- double blur_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "blur_rand", 0, 0, 100);
-
- double opacity_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_per_i", 0, 0, 100);
- double opacity_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_per_j", 0, 0, 100);
- bool opacity_alternatei = prefs->getBool(prefs_path, "opacity_alternatei");
- bool opacity_alternatej = prefs->getBool(prefs_path, "opacity_alternatej");
- double opacity_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "opacity_rand", 0, 0, 100);
-
- Glib::ustring initial_color = prefs->getString(prefs_path, "initial_color");
- double hue_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_per_j", 0, -100, 100);
- double hue_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_per_i", 0, -100, 100);
- double hue_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "hue_rand", 0, 0, 100);
- double saturation_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_per_j", 0, -100, 100);
- double saturation_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_per_i", 0, -100, 100);
- double saturation_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "saturation_rand", 0, 0, 100);
- double lightness_per_j = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_per_j", 0, -100, 100);
- double lightness_per_i = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_per_i", 0, -100, 100);
- double lightness_rand = 0.01 * prefs->getDoubleLimited(prefs_path, "lightness_rand", 0, 0, 100);
- bool color_alternatej = prefs->getBool(prefs_path, "color_alternatej");
- bool color_alternatei = prefs->getBool(prefs_path, "color_alternatei");
-
- int type = prefs->getInt(prefs_path, "symmetrygroup", 0);
-
- bool keepbbox = prefs->getBool(prefs_path, "keepbbox", true);
-
- int imax = prefs->getInt(prefs_path, "imax", 2);
- int jmax = prefs->getInt(prefs_path, "jmax", 2);
-
- bool fillrect = prefs->getBool(prefs_path, "fillrect");
- double fillwidth = prefs->getDoubleLimited(prefs_path, "fillwidth", 50, 0, 1e6);
- double fillheight = prefs->getDoubleLimited(prefs_path, "fillheight", 50, 0, 1e6);
-
- bool dotrace = prefs->getBool(prefs_path, "dotrace");
- int pick = prefs->getInt(prefs_path, "pick");
- bool pick_to_presence = prefs->getBool(prefs_path, "pick_to_presence");
- bool pick_to_size = prefs->getBool(prefs_path, "pick_to_size");
- bool pick_to_color = prefs->getBool(prefs_path, "pick_to_color");
- bool pick_to_opacity = prefs->getBool(prefs_path, "pick_to_opacity");
- double rand_picked = 0.01 * prefs->getDoubleLimited(prefs_path, "rand_picked", 0, 0, 100);
- bool invert_picked = prefs->getBool(prefs_path, "invert_picked");
- double gamma_picked = prefs->getDoubleLimited(prefs_path, "gamma_picked", 0, -10, 10);
+ 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);
+ double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_j", 0, -10000, 10000);
+ double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_j", 0, -10000, 10000);
+ double shiftx_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_rand", 0, 0, 1000);
+ double shifty_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_rand", 0, 0, 1000);
+ double shiftx_exp = prefs->getDoubleLimited(prefs_path + "shiftx_exp", 1, 0, 10);
+ double shifty_exp = prefs->getDoubleLimited(prefs_path + "shifty_exp", 1, 0, 10);
+ bool shiftx_alternate = prefs->getBool(prefs_path + "shiftx_alternate");
+ bool shifty_alternate = prefs->getBool(prefs_path + "shifty_alternate");
+ bool shiftx_cumulate = prefs->getBool(prefs_path + "shiftx_cumulate");
+ bool shifty_cumulate = prefs->getBool(prefs_path + "shifty_cumulate");
+ bool shiftx_excludew = prefs->getBool(prefs_path + "shiftx_excludew");
+ bool shifty_excludeh = prefs->getBool(prefs_path + "shifty_excludeh");
+
+ double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_i", 0, -100, 1000);
+ double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_i", 0, -100, 1000);
+ double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_j", 0, -100, 1000);
+ double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_j", 0, -100, 1000);
+ double scalex_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_rand", 0, 0, 1000);
+ double scaley_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_rand", 0, 0, 1000);
+ double scalex_exp = prefs->getDoubleLimited(prefs_path + "scalex_exp", 1, 0, 10);
+ double scaley_exp = prefs->getDoubleLimited(prefs_path + "scaley_exp", 1, 0, 10);
+ double scalex_log = prefs->getDoubleLimited(prefs_path + "scalex_log", 0, 0, 10);
+ double scaley_log = prefs->getDoubleLimited(prefs_path + "scaley_log", 0, 0, 10);
+ bool scalex_alternate = prefs->getBool(prefs_path + "scalex_alternate");
+ bool scaley_alternate = prefs->getBool(prefs_path + "scaley_alternate");
+ bool scalex_cumulate = prefs->getBool(prefs_path + "scalex_cumulate");
+ bool scaley_cumulate = prefs->getBool(prefs_path + "scaley_cumulate");
+
+ double rotate_per_i = prefs->getDoubleLimited(prefs_path + "rotate_per_i", 0, -180, 180);
+ double rotate_per_j = prefs->getDoubleLimited(prefs_path + "rotate_per_j", 0, -180, 180);
+ double rotate_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "rotate_rand", 0, 0, 100);
+ bool rotate_alternatei = prefs->getBool(prefs_path + "rotate_alternatei");
+ bool rotate_alternatej = prefs->getBool(prefs_path + "rotate_alternatej");
+ bool rotate_cumulatei = prefs->getBool(prefs_path + "rotate_cumulatei");
+ bool rotate_cumulatej = prefs->getBool(prefs_path + "rotate_cumulatej");
+
+ double blur_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "blur_per_i", 0, 0, 100);
+ double blur_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "blur_per_j", 0, 0, 100);
+ bool blur_alternatei = prefs->getBool(prefs_path + "blur_alternatei");
+ bool blur_alternatej = prefs->getBool(prefs_path + "blur_alternatej");
+ double blur_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "blur_rand", 0, 0, 100);
+
+ double opacity_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "opacity_per_i", 0, 0, 100);
+ double opacity_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "opacity_per_j", 0, 0, 100);
+ bool opacity_alternatei = prefs->getBool(prefs_path + "opacity_alternatei");
+ bool opacity_alternatej = prefs->getBool(prefs_path + "opacity_alternatej");
+ double opacity_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "opacity_rand", 0, 0, 100);
+
+ Glib::ustring initial_color = prefs->getString(prefs_path + "initial_color");
+ double hue_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "hue_per_j", 0, -100, 100);
+ double hue_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "hue_per_i", 0, -100, 100);
+ double hue_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "hue_rand", 0, 0, 100);
+ double saturation_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_j", 0, -100, 100);
+ double saturation_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_i", 0, -100, 100);
+ double saturation_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_rand", 0, 0, 100);
+ double lightness_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_j", 0, -100, 100);
+ double lightness_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_i", 0, -100, 100);
+ double lightness_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "lightness_rand", 0, 0, 100);
+ bool color_alternatej = prefs->getBool(prefs_path + "color_alternatej");
+ bool color_alternatei = prefs->getBool(prefs_path + "color_alternatei");
+
+ int type = prefs->getInt(prefs_path + "symmetrygroup", 0);
+ bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
+ int imax = prefs->getInt(prefs_path + "imax", 2);
+ int jmax = prefs->getInt(prefs_path + "jmax", 2);
+
+ bool fillrect = prefs->getBool(prefs_path + "fillrect");
+ double fillwidth = prefs->getDoubleLimited(prefs_path + "fillwidth", 50, 0, 1e6);
+ double fillheight = prefs->getDoubleLimited(prefs_path + "fillheight", 50, 0, 1e6);
+
+ bool dotrace = prefs->getBool(prefs_path + "dotrace");
+ int pick = prefs->getInt(prefs_path + "pick");
+ bool pick_to_presence = prefs->getBool(prefs_path + "pick_to_presence");
+ bool pick_to_size = prefs->getBool(prefs_path + "pick_to_size");
+ bool pick_to_color = prefs->getBool(prefs_path + "pick_to_color");
+ bool pick_to_opacity = prefs->getBool(prefs_path + "pick_to_opacity");
+ double rand_picked = 0.01 * prefs->getDoubleLimited(prefs_path + "rand_picked", 0, 0, 100);
+ bool invert_picked = prefs->getBool(prefs_path + "invert_picked");
+ double gamma_picked = prefs->getDoubleLimited(prefs_path + "gamma_picked", 0, -10, 10);
if (dotrace) {
clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj));
@@ -1245,7 +1243,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
x0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-x0", 0);
y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0);
} else {
- bool prefs_bbox = prefs->getBool("tools", "bounding_box", false);
+ bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
SPItem::BBoxType bbox_type = ( prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX );
boost::optional<Geom::Rect> r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)),
@@ -1546,7 +1544,7 @@ clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
{
const gchar *attr = (const gchar *) data;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path, attr, gtk_toggle_button_get_active(tb));
+ prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb));
}
static GtkWidget *
@@ -1558,7 +1556,7 @@ clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool value = prefs->getBool(prefs_path, attr);
+ bool value = prefs->getBool(prefs_path + attr);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
@@ -1576,7 +1574,7 @@ clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs->setDouble(prefs_path, pref, adj->value);
+ prefs->setDouble(prefs_path + pref, adj->value);
}
static GtkWidget *
@@ -1602,7 +1600,7 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l
gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double value = prefs->getDoubleLimited(prefs_path, attr, exponent? 1.0 : 0.0, lower, upper);
+ double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
gtk_signal_connect(GTK_OBJECT(a), "value_changed",
GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
@@ -1628,7 +1626,7 @@ clonetiler_symgroup_changed( GtkMenuItem */*item*/, gpointer data )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint group_new = GPOINTER_TO_INT (data);
- prefs->setInt(prefs_path, "symmetrygroup", group_new);
+ prefs->setInt(prefs_path + "symmetrygroup", group_new);
}
static void
@@ -1636,14 +1634,14 @@ clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs->setInt(prefs_path, pref, (int) floor(adj->value + 0.5));
+ prefs->setInt(prefs_path + pref, (int) floor(adj->value + 0.5));
}
static void
clonetiler_keep_bbox_toggled( GtkToggleButton *tb, gpointer /*data*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path, "keepbbox", gtk_toggle_button_get_active(tb));
+ prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb));
}
static void
@@ -1651,7 +1649,7 @@ clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
const gchar *pref = (const gchar *) data;
- prefs->setBool(prefs_path, pref, gtk_toggle_button_get_active(tb));
+ prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb));
}
@@ -1752,7 +1750,7 @@ clonetiler_pick_switched( GtkToggleButton */*tb*/, gpointer data )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint v = GPOINTER_TO_INT (data);
- prefs->setInt(prefs_path, "pick", v);
+ prefs->setInt(prefs_path + "pick", v);
}
@@ -1770,7 +1768,7 @@ clonetiler_switch_to_create( GtkToggleButton */*tb*/, GtkWidget *dlg )
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path, "fillrect", false);
+ prefs->setBool(prefs_path + "fillrect", false);
}
@@ -1788,7 +1786,7 @@ clonetiler_switch_to_fill( GtkToggleButton */*tb*/, GtkWidget *dlg )
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path, "fillrect", true);
+ prefs->setBool(prefs_path + "fillrect", true);
}
@@ -1802,7 +1800,7 @@ clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u)
gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble(prefs_path, "fillwidth", pixels);
+ prefs->setDouble(prefs_path + "fillwidth", pixels);
}
static void
@@ -1813,7 +1811,7 @@ clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u)
gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble(prefs_path, "fillheight", pixels);
+ prefs->setDouble(prefs_path + "fillheight", pixels);
}
@@ -1823,7 +1821,7 @@ clonetiler_do_pick_toggled( GtkToggleButton *tb, gpointer /*data*/ )
GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
+ prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb));
if (vvb)
gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
@@ -1843,13 +1841,13 @@ clonetiler_dialog (void)
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs->getInt(prefs_path, "x", -1000);
- y = prefs->getInt(prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
if (w ==0 || h == 0) {
- w = prefs->getInt(prefs_path, "w", 0);
- h = prefs->getInt(prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
@@ -1913,7 +1911,7 @@ clonetiler_dialog (void)
gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
GtkWidget *m = gtk_menu_new ();
- int current = prefs->getInt(prefs_path, "symmetrygroup", 0);
+ int current = prefs->getInt(prefs_path + "symmetrygroup", 0);
struct SymGroups {
int group;
@@ -2461,7 +2459,7 @@ clonetiler_dialog (void)
GtkWidget *l = gtk_label_new (_("Initial color: "));
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
- guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path, "initial_color").data(), 0x000000ff);
+ guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff);
color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke)")), rgba, false);
_color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
@@ -2593,7 +2591,7 @@ clonetiler_dialog (void)
GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
- bool old = prefs->getBool(prefs_path, "dotrace");
+ bool old = prefs->getBool(prefs_path + "dotrace");
gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL);
gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
@@ -2625,7 +2623,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 1, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_COLOR);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
@@ -2633,7 +2631,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 2, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_OPACITY);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
@@ -2641,7 +2639,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 1, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_R);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
@@ -2649,7 +2647,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 2, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_G);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
@@ -2657,7 +2655,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 3, 2);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_B);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
}
{
//TRANSLATORS: only translate "string" in "context|string".
@@ -2667,7 +2665,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 1, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_H);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
}
{
//TRANSLATORS: only translate "string" in "context|string".
@@ -2677,7 +2675,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 2, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_S);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
}
{
//TRANSLATORS: only translate "string" in "context|string".
@@ -2687,7 +2685,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 3, 3);
gtk_signal_connect (GTK_OBJECT (radio), "toggled",
GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path, "pick", 0) == PICK_L);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L);
}
}
@@ -2748,7 +2746,7 @@ clonetiler_dialog (void)
{
GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
- bool old = prefs->getBool(prefs_path, "pick_to_presence", true);
+ bool old = prefs->getBool(prefs_path + "pick_to_presence", true);
gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 1, 1);
@@ -2758,7 +2756,7 @@ clonetiler_dialog (void)
{
GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
- bool old = prefs->getBool(prefs_path, "pick_to_size");
+ bool old = prefs->getBool(prefs_path + "pick_to_size");
gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 2, 1);
@@ -2768,7 +2766,7 @@ clonetiler_dialog (void)
{
GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
- bool old = prefs->getBool(prefs_path, "pick_to_color", 0);
+ bool old = prefs->getBool(prefs_path + "pick_to_color", 0);
gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL);
clonetiler_table_attach (table, b, 0.0, 1, 2);
@@ -2778,7 +2776,7 @@ clonetiler_dialog (void)
{
GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
- bool old = prefs->getBool(prefs_path, "pick_to_opacity", 0);
+ bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0);
gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
clonetiler_table_attach (table, b, 0.0, 2, 2);
@@ -2786,7 +2784,7 @@ clonetiler_dialog (void)
GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
}
}
- gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path, "dotrace"));
+ gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace"));
}
}
@@ -2804,7 +2802,7 @@ clonetiler_dialog (void)
{
GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
- int value = prefs->getInt(prefs_path, "jmax", 2);
+ int value = prefs->getInt(prefs_path + "jmax", 2);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
@@ -2824,7 +2822,7 @@ clonetiler_dialog (void)
{
GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
- int value = prefs->getInt(prefs_path, "imax", 2);
+ int value = prefs->getInt(prefs_path + "imax", 2);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
@@ -2851,7 +2849,7 @@ clonetiler_dialog (void)
GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
- double value = prefs->getDouble(prefs_path, "fillwidth", 50.0);
+ double value = prefs->getDouble(prefs_path + "fillwidth", 50.0);
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const units = sp_pixels_get_units (value, unit);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
@@ -2875,7 +2873,7 @@ clonetiler_dialog (void)
GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0);
sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
- double value = prefs->getDouble(prefs_path, "fillheight", 50.0);
+ double value = prefs->getDouble(prefs_path + "fillheight", 50.0);
SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
gdouble const units = sp_pixels_get_units (value, unit);
gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
@@ -2902,7 +2900,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 1, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
}
- if (!prefs->getBool(prefs_path, "fillrect")) {
+ if (!prefs->getBool(prefs_path + "fillrect")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
}
@@ -2912,7 +2910,7 @@ clonetiler_dialog (void)
clonetiler_table_attach (table, radio, 0.0, 2, 1);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
}
- if (prefs->getBool(prefs_path, "fillrect")) {
+ if (prefs->getBool(prefs_path + "fillrect")) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
}
@@ -2925,7 +2923,7 @@ clonetiler_dialog (void)
gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
- bool keepbbox = prefs->getBool(prefs_path, "keepbbox", true);
+ bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL);
gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp
index dc9f4ac2a..b306e42d6 100644
--- a/src/dialogs/dialog-events.cpp
+++ b/src/dialogs/dialog-events.cpp
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
#include "desktop.h"
#include "inkscape-private.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "event-context.h"
#include "dialog-events.h"
@@ -172,16 +172,17 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data)
void
sp_transientize (GtkWidget *dialog)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
#ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs
// _set_skip_taskbar_hint makes transient dialogs NON-transient! When dialogs
// are made transient (_set_transient_for), they are already removed from
// the taskbar in Win32.
- if (prefs_get_int_attribute ( "options.dialogsskiptaskbar", "value", 0)) {
+ if (prefs->getBool( "/options/dialogsskiptaskbar/value")) {
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
}
#endif
- gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2 );
+ gint transient_policy = prefs->getIntLimited("/options/transientpolicy/value", 1, 0, 2);
#ifdef WIN32 // Win32 special code to enable transient dialogs
transient_policy = 2;
@@ -207,7 +208,8 @@ void
sp_transientize_callback ( Inkscape::Application * /*inkscape*/,
SPDesktop *desktop, win_data *wd )
{
- gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2);
#ifdef WIN32 // Win32 special code to enable transient dialogs
transient_policy = 2;
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 816a50754..dc337ef8e 100644
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
@@ -114,7 +114,7 @@ static void sp_export_filename_modified (GtkObject * object, gpointer data);
static inline void sp_export_find_default_selection(GtkWidget * dlg);
static void sp_export_detect_size(GtkObject * base);
-static const gchar *prefs_path = "dialogs.export";
+static Glib::ustring const prefs_path = "/dialogs/export/";
// these all need to be reinitialized to their defaults during dialog_destroy
static GtkWidget *dlg = NULL;
@@ -171,10 +171,10 @@ sp_export_dialog_delete ( GtkObject */*object*/, GdkEvent */*event*/, gpointer /
if (y<0) y=0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(prefs_path, "x", x);
- prefs->setInt(prefs_path, "y", y);
- prefs->setInt(prefs_path, "w", w);
- prefs->setInt(prefs_path, "h", h);
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
@@ -400,13 +400,13 @@ sp_export_dialog (void)
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs->getInt(prefs_path, "x", 0);
- y = prefs->getInt(prefs_path, "y", 0);
+ x = prefs->getInt(prefs_path + "x", 0);
+ y = prefs->getInt(prefs_path + "y", 0);
}
if (w ==0 || h == 0) {
- w = prefs->getInt(prefs_path, "w", 0);
- h = prefs->getInt(prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
@@ -484,7 +484,7 @@ sp_export_dialog (void)
dlg );
sp_export_spinbutton_new ( "xdpi",
- prefs->getDouble("dialogs.export.defaultxdpi", "value", DPI_BASE),
+ prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 0,
NULL, _("dp_i"), 2, 1,
G_CALLBACK (sp_export_xdpi_value_changed),
@@ -501,7 +501,7 @@ sp_export_dialog (void)
* Needs fixing: there's no way to set ydpi currently, so we use
* the defaultxdpi value here, too...
*/
- sp_export_spinbutton_new ( "ydpi", prefs->getDouble("dialogs.export.defaultxdpi", "value", DPI_BASE),
+ sp_export_spinbutton_new ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
0.01, 100000.0, 0.1, 1.0, NULL, GTK_WIDGET(t->gobj()), 3, 1,
NULL, _("dpi"), 2, 0, NULL, dlg );
@@ -703,7 +703,7 @@ sp_export_find_default_selection(GtkWidget * dlg)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int i = SELECTION_NUMBER_OF;
- Glib::ustring what = prefs->getString("dialogs.export.exportarea", "value");
+ Glib::ustring what = prefs->getString("/dialogs/export/exportarea/value");
if (!what.empty()) {
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
@@ -881,7 +881,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
// remember area setting
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("dialogs.export.exportarea", "value", selection_names[key]);
+ prefs->setString("/dialogs/export/exportarea/value", selection_names[key]);
if ( key != SELECTION_CUSTOM && bbox ) {
sp_export_set_area (base, bbox->min()[Geom::X],
@@ -1796,7 +1796,7 @@ sp_export_xdpi_value_changed (GtkAdjustment */*adj*/, GtkObject *base)
// remember xdpi setting
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("dialogs.export.defaultxdpi", "value", xdpi);
+ prefs->setDouble("/dialogs/export/defaultxdpi/value", xdpi);
bmwidth = (x1 - x0) * xdpi / DPI_BASE;
diff --git a/src/dialogs/fill-style.cpp b/src/dialogs/fill-style.cpp
index ebf2d4bdd..e095425a9 100644
--- a/src/dialogs/fill-style.cpp
+++ b/src/dialogs/fill-style.cpp
@@ -21,21 +21,21 @@
#endif
-#include <widgets/sp-widget.h>
-#include <sp-linear-gradient.h>
-#include <sp-pattern.h>
-#include <sp-radial-gradient.h>
-#include <widgets/paint-selector.h>
-#include <style.h>
-#include <gradient-chemistry.h>
-#include <desktop-style.h>
-#include <desktop-handles.h>
-#include <selection.h>
-#include <inkscape.h>
-#include <document-private.h>
-#include <xml/repr.h>
+#include "widgets/sp-widget.h"
+#include "sp-linear-gradient.h"
+#include "sp-pattern.h"
+#include "sp-radial-gradient.h"
+#include "widgets/paint-selector.h"
+#include "style.h"
+#include "gradient-chemistry.h"
+#include "desktop-style.h"
+#include "desktop-handles.h"
+#include "selection.h"
+#include "inkscape.h"
+#include "document-private.h"
+#include "xml/repr.h"
#include <glibmm/i18n.h>
-#include <display/sp-canvas.h>
+#include "display/sp-canvas.h"
// These can be deleted once we sort out the libart dependence.
diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp
index 6f9eca0d7..96a630553 100644
--- a/src/dialogs/find.cpp
+++ b/src/dialogs/find.cpp
@@ -44,7 +44,7 @@ sp_find_dialog(){
#include "desktop-handles.h"
#include "dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "../verbs.h"
#include "../interface.h"
#include "../sp-text.h"
@@ -77,7 +77,7 @@ static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar const *prefs_path = "dialogs.find";
+static Glib::ustring const prefs_path = "/dialogs/find/";
@@ -99,10 +99,11 @@ static gboolean sp_find_dialog_delete(GtkObject *, GdkEvent *, gpointer /*data*/
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
}
@@ -647,15 +648,16 @@ sp_find_dialog_old (void)
{
gchar title[500];
sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_FIND), title);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", -1000);
- y = prefs_get_int_attribute (prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
diff --git a/src/dialogs/iconpreview.cpp b/src/dialogs/iconpreview.cpp
index c3d15d830..f31914e3e 100644
--- a/src/dialogs/iconpreview.cpp
+++ b/src/dialogs/iconpreview.cpp
@@ -25,7 +25,7 @@
#include <gtkmm/buttonbox.h>
#include <gtkmm/stock.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape.h"
#include "document.h"
#include "desktop-handles.h"
@@ -50,7 +50,7 @@ namespace Dialogs {
IconPreviewPanel&
IconPreviewPanel::getInstance()
{
- IconPreviewPanel &instance = *new IconPreviewPanel();
+ static IconPreviewPanel &instance = *new IconPreviewPanel();
instance.refreshPreview();
@@ -82,39 +82,32 @@ void IconPreviewPanel::on_button_clicked(int which)
* Constructor
*/
IconPreviewPanel::IconPreviewPanel() :
- UI::Widget::Panel("", "dialogs.iconpreview", SP_VERB_VIEW_ICON_PREVIEW),
+ UI::Widget::Panel("", "/dialogs/iconpreview", SP_VERB_VIEW_ICON_PREVIEW),
hot(1),
refreshButton(0),
selectionButton(0)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
numEntries = 0;
- Inkscape::XML::Node *things = inkscape_get_repr(INKSCAPE, "iconpreview.sizes.default");
- if (things) {
- std::vector<int> rawSizes;
- for ( Inkscape::XML::Node *child = things->firstChild(); child; child = child->next() )
- {
- gchar const *id = child->attribute("id");
- if ( id )
- {
- std::string path("iconpreview.sizes.default.");
- path += id;
- gint show = prefs_get_int_attribute_limited( path.c_str(), "show", 1, 0, 1 );
- gint sizeVal = prefs_get_int_attribute( path.c_str(), "value", -1 );
- if ( show && (sizeVal > 0) )
- {
- rawSizes.push_back( sizeVal );
- }
+
+ std::vector<Glib::ustring> pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default");
+ std::vector<int> rawSizes;
+
+ for (std::vector<Glib::ustring>::iterator i = pref_sizes.begin(); i != pref_sizes.end(); ++i) {
+ if (prefs->getBool(*i + "/show", true)) {
+ int sizeVal = prefs->getInt(*i + "/value", -1);
+ if (sizeVal > 0) {
+ rawSizes.push_back(sizeVal);
}
}
+ }
- if ( !rawSizes.empty() )
- {
- numEntries = rawSizes.size();
- sizes = new int[numEntries];
- int i = 0;
- for ( std::vector<int>::iterator it = rawSizes.begin(); it != rawSizes.end(); ++it, ++i ) {
- sizes[i] = *it;
- }
+ if ( !rawSizes.empty() ) {
+ numEntries = rawSizes.size();
+ sizes = new int[numEntries];
+ int i = 0;
+ for ( std::vector<int>::iterator it = rawSizes.begin(); it != rawSizes.end(); ++it, ++i ) {
+ sizes[i] = *it;
}
}
@@ -189,7 +182,7 @@ IconPreviewPanel::IconPreviewPanel() :
tips.set_tip((*selectionButton), _("Selection only or whole document"));
selectionButton->signal_clicked().connect( sigc::mem_fun(*this, &IconPreviewPanel::modeToggled) );
- gint val = prefs_get_int_attribute_limited( "iconpreview", "selectionOnly", 0, 0, 1 );
+ gint val = prefs->getBool("/iconpreview/selectionOnly");
selectionButton->set_active( val != 0 );
refreshButton = new Gtk::Button(Gtk::Stock::REFRESH); // , GTK_RESPONSE_APPLY
@@ -248,7 +241,8 @@ void IconPreviewPanel::refreshPreview()
void IconPreviewPanel::modeToggled()
{
- prefs_set_int_attribute( "iconpreview", "selectionOnly", (selectionButton && selectionButton->get_active()) ? 1 : 0 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/iconpreview/selectionOnly", (selectionButton && selectionButton->get_active()));
refreshPreview();
}
@@ -307,13 +301,9 @@ void IconPreviewPanel::updateMagnify()
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ 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 :
-
-//#########################################################################
-//## E N D O F F I L E
-//#########################################################################
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/dialogs/input.cpp b/src/dialogs/input.cpp
index f4690623e..e23fcc848 100644
--- a/src/dialogs/input.cpp
+++ b/src/dialogs/input.cpp
@@ -1,9 +1,9 @@
#define __SP_INPUT_C__
-/*
- * Extended input devices dialog
- *
- * Authors:
+/** @file
+ * @brief Extended input devices dialog
+ */
+/* Authors:
* Nicklas Lindgren <nili@lysator.liu.se>
* Johan Engelen <goejendaagh@zonnet.nl>
*
@@ -19,14 +19,14 @@
#include <gtk/gtkinputdialog.h>
#include <glibmm/ustring.h>
-#include "../inkscape.h"
-#include "../macros.h"
-#include "../verbs.h"
-#include "../interface.h"
-#include "../xml/repr.h"
+#include "macros.h"
+#include "verbs.h"
+#include "inkscape.h"
+#include "interface.h"
+#include "xml/repr.h"
-#include "dialog-events.h"
-#include "../prefs-utils.h"
+#include "dialogs/dialog-events.h"
+#include "preferences.h"
#define MIN_ONSCREEN_DISTANCE 50
@@ -35,7 +35,7 @@ static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static const gchar *prefs_path = "dialogs.input";
+static Glib::ustring const prefs_path = "/dialogs/input/";
static void
sp_input_dialog_destroy (GtkObject */*object*/, gpointer /*data*/)
@@ -48,16 +48,17 @@ sp_input_dialog_destroy (GtkObject */*object*/, gpointer /*data*/)
static gboolean
sp_input_dialog_delete (GtkObject */*object*/, GdkEvent */*event*/, gpointer /*data*/)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
@@ -70,25 +71,21 @@ static const gchar *axis_use_strings[GDK_AXIS_LAST] = {
void
sp_input_load_from_preferences (void)
{
- Inkscape::XML::Node *devices = inkscape_get_repr(INKSCAPE, "devices");
- if (devices == NULL)
- return;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::XML::Node *repr;
- GList *list_ptr;
-
- for (list_ptr = gdk_devices_list(); list_ptr != NULL; list_ptr = list_ptr->next) {
+ for (GList *list_ptr = gdk_devices_list(); list_ptr != NULL; list_ptr = list_ptr->next) {
GdkDevice *device = static_cast<GdkDevice *>(list_ptr->data);
- repr = sp_repr_lookup_child(devices, "id", device->name);
- if (repr != NULL) {
+ //repr = sp_repr_lookup_child(devices, "id", device->name);
+ Glib::ustring device_path = Glib::ustring("/devices/") + device->name;
+ if (/*repr != NULL*/ 1) {
GdkInputMode mode;
- const gchar *attribute = repr->attribute("mode");
+ Glib::ustring device_mode = prefs->getString(device_path + "/mode");
- if (attribute == NULL)
+ if (device_mode.empty())
mode = GDK_MODE_DISABLED;
- else if (!strcmp(attribute, "screen"))
+ else if (device_mode == "screen")
mode = GDK_MODE_SCREEN;
- else if (!strcmp(attribute, "window"))
+ else if (device_mode == "window")
mode = GDK_MODE_WINDOW;
else
mode = GDK_MODE_DISABLED;
@@ -97,50 +94,40 @@ sp_input_load_from_preferences (void)
gdk_device_set_mode(device, mode);
}
- const gchar *temp_ptr;
- Glib::ustring::size_type pos0;
- Glib::ustring::size_type pos1;
- gint i;
- gint j;
-
+ Glib::ustring::size_type pos0, pos1;
GdkAxisUse axis_use;
- temp_ptr = repr->attribute("axes");
- if (temp_ptr != NULL) {
- const Glib::ustring temp_str = temp_ptr;
- pos0 = pos1 = 0;
- for (i=0; i < device->num_axes; i++) {
- pos1 = temp_str.find(";", pos0);
- if (pos1 == Glib::ustring::npos)
- break; // Too few axis specifications
-
- axis_use = GDK_AXIS_IGNORE;
- for (j=0; j < GDK_AXIS_LAST; j++)
- if (!strcmp(temp_str.substr(pos0, pos1-pos0).c_str(), axis_use_strings[j])) {
- axis_use = static_cast<GdkAxisUse>(j);
- break;
- }
- gdk_device_set_axis_use(device, i, axis_use);
- pos0 = pos1 + 1;
- }
+ //temp_ptr = repr->attribute("axes");
+ Glib::ustring const axes_str = prefs->getString(device_path + "/axes");
+ pos0 = pos1 = 0;
+ for (gint i=0; i < device->num_axes; i++) {
+ pos1 = axes_str.find(';', pos0);
+ if (pos1 == Glib::ustring::npos)
+ break; // Too few axis specifications
+
+ axis_use = GDK_AXIS_IGNORE;
+ for (gint j=0; j < GDK_AXIS_LAST; j++)
+ if (!strcmp(axes_str.substr(pos0, pos1-pos0).c_str(), axis_use_strings[j])) {
+ axis_use = static_cast<GdkAxisUse>(j);
+ break;
+ }
+ gdk_device_set_axis_use(device, i, axis_use);
+ pos0 = pos1 + 1;
}
guint keyval;
GdkModifierType modifier;
- temp_ptr = repr->attribute("keys");
- if (temp_ptr != NULL) {
- const Glib::ustring temp_str = temp_ptr;
- pos0 = pos1 = 0;
- for (i=0; i < device->num_keys; i++) {
- pos1 = temp_str.find(";", pos0);
- if (pos1 == Glib::ustring::npos)
- break; // Too few key specifications
-
- gtk_accelerator_parse(temp_str.substr(pos0, pos1-pos0).c_str(), &keyval, &modifier);
- gdk_device_set_key(device, i, keyval, modifier);
- pos0 = pos1 + 1;
- }
+ Glib::ustring const keys_str = prefs->getString(device_path + "/keys");
+ pos0 = pos1 = 0;
+ for (gint i=0; i < device->num_keys; i++) {
+ pos1 = keys_str.find(';', pos0);
+ if (pos1 == Glib::ustring::npos)
+ break; // Too few key specifications
+
+ gtk_accelerator_parse(keys_str.substr(pos0, pos1-pos0).c_str(), &keyval, &modifier);
+ gdk_device_set_key(device, i, keyval, modifier);
+ pos0 = pos1 + 1;
}
}
}
@@ -149,56 +136,43 @@ sp_input_load_from_preferences (void)
void
sp_input_save_to_preferences (void)
{
- Inkscape::XML::Node *devices = inkscape_get_repr(INKSCAPE, "devices");
- if (devices == NULL)
- // TODO: find a clean way to add a node to the preferences root, or
- // give an error message
- return;
-
- Inkscape::XML::Node *repr;
- GList *list_ptr;
-
- for (list_ptr = gdk_devices_list(); list_ptr != NULL; list_ptr = list_ptr->next) {
- gint i;
- Glib::ustring temp_attribute;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ for (GList *list_ptr = gdk_devices_list(); list_ptr != NULL; list_ptr = list_ptr->next) {
GdkDevice *device = static_cast<GdkDevice *>(list_ptr->data);
- repr = sp_repr_lookup_child(devices, "id", device->name);
- if (repr == NULL) {
- repr = devices->document()->createElement("group");
- repr->setAttribute("id", device->name);
- devices->appendChild(repr);
- Inkscape::GC::release(repr);
- }
+ //repr = sp_repr_lookup_child(devices, "id", device->name);
+ Glib::ustring device_path = Glib::ustring("/devices/") + device->name;
+
switch (device->mode) {
default:
case GDK_MODE_DISABLED: {
- repr->setAttribute("mode", "disabled");
+ prefs->setString(device_path + "/mode", "disabled");
break;
}
case GDK_MODE_SCREEN: {
- repr->setAttribute("mode", "screen");
+ prefs->setString(device_path + "/mode", "screen");
break;
}
case GDK_MODE_WINDOW: {
- repr->setAttribute("mode", "window");
+ prefs->setString(device_path + "/mode", "window");
break;
}
}
- temp_attribute = "";
- for (i=0; i < device->num_axes; i++) {
+ Glib::ustring temp_attribute = "";
+ for (gint i=0; i < device->num_axes; i++) {
temp_attribute += axis_use_strings[device->axes[i].use];
temp_attribute += ";";
}
- repr->setAttribute("axes", temp_attribute.c_str());
+ prefs->setString(device_path + "/axes", temp_attribute);
temp_attribute = "";
- for (i=0; i < device->num_keys; i++) {
+ for (gint i=0; i < device->num_keys; i++) {
temp_attribute += gtk_accelerator_name(device->keys[i].keyval, device->keys[i].modifiers);
temp_attribute += ";";
}
- repr->setAttribute("keys", temp_attribute.c_str());
+ prefs->setString(device_path + "/keys", temp_attribute);
}
}
@@ -208,14 +182,11 @@ sp_input_save_button (GtkObject */*object*/, gpointer /*data*/)
sp_input_save_to_preferences();
}
-/**
- * \brief Dialog
- *
- */
void
sp_input_dialog (void)
{
if (dlg == NULL) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gchar title[500];
sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_INPUT), title);
@@ -223,13 +194,13 @@ sp_input_dialog (void)
dlg = gtk_input_dialog_new();
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", -1000);
- y = prefs_get_int_attribute (prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp
index 9b816436b..808775786 100644
--- a/src/dialogs/item-properties.cpp
+++ b/src/dialogs/item-properties.cpp
@@ -40,7 +40,7 @@
#include "../interface.h"
#include "dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#define MIN_ONSCREEN_DISTANCE 50
@@ -49,7 +49,7 @@ static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar const *prefs_path = "dialogs.object";
+static Glib::ustring const prefs_path = "/dialogs/object/";
static void sp_item_widget_modify_selection (SPWidget *spw, Inkscape::Selection *selection, guint flags, GtkWidget *itemw);
static void sp_item_widget_change_selection (SPWidget *spw, Inkscape::Selection *selection, GtkWidget *itemw);
@@ -75,10 +75,11 @@ sp_item_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer /*da
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
@@ -479,16 +480,16 @@ sp_item_dialog (void)
gchar title[500];
sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_ITEM), title);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", -1000);
- y = prefs_get_int_attribute (prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
-
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp
index a8c55f9de..1b754c606 100644
--- a/src/dialogs/layers-panel.cpp
+++ b/src/dialogs/layers-panel.cpp
@@ -36,7 +36,7 @@
#include "widgets/icon.h"
#include "ui/widget/imagetoggler.h"
#include <gtkmm/widget.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "xml/repr.h"
#include "svg/css-ostringstream.h"
#include "desktop-style.h"
@@ -581,7 +581,7 @@ bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*mod
* Constructor
*/
LayersPanel::LayersPanel() :
- UI::Widget::Panel("", "dialogs.layers", SP_VERB_DIALOG_LAYERS),
+ UI::Widget::Panel("", "/dialogs/layers", SP_VERB_DIALOG_LAYERS),
_maxNestDepth(20),
_mgr(0),
_desktop(0),
@@ -590,7 +590,8 @@ LayersPanel::LayersPanel() :
_toggleEvent(0),
_compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND)
{
- _maxNestDepth = prefs_get_int_attribute_limited("dialogs.layers", "maxDepth", 20, 1, 1000);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _maxNestDepth = prefs->getIntLimited("/dialogs/layers/maxDepth", 20, 1, 1000);
ModelColumns *zoop = new ModelColumns();
_model = zoop;
diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp
index 00e308278..c7173ad1e 100644
--- a/src/dialogs/stroke-style.cpp
+++ b/src/dialogs/stroke-style.cpp
@@ -8,6 +8,7 @@
* Bryce Harrington <brycehar@bryceharrington.org>
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <maximilian.albert@gmail.com>
+ * Josh Andler <scislac@users.sf.net>
*
* Copyright (C) 2001-2005 authors
* Copyright (C) 2001 Ximian, Inc.
@@ -59,6 +60,7 @@
#include "helper/stock-items.h"
#include "io/sys.h"
#include "ui/cache/svg_preview_cache.h"
+#include "xml/repr.h"
#include "dialogs/stroke-style.h"
@@ -1080,7 +1082,7 @@ sp_stroke_style_line_widget_new(void)
gint i = 0;
/* Stroke width */
- spw_label(t, _("Width:"), 0, i);
+ spw_label(t, Q_("StrokeWidth|Width:"), 0, i);
hb = spw_hbox(t, 3, 1, i);
@@ -1209,7 +1211,7 @@ sp_stroke_style_line_widget_new(void)
/* Dash */
spw_label(t, _("Dashes:"), 0, i);
- ds = manage(new SPDashSelector(inkscape_get_repr(INKSCAPE, "palette.dashes")));
+ ds = manage(new SPDashSelector);
ds->show();
t->attach(*ds, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
@@ -1227,6 +1229,7 @@ sp_stroke_style_line_widget_new(void)
// (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
spw_label(t, _("Start Markers:"), 0, i);
marker_start_menu = ink_marker_menu(spw ,"marker-start", sandbox);
+ tt->set_tip(*marker_start_menu, _("Start Markers are drawn on the first node of a path or shape"));
marker_start_menu_connection = marker_start_menu->signal_changed().connect(
sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
sigc::ptr_fun(&sp_marker_select), marker_start_menu, spw, SP_MARKER_LOC_START));
@@ -1237,6 +1240,7 @@ sp_stroke_style_line_widget_new(void)
i++;
spw_label(t, _("Mid Markers:"), 0, i);
marker_mid_menu = ink_marker_menu(spw ,"marker-mid", sandbox);
+ tt->set_tip(*marker_mid_menu, _("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
marker_mid_menu_connection = marker_mid_menu->signal_changed().connect(
sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
sigc::ptr_fun(&sp_marker_select), marker_mid_menu,spw, SP_MARKER_LOC_MID));
@@ -1247,6 +1251,7 @@ sp_stroke_style_line_widget_new(void)
i++;
spw_label(t, _("End Markers:"), 0, i);
marker_end_menu = ink_marker_menu(spw ,"marker-end", sandbox);
+ tt->set_tip(*marker_end_menu, _("End Markers are drawn on the last node of a path or shape"));
marker_end_menu_connection = marker_end_menu->signal_changed().connect(
sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
sigc::ptr_fun(&sp_marker_select), marker_end_menu, spw, SP_MARKER_LOC_END));
diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp
index 5d76cc8f6..71c16d87a 100644
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
@@ -1047,9 +1047,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
if ( !possible.empty() ) {
JustForNow* first = 0;
Glib::ustring targetName;
- if ( _prefs_path ) {
+ if ( !_prefs_path.empty() ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- targetName = prefs->getString(_prefs_path, "palette");
+ targetName = prefs->getString(_prefs_path + "/palette");
if (!targetName.empty()) {
for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
if ( (*iter)->_name == targetName ) {
@@ -1123,9 +1123,9 @@ void SwatchesPanel::_handleAction( int setId, int itemId )
_holder->clear();
JustForNow* curr = possible[itemId];
- if ( _prefs_path ) {
+ if ( !_prefs_path.empty() ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, "palette", curr->_name);
+ prefs->setString(_prefs_path + "/palette", curr->_name);
}
if ( curr->_prefWidth > 0 ) {
diff --git a/src/dialogs/swatches.h b/src/dialogs/swatches.h
index 310272b1c..630fada7c 100644
--- a/src/dialogs/swatches.h
+++ b/src/dialogs/swatches.h
@@ -90,7 +90,7 @@ private:
class SwatchesPanel : public Inkscape::UI::Widget::Panel
{
public:
- SwatchesPanel(gchar const* prefsPath = "dialogs.swatches");
+ SwatchesPanel(gchar const* prefsPath = "/dialogs/swatches");
virtual ~SwatchesPanel();
static SwatchesPanel& getInstance();
diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp
index 8f4d1b8bd..1f8395c95 100644
--- a/src/dialogs/text-edit.cpp
+++ b/src/dialogs/text-edit.cpp
@@ -45,7 +45,7 @@ extern "C" {
#include <libnrtype/font-style-to-pos.h>
#include "dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "../verbs.h"
#include "../interface.h"
#include "svg/css-ostringstream.h"
@@ -80,7 +80,7 @@ static GtkWidget *dlg = NULL;
static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar const *prefs_path = "dialogs.textandfont";
+static Glib::ustring const prefs_path = "/dialogs/textandfont/";
@@ -104,10 +104,11 @@ sp_text_edit_dialog_delete( GtkObject */*object*/, GdkEvent */*event*/, gpointer
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
}
@@ -142,16 +143,16 @@ sp_text_edit_dialog (void)
gchar title[500];
sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_TEXT), title);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
dlg = sp_window_new (title, TRUE);
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", -1000);
- y = prefs_get_int_attribute (prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
-
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
@@ -608,9 +609,10 @@ sp_text_edit_dialog_set_default( GtkButton */*button*/, GtkWidget *dlg )
GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default");
SPCSSAttr *css = sp_get_text_dialog_style ();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE));
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ prefs->mergeStyle("/tools/text/style", css);
g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE));
sp_repr_css_attr_unref (css);
@@ -650,7 +652,8 @@ sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg )
if (items == 0) {
// no text objects; apply style to prefs for new objects
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
gtk_widget_set_sensitive (def, FALSE);
} else if (items == 1) {
/* exactly one text object; now set its text, too */
@@ -749,13 +752,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg,
// (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) {
- repr = inkscape_get_repr (INKSCAPE, "tools.text");
- if (repr) {
- gtk_widget_set_sensitive (notebook, TRUE);
- sp_style_read_from_repr (query, repr);
- } else {
- gtk_widget_set_sensitive (notebook, FALSE);
- }
+ sp_style_read_from_prefs(query, "/tools/text");
}
// FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists
diff --git a/src/dialogs/tiledialog.cpp b/src/dialogs/tiledialog.cpp
index 1643057e8..f597c601b 100644
--- a/src/dialogs/tiledialog.cpp
+++ b/src/dialogs/tiledialog.cpp
@@ -24,7 +24,7 @@
#include <gtkmm/stock.h>
#include "verbs.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape.h"
#include "desktop-handles.h"
#include "selection.h"
@@ -383,7 +383,8 @@ void TileDialog::on_row_spinbutton_changed()
double PerCol = ceil(selcount / NoOfColsSpinner.get_value());
NoOfRowsSpinner.set_value(PerCol);
- prefs_set_double_attribute ("dialogs.gridtiler", "NoOfCols", NoOfColsSpinner.get_value());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/NoOfCols", NoOfColsSpinner.get_value());
updating=false;
}
@@ -407,7 +408,8 @@ void TileDialog::on_col_spinbutton_changed()
double PerRow = ceil(selcount / NoOfRowsSpinner.get_value());
NoOfColsSpinner.set_value(PerRow);
- prefs_set_double_attribute ("dialogs.gridtiler", "NoOfCols", PerRow);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/NoOfCols", PerRow);
updating=false;
}
@@ -417,8 +419,8 @@ void TileDialog::on_col_spinbutton_changed()
*/
void TileDialog::on_xpad_spinbutton_changed()
{
-
- prefs_set_double_attribute ("dialogs.gridtiler", "XPad", XPadSpinner.get_value());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/XPad", XPadSpinner.get_value());
}
@@ -427,9 +429,8 @@ void TileDialog::on_xpad_spinbutton_changed()
*/
void TileDialog::on_ypad_spinbutton_changed()
{
-
- prefs_set_double_attribute ("dialogs.gridtiler", "YPad", YPadSpinner.get_value());
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/YPad", YPadSpinner.get_value());
}
@@ -438,13 +439,13 @@ void TileDialog::on_ypad_spinbutton_changed()
*/
void TileDialog::on_RowSize_checkbutton_changed()
{
-
- if (RowHeightButton.get_active()) {
- prefs_set_double_attribute ("dialogs.gridtiler", "AutoRowSize", 20);
- } else {
- prefs_set_double_attribute ("dialogs.gridtiler", "AutoRowSize", -20);
- }
- RowHeightBox.set_sensitive ( !RowHeightButton.get_active());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (RowHeightButton.get_active()) {
+ prefs->setDouble("/dialogs/gridtiler/AutoRowSize", 20);
+ } else {
+ prefs->setDouble("/dialogs/gridtiler/AutoRowSize", -20);
+ }
+ RowHeightBox.set_sensitive ( !RowHeightButton.get_active());
}
/**
@@ -452,14 +453,13 @@ void TileDialog::on_RowSize_checkbutton_changed()
*/
void TileDialog::on_ColSize_checkbutton_changed()
{
-
- if (ColumnWidthButton.get_active()) {
- prefs_set_double_attribute ("dialogs.gridtiler", "AutoColSize", 20);
- } else {
- prefs_set_double_attribute ("dialogs.gridtiler", "AutoColSize", -20);
- }
- ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active());
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (ColumnWidthButton.get_active()) {
+ prefs->setDouble("/dialogs/gridtiler/AutoColSize", 20);
+ } else {
+ prefs->setDouble("/dialogs/gridtiler/AutoColSize", -20);
+ }
+ ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active());
}
/**
@@ -474,7 +474,8 @@ void TileDialog::on_rowSize_spinbutton_changed()
// in turn, prevent listener from responding
updating = true;
- prefs_set_double_attribute ("dialogs.gridtiler", "RowHeight", RowHeightSpinner.get_value());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/RowHeight", RowHeightSpinner.get_value());
updating=false;
}
@@ -491,7 +492,8 @@ void TileDialog::on_colSize_spinbutton_changed()
// in turn, prevent listener from responding
updating = true;
- prefs_set_double_attribute ("dialogs.gridtiler", "ColWidth", ColumnWidthSpinner.get_value());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/dialogs/gridtiler/ColWidth", ColumnWidthSpinner.get_value());
updating=false;
}
@@ -501,13 +503,14 @@ void TileDialog::on_colSize_spinbutton_changed()
*/
void TileDialog::Spacing_button_changed()
{
- if (SpaceManualRadioButton.get_active()) {
- prefs_set_double_attribute ("dialogs.gridtiler", "SpacingType", 20);
- } else {
- prefs_set_double_attribute ("dialogs.gridtiler", "SpacingType", -20);
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (SpaceManualRadioButton.get_active()) {
+ prefs->setDouble("/dialogs/gridtiler/SpacingType", 20);
+ } else {
+ prefs->setDouble("/dialogs/gridtiler/SpacingType", -20);
+ }
- SizesHBox.set_sensitive ( SpaceManualRadioButton.get_active());
+ SizesHBox.set_sensitive ( SpaceManualRadioButton.get_active());
}
/**
@@ -515,17 +518,17 @@ void TileDialog::Spacing_button_changed()
*/
void TileDialog::VertAlign_changed()
{
- if (VertTopRadioButton.get_active()) {
- VertAlign = 0;
- prefs_set_double_attribute ("dialogs.gridtiler", "VertAlign", 0);
- } else if (VertCentreRadioButton.get_active()){
- VertAlign = 1;
- prefs_set_double_attribute ("dialogs.gridtiler", "VertAlign", 1);
- } else if (VertBotRadioButton.get_active()){
- VertAlign = 2;
- prefs_set_double_attribute ("dialogs.gridtiler", "VertAlign", 2);
- }
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (VertTopRadioButton.get_active()) {
+ VertAlign = 0;
+ prefs->setInt("/dialogs/gridtiler/VertAlign", 0);
+ } else if (VertCentreRadioButton.get_active()){
+ VertAlign = 1;
+ prefs->setInt("/dialogs/gridtiler/VertAlign", 1);
+ } else if (VertBotRadioButton.get_active()){
+ VertAlign = 2;
+ prefs->setInt("/dialogs/gridtiler/VertAlign", 2);
+ }
}
/**
@@ -533,17 +536,17 @@ void TileDialog::VertAlign_changed()
*/
void TileDialog::HorizAlign_changed()
{
- if (HorizLeftRadioButton.get_active()) {
- HorizAlign = 0;
- prefs_set_double_attribute ("dialogs.gridtiler", "HorizAlign", 0);
- } else if (HorizCentreRadioButton.get_active()){
- HorizAlign = 1;
- prefs_set_double_attribute ("dialogs.gridtiler", "HorizAlign", 1);
- } else if (HorizRightRadioButton.get_active()){
- HorizAlign = 2;
- prefs_set_double_attribute ("dialogs.gridtiler", "HorizAlign", 2);
- }
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (HorizLeftRadioButton.get_active()) {
+ HorizAlign = 0;
+ prefs->setInt("/dialogs/gridtiler/HorizAlign", 0);
+ } else if (HorizCentreRadioButton.get_active()){
+ HorizAlign = 1;
+ prefs->setInt("/dialogs/gridtiler/HorizAlign", 1);
+ } else if (HorizRightRadioButton.get_active()){
+ HorizAlign = 2;
+ prefs->setInt("/dialogs/gridtiler/HorizAlign", 2);
+ }
}
/**
@@ -551,14 +554,14 @@ void TileDialog::HorizAlign_changed()
*/
void TileDialog::updateSelection()
{
- double col_width, row_height;
// quit if run by the attr_changed listener
if (updating) {
- return;
- }
+ return;
+ }
- col_width=0;
- row_height=0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double col_width = 0;
+ double row_height = 0;
// in turn, prevent listener from responding
updating = true;
SPDesktop *desktop = getDesktop();
@@ -575,14 +578,14 @@ void TileDialog::updateSelection()
if (selcount<NoOfColsSpinner.get_value()) {
double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value());
NoOfColsSpinner.set_value(NoOfCols);
- prefs_set_double_attribute ("dialogs.gridtiler", "NoOfCols", NoOfCols);
+ prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols);
}
} else {
double PerRow = ceil(sqrt(selcount));
double PerCol = ceil(sqrt(selcount));
NoOfRowsSpinner.set_value(PerRow);
NoOfColsSpinner.set_value(PerCol);
- prefs_set_double_attribute ("dialogs.gridtiler", "NoOfCols", PerCol);
+ prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast<int>(PerCol));
}
@@ -610,10 +613,11 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap
* Constructor
*/
TileDialog::TileDialog()
- : UI::Widget::Panel("", "dialogs.gridtiler", SP_VERB_SELECTION_GRIDTILE)
+ : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE)
{
// bool used by spin button callbacks to stop loops where they change each other.
updating = false;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!)
GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -663,7 +667,7 @@ TileDialog::TileDialog()
gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj());
RowHeightButton.set_label(_("Equal height"));
- double AutoRow = prefs_get_double_attribute ("dialogs.gridtiler", "AutoRowSize", 15);
+ double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15);
if (AutoRow>0)
AutoRowSize=true;
else
@@ -693,7 +697,7 @@ TileDialog::TileDialog()
VertBotRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed));
VertAlignVBox.pack_start(VertBotRadioButton, false, false, 0);
- VertAlign = prefs_get_double_attribute ("dialogs.gridtiler", "VertAlign", 1);
+ VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1);
if (VertAlign == 0) {
VertTopRadioButton.set_active(TRUE);
}
@@ -733,7 +737,7 @@ TileDialog::TileDialog()
gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj());
ColumnWidthButton.set_label(_("Equal width"));
- double AutoCol = prefs_get_double_attribute ("dialogs.gridtiler", "AutoColSize", 15);
+ double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15);
if (AutoCol>0)
AutoColSize=true;
else
@@ -767,7 +771,7 @@ TileDialog::TileDialog()
HorizAlignHBox.pack_start(*(new Gtk::HBox()), true, true, 0); // centering strut
- HorizAlign = prefs_get_double_attribute ("dialogs.gridtiler", "HorizAlign", 1);
+ HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1);
if (HorizAlign == 0) {
HorizLeftRadioButton.set_active(TRUE);
}
@@ -810,7 +814,7 @@ TileDialog::TileDialog()
YPadSpinner.set_digits(1);
YPadSpinner.set_increments(0.2, 2);
YPadSpinner.set_range(-10000, 10000);
- double YPad = prefs_get_double_attribute ("dialogs.gridtiler", "YPad", 15);
+ double YPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15);
YPadSpinner.set_value(YPad);
YPadBox.pack_start(YPadSpinner, true, true, MARGIN);
tips.set_tip(YPadSpinner, _("Vertical spacing between rows (px units)"));
@@ -835,7 +839,7 @@ TileDialog::TileDialog()
XPadSpinner.set_digits(1);
XPadSpinner.set_increments(0.2, 2);
XPadSpinner.set_range(-10000, 10000);
- double XPad = prefs_get_double_attribute ("dialogs.gridtiler", "XPad", 15);
+ double XPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15);
XPadSpinner.set_value(XPad);
XPadBox.pack_start(XPadSpinner, true, true, MARGIN);
tips.set_tip(XPadSpinner, _("Horizontal spacing between columns (px units)"));
@@ -850,7 +854,7 @@ TileDialog::TileDialog()
contents->pack_start(TileBox);
- double SpacingType = prefs_get_double_attribute ("dialogs.gridtiler", "SpacingType", 15);
+ double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15);
if (SpacingType>0) {
ManualSpacing=true;
} else {
@@ -867,20 +871,10 @@ TileDialog::TileDialog()
show_all_children();
}
-
-
-
-
-
} //namespace Dialog
} //namespace UI
} //namespace Inkscape
-//#########################################################################
-//## E N D O F F I L E
-//#########################################################################
-
-
/*
Local Variables:
mode:c++
@@ -890,7 +884,4 @@ TileDialog::TileDialog()
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
-
-
-
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 ::
diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp
index 89892aab4..06103e9b3 100644
--- a/src/dialogs/xml-tree.cpp
+++ b/src/dialogs/xml-tree.cpp
@@ -54,7 +54,7 @@
#include "widgets/icon.h"
#include "dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "../verbs.h"
#include "../interface.h"
@@ -78,7 +78,7 @@ static sigc::connection document_replaced_connection;
static win_data wd;
// impossible original values to make sure they are read from prefs
static gint x = -1000, y = -1000, w = 0, h = 0;
-static gchar const *const prefs_path = "dialogs.xml";
+static Glib::ustring const prefs_path = "/dialogs/xml/";
static GtkWidget *status = NULL;
static Inkscape::MessageStack *_message_stack = NULL;
static Inkscape::MessageContext *_message_context = NULL;
@@ -212,13 +212,14 @@ void sp_xml_tree_dialog()
gtk_tooltips_enable(tooltips);
dlg = sp_window_new("", TRUE);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute(prefs_path, "x", -1000);
- y = prefs_get_int_attribute(prefs_path, "y", -1000);
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
}
if (w ==0 || h == 0) {
- w = prefs_get_int_attribute(prefs_path, "w", 0);
- h = prefs_get_int_attribute(prefs_path, "h", 0);
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
}
// if (x<0) x=0;
@@ -924,10 +925,11 @@ static gboolean on_delete(GtkObject */*object*/, GdkEvent */*event*/, gpointer /
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute(prefs_path, "x", x);
- prefs_set_int_attribute(prefs_path, "y", y);
- prefs_set_int_attribute(prefs_path, "w", w);
- prefs_set_int_attribute(prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
return FALSE; // which means, go ahead and destroy it
}
diff --git a/src/display/bezier-utils-test.cpp b/src/display/bezier-utils-test.cpp
index edeb9e3b7..4d6313886 100644
--- a/src/display/bezier-utils-test.cpp
+++ b/src/display/bezier-utils-test.cpp
@@ -7,7 +7,7 @@
#define's and `using' directives of the included file. */
#include "bezier-utils.cpp"
-using NR::Point;
+using Geom::Point;
static bool range_approx_equal(double const a[], double const b[], unsigned len);
@@ -22,9 +22,9 @@ static bool range_equal(T const a[], T const b[], unsigned len) {
return true;
}
-inline bool point_approx_equal(NR::Point const &a, NR::Point const &b, double const eps)
+inline bool point_approx_equal(Geom::Point const &a, Geom::Point const &b, double const eps)
{
- using NR::X; using NR::Y;
+ using Geom::X; using Geom::Y;
return ( NR_DF_TEST_CLOSE(a[X], b[X], eps) &&
NR_DF_TEST_CLOSE(a[Y], b[Y], eps) );
}
@@ -86,7 +86,7 @@ int main(int /*argc*/, char */*argv*/[]) {
utest_start("bezier-utils.cpp");
UTEST_TEST("copy_without_nans_or_adjacent_duplicates") {
- NR::Point const src[] = {
+ Geom::Point const src[] = {
Point(2., 3.),
Point(2., 3.),
Point(0., 0.),
diff --git a/src/display/bezier-utils-test.h b/src/display/bezier-utils-test.h
index eb2b13d7b..cc24adaad 100644
--- a/src/display/bezier-utils-test.h
+++ b/src/display/bezier-utils-test.h
@@ -19,9 +19,9 @@ static bool range_approx_equal(double const a[], double const b[], unsigned cons
return true;
}
-static inline bool point_approx_equal(NR::Point const &a, NR::Point const &b, double const eps)
+static inline bool point_approx_equal(Geom::Point const &a, Geom::Point const &b, double const eps)
{
- using NR::X; using NR::Y;
+ using Geom::X; using Geom::Y;
return ( NR_DF_TEST_CLOSE(a[X], b[X], eps) &&
NR_DF_TEST_CLOSE(a[Y], b[Y], eps) );
}
@@ -35,7 +35,7 @@ static inline double square(double const x) {
the most important test is that the root-mean-square of errors in the estimation are low rather
than that the control points found are the same.
**/
-static void compare_ctlpts(NR::Point const est_b[], NR::Point const exp_est_b[])
+static void compare_ctlpts(Geom::Point const est_b[], Geom::Point const exp_est_b[])
{
unsigned diff_mask = 0;
for (unsigned i = 0; i < 4; ++i) {
@@ -62,13 +62,13 @@ static void compare_ctlpts(NR::Point const est_b[], NR::Point const exp_est_b[])
}
}
-static void compare_rms(NR::Point const est_b[], double const t[], NR::Point const d[], unsigned const n,
+static void compare_rms(Geom::Point const est_b[], double const t[], Geom::Point const d[], unsigned const n,
double const exp_rms_error)
{
double sum_errsq = 0.0;
for (unsigned i = 0; i < n; ++i) {
- NR::Point const fit_pt = bezier_pt(3, est_b, t[i]);
- NR::Point const diff = fit_pt - d[i];
+ Geom::Point const fit_pt = bezier_pt(3, est_b, t[i]);
+ Geom::Point const diff = fit_pt - d[i];
sum_errsq += dot(diff, diff);
}
double const rms_error = sqrt( sum_errsq / n );
@@ -84,13 +84,13 @@ static void compare_rms(NR::Point const est_b[], double const t[], NR::Point con
class BezierUtilsTest : public CxxTest::TestSuite {
public:
- static NR::Point const c[4];
+ static Geom::Point const c[4];
static double const t[24];
static unsigned const n;
- NR::Point d[24];
- static NR::Point const src_b[4];
- static NR::Point const tHat1;
- static NR::Point const tHat2;
+ Geom::Point d[24];
+ static Geom::Point const src_b[4];
+ static Geom::Point const tHat1;
+ static Geom::Point const tHat2;
BezierUtilsTest()
{
@@ -109,23 +109,23 @@ public:
void testCopyWithoutNansOrAdjacentDuplicates()
{
- NR::Point const src[] = {
- NR::Point(2., 3.),
- NR::Point(2., 3.),
- NR::Point(0., 0.),
- NR::Point(2., 3.),
- NR::Point(2., 3.),
- NR::Point(1., 9.),
- NR::Point(1., 9.)
+ Geom::Point const src[] = {
+ Geom::Point(2., 3.),
+ Geom::Point(2., 3.),
+ Geom::Point(0., 0.),
+ Geom::Point(2., 3.),
+ Geom::Point(2., 3.),
+ Geom::Point(1., 9.),
+ Geom::Point(1., 9.)
};
- NR::Point const exp_dest[] = {
- NR::Point(2., 3.),
- NR::Point(0., 0.),
- NR::Point(2., 3.),
- NR::Point(1., 9.)
+ Geom::Point const exp_dest[] = {
+ Geom::Point(2., 3.),
+ Geom::Point(0., 0.),
+ Geom::Point(2., 3.),
+ Geom::Point(1., 9.)
};
g_assert( G_N_ELEMENTS(src) == 7 );
- NR::Point dest[7];
+ Geom::Point dest[7];
struct tst {
unsigned src_ix0;
unsigned src_len;
@@ -157,11 +157,11 @@ public:
void testBezierPt1()
{
- NR::Point const a[] = {NR::Point(2.0, 4.0),
- NR::Point(1.0, 8.0)};
+ Geom::Point const a[] = {Geom::Point(2.0, 4.0),
+ Geom::Point(1.0, 8.0)};
TS_ASSERT_EQUALS( bezier_pt(1, a, 0.0) , a[0] );
TS_ASSERT_EQUALS( bezier_pt(1, a, 1.0) , a[1] );
- TS_ASSERT_EQUALS( bezier_pt(1, a, 0.5) , NR::Point(1.5, 6.0) );
+ TS_ASSERT_EQUALS( bezier_pt(1, a, 0.5) , Geom::Point(1.5, 6.0) );
double const t[] = {0.5, 0.25, 0.3, 0.6};
for (unsigned i = 0; i < G_N_ELEMENTS(t); ++i) {
double const ti = t[i], si = 1.0 - ti;
@@ -171,17 +171,17 @@ public:
void testBezierPt2()
{
- NR::Point const b[] = {NR::Point(1.0, 2.0),
- NR::Point(8.0, 4.0),
- NR::Point(3.0, 1.0)};
+ Geom::Point const b[] = {Geom::Point(1.0, 2.0),
+ Geom::Point(8.0, 4.0),
+ Geom::Point(3.0, 1.0)};
TS_ASSERT_EQUALS( bezier_pt(2, b, 0.0) , b[0] );
TS_ASSERT_EQUALS( bezier_pt(2, b, 1.0) , b[2] );
- TS_ASSERT_EQUALS( bezier_pt(2, b, 0.5) , NR::Point(5.0, 2.75) );
+ TS_ASSERT_EQUALS( bezier_pt(2, b, 0.5) , Geom::Point(5.0, 2.75) );
double const t[] = {0.5, 0.25, 0.3, 0.6};
for (unsigned i = 0; i < G_N_ELEMENTS(t); ++i) {
double const ti = t[i], si = 1.0 - ti;
- NR::Point const exp_pt( si*si * b[0] + 2*si*ti * b[1] + ti*ti * b[2] );
- NR::Point const pt(bezier_pt(2, b, ti));
+ Geom::Point const exp_pt( si*si * b[0] + 2*si*ti * b[1] + ti*ti * b[2] );
+ Geom::Point const pt(bezier_pt(2, b, ti));
TS_ASSERT(point_approx_equal(pt, exp_pt, 1e-11));
}
}
@@ -190,7 +190,7 @@ public:
{
TS_ASSERT_EQUALS( bezier_pt(3, c, 0.0) , c[0] );
TS_ASSERT_EQUALS( bezier_pt(3, c, 1.0) , c[3] );
- TS_ASSERT_EQUALS( bezier_pt(3, c, 0.5) , NR::Point(4.0, 13.0/8.0) );
+ TS_ASSERT_EQUALS( bezier_pt(3, c, 0.5) , Geom::Point(4.0, 13.0/8.0) );
double const t[] = {0.5, 0.25, 0.3, 0.6};
for (unsigned i = 0; i < G_N_ELEMENTS(t); ++i) {
double const ti = t[i], si = 1.0 - ti;
@@ -206,18 +206,18 @@ public:
void testComputeMaxErrorRatio()
{
struct Err_tst {
- NR::Point pt;
+ Geom::Point pt;
double u;
double err;
} const err_tst[] = {
{c[0], 0.0, 0.0},
- {NR::Point(4.0, 13.0/8.0), 0.5, 0.0},
- {NR::Point(4.0, 2.0), 0.5, 9.0/64.0},
- {NR::Point(3.0, 2.0), 0.5, 1.0 + 9.0/64.0},
- {NR::Point(6.0, 2.0), 0.5, 4.0 + 9.0/64.0},
+ {Geom::Point(4.0, 13.0/8.0), 0.5, 0.0},
+ {Geom::Point(4.0, 2.0), 0.5, 9.0/64.0},
+ {Geom::Point(3.0, 2.0), 0.5, 1.0 + 9.0/64.0},
+ {Geom::Point(6.0, 2.0), 0.5, 4.0 + 9.0/64.0},
{c[3], 1.0, 0.0},
};
- NR::Point d[G_N_ELEMENTS(err_tst)];
+ Geom::Point d[G_N_ELEMENTS(err_tst)];
double u[G_N_ELEMENTS(err_tst)];
for (unsigned i = 0; i < G_N_ELEMENTS(err_tst); ++i) {
Err_tst const &t = err_tst[i];
@@ -235,8 +235,8 @@ public:
{
/* n == 2 */
{
- NR::Point const d[] = {NR::Point(2.9415, -5.8149),
- NR::Point(23.021, 4.9814)};
+ Geom::Point const d[] = {Geom::Point(2.9415, -5.8149),
+ Geom::Point(23.021, 4.9814)};
double u[G_N_ELEMENTS(d)];
double const exp_u[] = {0.0, 1.0};
g_assert( G_N_ELEMENTS(u) == G_N_ELEMENTS(exp_u) );
@@ -248,9 +248,9 @@ public:
{
double const exp_u[] = {0.0, 0.1829, 0.2105, 0.2105, 0.619, 0.815, 0.999, 1.0};
unsigned const n = G_N_ELEMENTS(exp_u);
- NR::Point d[n];
+ Geom::Point d[n];
double u[n];
- NR::Point const a(-23.985, 4.915), b(4.9127, 5.203);
+ Geom::Point const a(-23.985, 4.915), b(4.9127, 5.203);
for (unsigned i = 0; i < n; ++i) {
double bi = exp_u[i], ai = 1.0 - bi;
d[i] = ai * a + bi * b;
@@ -262,7 +262,7 @@ public:
void testGenerateBezier()
{
- NR::Point est_b[4];
+ Geom::Point est_b[4];
generate_bezier(est_b, d, t, n, tHat1, tHat2, 1.0);
compare_ctlpts(est_b, src_b);
@@ -274,16 +274,16 @@ public:
void testSpBezierFitCubicFull()
{
- NR::Point est_b[4];
+ Geom::Point est_b[4];
int splitpoints[2];
gint const succ = sp_bezier_fit_cubic_full(est_b, splitpoints, d, n, tHat1, tHat2, square(1.2), 1);
TS_ASSERT_EQUALS( succ , 1 );
- NR::Point const exp_est_b[4] = {
- NR::Point(5.000000, -3.000000),
- NR::Point(7.5753, -0.4247),
- NR::Point(4.77533, 1.22467),
- NR::Point(3, 3)
+ Geom::Point const exp_est_b[4] = {
+ Geom::Point(5.000000, -3.000000),
+ Geom::Point(7.5753, -0.4247),
+ Geom::Point(4.77533, 1.22467),
+ Geom::Point(3, 3)
};
compare_ctlpts(est_b, exp_est_b);
@@ -294,15 +294,15 @@ public:
void testSpBezierFitCubic()
{
- NR::Point est_b[4];
+ Geom::Point est_b[4];
gint const succ = sp_bezier_fit_cubic(est_b, d, n, square(1.2));
TS_ASSERT_EQUALS( succ , 1 );
- NR::Point const exp_est_b[4] = {
- NR::Point(5.000000, -3.000000),
- NR::Point(7.57134, -0.423509),
- NR::Point(4.77929, 1.22426),
- NR::Point(3, 3)
+ Geom::Point const exp_est_b[4] = {
+ Geom::Point(5.000000, -3.000000),
+ Geom::Point(7.57134, -0.423509),
+ Geom::Point(4.77929, 1.22426),
+ Geom::Point(3, 3)
};
compare_ctlpts(est_b, exp_est_b);
@@ -321,22 +321,22 @@ public:
};
// This is not very neat, but since we know this header is only included by the generated CxxTest file it shouldn't give any problems
-NR::Point const BezierUtilsTest::c[4] = {
- NR::Point(1.0, 2.0),
- NR::Point(8.0, 4.0),
- NR::Point(3.0, 1.0),
- NR::Point(-2.0, -4.0)};
+Geom::Point const BezierUtilsTest::c[4] = {
+ Geom::Point(1.0, 2.0),
+ Geom::Point(8.0, 4.0),
+ Geom::Point(3.0, 1.0),
+ Geom::Point(-2.0, -4.0)};
double const BezierUtilsTest::t[24] = {
0.0, .001, .03, .05, .09, .13, .18, .25, .29, .33, .39, .44,
.51, .57, .62, .69, .75, .81, .91, .93, .97, .98, .999, 1.0};
unsigned const BezierUtilsTest::n = G_N_ELEMENTS(BezierUtilsTest::t);
-NR::Point const BezierUtilsTest::src_b[4] = {
- NR::Point(5., -3.),
- NR::Point(8., 0.),
- NR::Point(4., 2.),
- NR::Point(3., 3.)};
-NR::Point const BezierUtilsTest::tHat1(unit_vector( BezierUtilsTest::src_b[1] - BezierUtilsTest::src_b[0] ));
-NR::Point const BezierUtilsTest::tHat2(unit_vector( BezierUtilsTest::src_b[2] - BezierUtilsTest::src_b[3] ));
+Geom::Point const BezierUtilsTest::src_b[4] = {
+ Geom::Point(5., -3.),
+ Geom::Point(8., 0.),
+ Geom::Point(4., 2.),
+ Geom::Point(3., 3.)};
+Geom::Point const BezierUtilsTest::tHat1(unit_vector( BezierUtilsTest::src_b[1] - BezierUtilsTest::src_b[0] ));
+Geom::Point const BezierUtilsTest::tHat2(unit_vector( BezierUtilsTest::src_b[2] - BezierUtilsTest::src_b[3] ));
/*
Local Variables:
diff --git a/src/display/bezier-utils.cpp b/src/display/bezier-utils.cpp
index 5d09e66a7..b538f7fba 100644
--- a/src/display/bezier-utils.cpp
+++ b/src/display/bezier-utils.cpp
@@ -80,10 +80,10 @@ static Geom::Point const unconstrained_tangent(0, 0);
#ifdef BEZIER_DEBUG
# define DOUBLE_ASSERT(x) g_assert( ( (x) > -SP_HUGE ) && ( (x) < SP_HUGE ) )
# define BEZIER_ASSERT(b) do { \
- DOUBLE_ASSERT((b)[0][NR::X]); DOUBLE_ASSERT((b)[0][NR::Y]); \
- DOUBLE_ASSERT((b)[1][NR::X]); DOUBLE_ASSERT((b)[1][NR::Y]); \
- DOUBLE_ASSERT((b)[2][NR::X]); DOUBLE_ASSERT((b)[2][NR::Y]); \
- DOUBLE_ASSERT((b)[3][NR::X]); DOUBLE_ASSERT((b)[3][NR::Y]); \
+ DOUBLE_ASSERT((b)[0][Geom::X]); DOUBLE_ASSERT((b)[0][Geom::Y]); \
+ DOUBLE_ASSERT((b)[1][Geom::X]); DOUBLE_ASSERT((b)[1][Geom::Y]); \
+ DOUBLE_ASSERT((b)[2][Geom::X]); DOUBLE_ASSERT((b)[2][Geom::Y]); \
+ DOUBLE_ASSERT((b)[3][Geom::X]); DOUBLE_ASSERT((b)[3][Geom::Y]); \
} while(0)
#else
# define DOUBLE_ASSERT(x) do { } while(0)
@@ -148,8 +148,8 @@ copy_without_nans_or_adjacent_duplicates(Geom::Point const src[], unsigned src_l
if ( si == src_len ) {
return 0;
}
- if (!IS_NAN(src[si][NR::X]) &&
- !IS_NAN(src[si][NR::Y])) {
+ if (!IS_NAN(src[si][Geom::X]) &&
+ !IS_NAN(src[si][Geom::Y])) {
dest[0] = Geom::Point(src[si]);
++si;
break;
@@ -160,8 +160,8 @@ copy_without_nans_or_adjacent_duplicates(Geom::Point const src[], unsigned src_l
for (; si < src_len; ++si) {
Geom::Point const src_pt = Geom::Point(src[si]);
if ( src_pt != dest[di]
- && !IS_NAN(src_pt[NR::X])
- && !IS_NAN(src_pt[NR::Y])) {
+ && !IS_NAN(src_pt[Geom::X])
+ && !IS_NAN(src_pt[Geom::Y])) {
dest[++di] = src_pt;
}
}
@@ -806,7 +806,7 @@ sp_darray_center_tangent(Geom::Point const d[],
if ( d[center + 1] == d[center - 1] ) {
/* Rotate 90 degrees in an arbitrary direction. */
Geom::Point const diff = d[center] - d[center - 1];
- ret = NR::rot90(diff);
+ ret = Geom::rot90(diff);
} else {
ret = d[center - 1] - d[center + 1];
}
@@ -959,11 +959,11 @@ compute_hook(Geom::Point const &a, Geom::Point const &b, double const u, BezierC
{
Geom::Point const P = bezier_pt(3, bezCurve, u);
Geom::Point const diff = .5 * (a + b) - P;
- double const dist = NR::L2(diff);
+ double const dist = Geom::L2(diff);
if (dist < tolerance) {
return 0;
}
- double const allowed = NR::L2(b - a) + tolerance;
+ double const allowed = Geom::L2(b - a) + tolerance;
return dist / allowed;
/** \todo
* effic: Hooks are very rare. We could start by comparing
diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h
index 5e6188eee..34bc19946 100644
--- a/src/display/canvas-arena.h
+++ b/src/display/canvas-arena.h
@@ -32,7 +32,7 @@ struct _SPCanvasArena {
guint cursor : 1;
guint sticky : 1;
- NR::Point c; // what is this?
+ Geom::Point c; // what is this?
NRArena *arena;
NRArenaItem *root;
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 0f5045c4d..e181035eb 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -194,17 +194,17 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
: CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.axonom", "units").data() );
+ gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/axonom/units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
- origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
- color = prefs->getInt("options.grids.axonom", "color", 0x0000ff20);
- empcolor = prefs->getInt("options.grids.axonom", "empcolor", 0x0000ff40);
- empspacing = prefs->getInt("options.grids.axonom", "empspacing", 5);
- lengthy = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "spacing_y", 1.0), *gridunit );
- angle_deg[X] = prefs->getDouble("options.grids.axonom", "angle_x", 30.0);
- angle_deg[Z] = prefs->getDouble("options.grids.axonom", "angle_z", 30.0);
+ origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_x", 0.0), *gridunit );
+ origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_y", 0.0), *gridunit );
+ color = prefs->getInt("/options/grids/axonom/color", 0x0000ff20);
+ empcolor = prefs->getInt("/options/grids/axonom/empcolor", 0x0000ff40);
+ empspacing = prefs->getInt("/options/grids/axonom/empspacing", 5);
+ lengthy = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/spacing_y", 1.0), *gridunit );
+ angle_deg[X] = prefs->getDouble("/options/grids/axonom/angle_x", 30.0);
+ angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0);
angle_deg[Y] = 0;
angle_rad[X] = deg_to_rad(angle_deg[X]);
@@ -298,7 +298,6 @@ static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color)
void
CanvasAxonomGrid::readRepr()
{
- /// @todo Replace direct XML preference node manipulation with calls to public prefs API
gchar const *value;
if ( (value = repr->attribute("originx")) ) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit);
@@ -551,7 +550,7 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint32 _empcolor;
- bool preference = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false);
+ bool preference = prefs->getBool("/options/grids/no_emphasize_when_zoomedout", false);
if( scaled && preference ) {
_empcolor = color;
} else {
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 9b6b512b0..8505426d3 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -1,10 +1,8 @@
-#define INKSCAPE_CANVAS_GRID_C
-
-/*
- *
- * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
+/** @file
+ * @brief Cartesian grid implementation
+ */
+/* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
- *
*/
/* As a general comment, I am not exactly proud of how things are done.
@@ -13,6 +11,7 @@
* Don't be shy to correct things.
*/
+#define INKSCAPE_CANVAS_GRID_C
#include "sp-canvas-util.h"
#include "util/mathfns.h"
@@ -416,17 +415,17 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD
: CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.xy", "units").data() );
+ gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/xy/units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit);
- origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit);
- color = prefs->getInt("options.grids.xy", "color", 0x0000ff20);
- empcolor = prefs->getInt("options.grids.xy", "empcolor", 0x0000ff40);
- empspacing = prefs->getInt("options.grids.xy", "empspacing", 5);
- spacing[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit);
- spacing[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit);
- render_dotted = prefs->getBool("options.grids.xy", "dotted", false);
+ origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_x", 0.0), *gridunit);
+ origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_y", 0.0), *gridunit);
+ color = prefs->getInt("/options/grids/xy/color", 0x0000ff20);
+ empcolor = prefs->getInt("/options/grids/xy/empcolor", 0x0000ff40);
+ empspacing = prefs->getInt("/options/grids/xy/empspacing", 5);
+ spacing[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/spacing_x", 0.0), *gridunit);
+ spacing[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/spacing_y", 0.0), *gridunit);
+ render_dotted = prefs->getBool("/options/grids/xy/dotted", false);
snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0);
@@ -889,7 +888,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf)
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint32 _empcolor;
- bool no_emp_when_zoomed_out = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false);
+ bool no_emp_when_zoomed_out = prefs->getBool("/options/grids/no_emphasize_when_zoomedout", false);
if( (scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out ) {
_empcolor = color;
} else {
@@ -1000,14 +999,10 @@ void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point co
*/
bool CanvasXYGridSnapper::ThisSnapperMightSnap() const
{
- return _snap_enabled && _snap_from != 0;
+ return _snapmanager->snapprefs.getSnapModeBBoxOrNodes();
}
-
-
-
-
-}; /* namespace Inkscape */
+} // namespace Inkscape
/*
diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h
index 66f3bc43c..f50537065 100644
--- a/src/display/canvas-grid.h
+++ b/src/display/canvas-grid.h
@@ -1,16 +1,13 @@
-#ifndef INKSCAPE_CANVAS_GRID_H
-#define INKSCAPE_CANVAS_GRID_H
-
-/*
- * Inkscape::CXYGrid
- *
- * Generic (and quite unintelligent) grid item for gnome canvas
- *
- * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
+/** @file
+ * @brief Cartesian grid item for the Inkscape canvas
+ */
+/* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
- *
*/
+#ifndef INKSCAPE_CANVAS_GRID_H
+#define INKSCAPE_CANVAS_GRID_H
+
#include <cstring>
#include <string>
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index 21e1fbd48..f7a8cfb01 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -74,8 +74,8 @@ static void
sp_canvastext_init (SPCanvasText *canvastext)
{
canvastext->rgba = 0x0000ff7f;
- canvastext->s[NR::X] = canvastext->s[NR::Y] = 0.0;
- canvastext->affine = NR::identity();
+ canvastext->s[Geom::X] = canvastext->s[Geom::Y] = 0.0;
+ canvastext->affine = Geom::identity();
canvastext->fontsize = 10.0;
canvastext->item = NULL;
canvastext->text = NULL;
@@ -113,9 +113,9 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf)
guint32 rgba = cl->rgba;
cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba));
- NR::Point s = cl->s * cl->affine;
- double offsetx = s[NR::X] - buf->rect.x0;
- double offsety = s[NR::Y] - buf->rect.y0;
+ Geom::Point s = cl->s * cl->affine;
+ double offsetx = s[Geom::X] - buf->rect.x0;
+ double offsety = s[Geom::Y] - buf->rect.y0;
offsetx -= anchor_offset_x;
offsety += anchor_offset_y;
@@ -150,10 +150,10 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned i
cairo_text_extents_t bbox;
cairo_text_extents(&tmp_buf, cl->text, &bbox);
**/
- item->x1 = s[NR::X] + 0;
- item->y1 = s[NR::Y] - cl->fontsize;
- item->x2 = s[NR::X] + cl->fontsize * strlen(cl->text);
- item->y2 = s[NR::Y] + cl->fontsize * 0.5; // for letters below the baseline
+ item->x1 = s[Geom::X] + 0;
+ item->y1 = s[Geom::Y] - cl->fontsize;
+ item->x2 = s[Geom::X] + cl->fontsize * strlen(cl->text);
+ item->y2 = s[Geom::Y] + cl->fontsize * 0.5; // for letters below the baseline
// adjust update region according to anchor shift
// FIXME: use the correct text extent
@@ -208,16 +208,16 @@ sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0)
g_return_if_fail (ct != NULL);
g_return_if_fail (SP_IS_CANVASTEXT (ct));
- if (DIFFER (x0, ct->s[NR::X]) || DIFFER (y0, ct->s[NR::Y])) {
- ct->s[NR::X] = x0;
- ct->s[NR::Y] = y0;
+ if (DIFFER (x0, ct->s[Geom::X]) || DIFFER (y0, ct->s[Geom::Y])) {
+ ct->s[Geom::X] = x0;
+ ct->s[Geom::Y] = y0;
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
}
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
}
void
-sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start)
+sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start)
{
sp_canvastext_set_coords(ct, start[0], start[1]);
}
diff --git a/src/display/canvas-text.h b/src/display/canvas-text.h
index bb732ae6f..0e4724d92 100644
--- a/src/display/canvas-text.h
+++ b/src/display/canvas-text.h
@@ -41,7 +41,7 @@ SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, Geom::Point pos, gchar co
void sp_canvastext_set_rgba32 (SPCanvasText *ct, guint32 rgba);
void sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0);
-void sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start);
+void sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start);
void sp_canvastext_set_text (SPCanvasText *ct, gchar const* new_text);
void sp_canvastext_set_number_as_text (SPCanvasText *ct, int num);
void sp_canvastext_set_fontsize (SPCanvasText *ct, double size);
diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp
index 5f20d077a..ef60f0502 100644
--- a/src/display/nr-arena-glyphs.cpp
+++ b/src/display/nr-arena-glyphs.cpp
@@ -89,7 +89,7 @@ static void
nr_arena_glyphs_init(NRArenaGlyphs *glyphs)
{
glyphs->style = NULL;
- glyphs->g_transform.set_identity();
+ glyphs->g_transform.setIdentity();
glyphs->font = NULL;
glyphs->glyph = 0;
@@ -142,7 +142,7 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
bbox.x0 = bbox.y0 = NR_HUGE;
bbox.x1 = bbox.y1 = -NR_HUGE;
- float const scale = NR::expansion(gc->transform);
+ float const scale = gc->transform.descrim();
if (!glyphs->style->fill.isNone()) {
Geom::Matrix t;
@@ -265,7 +265,7 @@ nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int
if (transform) {
glyphs->g_transform = *transform;
} else {
- glyphs->g_transform.set_identity();
+ glyphs->g_transform.setIdentity();
}
if (font) font->Ref();
@@ -298,7 +298,7 @@ nr_arena_glyphs_fill_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m)
if (glyphs->rfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) {
raster_glyph *g = glyphs->rfont->GetGlyph(glyphs->glyph);
- if ( g ) g->Blit(NR::Point(glyphs->x, glyphs->y), *m);
+ if ( g ) g->Blit(Geom::Point(glyphs->x, glyphs->y), *m);
}
return item->state;
@@ -310,7 +310,7 @@ nr_arena_glyphs_stroke_mask(NRArenaGlyphs *glyphs, NRRectL *area, NRPixBlock *m)
NRArenaItem *item = NR_ARENA_ITEM(glyphs);
if (glyphs->sfont && nr_rect_l_test_intersect_ptr(area, &item->bbox)) {
raster_glyph *g=glyphs->sfont->GetGlyph(glyphs->glyph);
- if ( g ) g->Blit(NR::Point(glyphs->x, glyphs->y),*m);
+ if ( g ) g->Blit(Geom::Point(glyphs->x, glyphs->y),*m);
}
return item->state;
diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h
index 9c6762363..5bf94f3fc 100644
--- a/src/display/nr-arena-glyphs.h
+++ b/src/display/nr-arena-glyphs.h
@@ -33,7 +33,7 @@ NRType nr_arena_glyphs_get_type (void);
struct NRArenaGlyphs : public NRArenaItem {
/* Glyphs data */
SPStyle *style;
- NR::Matrix g_transform;
+ Geom::Matrix g_transform;
font_instance *font;
gint glyph;
@@ -41,7 +41,7 @@ struct NRArenaGlyphs : public NRArenaItem {
raster_font *sfont;
float x, y;
-// NR::Matrix cached_tr;
+// Geom::Matrix cached_tr;
// Shape *cached_shp;
// bool cached_shp_dirty;
// bool cached_style_dirty;
diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp
index c8a988483..17c9ab07c 100644
--- a/src/display/nr-arena-image.cpp
+++ b/src/display/nr-arena-image.cpp
@@ -15,7 +15,7 @@
#include <libnr/nr-compose-transform.h>
#include <2geom/transforms.h>
#include <libnr/nr-blit.h>
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "nr-arena-image.h"
#include "style.h"
#include "display/nr-arena.h"
@@ -173,7 +173,8 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned
static unsigned int
nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixBlock *pb, unsigned int /*flags*/ )
{
- nr_arena_image_x_sample = prefs_get_int_attribute ("options.bitmapoversample", "value", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ nr_arena_image_x_sample = prefs->getInt("/options/bitmapoversample/value", 1);
nr_arena_image_y_sample = nr_arena_image_x_sample;
bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE);
@@ -228,7 +229,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB
if (!ct)
return item->state;
- guint32 rgba = prefs_get_int_attribute("options.wireframecolors", "images", 0xff0000ff);
+ guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff);
// FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat
// by setting color channels in the "wrong" order
cairo_set_source_rgba(ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba));
diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp
index b9a0cc371..d944b4228 100644
--- a/src/display/nr-arena-item.cpp
+++ b/src/display/nr-arena-item.cpp
@@ -30,7 +30,7 @@
#include "nr-filter.h"
#include "libnr/nr-rect.h"
#include "nr-arena-group.h"
-#include "prefs-utils.h"
+#include "preferences.h"
namespace GC = Inkscape::GC;
@@ -343,13 +343,14 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area
// render clip and mask, if any
guint32 saved_rgba = item->arena->outlinecolor; // save current outline color
// render clippath as an object, using a different color
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item->clip) {
- item->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "clips", 0x00ff00ff); // green clips
+ item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips
NR_ARENA_ITEM_VIRTUAL (item->clip, render) (ct, item->clip, &carea, pb, flags);
}
// render mask as an object, using a different color
if (item->mask) {
- item->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "masks", 0x0000ffff); // blue masks
+ item->arena->outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks
NR_ARENA_ITEM_VIRTUAL (item->mask, render) (ct, item->mask, &carea, pb, flags);
}
item->arena->outlinecolor = saved_rgba; // restore outline color
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp
index 6a252e5f5..4c988be46 100644
--- a/src/display/nr-arena-shape.cpp
+++ b/src/display/nr-arena-shape.cpp
@@ -29,7 +29,6 @@
#include <livarot/float-line.h>
#include <livarot/int-line.h>
#include <style.h>
-#include "prefs-utils.h"
#include "inkscape-cairo.h"
#include "helper/geom.h"
#include "helper/geom-curves.h"
diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h
index 8ff8c476a..455757806 100644
--- a/src/display/nr-arena-shape.h
+++ b/src/display/nr-arena-shape.h
@@ -154,6 +154,7 @@ struct NRArenaShape : public NRArenaItem {
static NRArenaShape *create(NRArena *arena) {
NRArenaShape *obj=reinterpret_cast<NRArenaShape *>(nr_object_new(NR_TYPE_ARENA_SHAPE));
obj->init(arena);
+ obj->key = 0;
return obj;
}
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp
index 76b541ace..14a039630 100644
--- a/src/display/nr-filter-gaussian.cpp
+++ b/src/display/nr-filter-gaussian.cpp
@@ -30,7 +30,7 @@
#include "libnr/nr-matrix.h"
#include "libnr/nr-matrix-fns.h"
#include "util/fixed_point.h"
-#include "prefs-utils.h"
+#include "preferences.h"
// IIR filtering method based on:
// L.J. van Vliet, I.T. Young, and P.W. Verbeek, Recursive Gaussian Derivative Filters,
@@ -85,7 +85,7 @@ namespace NR {
FilterGaussian::FilterGaussian()
{
- _deviation_x = _deviation_y = prefs_get_double_attribute("options.filtertest", "value", 1.0);
+ _deviation_x = _deviation_y = 0.0;
}
FilterPrimitive *FilterGaussian::create()
@@ -545,7 +545,8 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
int const PC = NR_PIXBLOCK_BPP(in);
// Subsampling constants
- int const quality = prefs_get_int_attribute("options.blurquality", "value", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int const quality = prefs->getInt("/options/blurquality/value");
int const x_step_l2 = _effect_subsample_step_log2(deviation_x_org, quality);
int const y_step_l2 = _effect_subsample_step_log2(deviation_y_org, quality);
int const x_step = 1<<x_step_l2;
diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp
index 1501afcbe..c099663fd 100644
--- a/src/display/nr-filter-slot.cpp
+++ b/src/display/nr-filter-slot.cpp
@@ -65,6 +65,9 @@ inline static int _min2(const double a, const double b) {
namespace NR {
FilterSlot::FilterSlot(int slots, NRArenaItem const *item)
+ : filterquality(FILTER_QUALITY_BEST),
+ _last_out(-1),
+ _arena_item(item)
{
_slot_count = ((slots > 0) ? slots : 2);
_slot = new NRPixBlock*[_slot_count];
@@ -74,10 +77,6 @@ FilterSlot::FilterSlot(int slots, NRArenaItem const *item)
_slot[i] = NULL;
_slot_number[i] = NR_FILTER_SLOT_NOT_SET;
}
-
- _last_out = -1;
-
- _arena_item = item;
}
FilterSlot::~FilterSlot()
@@ -163,7 +162,11 @@ void FilterSlot::get_final(int slot_nr, NRPixBlock *result) {
memset(NR_PIXBLOCK_PX(result), 0, size);
if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) {
- transform_bicubic(result, final_usr, trans);
+ if (filterquality == FILTER_QUALITY_BEST) {
+ transform_bicubic(result, final_usr, trans);
+ } else {
+ transform_nearest(result, final_usr, trans);
+ }
} else if (fabs(trans[0] - 1) > 1e-6 || fabs(trans[3] - 1) > 1e-6) {
scale_bicubic(result, final_usr);
} else {
@@ -223,7 +226,11 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb)
g_warning("Memory allocation failed in NR::FilterSlot::set (transform)");
return;
}
- transform_bicubic(trans_pb, pb, trans);
+ if (filterquality == FILTER_QUALITY_BEST) {
+ transform_bicubic(trans_pb, pb, trans);
+ } else {
+ transform_nearest(trans_pb, pb, trans);
+ }
nr_pixblock_release(pb);
delete pb;
pb = trans_pb;
@@ -338,6 +345,10 @@ void FilterSlot::set_units(FilterUnits const &units) {
this->units = units;
}
+void FilterSlot::set_quality(FilterQuality const q) {
+ filterquality = q;
+}
+
}
/*
diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h
index aaf22e513..b566be10e 100644
--- a/src/display/nr-filter-slot.h
+++ b/src/display/nr-filter-slot.h
@@ -15,6 +15,7 @@
*/
#include "libnr/nr-pixblock.h"
+#include "display/nr-filter-types.h"
#include "display/nr-filter-units.h"
struct NRArenaItem;
@@ -72,6 +73,9 @@ public:
/** Sets the unit system to be used for the internal images. */
void set_units(FilterUnits const &units);
+ /** Sets the filtering quality. Affects used interpolation methods */
+ void set_quality(FilterQuality const q);
+
private:
NRPixBlock **_slot;
int *_slot_number;
@@ -79,6 +83,8 @@ private:
int _last_out;
+ FilterQuality filterquality;
+
NRArenaItem const *_arena_item;
FilterUnits units;
diff --git a/src/display/nr-filter-types.h b/src/display/nr-filter-types.h
index ee24840cf..a54bfa670 100644
--- a/src/display/nr-filter-types.h
+++ b/src/display/nr-filter-types.h
@@ -37,6 +37,14 @@ enum FilterSlotType {
/* Unnamed slot is for NR::FilterSlot internal use. Passing it as
* parameter to NR::FilterSlot accessors may have unforeseen consequences. */
+enum FilterQuality {
+ FILTER_QUALITY_BEST = 2,
+ FILTER_QUALITY_BETTER = 1,
+ FILTER_QUALITY_NORMAL = 0,
+ FILTER_QUALITY_WORSE = -1,
+ FILTER_QUALITY_WORST = -2
+};
+
} /* namespace NR */
#endif // __NR_FILTER_TYPES_H__
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index 8930a74df..31aec0748 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -46,6 +46,8 @@
#include "libnr/nr-scale.h"
#include "svg/svg-length.h"
#include "sp-filter-units.h"
+#include "preferences.h"
+
#if defined (SOLARIS) && (SOLARIS == 8)
#include "round.h"
using Inkscape::round;
@@ -111,8 +113,12 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
return 1;
}
- Matrix trans = item->ctm;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ FilterQuality const filterquality = (FilterQuality)prefs->getInt("/options/filterquality/value");
+
+ Geom::Matrix trans = item->ctm;
FilterSlot slot(_slot_count, item);
+ slot.set_quality(filterquality);
Geom::Rect item_bbox;
if (item->item_bbox) {
@@ -130,7 +136,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
}
Geom::Rect filter_area = filter_effect_area(item_bbox);
- if (item_bbox.isEmpty()) {
+ if (item_bbox.area() == 0.0) {
// It's no use to try and filter an empty object.
return 1;
}
@@ -152,18 +158,19 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
units.set_automatic_resolution(false);
units.set_resolution(_x_pixels, y_len);
} else {
- Point origo = filter_area.min();
+ Geom::Point origo = filter_area.min();
origo *= trans;
- Point max_i(filter_area.max()[X], filter_area.min()[Y]);
+ Geom::Point max_i(filter_area.max()[X], filter_area.min()[Y]);
max_i *= trans;
- Point max_j(filter_area.min()[X], filter_area.max()[Y]);
+ Geom::Point max_j(filter_area.min()[X], filter_area.max()[Y]);
max_j *= trans;
double i_len = sqrt((origo[X] - max_i[X]) * (origo[X] - max_i[X])
+ (origo[Y] - max_i[Y]) * (origo[Y] - max_i[Y]));
double j_len = sqrt((origo[X] - max_j[X]) * (origo[X] - max_j[X])
+ (origo[Y] - max_j[Y]) * (origo[Y] - max_j[Y]));
units.set_automatic_resolution(true);
- units.set_resolution(i_len, j_len);
+ double const divisor = _resolution_divisor(filterquality);
+ units.set_resolution(i_len / divisor, j_len / divisor);
}
units.set_paraller(false);
@@ -211,7 +218,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
return 0;
}
-void Filter::area_enlarge(NRRectL &bbox, Matrix const &m) {
+void Filter::area_enlarge(NRRectL &bbox, Geom::Matrix const &m) {
for (int i = 0 ; i < _primitive_count ; i++) {
if (_primitive[i]) _primitive[i]->area_enlarge(bbox, m);
}
@@ -238,7 +245,7 @@ void Filter::bbox_enlarge(NRRectL &bbox) {
Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox)
{
- Point minp, maxp;
+ Geom::Point minp, maxp;
double len_x = bbox.max()[X] - bbox.min()[X];
double len_y = bbox.max()[Y] - bbox.min()[Y];
/* TODO: fetch somehow the object ex and em lengths */
@@ -432,6 +439,26 @@ void Filter::reset_resolution() {
_y_pixels = -1;
}
+double Filter::_resolution_divisor(FilterQuality const quality) const {
+ double divisor = 1;
+ switch (quality) {
+ case FILTER_QUALITY_WORST:
+ divisor = 8;
+ break;
+ case FILTER_QUALITY_WORSE:
+ divisor = 4;
+ break;
+ case FILTER_QUALITY_NORMAL:
+ divisor = 2;
+ break;
+ case FILTER_QUALITY_BETTER:
+ case FILTER_QUALITY_BEST:
+ default:
+ break;
+ }
+ return divisor;
+}
+
} /* namespace NR */
/*
diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h
index 1dbdfd1ef..ae3857c65 100644
--- a/src/display/nr-filter.h
+++ b/src/display/nr-filter.h
@@ -144,7 +144,7 @@ public:
* to be rendered so that after filtering, the original area is
* drawn correctly.
*/
- void area_enlarge(NRRectL &area, Matrix const &m);
+ void area_enlarge(NRRectL &area, Geom::Matrix const &m);
/**
* Given an object bounding box, this function enlarges it so that
* it contains the filter effect area.
@@ -198,6 +198,7 @@ private:
void _create_constructor_table();
void _enlarge_primitive_table();
void _common_init();
+ double _resolution_divisor(FilterQuality const quality) const;
};
diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp
index 28d29b59c..02c9a9ea2 100644
--- a/src/display/nr-svgfonts.cpp
+++ b/src/display/nr-svgfonts.cpp
@@ -91,11 +91,17 @@ SvgFont::scaled_font_init (cairo_scaled_font_t *scaled_font,
return CAIRO_STATUS_SUCCESS;
}
-unsigned int compare_them(char* s1, char* s2){
- unsigned int p=0;
- while((s1[p] == s2[p]) && s1[p] != '\0' && s2[p] != '\0') p++;
- if (s1[p]=='\0') return p;
- else return 0;
+unsigned int size_of_substring(gchar* substring, gchar* str){
+ const gchar* original_substring = substring;
+
+ while((g_utf8_get_char(substring)==g_utf8_get_char(str)) && g_utf8_get_char(substring) != 0 && g_utf8_get_char(str) != 0){
+ substring = g_utf8_next_char(substring);
+ str = g_utf8_next_char(str);
+ }
+ if (g_utf8_get_char(substring)==0)
+ return substring - original_substring;
+ else
+ return 0;
}
cairo_status_t
@@ -115,15 +121,31 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
unsigned long i;
int count = 0;
- char* _utf8 = (char*) utf8;
+ gchar* _utf8 = (gchar*) utf8;
unsigned int len;
- //First we findout whats the worst case number of glyphs.
- while(_utf8[0] != '\0'){
- _utf8++;
- count++;
+ bool missing;
+ //First we findout whats the number of glyphs needed.
+ while(g_utf8_get_char(_utf8) != 0){
+ missing = true;
+ for (i=0; i < (unsigned long) this->glyphs.size(); i++){
+ if ( (len = size_of_substring(this->glyphs[i]->unicode, _utf8)) ){
+ //TODO: store this cluster
+ _utf8+=len;
+ count++;
+ missing=false;
+ break;
+ }
+ }
+ if (missing){
+ //TODO: store this cluster
+ _utf8++;
+ count++;
+ }
}
+//g_warning("count is %d", count);
+
//We use that info to allocate memory for the glyphs
*glyphs = (cairo_glyph_t*) malloc(count*sizeof(cairo_glyph_t));
@@ -134,10 +156,10 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
double x=0, y=0;//These vars store the position of the glyph within the rendered string
bool is_horizontal_text = true; //TODO
_utf8 = (char*) utf8;
- while(_utf8[0] != '\0'){
+ while(g_utf8_get_char(_utf8) != 0){
len = 0;
for (i=0; i < (unsigned long) this->glyphs.size(); i++){
- if ( (len = compare_them(this->glyphs[i]->unicode, _utf8)) ){
+ if ( (len = size_of_substring(this->glyphs[i]->unicode, _utf8)) ){
//check whether is there a glyph declared on the SVG document
// that matches with the text string in its current position
for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){
@@ -167,7 +189,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
//advance glyph coordinates:
if (is_horizontal_text) x++;
else y++;
- _utf8+=len; //advance 'len' chars in our string pointer
+ _utf8+=len; //advance 'len' bytes in our string pointer
//continue;
goto dirty;
}
@@ -180,7 +202,7 @@ dirty:
//advance glyph coordinates:
if (is_horizontal_text) x++;
else y++;
- _utf8++; //advance 1 char in our string pointer
+ _utf8 = g_utf8_next_char(_utf8); //advance 1 char in our string pointer
}
}
*num_glyphs = count;
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index d82e39238..53dd6c62c 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -35,7 +35,7 @@
#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-matrix-ops.h>
#include <libnr/nr-convex-hull.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape.h"
#include "sodipodi-ctrlrect.h"
#if ENABLE_LCMS
@@ -45,6 +45,8 @@
#include "libnr/nr-blit.h"
#include "display/inkscape-cairo.h"
#include "debug/gdk-event-latency-tracker.h"
+#include "desktop.h"
+#include "sp-namedview.h"
using Inkscape::Debug::GdkEventLatencyTracker;
@@ -945,6 +947,10 @@ static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int n
static void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val);
static int do_update (SPCanvas *canvas);
+static gboolean sp_canvas_snap_watchdog_callback(gpointer data);
+static void sp_canvas_snap_watchdog_set(SPCanvas *canvas, GdkEventMotion *event);
+static void sp_canvas_snap_watchdog_kill(SPCanvas *canvas);
+
/**
* Registers the SPCanvas class if necessary, and returns the type ID
* associated to it.
@@ -1042,6 +1048,8 @@ sp_canvas_init (SPCanvas *canvas)
canvas->is_scrolling = false;
+ canvas->watchdog_id = 0;
+ canvas->watchdog_event = NULL;
}
/**
@@ -1106,7 +1114,7 @@ static void track_latency(GdkEvent const *event) {
GdkEventLatencyTracker &tracker = GdkEventLatencyTracker::default_tracker();
boost::optional<double> latency = tracker.process(event);
if (latency && *latency > 2.0) {
- g_warning("Event latency reached %f sec (%1.4f)", *latency, tracker.getSkew());
+ //g_warning("Event latency reached %f sec (%1.4f)", *latency, tracker.getSkew());
}
}
@@ -1157,7 +1165,8 @@ sp_canvas_realize (GtkWidget *widget)
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, widget);
- if ( prefs_get_int_attribute ("options.useextinput", "value", 1) )
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if ( prefs->getBool("/options/useextinput/value", true) )
gtk_widget_set_events(widget, attributes.event_mask);
widget->style = gtk_style_attach (widget->style, widget->window);
@@ -1574,7 +1583,10 @@ static inline void request_motions(GdkWindow *w, GdkEventMotion *event) {
static int
sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
{
- int status;
+ static guint32 prev_time;
+ static boost::optional<Geom::Point> prev_pos;
+
+ int status;
SPCanvas *canvas = SP_CANVAS (widget);
track_latency((GdkEvent *)event);
@@ -1584,7 +1596,52 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
if (canvas->pixmap_gc == NULL) // canvas being deleted
return FALSE;
-
+
+ // Snap when speed drops below e.g. 0.1 px/msec, or when no motion events have occured for 100 msec.
+ // i.e. snap when we're at stand still. The speed threshold enforces snapping for tablets, which will never
+ // be full at stand still and might keep spitting out motion events.
+
+ // When moving at speeds around the speed limit, Inkscape might snap for one motion event but not for the
+ // next, which will make the object that's being dragged jump from the snapped position to the mouse
+ // position and back again. That could be annoying, but I don't see an easy way around this.
+
+ if (event->type == GDK_MOTION_NOTIFY) {
+ Geom::Point event_pos(event->x, event->y);
+ guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
+
+ sp_canvas_snap_watchdog_kill(canvas);
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+
+ if (prev_pos) {
+ Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
+ guint32 delta_t = event_t - prev_time;
+ gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
+ // std::cout << "speed = " << speed << " px/msec " << "| time passed = " << delta_t << " msec" << std::endl;
+ if (speed < 0.1) {
+ if (dt) {
+ dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+ }
+ } else {
+ // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event.
+ if (dt) {
+ dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true);
+ }
+ // We must snap at some point in time though, so set a watchdog timer at 100 msec from
+ // now, just in case there's no future motion event that's under the speed limit.
+ sp_canvas_snap_watchdog_set(canvas, event);
+ }
+ } else {
+ // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
+ if (dt) {
+ dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true);
+ }
+ sp_canvas_snap_watchdog_set(canvas, event);
+ }
+
+ prev_pos = event_pos;
+ prev_time = event_t;
+ }
+
canvas->state = event->state;
pick_current_item (canvas, (GdkEvent *) event);
@@ -1597,6 +1654,43 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event)
return status;
}
+gboolean sp_canvas_snap_watchdog_callback(gpointer data)
+{
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (dt) {
+ dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+ }
+
+ SPCanvas *canvas = reinterpret_cast<SPCanvas *>(data);
+ emit_event(canvas, canvas->watchdog_event);
+ gdk_event_free(canvas->watchdog_event);
+ canvas->watchdog_event = NULL;
+ canvas->watchdog_id = 0;
+
+ return FALSE;
+}
+
+void sp_canvas_snap_watchdog_set(SPCanvas *canvas, GdkEventMotion *event)
+{
+ g_assert(canvas->watchdog_id == 0);
+ canvas->watchdog_id = g_timeout_add(100, &sp_canvas_snap_watchdog_callback, canvas);
+ g_assert(canvas->watchdog_event == NULL);
+ canvas->watchdog_event = gdk_event_copy( (GdkEvent *) event);
+}
+
+void sp_canvas_snap_watchdog_kill(SPCanvas *canvas)
+{
+ if (canvas->watchdog_id) {
+ g_source_remove(canvas->watchdog_id); // Kill the watchdog
+ canvas->watchdog_id = 0;
+ }
+
+ if (canvas->watchdog_event) {
+ gdk_event_free(canvas->watchdog_event);
+ canvas->watchdog_event = NULL;
+ }
+}
+
static void
sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int sw)
{
@@ -1635,7 +1729,8 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1,
#if ENABLE_LCMS
cmsHTRANSFORM transf = 0;
- long long int fromDisplay = prefs_get_int_attribute_limited( "options.displayprofile", "from_display", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
if ( fromDisplay ) {
transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" );
} else {
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 60bda5818..8b0958ca5 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -75,7 +75,7 @@ struct SPCanvasItem : public GtkObject {
SPCanvasItem *parent;
double x1, y1, x2, y2;
- NR::Rect bounds;
+ Geom::Rect bounds;
Geom::Matrix xform;
};
@@ -193,6 +193,9 @@ struct SPCanvas {
Geom::Rect getViewbox() const;
NR::IRect getViewboxIntegers() const;
+
+ guint watchdog_id;
+ GdkEvent *watchdog_event;
};
GtkWidget *sp_canvas_new_aa();
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index 31766c3c2..b307684e5 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -97,7 +97,7 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
SPCtrlQuadr *cq = SP_CTRLQUADR (item);
- //NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1));
+ //Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1));
if (!buf->ct)
return;
diff --git a/src/document.cpp b/src/document.cpp
index b27d8d1cb..28a2be9a1 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -52,7 +52,7 @@
#include "document-private.h"
#include "dir-util.h"
#include "unit-constants.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "libavoid/router.h"
#include "sp-item-group.h"
#include "profile-manager.h"
@@ -258,6 +258,7 @@ sp_document_create(Inkscape::XML::Document *rdoc,
SPDocument *document;
Inkscape::XML::Node *rroot;
Inkscape::Version sodipodi_version;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
rroot = rdoc->root();
@@ -313,18 +314,38 @@ sp_document_create(Inkscape::XML::Document *rdoc,
// creating namedview
if (!sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview")) {
// if there's none in the document already,
- Inkscape::XML::Node *r = NULL;
Inkscape::XML::Node *rnew = NULL;
- r = inkscape_get_repr(INKSCAPE, "template.base");
- // see if there's a template with id="base" in the preferences
- if (!r) {
- // if there's none, create an empty element
- rnew = rdoc->createElement("sodipodi:namedview");
- rnew->setAttribute("id", "base");
- } else {
- // otherwise, take from preferences
- rnew = r->duplicate(rroot->document());
+
+ rnew = rdoc->createElement("sodipodi:namedview");
+ //rnew->setAttribute("id", "base");
+
+ // Add namedview data from the preferences
+ // we can't use getAllEntries because this could produce non-SVG doubles
+ Glib::ustring pagecolor = prefs->getString("/template/base/pagecolor");
+ if (!pagecolor.empty()) {
+ rnew->setAttribute("pagecolor", pagecolor.data());
+ }
+ Glib::ustring bordercolor = prefs->getString("/template/base/pagecolor");
+ if (!bordercolor.empty()) {
+ rnew->setAttribute("bordercolor", bordercolor.data());
}
+ sp_repr_set_svg_double(rnew, "borderopacity",
+ prefs->getDouble("/template/base/borderopacity", 1.0));
+ sp_repr_set_svg_double(rnew, "objecttolerance",
+ prefs->getDouble("/template/base/objecttolerance", 10.0));
+ sp_repr_set_svg_double(rnew, "gridtolerance",
+ prefs->getDouble("/template/base/gridtolerance", 10.0));
+ sp_repr_set_svg_double(rnew, "guidetolerance",
+ prefs->getDouble("/template/base/guidetolerance", 10.0));
+ sp_repr_set_svg_double(rnew, "inkscape:pageopacity",
+ prefs->getDouble("/template/base/inkscape:pageopacity", 0.0));
+ sp_repr_set_int(rnew, "inkscape:pageshadow",
+ prefs->getInt("/template/base/inkscape:pageshadow", 2));
+ sp_repr_set_int(rnew, "inkscape:window-width",
+ prefs->getInt("/template/base/inkscape:window-width", 640));
+ sp_repr_set_int(rnew, "inkscape:window-height",
+ prefs->getInt("/template/base/inkscape:window-height", 480));
+
// insert into the document
rroot->addChild(rnew, NULL);
// clean up
@@ -931,8 +952,8 @@ sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GS
Geom::Point const p, bool take_insensitive)
{
g_return_val_if_fail(group, NULL);
-
- gdouble delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
@@ -968,8 +989,8 @@ SPItem*
find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
{
SPItem *seen = NULL, *newseen = NULL;
-
- gdouble delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
if (!SP_IS_ITEM(o)) continue;
@@ -1010,8 +1031,8 @@ SPItem*
find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
{
SPItem *seen = NULL;
-
- gdouble delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
if (!SP_IS_ITEM(o)) continue;
@@ -1068,12 +1089,13 @@ GSList *
sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<Geom::Point> points)
{
GSList *items = NULL;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// When picking along the path, we don't want small objects close together
// (such as hatching strokes) to obscure each other by their deltas,
// so we temporarily set delta to a small value
- gdouble saved_delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0);
- prefs_set_double_attribute ("options.cursortolerance", "value", 0.25);
+ gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
+ prefs->setDouble("/options/cursortolerance/value", 0.25);
for(unsigned int i = 0; i < points.size(); i++) {
SPItem *item = sp_document_item_at_point(document, key, points[i],
@@ -1083,7 +1105,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto
}
// and now we restore it back
- prefs_set_double_attribute ("options.cursortolerance", "value", saved_delta);
+ prefs->setDouble("/options/cursortolerance/value", saved_delta);
return items;
}
diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp
index 363ea0b6e..f4abd596e 100644
--- a/src/draw-anchor.cpp
+++ b/src/draw-anchor.cpp
@@ -25,7 +25,7 @@
* Creates an anchor object and initializes it.
*/
SPDrawAnchor *
-sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, NR::Point delta)
+sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Point delta)
{
if (SP_IS_LPETOOL_CONTEXT(dc)) {
// suppress all kinds of anchors in LPEToolContext
@@ -78,7 +78,7 @@ sp_draw_anchor_destroy(SPDrawAnchor *anchor)
* pointer to it or NULL.
*/
SPDrawAnchor *
-sp_draw_anchor_test(SPDrawAnchor *anchor, NR::Point w, gboolean activate)
+sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate)
{
SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(anchor->dc);
diff --git a/src/draw-anchor.h b/src/draw-anchor.h
index 1036a5472..027761684 100644
--- a/src/draw-anchor.h
+++ b/src/draw-anchor.h
@@ -6,8 +6,8 @@
*/
#include <glib/gtypes.h>
+#include <2geom/point.h>
-#include "libnr/nr-point.h"
struct SPDrawContext;
struct SPCurve;
struct SPCanvasItem;
@@ -19,15 +19,15 @@ struct SPDrawAnchor {
SPCurve *curve;
guint start : 1;
guint active : 1;
- NR::Point dp;
+ Geom::Point dp;
SPCanvasItem *ctrl;
};
SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start,
- NR::Point delta);
+ Geom::Point delta);
SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor);
-SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, NR::Point w, gboolean activate);
+SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate);
#endif /* !SEEN_DRAW_ANCHOR_H */
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index d21ee5ffe..d1124b75a 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -35,7 +35,7 @@
#include "message-stack.h"
#include "pen-context.h"
#include "lpe-tool-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "snap.h"
@@ -49,7 +49,7 @@ static void sp_draw_context_init(SPDrawContext *dc);
static void sp_draw_context_dispose(GObject *object);
static void sp_draw_context_setup(SPEventContext *ec);
-static void sp_draw_context_set(SPEventContext *ec, gchar const *key, gchar const *value);
+static void sp_draw_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static void sp_draw_context_finish(SPEventContext *ec);
static gint sp_draw_context_root_handler(SPEventContext *event_context, GdkEvent *event);
@@ -225,7 +225,7 @@ sp_draw_context_finish(SPEventContext *ec)
}
static void
-sp_draw_context_set(SPEventContext */*ec*/, const gchar */*key*/, const gchar */*value*/)
+sp_draw_context_set(SPEventContext */*ec*/, Inkscape::Preferences::Entry */*val*/)
{
}
@@ -263,12 +263,12 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
return ret;
}
-static char const *
+static Glib::ustring const
tool_name(SPDrawContext *dc)
{
return ( SP_IS_PEN_CONTEXT(dc)
- ? "tools.freehand.pen"
- : "tools.freehand.pencil" );
+ ? "/tools/freehand/pen"
+ : "/tools/freehand/pencil" );
}
static void
@@ -292,13 +292,14 @@ void
spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item && SP_IS_LPE_ITEM(item)) {
- if (prefs_get_int_attribute(tool_name(dc), "freehand-mode", 0) == 1) {
+ if (prefs->getBool(tool_name(dc) + "/freehand-mode", 0) == 1) {
Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
}
- int shape = prefs_get_int_attribute(tool_name(dc), "shape", 0);
+ int shape = prefs->getInt(tool_name(dc) + "/shape", 0);
bool shape_applied = false;
SPCSSAttr *css_item = sp_css_attr_from_object (SP_OBJECT(item), SP_STYLE_FLAG_ALWAYS);
const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
@@ -469,7 +470,8 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/)
void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o,
guint state)
{
- unsigned const snaps = abs(prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
/* 0 means no snapping. */
/* mirrored by fabs, so this corresponds to 15 degrees */
@@ -484,8 +486,8 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
for (unsigned i = 0; i < snaps; i++) {
double const ndot = fabs(dot(v,Geom::rot90(delta)));
- Geom::Point t(r00*v[NR::X] + r01*v[NR::Y],
- r10*v[NR::X] + r11*v[NR::Y]);
+ Geom::Point t(r00*v[Geom::X] + r01*v[Geom::Y],
+ r10*v[Geom::X] + r11*v[Geom::Y]);
if (ndot < bn) {
/* I think it is better numerically to use the normal, rather than the dot product
* to assess solutions, but I haven't proven it. */
@@ -506,7 +508,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
Geom::Point pt2g = to_2geom(p);
- m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, pt2g, Inkscape::Snapper::ConstraintLine(best));
+ m.constrainedSnapReturnByRef( Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::Snapper::ConstraintLine(best));
p = from_2geom(pt2g);
}
}
@@ -518,7 +520,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, gu
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
Geom::Point pt2g = to_2geom(p);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
p = from_2geom(pt2g);
}
@@ -666,7 +668,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
} else {
repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool(desktop, repr, tool_name(dc), false);
+ sp_desktop_apply_style_tool(desktop, repr, tool_name(dc).data(), false);
}
gchar *str = sp_svg_write_path( c->get_pathvector() );
@@ -794,7 +796,8 @@ spdc_free_colors(SPDrawContext *dc)
/* Create a single dot represented by a circle */
void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state) {
- g_return_if_fail(!strcmp(tool, "tools.freehand.pen") || !strcmp(tool, "tools.freehand.pencil"));
+ g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil"));
+ Glib::ustring tool_path = tool;
SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
@@ -825,9 +828,11 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
/* put the circle where the mouse click occurred and set the diameter to the
current stroke width, multiplied by the amount specified in the preferences */
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
Geom::Matrix const i2d (sp_item_i2d_affine (item));
Geom::Point pp = pt * i2d;
- double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0);
+ double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0);
if (event_state & GDK_MOD1_MASK) {
/* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
as specified in prefs. Very simple, but it might be sufficient in practice. If not,
@@ -840,8 +845,8 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
rad *= 2;
}
- sp_repr_set_svg_double (repr, "sodipodi:cx", pp[NR::X]);
- sp_repr_set_svg_double (repr, "sodipodi:cy", pp[NR::Y]);
+ sp_repr_set_svg_double (repr, "sodipodi:cx", pp[Geom::X]);
+ sp_repr_set_svg_double (repr, "sodipodi:cy", pp[Geom::Y]);
sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width);
sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
item->updateRepr();
diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp
index 0e30acf1b..1f6842a5c 100644
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
@@ -30,7 +30,7 @@
#include "color.h"
#include "color-rgba.h"
#include "desktop-style.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
@@ -114,11 +114,12 @@ static void sp_dropper_context_setup(SPEventContext *ec)
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->area), 0x0000007f, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_hide(dc->area);
- if (prefs_get_int_attribute("tools.dropper", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/dropper/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.dropper", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/dropper/gradientdrag")) {
ec->enableGrDrag();
}
}
@@ -142,10 +143,11 @@ static void sp_dropper_context_finish(SPEventContext *ec)
guint32 sp_dropper_context_get_color(SPEventContext *ec)
{
SPDropperContext *dc = SP_DROPPER_CONTEXT(ec);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int pick = prefs_get_int_attribute("tools.dropper", "pick",
+ int pick = prefs->getInt("/tools/dropper/pick",
SP_DROPPER_PICK_VISIBLE);
- int setalpha = prefs_get_int_attribute("tools.dropper", "setalpha", 1);
+ bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
return SP_RGBA32_F_COMPOSE(dc->R, dc->G, dc->B,
(pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? dc->alpha : 1.0);
@@ -157,9 +159,10 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
SPDropperContext *dc = (SPDropperContext *) event_context;
int ret = FALSE;
SPDesktop *desktop = event_context->desktop;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int pick = prefs_get_int_attribute("tools.dropper", "pick", SP_DROPPER_PICK_VISIBLE);
- int setalpha = prefs_get_int_attribute("tools.dropper", "setalpha", 1);
+ int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
+ bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
switch (event->type) {
case GDK_BUTTON_PRESS:
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp
index 2d4782f9b..e22520ecb 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/dyna-draw-context.cpp
@@ -46,7 +46,7 @@
#include "desktop-affine.h"
#include "desktop-style.h"
#include "message-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "pixmaps/cursor-calligraphy.xpm"
#include "libnr/nr-matrix-ops.h"
#include "libnr/nr-scale-translate-ops.h"
@@ -84,7 +84,7 @@ static void sp_dyna_draw_context_init(SPDynaDrawContext *ddc);
static void sp_dyna_draw_context_dispose(GObject *object);
static void sp_dyna_draw_context_setup(SPEventContext *ec);
-static void sp_dyna_draw_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_dyna_draw_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *value);
static gint sp_dyna_draw_context_root_handler(SPEventContext *ec, GdkEvent *event);
static void clear_current(SPDynaDrawContext *dc);
@@ -236,27 +236,28 @@ sp_dyna_draw_context_setup(SPEventContext *ec)
sp_event_context_read(ec, "cap_rounding");
ddc->is_drawing = false;
-
ddc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
- if (prefs_get_int_attribute("tools.calligraphic", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/calligraphic/selcue")) {
ec->enableSelectionCue();
}
}
static void
-sp_dyna_draw_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_dyna_draw_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPDynaDrawContext *ddc = SP_DYNA_DRAW_CONTEXT(ec);
+ Glib::ustring path = val->getEntryName();
- if (!strcmp(key, "tracebackground")) {
- ddc->trace_bg = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "keep_selected")) {
- ddc->keep_selected = (val && strcmp(val, "0"));
+ if (path == "tracebackground") {
+ ddc->trace_bg = val->getBool();
+ } else if (path == "keep_selected") {
+ ddc->keep_selected = val->getBool();
} else {
//pass on up to parent class to handle common attributes.
if ( dd_parent_class->set ) {
- dd_parent_class->set(ec, key, val);
+ dd_parent_class->set(ec, val);
}
}
@@ -337,7 +338,7 @@ sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p)
// This prevents flips, blobs, and jerks caused by microscopic tremor of the tablet pen,
// especially bothersome at the start of the stroke where we don't yet have the inertia to
// smooth them out.
- if ( NR::L2(force) < DYNA_EPSILON || (dc->vel_max < DYNA_VEL_START && NR::L2(force) < DYNA_EPSILON_START)) {
+ if ( Geom::L2(force) < DYNA_EPSILON || (dc->vel_max < DYNA_VEL_START && Geom::L2(force) < DYNA_EPSILON_START)) {
return FALSE;
}
@@ -346,8 +347,8 @@ sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p)
/* Calculate new velocity */
dc->vel += dc->acc;
- if (NR::L2(dc->vel) > dc->vel_max)
- dc->vel_max = NR::L2(dc->vel);
+ if (Geom::L2(dc->vel) > dc->vel_max)
+ dc->vel_max = Geom::L2(dc->vel);
/* Calculate angle of drawing tool */
@@ -371,11 +372,11 @@ sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p)
}
// 2. perpendicular to dc->vel (absolutely non-flat nib):
- gdouble const mag_vel = NR::L2(dc->vel);
+ gdouble const mag_vel = Geom::L2(dc->vel);
if ( mag_vel < DYNA_EPSILON ) {
return FALSE;
}
- Geom::Point ang2 = NR::rot90(dc->vel) / mag_vel;
+ Geom::Point ang2 = Geom::rot90(dc->vel) / mag_vel;
// 3. Average them using flatness parameter:
// calculate angles
@@ -397,8 +398,8 @@ sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p)
// Try to detect a sudden flip when the new angle differs too much from the previous for the
// current velocity; in that case discard this move
- double angle_delta = NR::L2(Geom::Point (cos (new_ang), sin (new_ang)) - dc->ang);
- if ( angle_delta / NR::L2(dc->vel) > 4000 ) {
+ double angle_delta = Geom::L2(Geom::Point (cos (new_ang), sin (new_ang)) - dc->ang);
+ if ( angle_delta / Geom::L2(dc->vel) > 4000 ) {
return FALSE;
}
@@ -437,8 +438,8 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc)
if (dc->trace_bg) {
// pick single pixel
NRPixBlock pb;
- int x = (int) floor(brush_w[NR::X]);
- int y = (int) floor(brush_w[NR::Y]);
+ int x = (int) floor(brush_w[Geom::X]);
+ int y = (int) floor(brush_w[Geom::Y]);
nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x, y, x+1, y+1, TRUE);
sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(SP_EVENT_CONTEXT(dc)->desktop)), &pb);
const unsigned char *s = NR_PIXBLOCK_PX(&pb);
@@ -453,7 +454,7 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc)
//g_print ("L %g thick %g\n", L, trace_thick);
}
- double width = (pressure_thick * trace_thick - vel_thin * NR::L2(dc->vel)) * dc->width;
+ double width = (pressure_thick * trace_thick - vel_thin * Geom::L2(dc->vel)) * dc->width;
double tremble_left = 0, tremble_right = 0;
if (dc->tremor > 0) {
@@ -473,8 +474,8 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc)
// (2) deflection depends on width, but is upped for small widths for better visual uniformity across widths;
// (3) deflection somewhat depends on speed, to prevent fast strokes looking
// comparatively smooth and slow ones excessively jittery
- tremble_left = (y1)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*NR::L2(dc->vel));
- tremble_right = (y2)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*NR::L2(dc->vel));
+ tremble_left = (y1)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(dc->vel));
+ tremble_right = (y2)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(dc->vel));
}
if ( width < 0.02 * dc->width ) {
@@ -644,11 +645,11 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
// mass recommended; with zero mass, jerks are still quite noticeable).
double speed = 1;
- if (NR::L2(dc->hatch_last_nearest) != 0) {
+ if (Geom::L2(dc->hatch_last_nearest) != 0) {
// the distance nearest moved since the last motion event
- double nearest_moved = NR::L2(nearest - dc->hatch_last_nearest);
+ double nearest_moved = Geom::L2(nearest - dc->hatch_last_nearest);
// the distance pointer moved since the last motion event
- double pointer_moved = NR::L2(pointer - dc->hatch_last_pointer);
+ double pointer_moved = Geom::L2(pointer - dc->hatch_last_pointer);
// store them in stacks limited to SPEED_ELEMENTS
dc->hatch_nearest_past.push_front(nearest_moved);
if (dc->hatch_nearest_past.size() > SPEED_ELEMENTS)
@@ -686,7 +687,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
// summed, to detect if we accidentally flipped to the other side of the
// guide
double dot = NR::dot (pointer - nearest, dc->hatch_vector_accumulated);
- dot /= NR::L2(pointer - nearest) * NR::L2(dc->hatch_vector_accumulated);
+ dot /= Geom::L2(pointer - nearest) * Geom::L2(dc->hatch_vector_accumulated);
if (dc->hatch_spacing != 0) { // spacing was already set
double target;
@@ -769,7 +770,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
} else {
// Not drawing but spacing set: gray, center snapped, fixed radius
Geom::Point c = (nearest + dc->hatch_spacing * hatch_unit_vector) * motion_to_curve.inverse();
- if (!IS_NAN(c[NR::X]) && !IS_NAN(c[NR::Y])) {
+ if (!IS_NAN(c[Geom::X]) && !IS_NAN(c[Geom::Y])) {
NR::Matrix const sm (Geom::Scale(dc->hatch_spacing, dc->hatch_spacing) * Geom::Translate(c));
sp_canvas_item_affine_absolute(dc->hatch_area, sm);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->hatch_area), 0x7f7f7fff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -973,7 +974,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize)
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "tools.calligraphic", false);
+ sp_desktop_apply_style_tool (desktop, repr, "/tools/calligraphic", false);
dc->repr = repr;
@@ -1014,11 +1015,11 @@ add_cap(SPCurve *curve,
Geom::Point const &to,
double rounding)
{
- if (NR::L2( to - from ) > DYNA_EPSILON) {
+ if (Geom::L2( to - from ) > DYNA_EPSILON) {
Geom::Point vel = rounding * NR::rot90( to - from ) / sqrt(2.0);
- double mag = NR::L2(vel);
+ double mag = Geom::L2(vel);
- Geom::Point v = mag * NR::rot90( to - from ) / NR::L2( to - from );
+ Geom::Point v = mag * NR::rot90( to - from ) / Geom::L2( to - from );
curve->curveto(from + v, to + v, to);
}
}
@@ -1195,11 +1196,11 @@ fit_and_split(SPDynaDrawContext *dc, gboolean release)
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
curve->unref();
- guint32 fillColor = sp_desktop_get_color_tool (desktop, "tools.calligraphic", true);
- //guint32 strokeColor = sp_desktop_get_color_tool (desktop, "tools.calligraphic", false);
- double opacity = sp_desktop_get_master_opacity_tool (desktop, "tools.calligraphic");
- double fillOpacity = sp_desktop_get_opacity_tool (desktop, "tools.calligraphic", true);
- //double strokeOpacity = sp_desktop_get_opacity_tool (desktop, "tools.calligraphic", false);
+ guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/calligraphic", true);
+ //guint32 strokeColor = sp_desktop_get_color_tool (desktop, "/tools/calligraphic", false);
+ double opacity = sp_desktop_get_master_opacity_tool (desktop, "/tools/calligraphic");
+ double fillOpacity = sp_desktop_get_opacity_tool (desktop, "/tools/calligraphic", true);
+ //double strokeOpacity = sp_desktop_get_opacity_tool (desktop, "/tools/calligraphic", false);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), ((fillColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*fillOpacity)), SP_WIND_RULE_EVENODD);
//on second thougtht don't do stroke yet because we don't have stoke-width yet and because stoke appears between segments while drawing
//sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), ((strokeColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*strokeOpacity)), 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index d82d7ea89..fab6f4dad 100644
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
@@ -46,7 +46,7 @@
#include "desktop-affine.h"
#include "desktop-style.h"
#include "message-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "pixmaps/cursor-eraser.xpm"
#include "xml/repr.h"
#include "context-fns.h"
@@ -84,7 +84,7 @@ static void sp_eraser_context_init(SPEraserContext *erc);
static void sp_eraser_context_dispose(GObject *object);
static void sp_eraser_context_setup(SPEventContext *ec);
-static void sp_eraser_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_eraser_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_eraser_context_root_handler(SPEventContext *ec, GdkEvent *event);
static void clear_current(SPEraserContext *dc);
@@ -204,7 +204,8 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = {
erc->_message_context = new Inkscape::MessageContext(desktop->messageStack());
- if (prefs_get_int_attribute("tools.eraser", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/eraser/selcue", 0) != 0) {
ec->enableSelectionCue();
}
// TODO temp force:
@@ -213,11 +214,11 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = {
}
static void
-sp_eraser_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_eraser_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
//pass on up to parent class to handle common attributes.
if ( eraser_parent_class->set ) {
- eraser_parent_class->set(ec, key, val);
+ eraser_parent_class->set(ec, val);
}
}
@@ -295,7 +296,7 @@ sp_eraser_apply(SPEraserContext *dc, Geom::Point p)
// This prevents flips, blobs, and jerks caused by microscopic tremor of the tablet pen,
// especially bothersome at the start of the stroke where we don't yet have the inertia to
// smooth them out.
- if ( NR::L2(force) < ERASER_EPSILON || (dc->vel_max < ERASER_VEL_START && NR::L2(force) < ERASER_EPSILON_START)) {
+ if ( Geom::L2(force) < ERASER_EPSILON || (dc->vel_max < ERASER_VEL_START && Geom::L2(force) < ERASER_EPSILON_START)) {
return FALSE;
}
@@ -304,8 +305,8 @@ sp_eraser_apply(SPEraserContext *dc, Geom::Point p)
/* Calculate new velocity */
dc->vel += dc->acc;
- if (NR::L2(dc->vel) > dc->vel_max)
- dc->vel_max = NR::L2(dc->vel);
+ if (Geom::L2(dc->vel) > dc->vel_max)
+ dc->vel_max = Geom::L2(dc->vel);
/* Calculate angle of drawing tool */
@@ -717,7 +718,7 @@ set_to_accumulated(SPEraserContext *dc)
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "tools.eraser", false);
+ sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false);
dc->repr = repr;
@@ -735,7 +736,9 @@ set_to_accumulated(SPEraserContext *dc)
if ( dc->repr ) {
bool wasSelection = false;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- gint eraserMode = (prefs_get_int_attribute("tools.eraser", "mode", 0) != 0) ? 1 : 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr));
@@ -1001,7 +1004,8 @@ fit_and_split(SPEraserContext *dc, gboolean release)
g_print("[%d]Yup\n", dc->npoints);
#endif
if (!release) {
- gint eraserMode = (prefs_get_int_attribute("tools.eraser", "mode", 0) != 0) ? 1 : 0;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
g_assert(!dc->currentcurve->is_empty());
SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop),
@@ -1011,11 +1015,11 @@ fit_and_split(SPEraserContext *dc, gboolean release)
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
curve->unref();
- guint32 fillColor = sp_desktop_get_color_tool (desktop, "tools.eraser", true);
- //guint32 strokeColor = sp_desktop_get_color_tool (desktop, "tools.eraser", false);
- double opacity = sp_desktop_get_master_opacity_tool (desktop, "tools.eraser");
- double fillOpacity = sp_desktop_get_opacity_tool (desktop, "tools.eraser", true);
- //double strokeOpacity = sp_desktop_get_opacity_tool (desktop, "tools.eraser", false);
+ guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/eraser", true);
+ //guint32 strokeColor = sp_desktop_get_color_tool (desktop, "/tools/eraser", false);
+ double opacity = sp_desktop_get_master_opacity_tool (desktop, "/tools/eraser");
+ double fillOpacity = sp_desktop_get_opacity_tool (desktop, "/tools/eraser", true);
+ //double strokeOpacity = sp_desktop_get_opacity_tool (desktop, "/tools/eraser", false);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), ((fillColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*fillOpacity)), SP_WIND_RULE_EVENODD);
//on second thougtht don't do stroke yet because we don't have stoke-width yet and because stoke appears between segments while drawing
//sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), ((strokeColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*strokeOpacity)), 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
diff --git a/src/event-context.cpp b/src/event-context.cpp
index e5f81a2b9..be7b2e033 100644
--- a/src/event-context.cpp
+++ b/src/event-context.cpp
@@ -48,7 +48,7 @@
#include "interface.h"
#include "macros.h"
#include "tools-switch.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "message-context.h"
#include "gradient-drag.h"
#include "object-edit.h"
@@ -166,10 +166,8 @@ sp_event_context_dispose(GObject *object)
ec->desktop = NULL;
}
- if (ec->prefs_repr) {
- sp_repr_remove_listener_by_data(ec->prefs_repr, ec);
- Inkscape::GC::release(ec->prefs_repr);
- ec->prefs_repr = NULL;
+ if (ec->pref_observer) {
+ delete ec->pref_observer;
}
G_OBJECT_CLASS(parent_class)->dispose(object);
@@ -338,17 +336,19 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
static unsigned int zoom_rb = 0;
SPDesktop *desktop = event_context->desktop;
-
- tolerance = prefs_get_int_attribute_limited(
- "options.dragtolerance","value", 0, 0, 100);
- double const zoom_inc = prefs_get_double_attribute_limited(
- "options.zoomincrement", "value", M_SQRT2, 1.01, 10);
- double const acceleration = prefs_get_double_attribute_limited(
- "options.scrollingacceleration", "value", 0, 0, 6);
- int const key_scroll = prefs_get_int_attribute_limited(
- "options.keyscroll", "value", 10, 0, 1000);
- int const wheel_scroll = prefs_get_int_attribute_limited(
- "options.wheelscroll", "value", 40, 0, 1000);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ /// @todo REmove redundant /value in preference keys
+ tolerance = prefs->getIntLimited(
+ "/options/dragtolerance/value", 0, 0, 100);
+ double const zoom_inc = prefs->getDoubleLimited(
+ "/options/zoomincrement/value", M_SQRT2, 1.01, 10);
+ double const acceleration = prefs->getDoubleLimited(
+ "/options/scrollingacceleration/value", 0, 0, 6);
+ int const key_scroll = prefs->getIntLimited(
+ "/options/keyscroll/value", 10, 0, 1000);
+ int const wheel_scroll = prefs->getIntLimited(
+ "/options/wheelscroll/value", 40, 0, 1000);
gint ret = FALSE;
@@ -603,7 +603,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
}
break;
case GDK_space:
- if (prefs_get_int_attribute("options.spacepans","value", 0) == 1) {
+ if (prefs->getBool("/options/spacepans/value")) {
event_context->space_panning = true;
event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, _("<b>Space+mouse drag</b> to pan canvas"));
ret= TRUE;
@@ -652,7 +652,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
case GDK_SCROLL:
{
bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
- bool wheelzooms = (prefs_get_int_attribute("options.wheelzooms","value", 0) == 1);
+ bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
/* shift + wheel, pan left--right */
if (event->scroll.state & GDK_SHIFT_MASK) {
switch (event->scroll.direction) {
@@ -738,34 +738,30 @@ sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, GdkEvent
}
/**
- * Gets called when attribute changes value.
+ * @brief An observer that relays pref changes to the derived classes
*/
-static void
-sp_ec_repr_attr_changed(Inkscape::XML::Node */*prefs_repr*/, gchar const *key, gchar const */*oldval*/, gchar const *newval,
- bool /*is_interactive*/, gpointer data)
-{
- SPEventContext *ec;
-
- ec = SP_EVENT_CONTEXT(data);
-
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, key, newval);
+class ToolPrefObserver : public Inkscape::Preferences::Observer {
+public:
+ ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) :
+ Inkscape::Preferences::Observer(path),
+ _ec(ec) {}
+ virtual void notify(Inkscape::Preferences::Entry const &val)
+ {
+ if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) {
+ ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec,
+ const_cast<Inkscape::Preferences::Entry*>(&val));
+ }
}
-}
-
-Inkscape::XML::NodeEventVector sp_ec_event_vector = {
- NULL, /* Child added */
- NULL, /* Child removed */
- sp_ec_repr_attr_changed,
- NULL, /* Content changed */
- NULL /* Order changed */
+private:
+ SPEventContext * const _ec;
};
/**
* Creates new SPEventContext object and calls its virtual setup() function.
+ * @todo This is bogus. pref_path should be a private property of the inheriting objects.
*/
SPEventContext *
-sp_event_context_new(GType type, SPDesktop *desktop, Inkscape::XML::Node *prefs_repr, unsigned int key)
+sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned int key)
{
g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
g_return_val_if_fail(desktop != NULL, NULL);
@@ -775,10 +771,13 @@ sp_event_context_new(GType type, SPDesktop *desktop, Inkscape::XML::Node *prefs_
ec->desktop = desktop;
ec->_message_context = new Inkscape::MessageContext(desktop->messageStack());
ec->key = key;
- ec->prefs_repr = prefs_repr;
- if (ec->prefs_repr) {
- Inkscape::GC::anchor(ec->prefs_repr);
- sp_repr_add_listener(ec->prefs_repr, &sp_ec_event_vector, ec);
+ ec->pref_observer = NULL;
+
+ if (pref_path) {
+ ec->pref_observer = new ToolPrefObserver(pref_path, ec);
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->addObserver(*(ec->pref_observer));
}
if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup)
@@ -848,10 +847,11 @@ sp_event_context_read(SPEventContext *ec, gchar const *key)
g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
g_return_if_fail(key != NULL);
- if (ec->prefs_repr) {
- gchar const *val = ec->prefs_repr->attribute(key);
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set)
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, key, val);
+ if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Inkscape::Preferences::Entry val = prefs->getEntry(
+ ec->pref_observer->observed_path + '/' + key );
+ ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val);
}
}
diff --git a/src/event-context.h b/src/event-context.h
index fbffc4065..9b464b7fa 100644
--- a/src/event-context.h
+++ b/src/event-context.h
@@ -21,7 +21,8 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkevents.h>
-#include <2geom/forward.h>
+#include "2geom/forward.h"
+#include "preferences.h"
struct GrDrag;
struct SPDesktop;
@@ -48,7 +49,7 @@ struct SPEventContext : public GObject {
SPEventContext *next;
unsigned key;
SPDesktop *desktop;
- Inkscape::XML::Node *prefs_repr;
+ Inkscape::Preferences::Observer *pref_observer;
gchar const *const *cursor_shape;
gint hot_x, hot_y; ///< indicates the cursor's hot spot
GdkCursor *cursor;
@@ -83,7 +84,7 @@ struct SPEventContext : public GObject {
struct SPEventContextClass : public GObjectClass {
void (* setup)(SPEventContext *ec);
void (* finish)(SPEventContext *ec);
- void (* set)(SPEventContext *ec, gchar const *key, gchar const *val);
+ void (* set)(SPEventContext *ec, Inkscape::Preferences::Entry *val);
void (* activate)(SPEventContext *ec);
void (* deactivate)(SPEventContext *ec);
gint (* root_handler)(SPEventContext *ec, GdkEvent *event);
@@ -95,7 +96,7 @@ struct SPEventContextClass : public GObjectClass {
#define SP_EVENT_CONTEXT_STATIC 0
-SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, Inkscape::XML::Node *prefs_repr, unsigned key);
+SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned key);
void sp_event_context_finish(SPEventContext *ec);
void sp_event_context_read(SPEventContext *ec, gchar const *key);
void sp_event_context_activate(SPEventContext *ec);
diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp
index ec2878f5d..7e40522b3 100644
--- a/src/extension/error-file.cpp
+++ b/src/extension/error-file.cpp
@@ -16,7 +16,7 @@
#include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "dialogs/extensions.h"
#include "extension/extension.h"
@@ -24,7 +24,7 @@
/** The name and group of the preference to say whether the error
dialog should be shown on startup. */
-#define PREFERENCE_ID "dialogs.extension-error", "show-on-startup"
+#define PREFERENCE_ID "/dialogs/extension-error/show-on-startup"
namespace Inkscape {
namespace Extension {
@@ -59,10 +59,11 @@ ErrorFileNotice::ErrorFileNotice (void) :
Gtk::VBox * vbox = get_vbox();
/* This is some filler text, needs to change before relase */
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
checkbutton = Gtk::manage(new Gtk::CheckButton(_("Show dialog on startup")));
vbox->pack_start(*checkbutton, true, false, 5);
checkbutton->show();
- checkbutton->set_active(prefs_get_int_attribute(PREFERENCE_ID, 1) == 0 ? false : true);
+ checkbutton->set_active(prefs->getBool(PREFERENCE_ID, true));
checkbutton->signal_toggled().connect(sigc::mem_fun(this, &ErrorFileNotice::checkbox_toggle));
@@ -81,7 +82,8 @@ void
ErrorFileNotice::checkbox_toggle (void)
{
// std::cout << "Toggle value" << std::endl;
- prefs_set_int_attribute(PREFERENCE_ID, checkbutton->get_active() ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(PREFERENCE_ID, checkbutton->get_active());
}
/** \brief Shows the dialog
@@ -92,7 +94,8 @@ ErrorFileNotice::checkbox_toggle (void)
int
ErrorFileNotice::run (void)
{
- if (prefs_get_int_attribute(PREFERENCE_ID, 1) == 0)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (!prefs->getBool(PREFERENCE_ID, true))
return 0;
return Gtk::Dialog::run();
}
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 9475b4796..fc94205b6 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -120,7 +120,7 @@ Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg)
// 1. Check preferences
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring prefInterp = prefs->getString("extensions", interp->prefstring);
+ Glib::ustring prefInterp = prefs->getString("/extensions/" + Glib::ustring(interp->prefstring));
if (!prefInterp.empty()) {
interpName = prefInterp;
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 9a5aea86c..afacbed63 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -19,6 +19,7 @@
#include "inkscape.h"
+#include <glibmm/ustring.h>
#include <glibmm/i18n.h>
#include "system.h"
@@ -118,17 +119,16 @@ static void check_extensions();
* \brief Examines the given string preference and checks to see
* that at least one of the registered extensions matches
* it. If not, a default is assigned.
- * \param pref_path Preference path to load
- * \param pref_attr Attribute to load from the preference
+ * \param pref_path Preference path to update
* \param pref_default Default string to set
* \param extension_family List of extensions to search
*/
static void
-update_pref(gchar const *pref_path, gchar const *pref_attr,
+update_pref(Glib::ustring const &pref_path,
gchar const *pref_default) // , GSList *extension_family)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring pref = prefs->getString(pref_path, pref_attr);
+ Glib::ustring pref = prefs->getString(pref_path);
/*
gboolean missing=TRUE;
for (GSList *list = extension_family; list; list = g_slist_next(list)) {
@@ -141,7 +141,7 @@ update_pref(gchar const *pref_path, gchar const *pref_attr,
}
*/
if (!Inkscape::Extension::db.get( pref.data() ) /*missing*/) {
- prefs->setString(pref_path, pref_attr, pref_default);
+ prefs->setString(pref_path, pref_default);
}
}
@@ -164,7 +164,7 @@ init()
//Internal::EpsOutput::init(); // disabled, to be deleted, replaced by CairoEpsOutput
Internal::PrintPS::init();
#ifdef HAVE_CAIRO_PDF
- if (prefs->getInt("options.useoldpdfexporter", "value", 1) == 1) {
+ if (prefs->getBool("/options/useoldpdfexporter/value")) {
//g_print ("Using CairoPdfOutput: old pdf exporter\n");
Internal::CairoPdfOutput::init();
Internal::PrintCairoPDF::init();
@@ -268,7 +268,7 @@ init()
/* This is a hack to deal with updating saved outdated module
* names in the prefs...
*/
- update_pref("dialogs.save_as", "default",
+ update_pref("/dialogs/save_as/default",
SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE
// Inkscape::Extension::db.get_output_list()
);
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index 80454f9ed..e32012070 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -16,7 +16,7 @@
#include "desktop.h"
#include "selection.h"
#include "helper/action.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "path-chemistry.h"
#include "sp-item.h"
@@ -58,7 +58,8 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
float width = module->get_param_float("blur-width");
int steps = module->get_param_int("num-steps");
- double old_offset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
using Inkscape::Util::GSListConstIterator;
// TODO need to properly refcount the items, at least
@@ -96,10 +97,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
if (offset < 0.0) {
/* Doing an inset here folks */
offset *= -1.0;
- prefs_set_double_attribute("options.defaultoffsetwidth", "value", offset);
+ prefs->setDouble("/options/defaultoffsetwidth/value", offset);
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL);
} else if (offset > 0.0) {
- prefs_set_double_attribute("options.defaultoffsetwidth", "value", offset);
+ prefs->setDouble("/options/defaultoffsetwidth/value", offset);
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL);
}
@@ -109,7 +110,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
Inkscape::GC::release(new_group);
}
- prefs_set_double_attribute("options.defaultoffsetwidth", "value", old_offset);
+ prefs->setDouble("/options/defaultoffsetwidth/value", old_offset);
selection->clear();
selection->add(items.begin(), items.end());
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index fba0ab571..01afec0fc 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -61,23 +61,35 @@ CairoEpsOutput::check (Inkscape::Extension::Extension * module)
}
static bool
-ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap, int resolution, bool eps = false)
+ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false)
{
- CairoRenderer *renderer;
- CairoRenderContext *ctx;
-
sp_document_ensure_up_to_date(doc);
-/* Start */
+ SPItem *base = NULL;
+
+ bool pageBoundingBox = TRUE;
+ if (exportId && strcmp(exportId, "")) {
+ // we want to export the given item only
+ base = SP_ITEM(doc->getObjectById(exportId));
+ pageBoundingBox = exportCanvas;
+ }
+ else {
+ // we want to export the entire document from root
+ base = SP_ITEM(sp_document_root(doc));
+ pageBoundingBox = !exportDrawing;
+ }
+
+ if (!base)
+ return false;
+
/* Create new arena */
- SPItem *base = SP_ITEM(sp_document_root(doc));
NRArena *arena = NRArena::create();
unsigned dkey = sp_item_display_key_new(1);
- NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
- renderer = new CairoRenderer();
- ctx = renderer->createContext();
+ CairoRenderer *renderer = new CairoRenderer();
+ CairoRenderContext *ctx = renderer->createContext();
ctx->setPSLevel(level);
ctx->setEPS(eps);
ctx->setTextToPath(texttopath);
@@ -87,22 +99,21 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
bool ret = ctx->setPsTarget(filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, TRUE, NULL);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
}
}
- renderer->destroyContext(ctx);
/* Release arena */
sp_item_invoke_hide(base, dkey);
nr_object_unref((NRObject *) arena);
-/* end */
+
+ renderer->destroyContext(ctx);
delete renderer;
return ret;
-
}
@@ -122,89 +133,51 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc
if (ext == NULL)
return;
- const gchar *old_level = NULL;
const gchar *new_level = NULL;
- int level = 1;
+ int level = CAIRO_PS_LEVEL_2;
try {
- old_level = ext->get_param_enum("PSlevel");
new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && (g_ascii_strcasecmp("PS2", new_level) == 0))
- level = 0;
-// ext->set_param_enum("PSlevel", new_level);
- }
- catch(...) {
- g_warning("Parameter <PSlevel> might not exists");
- }
+ if((new_level != NULL) && !(g_ascii_strcasecmp("PS3", new_level) == 0))
+ level = CAIRO_PS_LEVEL_3;
+ } catch(...) {}
- bool old_textToPath = FALSE;
bool new_textToPath = FALSE;
try {
- old_textToPath = ext->get_param_bool("textToPath");
new_textToPath = mod->get_param_bool("textToPath");
- ext->set_param_bool("textToPath", new_textToPath);
- }
- catch(...) {
- g_warning("Parameter <textToPath> might not exists");
- }
+ } catch(...) {}
- bool old_blurToBitmap = FALSE;
bool new_blurToBitmap = FALSE;
try {
- old_blurToBitmap = ext->get_param_bool("blurToBitmap");
new_blurToBitmap = mod->get_param_bool("blurToBitmap");
- ext->set_param_bool("blurToBitmap", new_blurToBitmap);
- }
- catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
- }
+ } catch(...) {}
- int old_bitmapResolution = 72;
int new_bitmapResolution = 72;
try {
- old_bitmapResolution = ext->get_param_int("resolution");
new_bitmapResolution = mod->get_param_int("resolution");
- ext->set_param_int("resolution", new_bitmapResolution);
- }
- catch(...) {
- g_warning("Parameter <resolution> might not exists");
- }
-
- gchar * final_name;
- final_name = g_strdup_printf("> %s", uri);
- ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution);
- g_free(final_name);
+ } catch(...) {}
+ bool new_areaCanvas = true;
try {
- ext->set_param_int("resolution", old_bitmapResolution);
- }
- catch(...) {
- g_warning("Parameter <resolution> might not exists");
- }
- try {
- ext->set_param_bool("blurToBitmap", old_blurToBitmap);
- }
- catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
- }
+ new_areaCanvas = mod->get_param_bool("areaCanvas");
+ } catch(...) {}
+
+ bool new_areaDrawing = true;
try {
- ext->set_param_bool("textToPath", old_textToPath);
- }
- catch(...) {
- g_warning("Parameter <textToPath> might not exists");
- }
+ new_areaDrawing = mod->get_param_bool("areaDrawing");
+ } catch(...) {}
+
+ const gchar *new_exportId = NULL;
try {
-// ext->set_param_enum("PSlevel", old_level);
- }
- catch(...) {
- g_warning("Parameter <PSlevel> might not exists");
- }
+ new_exportId = mod->get_param_string("exportId");
+ } catch(...) {}
+ gchar * final_name;
+ final_name = g_strdup_printf("> %s", uri);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas);
+ g_free(final_name);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
-
- return;
-
}
@@ -224,89 +197,51 @@ CairoEpsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
if (ext == NULL)
return;
- const gchar *old_level = NULL;
const gchar *new_level = NULL;
- int level = 1;
+ int level = CAIRO_PS_LEVEL_2;
try {
- old_level = ext->get_param_enum("PSlevel");
new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && (g_ascii_strcasecmp("PS2", new_level) == 0))
- level = 0;
-// ext->set_param_enum("PSlevel", new_level);
- }
- catch(...) {
- g_warning("Parameter <PSlevel> might not exists");
- }
+ if((new_level != NULL) && !(g_ascii_strcasecmp("PS3", new_level) == 0))
+ level = CAIRO_PS_LEVEL_3;
+ } catch(...) {}
- bool old_textToPath = FALSE;
bool new_textToPath = FALSE;
try {
- old_textToPath = ext->get_param_bool("textToPath");
new_textToPath = mod->get_param_bool("textToPath");
- ext->set_param_bool("textToPath", new_textToPath);
- }
- catch(...) {
- g_warning("Parameter <textToPath> might not exists");
- }
+ } catch(...) {}
- bool old_blurToBitmap = FALSE;
bool new_blurToBitmap = FALSE;
try {
- old_blurToBitmap = ext->get_param_bool("blurToBitmap");
new_blurToBitmap = mod->get_param_bool("blurToBitmap");
- ext->set_param_bool("blurToBitmap", new_blurToBitmap);
- }
- catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
- }
+ } catch(...) {}
- int old_bitmapResolution = 72;
int new_bitmapResolution = 72;
try {
- old_bitmapResolution = ext->get_param_int("resolution");
new_bitmapResolution = mod->get_param_int("resolution");
- ext->set_param_int("resolution", new_bitmapResolution);
- }
- catch(...) {
- g_warning("Parameter <resolution> might not exists");
- }
-
- gchar * final_name;
- final_name = g_strdup_printf("> %s", uri);
- ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, true);
- g_free(final_name);
+ } catch(...) {}
+ bool new_areaCanvas = true;
try {
- ext->set_param_int("resolution", old_bitmapResolution);
- }
- catch(...) {
- g_warning("Parameter <resolution> might not exists");
- }
- try {
- ext->set_param_bool("blurToBitmap", old_blurToBitmap);
- }
- catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
- }
+ new_areaCanvas = mod->get_param_bool("areaCanvas");
+ } catch(...) {}
+
+ bool new_areaDrawing = true;
try {
- ext->set_param_bool("textToPath", old_textToPath);
- }
- catch(...) {
- g_warning("Parameter <textToPath> might not exists");
- }
+ new_areaDrawing = mod->get_param_bool("areaDrawing");
+ } catch(...) {}
+
+ const gchar *new_exportId = NULL;
try {
-// ext->set_param_enum("PSlevel", old_level);
- }
- catch(...) {
- g_warning("Parameter <PSlevel> might not exists");
- }
+ new_exportId = mod->get_param_string("exportId");
+ } catch(...) {}
+ gchar * final_name;
+ final_name = g_strdup_printf("> %s", uri);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas, true);
+ g_free(final_name);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
-
- return;
-
}
@@ -344,9 +279,12 @@ CairoPsOutput::init (void)
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
+ "<param name=\"areaCanvas\" gui-text=\"" N_("Export area is whole canvas") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is the drawing") "\" type=\"boolean\">true</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert blur effects to bitmaps") "\" type=\"boolean\">false</param>\n"
"<param name=\"resolution\" gui-text=\"" N_("Preferred resolution (DPI) of bitmaps") "\" type=\"int\" min=\"72\" max=\"2400\">90</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.ps</extension>\n"
"<mimetype>image/x-postscript</mimetype>\n"
@@ -378,9 +316,12 @@ CairoEpsOutput::init (void)
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
+ "<param name=\"areaCanvas\" gui-text=\"" N_("Export area is whole canvas") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is the drawing") "\" type=\"boolean\">true</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert blur effects to bitmaps") "\" type=\"boolean\">false</param>\n"
"<param name=\"resolution\" gui-text=\"" N_("Preferred resolution (DPI) of bitmaps") "\" type=\"int\" min=\"72\" max=\"2400\">90</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.eps</extension>\n"
"<mimetype>image/x-e-postscript</mimetype>\n"
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 4e6c74dff..c82cc7611 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -75,7 +75,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
/* Create new arena */
NRArena *arena = NRArena::create();
unsigned dkey = sp_item_display_key_new(1);
- NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
@@ -98,7 +98,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
/* Release arena */
sp_item_invoke_hide(base, dkey);
nr_object_unref((NRObject *) arena);
-/* end */
+
renderer->destroyContext(ctx);
delete renderer;
@@ -134,7 +134,7 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
// level = 1;
}
catch(...) {
-// g_warning("Parameter <PDFversion> might not exists");
+// g_warning("Parameter <PDFversion> might not exist");
}
bool new_textToPath = FALSE;
@@ -142,7 +142,7 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
new_textToPath = mod->get_param_bool("textToPath");
}
catch(...) {
- g_warning("Parameter <textToPath> might not exists");
+ g_warning("Parameter <textToPath> might not exist");
}
bool new_blurToBitmap = FALSE;
@@ -150,7 +150,7 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
new_blurToBitmap = mod->get_param_bool("blurToBitmap");
}
catch(...) {
- g_warning("Parameter <blurToBitmap> might not exists");
+ g_warning("Parameter <blurToBitmap> might not exist");
}
int new_bitmapResolution = 72;
@@ -158,7 +158,7 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
new_bitmapResolution = mod->get_param_int("resolution");
}
catch(...) {
- g_warning("Parameter <resolution> might not exists");
+ g_warning("Parameter <resolution> might not exist");
}
const gchar *new_exportId = NULL;
@@ -166,23 +166,23 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
new_exportId = mod->get_param_string("exportId");
}
catch(...) {
- g_warning("Parameter <exportId> might not exists");
+ g_warning("Parameter <exportId> might not exist");
}
bool new_exportDrawing = FALSE;
try {
- new_exportDrawing = mod->get_param_bool("exportDrawing");
+ new_exportDrawing = mod->get_param_bool("areaDrawing");
}
catch(...) {
- g_warning("Parameter <exportDrawing> might not exists");
+ g_warning("Parameter <areaDrawing> might not exist");
}
bool new_exportCanvas = FALSE;
try {
- new_exportCanvas = mod->get_param_bool("exportCanvas");
+ new_exportCanvas = mod->get_param_bool("areaCanvas");
}
catch(...) {
- g_warning("Parameter <exportCanvas> might not exists");
+ g_warning("Parameter <exportCanvas> might not exist");
}
gchar * final_name;
@@ -194,8 +194,6 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
if (!ret)
throw Inkscape::Extension::Output::save_failed();
-
- return;
}
#include "clear-n_.h"
@@ -220,8 +218,8 @@ CairoRendererPdfOutput::init (void)
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert filter effects to bitmaps") "\" type=\"boolean\">false</param>\n"
"<param name=\"resolution\" gui-text=\"" N_("Preferred resolution (DPI) of bitmaps") "\" type=\"int\" min=\"72\" max=\"2400\">90</param>\n"
- "<param name=\"exportDrawing\" gui-text=\"" N_("Export drawing, not page") "\" type=\"boolean\">false</param>\n"
- "<param name=\"exportCanvas\" gui-text=\"" N_("Export canvas") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"areaDrawing\" gui-text=\"" N_("Export drawing, not page") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"areaCanvas\" gui-text=\"" N_("Export canvas") "\" type=\"boolean\">false</param>\n"
"<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.pdf</extension>\n"
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 07d799b0f..86e04fb54 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -180,7 +180,12 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START]));
- Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front()));
+ Geom::Matrix tr;
+ if (marker->orient_auto) {
+ tr = sp_shape_marker_get_transform_at_start(path_it->front());
+ } else {
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(path_it->front().pointAt(0));
+ }
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(style->stroke_width.computed) * tr;
@@ -206,7 +211,12 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID]));
- Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
+ Geom::Matrix tr;
+ if (marker->orient_auto) {
+ tr = sp_shape_marker_get_transform(*curve_it1, *curve_it2);
+ } else {
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(curve_it1->pointAt(1));
+ }
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(style->stroke_width.computed) * tr;
@@ -236,7 +246,12 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
}
Geom::Curve const &lastcurve = (*path_it)[index];
- Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ Geom::Matrix tr;
+ if (marker->orient_auto) {
+ tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ } else {
+ tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1));
+ }
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(style->stroke_width.computed) * tr;
@@ -557,42 +572,42 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
{
g_assert( ctx != NULL );
- if (ctx->_vector_based_target) {
- // width and height in pt
- ctx->_width = sp_document_width(doc) * PT_PER_PX;
- ctx->_height = sp_document_height(doc) * PT_PER_PX;
- } else {
- ctx->_width = sp_document_width(doc);
- ctx->_height = sp_document_height(doc);
- }
+ if (!base)
+ base = SP_ITEM(sp_document_root(doc));
NRRect d;
- if (pageBoundingBox || !base) {
+ if (pageBoundingBox) {
d.x0 = d.y0 = 0;
- d.x1 = ceil(ctx->_width);
- d.y1 = ceil(ctx->_height);
+ d.x1 = ceil(sp_document_width(doc));
+ d.y1 = ceil(sp_document_height(doc));
} else {
- sp_item_invoke_bbox(base, &d, sp_item_i2r_affine(base), TRUE);
- if (ctx->_vector_based_target) {
- // convert from px to pt
- d.x0 *= PT_PER_PX;
- d.x1 *= PT_PER_PX;
- d.y0 *= PT_PER_PX;
- d.y1 *= PT_PER_PX;
- }
+ sp_item_invoke_bbox(base, &d, sp_item_i2r_affine(base), TRUE, SPItem::RENDERING_BBOX);
}
+
+ if (ctx->_vector_based_target) {
+ // convert from px to pt
+ d.x0 *= PT_PER_PX;
+ d.x1 *= PT_PER_PX;
+ d.y0 *= PT_PER_PX;
+ d.y1 *= PT_PER_PX;
+ }
+
+ ctx->_width = d.x1-d.x0;
+ ctx->_height = d.y1-d.y0;
+
TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height));
- bool ret = ctx->setupSurface(d.x1-d.x0, d.y1-d.y0);
+ bool ret = ctx->setupSurface(ctx->_width, ctx->_height);
- if (ret && !pageBoundingBox && base)
+ if (ret && !pageBoundingBox)
{
+ double high = sp_document_height(doc);
+ if (ctx->_vector_based_target)
+ high *= PT_PER_PX;
+
Geom::Matrix tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.y1 - ctx->_height) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
ctx->transform(&tp);
-
- ctx->_width = d.x1 - d.x0;
- ctx->_height = d.y1 - d.y0;
}
return ret;
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 14effbeb7..e8af0ec9d 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -3,7 +3,6 @@
#endif
#include "document-private.h"
#include <dir-util.h>
-#include "prefs-utils.h"
#include "extension/system.h"
#include "gdkpixbuf-input.h"
#include "selection-chemistry.h"
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index e28264eff..f58e37173 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -1210,7 +1210,9 @@ void SvgBuilder::_flushText() {
last_delta_pos = delta_pos;
// Append the character to the text buffer
- text_buffer.append((char *)&glyph.code, 1);
+ if (0 != glyph.code[0]) {
+ text_buffer.append((char *)&glyph.code, 1);
+ }
glyphs_in_a_row++;
i++;
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index ab90ddaf9..1dda3d73f 100644
--- a/src/extension/param/bool.cpp
+++ b/src/extension/param/bool.cpp
@@ -13,10 +13,10 @@
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
-#include <xml/node.h>
-
+#include "xml/node.h"
#include "../extension.h"
#include "bool.h"
+#include "preferences.h"
namespace Inkscape {
namespace Extension {
@@ -36,7 +36,8 @@ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * d
}
gchar * pref_name = this->pref_name();
- _value = (bool)prefs_get_int_attribute(PREF_DIR, pref_name, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _value = prefs->getBool(extension_pref_root + pref_name, _value);
g_free(pref_name);
return;
@@ -57,7 +58,8 @@ ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ )
_value = in;
gchar * prefname = this->pref_name();
- prefs_set_int_attribute(PREF_DIR, prefname, _value == true ? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(extension_pref_root + prefname, _value);
g_free(prefname);
return _value;
@@ -150,3 +152,14 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa
} /* namespace Extension */
} /* namespace Inkscape */
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 555461bc7..58db85748 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -50,7 +50,7 @@ ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*
string(value);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(PREF_DIR, prefname, value);
+ prefs->setString(extension_pref_root + prefname, value);
g_free(prefname);
return _value;
@@ -66,7 +66,7 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar *
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
+ Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
if (!paramval.empty())
diff --git a/src/extension/param/color.h b/src/extension/param/color.h
index 6836442a1..e6b44fbcb 100644
--- a/src/extension/param/color.h
+++ b/src/extension/param/color.h
@@ -8,10 +8,10 @@
*/
#include <gtkmm/widget.h>
-#include <xml/node.h>
-#include <document.h>
+#include "xml/node.h"
+#include "document.h"
#include <color.h>
-#include "parameter.h"
+#include "extension/param/parameter.h"
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp
index 61bfa9f5a..656e58c49 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -20,14 +20,10 @@
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
#include <sstream>
-
-
#include <glibmm/i18n.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
-#include <prefs-utils.h>
+#include "xml/node.h"
+#include "extension/extension.h"
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 33c153434..9d324a47c 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -22,23 +22,15 @@
#include <gtkmm/comboboxtext.h>
#include <gtkmm/tooltips.h>
#include <gtkmm/label.h>
-
#include <glibmm/i18n.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
-#include <prefs-utils.h>
-#include <document-private.h>
-#include <sp-object.h>
-
+#include "xml/node.h"
+#include "extension/extension.h"
+#include "document-private.h"
+#include "sp-object.h"
#include "enum.h"
#include "preferences.h"
-/** \brief The root directory in the preferences database for extension
- related parameters. */
-#define PREF_DIR "extensions"
-
namespace Inkscape {
namespace Extension {
@@ -106,7 +98,7 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
+ Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
if (!paramval.empty())
@@ -160,7 +152,7 @@ ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(PREF_DIR, prefname, _value);
+ prefs->setString(extension_pref_root + prefname, _value);
g_free(prefname);
}
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 1225648d6..40cb81ddd 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -13,9 +13,9 @@
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
+#include "xml/node.h"
+#include "extension/extension.h"
+#include "preferences.h"
#include "float.h"
namespace Inkscape {
@@ -53,7 +53,8 @@ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar *
}
gchar * pref_name = this->pref_name();
- _value = prefs_get_double_attribute(PREF_DIR, pref_name, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _value = prefs->getDouble(extension_pref_root + pref_name, _value);
g_free(pref_name);
// std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl;
@@ -81,7 +82,8 @@ ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
if (_value < _min) _value = _min;
gchar * prefname = this->pref_name();
- prefs_set_double_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(extension_pref_root + prefname, _value);
g_free(prefname);
return _value;
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index dc523435e..db7f9c67b 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -13,9 +13,9 @@
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
+#include "xml/node.h"
+#include "extension/extension.h"
+#include "preferences.h"
#include "int.h"
namespace Inkscape {
@@ -47,8 +47,9 @@ ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * des
_min = 0;
}
- gchar * pref_name = this->pref_name();
- _value = prefs_get_int_attribute(PREF_DIR, pref_name, _value);
+ gchar *pref_name = this->pref_name();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _value = prefs->getInt(extension_pref_root + pref_name, _value);
g_free(pref_name);
// std::cout << "New Int:: value: " << _value << " max: " << _max << " min: " << _min << std::endl;
@@ -76,7 +77,8 @@ ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
if (_value < _min) _value = _min;
gchar * prefname = this->pref_name();
- prefs_set_int_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(extension_pref_root + prefname, _value);
g_free(prefname);
return _value;
@@ -157,3 +159,14 @@ ParamInt::string (std::string &string)
} /* namespace Extension */
} /* namespace Inkscape */
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index bce6bc3d0..1c30b7e0e 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -223,13 +223,6 @@ ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sig
}
-
-
-
-
-
-
-
ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
{
@@ -264,7 +257,7 @@ ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const g
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
+ Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
if (!paramval.empty())
@@ -317,7 +310,8 @@ ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*
_value = g_strdup(page->name());
gchar * prefname = this->pref_name();
- prefs_set_string_attribute(PREF_DIR, prefname, _value);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString(extension_pref_root + prefname, _value);
g_free(prefname);
return _value;
@@ -434,4 +428,4 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp
index 5f434e5e1..2773af61d 100644
--- a/src/extension/param/parameter.cpp
+++ b/src/extension/param/parameter.cpp
@@ -1,9 +1,7 @@
-/** \file
- * Parameters for extensions.
+/** @file
+ * @brief Parameters for extensions.
*/
-
-/*
- * Author:
+/* Author:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
*
@@ -386,6 +384,8 @@ Parameter::string (std::list <std::string> &list)
return;
}
+Glib::ustring const extension_pref_root = "/extensions/";
+
} /* namespace Extension */
} /* namespace Inkscape */
@@ -398,4 +398,4 @@ Parameter::string (std::list <std::string> &list)
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index 1aeafbd7c..54249c12e 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -1,12 +1,7 @@
-#ifndef __INK_EXTENSION_PARAM_H__
-#define __INK_EXTENSION_PARAM_H__
-
-/** \file
- * Parameters for extensions.
+/** @file
+ * @brief Parameters for extensions.
*/
-
-/*
- * Authors:
+/* Authors:
* Ted Gould <ted@gould.cx>
*
* Copyright (C) 2005-2006 Authors
@@ -14,24 +9,29 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-/** \brief The root directory in the preferences database for extension-related parameters. */
-#define PREF_DIR "extensions"
+#ifndef SEEN_INK_EXTENSION_PARAM_H__
+#define SEEN_INK_EXTENSION_PARAM_H__
#include <gtkmm/widget.h>
+#include <glibmm/i18n.h>
#include "xml/document.h"
#include "xml/node.h"
#include "document.h"
-#include <extension/extension-forward.h>
-#include "prefs-utils.h"
-
-#include <glibmm/i18n.h>
-
+#include "extension/extension-forward.h"
#include <color.h>
namespace Inkscape {
namespace Extension {
+/**
+ * @brief The root directory in the preferences database for extension-related parameters
+ *
+ * The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works
+ * without having to append a separator.
+ */
+extern Glib::ustring const extension_pref_root;
+
/** \brief A class to represent the parameter of an extension
This is really a super class that allows them to abstract all
@@ -132,4 +132,4 @@ public:
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index c05191b58..1e4ba3c8f 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -25,12 +25,10 @@
#include <gtkmm/radiobuttongroup.h>
#include <gtkmm/tooltips.h>
#include <gtkmm/label.h>
-
#include <glibmm/i18n.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
+#include "xml/node.h"
+#include "extension/extension.h"
#include "preferences.h"
#include "document-private.h"
#include "sp-object.h"
@@ -113,7 +111,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
+ Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
if (!paramval.empty())
@@ -167,7 +165,7 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(PREF_DIR, prefname, _value);
+ prefs->setString(extension_pref_root + prefname, _value);
g_free(prefname);
}
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index 56ceeaad5..e32224332 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -13,9 +13,8 @@
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
-#include <xml/node.h>
-
-#include <extension/extension.h>
+#include "xml/node.h"
+#include "extension/extension.h"
#include "string.h"
#include "preferences.h"
@@ -53,7 +52,7 @@ ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node *
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(PREF_DIR, prefname, _value);
+ prefs->setString(extension_pref_root + prefname, _value);
g_free(prefname);
return _value;
@@ -80,7 +79,7 @@ ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring paramval = prefs->getString(PREF_DIR, pref_name);
+ Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
if (!paramval.empty())
diff --git a/src/file.cpp b/src/file.cpp
index b2f53b967..d5700bb6e 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -18,8 +18,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-/**
- * Note: This file needs to be cleaned up extensively.
+/** @file
+ * @note This file needs to be cleaned up extensively.
* What it probably needs is to have one .h file for
* the API, and two or more .cpp files for the implementations.
*/
@@ -28,6 +28,7 @@
# include "config.h"
#endif
+#include <gtk/gtk.h>
#include <glib/gmem.h>
#include <libnr/nr-pixops.h>
@@ -90,6 +91,17 @@
void dump_str(gchar const *str, gchar const *prefix);
void dump_ustr(Glib::ustring const &ustr);
+// what gets passed here is not actually an URI... it is an UTF-8 encoded filename (!)
+static void sp_file_add_recent(gchar const *uri)
+{
+ GtkRecentManager *recent = gtk_recent_manager_get_default();
+ gchar *fn = g_filename_from_utf8(uri, -1, NULL, NULL, NULL);
+ gchar *uri_to_add = g_filename_to_uri(fn, NULL, NULL);
+ gtk_recent_manager_add_item(recent, uri_to_add);
+ g_free(uri_to_add);
+ g_free(fn);
+}
+
/*######################
## N E W
@@ -219,7 +231,7 @@ sp_file_open(const Glib::ustring &uri,
sp_namedview_update_layers_from_document(desktop);
if (add_to_recent) {
- prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
+ sp_file_add_recent(SP_DOCUMENT_URI(doc));
}
return TRUE;
@@ -386,7 +398,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
if(open_path.empty())
{
- Glib::ustring attr = prefs->getString("dialogs.open", "path");
+ Glib::ustring attr = prefs->getString("/dialogs/open/path");
if (!attr.empty()) open_path = attr;
}
@@ -498,7 +510,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
open_path = Glib::path_get_dirname (fileName);
open_path.append(G_DIR_SEPARATOR_S);
- prefs->setString("dialogs.open", "path", open_path);
+ prefs->setString("/dialogs/open/path", open_path);
sp_file_open(fileName, selection);
}
@@ -689,7 +701,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, bool is_copy)
Glib::ustring default_extension;
char *attr = (char *)repr->attribute("inkscape:output_extension");
if (!attr) {
- Glib::ustring attr2 = prefs->getString("dialogs.save_as", "default");
+ Glib::ustring attr2 = prefs->getString("/dialogs/save_as/default");
if(!attr2.empty()) default_extension = attr2;
} else {
default_extension = attr;
@@ -710,7 +722,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, bool is_copy)
if (extension)
filename_extension = extension->get_extension();
- Glib::ustring attr3 = prefs->getString("dialogs.save_as", "path");
+ Glib::ustring attr3 = prefs->getString("/dialogs/save_as/path");
if (!attr3.empty())
save_path = attr3;
@@ -793,12 +805,13 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, bool is_copy)
success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy);
- if (success)
- prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
+ if (success) {
+ sp_file_add_recent(SP_DOCUMENT_URI(doc));
+ }
save_path = Glib::path_get_dirname(fileName);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("dialogs.save_as", "path", save_path);
+ prefs->setString("/dialogs/save_as/path", save_path);
return success;
}
@@ -987,15 +1000,15 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// object" option.
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool const saved_pref = prefs->getBool("options.transform", "pattern", true);
- prefs->setBool("options.transform", "pattern", true);
+ bool const saved_pref = prefs->getBool("/options/transform/pattern", true);
+ prefs->setBool("/options/transform/pattern", true);
sp_document_ensure_up_to_date(sp_desktop_document(desktop));
boost::optional<Geom::Rect> sel_bbox = selection->bounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
sp_selection_move_relative(selection, m);
}
- prefs->setBool("options.transform", "pattern", saved_pref);
+ prefs->setBool("/options/transform/pattern", saved_pref);
}
}
@@ -1100,7 +1113,7 @@ sp_file_export_dialog(void *widget)
Glib::ustring default_extension;
char *attr = (char *)repr->attribute("inkscape:output_extension");
if (!attr) {
- Glib::ustring attr2 = prefs->getString("dialogs.save_as", "default");
+ Glib::ustring attr2 = prefs->getString("/dialogs/save_as/default");
if(!attr2.empty()) default_extension = attr2;
} else {
default_extension = attr;
@@ -1118,7 +1131,7 @@ sp_file_export_dialog(void *widget)
if (extension)
filename_extension = extension->get_extension();
- Glib::ustring attr3 = prefs->getString("dialogs.save_as", "path");
+ Glib::ustring attr3 = prefs->getString("/dialogs/save_as/path");
if (!attr3.empty())
export_path = attr3;
@@ -1177,11 +1190,13 @@ sp_file_export_dialog(void *widget)
success = file_save(doc, fileName, selectionType, TRUE, FALSE);
- if (success)
- prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
+ if (success) {
+ Glib::RefPtr<Gtk::RecentManager> recent = Gtk::RecentManager::get_default();
+ recent->add_item(SP_DOCUMENT_URI(doc));
+ }
export_path = fileName;
- prefs->setString("dialogs.save_as", "path", export_path);
+ prefs->setString("/dialogs/save_as/path", export_path);
return success;
}
@@ -1301,8 +1316,8 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
// Create the uri
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring uri = "dav://";
- Glib::ustring username = prefs->getString("options.ocalusername", "str");
- Glib::ustring password = prefs->getString("options.ocalpassword", "str");
+ Glib::ustring username = prefs->getString("/options/ocalusername/str");
+ Glib::ustring password = prefs->getString("/options/ocalpassword/str");
if (username.empty() || password.empty())
{
if(!gotSuccess)
@@ -1322,7 +1337,7 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
uri.append(":");
uri.append(password);
uri.append("@");
- uri.append(prefs->getString("options.ocalurl", "str"));
+ uri.append(prefs->getString("/options/ocalurl/str"));
uri.append("/dav.php/");
uri.append(Glib::path_get_basename(fileName));
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 47e3d3d2b..992791976 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -1,21 +1,24 @@
#define __SP_FLOOD_CONTEXT_C__
-/** \file
-* Bucket fill drawing context, works by bitmap filling an area on a rendered version of the current display and then tracing the result using potrace.
-*
-* Author:
-* Lauris Kaplinski <lauris@kaplinski.com>
-* bulia byak <buliabyak@users.sf.net>
-* John Bintz <jcoswell@coswellproductions.org>
-*
-* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
-* Copyright (C) 2000-2005 authors
-* Copyright (C) 2000-2001 Ximian, Inc.
-*
-* Released under GNU GPL, read the file 'COPYING' for more information
-*/
+/** @file
+ * @brief Bucket fill drawing context, works by bitmap filling an area on a rendered version
+ * of the current display and then tracing the result using potrace.
+ */
+/* Author:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * bulia byak <buliabyak@users.sf.net>
+ * John Bintz <jcoswell@coswellproductions.org>
+ *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) 2000-2005 authors
+ * Copyright (C) 2000-2001 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
#include <gdk/gdkkeysyms.h>
#include <queue>
@@ -40,7 +43,7 @@
#include "object-edit.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "context-fns.h"
#include "rubberband.h"
@@ -223,7 +226,8 @@ static void sp_flood_context_setup(SPEventContext *ec)
rc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
- if (prefs_get_int_attribute("tools.paintbucket", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/paintbucket/selcue")) {
rc->enableSelectionCue();
}
}
@@ -437,6 +441,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
}
Inkscape::Trace::Potrace::PotraceTracingEngine pte;
+ pte.keepGoing = 1;
std::vector<Inkscape::Trace::TracingEngineResult> results = pte.traceGrayMap(gray_map);
gray_map->destroy(gray_map);
@@ -445,7 +450,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
long totalNodeCount = 0L;
- double offset = prefs_get_double_attribute("tools.paintbucket", "offset", 0.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double offset = prefs->getDouble("/tools/paintbucket/offset", 0.0);
for (unsigned int i=0 ; i<results.size() ; i++) {
Inkscape::Trace::TracingEngineResult result = results[i];
@@ -453,7 +459,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
Inkscape::XML::Node *pathRepr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool (desktop, pathRepr, "tools.paintbucket", false);
+ sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false);
Geom::PathVector pathv = sp_svg_read_pathv(result.getPathData().c_str());
Path *path = new Path;
@@ -887,8 +893,9 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
bool aborted = false;
int y_limit = height - 1;
- PaintBucketChannels method = (PaintBucketChannels)prefs_get_int_attribute("tools.paintbucket", "channels", 0);
- int threshold = prefs_get_int_attribute_limited("tools.paintbucket", "threshold", 1, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ PaintBucketChannels method = (PaintBucketChannels) prefs->getInt("/tools/paintbucket/channels", 0);
+ int threshold = prefs->getIntLimited("/tools/paintbucket/threshold", 1, 0, 100);
switch(method) {
case FLOOD_CHANNELS_ALPHA:
@@ -914,7 +921,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
bci.bbox = *bbox;
bci.screen = screen;
bci.dtc = dtc;
- bci.radius = prefs_get_int_attribute_limited("tools.paintbucket", "autogap", 0, 0, 3);
+ bci.radius = prefs->getIntLimited("/tools/paintbucket/autogap", 0, 0, 3);
bci.max_queue_size = (width * height) / 4;
bci.current_step = 0;
@@ -1159,7 +1166,7 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem
Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item);
/* Set style */
- sp_desktop_apply_style_tool (desktop, pathRepr, "tools.paintbucket", false);
+ sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false);
sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object"));
ret = TRUE;
}
@@ -1308,7 +1315,8 @@ static void sp_flood_finish(SPFloodContext *rc)
void flood_channels_set_channels( gint channels )
{
- prefs_set_int_attribute("tools.paintbucket", "channels", channels);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/tools/paintbucket/channels", channels);
}
/*
diff --git a/src/fontsize-expansion.cpp b/src/fontsize-expansion.cpp
deleted file mode 100644
index 50169c3c2..000000000
--- a/src/fontsize-expansion.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "libnr/nr-matrix-ops.h"
-
-/**
- * Returns the distance from the transformed baseline to the
- * transformation of a point at (0, 1); or 0 if \a m has no inverse.
- */
-double
-fontsize_expansion(NR::Matrix const &m)
-{
- double const denom(hypot(m[0], m[1]));
- if (!(denom > 1e-100)) {
- return 0.;
- }
- double const numer(m.descrim2());
- if (!(numer > 1e-100)) {
- return 0.;
- }
- return numer / denom;
-}
-
-/*
- 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:encoding=utf-8:textwidth=99 :
diff --git a/src/fontsize-expansion.h b/src/fontsize-expansion.h
deleted file mode 100644
index 2477cd49c..000000000
--- a/src/fontsize-expansion.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef INKSCAPE_FONTSIZE_EXPANSION_H
-#define INKSCAPE_FONTSIZE_EXPANSION_H
-
-#include "libnr/nr-forward.h"
-
-double fontsize_expansion(NR::Matrix const &m);
-
-
-#endif /* !INKSCAPE_FONTSIZE_EXPANSION_H */
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index 7b32b37d7..ce26d2c5f 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -38,7 +38,7 @@
#include "svg/svg.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
-#include "prefs-utils.h"
+#include "preferences.h"
// Terminology:
@@ -240,7 +240,8 @@ SPGradient *
sp_gradient_fork_vector_if_necessary (SPGradient *gr)
{
// Some people actually prefer their gradient vectors to be shared...
- if (prefs_get_int_attribute("options.forkgradientvectors", "value", 1) == 0)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (!prefs->getBool("/options/forkgradientvectors/value", true))
return gr;
if (SP_OBJECT_HREFCOUNT(gr) > 1) {
diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp
index 7181fab4e..3741bc499 100644
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -32,7 +32,7 @@
#include "gradient-context.h"
#include "gradient-chemistry.h"
#include <glibmm/i18n.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "gradient-drag.h"
#include "gradient-chemistry.h"
#include "xml/repr.h"
@@ -203,7 +203,8 @@ static void sp_gradient_context_setup(SPEventContext *ec)
((SPEventContextClass *) parent_class)->setup(ec);
}
- if (prefs_get_int_attribute("tools.gradient", "selcue", 1) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/gradient/selcue", true)) {
ec->enableSelectionCue();
}
@@ -488,11 +489,12 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPGradientContext *rc = SP_GRADIENT_CONTEXT(event_context);
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
- double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ double const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
GrDrag *drag = event_context->_grdrag;
g_assert (drag);
@@ -516,8 +518,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
} else {
for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
SPItem *item = SP_ITEM(i->data);
- SPGradientType new_type = (SPGradientType) prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR);
- guint new_fill = prefs_get_int_attribute ("tools.gradient", "newfillorstroke", 1);
+ SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
+ guint new_fill = prefs->getInt("/tools/gradient/newfillorstroke", 1);
SPGradient *vector = sp_gradient_vector_for_object(sp_desktop_document(desktop), desktop, SP_OBJECT (item), new_fill);
@@ -554,7 +556,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
/* Snap center to nearest magnetic point */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt);
rc->origin = from_2geom(button_dt);
}
@@ -861,8 +863,9 @@ static void sp_gradient_drag(SPGradientContext &rc, NR::Point const pt, guint /*
SPEventContext *ec = SP_EVENT_CONTEXT(&rc);
if (!selection->isEmpty()) {
- int type = prefs_get_int_attribute ("tools.gradient", "newgradient", 1);
- int fill_or_stroke = prefs_get_int_attribute ("tools.gradient", "newfillorstroke", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int type = prefs->getInt("/tools/gradient/newgradient", 1);
+ int fill_or_stroke = prefs->getInt("/tools/gradient/newfillorstroke", 1);
SPGradient *vector;
if (ec->item_to_select) {
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 994171d13..b507ab72b 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -27,11 +27,12 @@
#include "desktop-style.h"
#include "document.h"
#include "display/sp-ctrlline.h"
+#include "display/sp-canvas-util.h"
#include "xml/repr.h"
#include "svg/css-ostringstream.h"
#include "svg/svg.h"
#include "libnr/nr-point-fns.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-item.h"
#include "style.h"
#include "knot.h"
@@ -581,7 +582,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
SPDesktop *desktop = dragger->parent->desktop;
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p));
+ Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(p));
if (s.getSnapped()) {
p = s.getPoint();
sp_knot_moveto (knot, p);
@@ -614,7 +615,8 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
}
if (state & GDK_CONTROL_MASK) {
- unsigned snaps = abs(prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ unsigned snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
/* 0 means no snapping. */
// This list will store snap vectors from all draggables of dragger
@@ -1282,7 +1284,7 @@ GrDragger::GrDragger (GrDrag *parent, NR::Point p, GrDraggable *draggable)
this->knot = sp_knot_new (parent->desktop, NULL);
this->knot->setMode(SP_KNOT_MODE_XOR);
this->knot->setFill(GR_KNOT_COLOR_NORMAL, GR_KNOT_COLOR_MOUSEOVER, GR_KNOT_COLOR_MOUSEOVER);
- this->knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
+ this->knot->setStroke(0x0000007f, 0x0000007f, 0x0000007f);
sp_knot_update_ctrl(this->knot);
// move knot to the given point
@@ -1526,6 +1528,7 @@ GrDrag::addLine (SPItem *item, NR::Point p1, NR::Point p2, guint32 rgba)
{
SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(this->desktop),
SP_TYPE_CTRLLINE, NULL);
+ sp_canvas_item_move_to_z(line, 0);
SP_CTRLLINE(line)->item = item;
sp_ctrlline_set_coords(SP_CTRLLINE(line), p1, p2);
if (rgba != GR_LINE_COLOR_FILL) // fill is the default, so don't set color for it to speed up redraw
diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp
index d0ba2d20e..87ec60695 100644
--- a/src/graphlayout/graphlayout.cpp
+++ b/src/graphlayout/graphlayout.cpp
@@ -1,14 +1,15 @@
-/** \file
- * Interface between Inkscape code (SPItem) and graphlayout functions.
+/** @file
+ * @brief Interface between Inkscape code (SPItem) and graphlayout functions.
*/
/*
-* Authors:
-* Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
-*
-* Copyright (C) 2005 Authors
-*
-* Released under GNU GPL. Read the file 'COPYING' for more information.
-*/
+ * Authors:
+ * Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
+ *
+ * Copyright (C) 2005 Authors
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
#include <iostream>
#include <config.h>
#include <map>
@@ -142,11 +143,11 @@ void graphlayout(GSList const *const items) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SimpleConstraints scx,scy;
- double ideal_connector_length = prefs->getDouble("tools.connector", "length", 100.0);
+ double ideal_connector_length = prefs->getDouble("/tools/connector/length", 100.0);
double directed_edge_height_modifier = 1.0;
- bool directed = prefs->getBool("tools.connector", "directedlayout");
- bool avoid_overlaps = prefs->getBool("tools.connector", "avoidoverlaplayout");
+ bool directed = prefs->getBool("/tools/connector/directedlayout");
+ bool avoid_overlaps = prefs->getBool("/tools/connector/avoidoverlaplayout");
for (list<SPItem *>::iterator i(selected.begin());
i != selected.end();
diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp
index d1991e75d..d9c57f829 100644
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
@@ -43,7 +43,7 @@ Inkscape::GuideSnapper::LineList Inkscape::GuideSnapper::_getSnapLines(Geom::Poi
*/
bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const
{
- return _snapmanager->getNamedView() == NULL ? false : (_snap_enabled && _snap_from != 0 && _snapmanager->getNamedView()->showguides);
+ return _snapmanager->getNamedView() == NULL ? false : (_snap_enabled && _snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->getNamedView()->showguides);
}
void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp
index dd405b7d9..89ab32f55 100644
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
@@ -29,7 +29,7 @@
#include <sp-item.h>
#include <sp-root.h>
#include <sp-defs.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "dialogs/rdf.h"
/* This is an example of how to use libpng to read and write PNG files.
@@ -409,8 +409,11 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
}
// export with maximum blur rendering quality
- int saved_quality = prefs_get_int_attribute("options.blurquality", "value", 0);
- prefs_set_int_attribute("options.blurquality", "value", 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_quality = prefs->getInt("/options/blurquality/value", 0);
+ prefs->setInt("/options/blurquality/value", 2);
+ int saved_filter_quality = prefs->getInt("/options/filterquality/value", 0);
+ prefs->setInt("/options/filterquality/value", 2);
sp_document_ensure_up_to_date(doc);
@@ -487,8 +490,9 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
/* Free arena */
nr_object_unref((NRObject *) arena);
- // restore saved blur quality
- prefs_set_int_attribute("options.blurquality", "value", saved_quality);
+ // restore saved blur and filter quality
+ prefs->setInt("/options/blurquality/value", saved_quality);
+ prefs->setInt("/options/filterquality/value", saved_filter_quality);
return write_status;
}
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index bf3c25e94..51f740fb4 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -303,7 +303,7 @@ static gint inkscape_autosave(gpointer)
Glib::ustring autosave_dir;
{
- Glib::ustring tmp = prefs->getString("options.autosave", "path");
+ Glib::ustring tmp = prefs->getString("/options/autosave/path");
if (!tmp.empty()) {
autosave_dir = tmp;
} else {
@@ -322,7 +322,7 @@ static gint inkscape_autosave(gpointer)
gchar sptstr[256];
strftime(sptstr, 256, "%Y_%m_%d_%H_%M_%S", sptm);
- gint autosave_max = prefs->getInt("options.autosave", "max", 10);
+ gint autosave_max = prefs->getInt("/options/autosave/max", 10);
gint docnum = 0;
@@ -438,14 +438,14 @@ void inkscape_autosave_init()
autosave_timeout_id = 0;
}
- // g_debug("options.autosave.enable = %d", prefs->getBool("options.autosave", "enable", true));
+ // g_debug("options.autosave.enable = %d", prefs->getBool("/options/autosave/enable", true));
// Is autosave enabled?
- if (!prefs->getBool("options.autosave", "enable", true)){
+ if (!prefs->getBool("/options/autosave/enable", true)){
autosave_timeout_id = 0;
} else {
// Turn on autosave
- guint32 timeout = prefs->getInt("options.autosave", "interval", 10) * 60;
- // g_debug("options.autosave.interval = %d", prefs->getInt("options.autosave", "interval", 10));
+ guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60;
+ // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10));
#if GLIB_CHECK_VERSION(2,14,0)
autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL);
#else
@@ -772,7 +772,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
#define DEFAULT_LOG_REDIRECT false
#endif
- if (use_gui == TRUE && prefs->getBool("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
+ if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
{
Inkscape::UI::Dialogs::DebugDialog::getInstance()->captureLogMessages();
}
@@ -780,7 +780,7 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
/* Check for global remapping of Alt key */
if(use_gui)
{
- inkscape_mapalt(guint(prefs->getInt("options.mapalt", "value", 0)));
+ inkscape_mapalt(guint(prefs->getInt("/options/mapalt/value", 0)));
}
/* Initialize the extensions */
@@ -825,15 +825,6 @@ bool inkscape_load_menus (Inkscape::Application */*inkscape*/)
return false;
}
-/**
- * @deprecated Use the Preferences class instead, and try not to use _getNode
- */
-Inkscape::XML::Node *inkscape_get_repr(Inkscape::Application */*inkscape*/, const gchar *key)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->_getNode(key);
-}
-
void
inkscape_selection_modified (Inkscape::Selection *selection, guint flags)
diff --git a/src/inkscape.h b/src/inkscape.h
index 90737cc41..ca2894227 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -34,7 +34,6 @@ void inkscape_autosave_init();
void inkscape_application_init (const gchar *argv0, gboolean use_gui);
bool inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton, unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml, const gchar *e_notsp, const gchar *warn);
-Inkscape::XML::Node *inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key);
/* Menus */
bool inkscape_load_menus (Inkscape::Application * inkscape);
diff --git a/src/inkview.cpp b/src/inkview.cpp
index fee18612d..873cacc31 100644
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
@@ -555,7 +555,6 @@ void inkscape_ref (void) {}
void inkscape_unref (void) {}
void inkscape_add_document (SPDocument *document) {}
void inkscape_remove_document (SPDocument *document) {}
-Inkscape::XML::Node *inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key) {return NULL;}
#endif
diff --git a/src/interface.cpp b/src/interface.cpp
index 1bc00a250..8a3182103 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -1,9 +1,9 @@
#define __SP_INTERFACE_C__
-/**
- * Main UI stuff
- *
- * Authors:
+/** @file
+ * @brief Main UI stuff
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
@@ -23,7 +23,7 @@
#include "inkscape-private.h"
#include "extension/effect.h"
#include "widgets/icon.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "path-prefix.h"
#include "shortcuts.h"
@@ -132,6 +132,7 @@ static void sp_ui_menu_item_set_sensitive(SPAction *action,
static void sp_ui_menu_item_set_name(SPAction *action,
Glib::ustring name,
void *data);
+static void sp_recent_open(GtkRecentChooser *, gpointer);
SPActionEventVector menu_item_event_vector = {
{NULL},
@@ -170,15 +171,16 @@ sp_create_window(SPViewWidget *vw, gboolean editable)
win->signal_window_state_event().connect(sigc::mem_fun(*desktop, &SPDesktop::onWindowStateEvent));
win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint prefs_geometry =
- (2==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
+ (2==prefs->getInt("/options/savewindowgeometry/value", 0));
if (prefs_geometry) {
- gint pw = prefs_get_int_attribute("desktop.geometry", "width", -1);
- gint ph = prefs_get_int_attribute("desktop.geometry", "height", -1);
- gint px = prefs_get_int_attribute("desktop.geometry", "x", -1);
- gint py = prefs_get_int_attribute("desktop.geometry", "y", -1);
- gint full = prefs_get_int_attribute("desktop.geometry", "fullscreen", 0);
- gint maxed = prefs_get_int_attribute("desktop.geometry", "maximized", 0);
+ gint pw = prefs->getInt("/desktop/geometry/width", -1);
+ gint ph = prefs->getInt("/desktop/geometry/height", -1);
+ gint px = prefs->getInt("/desktop/geometry/x", -1);
+ gint py = prefs->getInt("/desktop/geometry/y", -1);
+ gint full = prefs->getBool("/desktop/geometry/fullscreen");
+ gint maxed = prefs->getBool("/desktop/geometry/maximized");
if (pw>0 && ph>0) {
gint w = MIN(gdk_screen_width(), pw);
gint h = MIN(gdk_screen_height(), ph);
@@ -633,18 +635,20 @@ checkitem_toggled(GtkCheckMenuItem *menuitem, gpointer user_data)
gchar const *pref = (gchar const *) user_data;
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
- gchar *pref_path;
+ Glib::ustring pref_path;
if (reinterpret_cast<SPDesktop*>(view)->is_focusMode()) {
- pref_path = g_strconcat("focus.", pref, NULL);
+ pref_path = "/focus/";
} else if (reinterpret_cast<SPDesktop*>(view)->is_fullscreen()) {
- pref_path = g_strconcat("fullscreen.", pref, NULL);
+ pref_path = "/fullscreen/";
} else {
- pref_path = g_strconcat("window.", pref, NULL);
- }
+ pref_path = "/window/";
+ }
+ pref_path += pref;
+ pref_path += "/state";
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gboolean checked = gtk_check_menu_item_get_active(menuitem);
- prefs_set_int_attribute(pref_path, "state", checked);
- g_free(pref_path);
+ prefs->setBool(pref_path, checked);
reinterpret_cast<SPDesktop*>(view)->layoutWidget();
}
@@ -657,13 +661,16 @@ checkitem_update(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_dat
gchar const *pref = (gchar const *) user_data;
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
- gchar const *pref_path;
- if ((static_cast<SPDesktop*>(view))->is_fullscreen())
- pref_path = g_strconcat("fullscreen.", pref, NULL);
- else
- pref_path = g_strconcat("window.", pref, NULL);
+ Glib::ustring pref_path;
+ if ((static_cast<SPDesktop*>(view))->is_fullscreen()) {
+ pref_path = "/fullscreen/";
+ } else {
+ pref_path = "/window/";
+ }
+ pref_path += pref;
- gint ison = prefs_get_int_attribute_limited(pref_path, "state", 1, 0, 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool ison = prefs->getBool(pref_path + "/state", true);
g_signal_handlers_block_by_func(G_OBJECT(menuitem), (gpointer)(GCallback)checkitem_toggled, user_data);
gtk_check_menu_item_set_active(menuitem, ison);
@@ -737,9 +744,16 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
}
static void
-sp_recent_open(GtkWidget */*widget*/, gchar const *uri)
+sp_recent_open(GtkRecentChooser *recent_menu, gpointer /*user_data*/)
{
- sp_file_open(uri, NULL);
+ // dealing with the bizarre filename convention in Inkscape for now
+ gchar *uri = gtk_recent_chooser_get_current_uri(GTK_RECENT_CHOOSER(recent_menu));
+ gchar *local_fn = g_filename_from_uri(uri, NULL, NULL);
+ gchar *utf8_fn = g_filename_to_utf8(local_fn, -1, NULL, NULL, NULL);
+ sp_file_open(utf8_fn, NULL);
+ g_free(utf8_fn);
+ g_free(local_fn);
+ g_free(uri);
}
static void
@@ -806,35 +820,6 @@ sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view)
}
void
-sp_menu_append_recent_documents(GtkWidget *menu, Inkscape::UI::View::View* /* view */)
-{
- gchar const **recent = prefs_get_recent_files();
- if (recent) {
- int i;
-
- for (i = 0; recent[i] != NULL; i += 2) {
- gchar const *uri = recent[i];
- gchar const *name = recent[i + 1];
-
- GtkWidget *item = gtk_menu_item_new_with_label(name);
- gtk_widget_show(item);
- g_signal_connect(G_OBJECT(item),
- "activate",
- G_CALLBACK(sp_recent_open),
- (gpointer)uri);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- }
-
- g_free(recent);
- } else {
- GtkWidget *item = gtk_menu_item_new_with_label(_("None"));
- gtk_widget_show(item);
- gtk_widget_set_sensitive(item, FALSE);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- }
-}
-
-void
sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view)
{
//sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu",
@@ -929,7 +914,25 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI:
continue;
}
if (!strcmp(menu_pntr->name(), "recent-file-list")) {
- sp_menu_append_recent_documents(menu, view);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ // create recent files menu
+ int max_recent = prefs->getInt("/options/maxrecentdocuments/value");
+ GtkWidget *recent_menu = gtk_recent_chooser_menu_new_for_manager(gtk_recent_manager_get_default());
+ gtk_recent_chooser_set_limit(GTK_RECENT_CHOOSER(recent_menu), max_recent);
+ // sort most recently used documents first to preserve previous behavior
+ gtk_recent_chooser_set_sort_type(GTK_RECENT_CHOOSER(recent_menu), GTK_RECENT_SORT_MRU);
+ g_signal_connect(G_OBJECT(recent_menu), "item-activated", G_CALLBACK(sp_recent_open), (gpointer) NULL);
+
+ // add filter to only open files added by Inkscape
+ GtkRecentFilter *inkscape_only_filter = gtk_recent_filter_new();
+ gtk_recent_filter_add_application(inkscape_only_filter, "inkscape");
+ gtk_recent_chooser_add_filter(GTK_RECENT_CHOOSER(recent_menu), inkscape_only_filter);
+
+ GtkWidget *recent_item = gtk_menu_item_new_with_mnemonic(_("Open _Recent"));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent_item), recent_menu);
+
+ gtk_menu_append(GTK_MENU(menu), GTK_WIDGET(recent_item));
continue;
}
if (!strcmp(menu_pntr->name(), "objects-checkboxes")) {
@@ -1188,6 +1191,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
if (position) {
NR::Point nearest = get_point_on_Path(livarot_path, position->piece, position->t);
NR::Point delta = nearest - button_doc;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
delta = desktop->d2w(delta);
double stroke_tolerance =
( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
@@ -1195,7 +1199,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
SP_OBJECT_STYLE (item)->stroke_width.computed *
to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5
: 0.0)
- + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if (NR::L2 (delta) < stroke_tolerance) {
fillnotstroke = false;
@@ -1253,15 +1257,16 @@ sp_ui_drag_data_received(GtkWidget *widget,
// To move the imported object, we must temporarily set the "transform pattern with
// object" option.
{
- int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1);
- prefs_set_int_attribute("options.transform", "pattern", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool const saved_pref = prefs->getBool("/options/transform/pattern", true);
+ prefs->setBool("/options/transform/pattern", true);
sp_document_ensure_up_to_date(sp_desktop_document(desktop));
boost::optional<Geom::Rect> sel_bbox = selection->bounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
sp_selection_move_relative(selection, m);
}
- prefs_set_int_attribute("options.transform", "pattern", saved_pref);
+ prefs->setBool("/options/transform/pattern", saved_pref);
}
Inkscape::GC::release(newgroup);
diff --git a/src/io/sys.cpp b/src/io/sys.cpp
index 029ff88fd..96d0ae983 100644
--- a/src/io/sys.cpp
+++ b/src/io/sys.cpp
@@ -23,7 +23,7 @@
#include <glibmm/ustring.h>
#include <gtk/gtkmessagedialog.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sys.h"
#ifdef WIN32
@@ -75,9 +75,10 @@ extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
- gint dump = prefs_get_int_attribute_limited("options.bulia", #key, 0, 0, 1);\
- gint dumpD = prefs_get_int_attribute_limited("options.bulia", #key"D", 0, 0, 1);\
- gint dumpD2 = prefs_get_int_attribute_limited("options.bulia", #key"D2", 0, 0, 1);\
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); \
+ gint dump = prefs->getBool("/options/bulia/" #key) ? 1 : 0;\
+ gint dumpD = prefs->getBool("/options/bulia/" #key"D") ? 1 : 0;\
+ gint dumpD2 = prefs->getBool("/options/bulia/" #key"D2") ? 1 : 0;\
dumpD &= ( (update_in_progress == 0) || dumpD2 );\
if ( dump )\
{\
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp
index 1fd6bc4b5..f6c82582b 100644
--- a/src/knot-holder-entity.cpp
+++ b/src/knot-holder-entity.cpp
@@ -19,7 +19,7 @@
#include "knotholder.h"
#include "sp-item.h"
#include "style.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "macros.h"
#include <libnr/nr-matrix-ops.h>
#include "sp-pattern.h"
@@ -93,7 +93,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p)
Geom::Point s = p * i2d;
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s);
return s * i2d.inverse();
}
@@ -168,7 +168,8 @@ PatternKnotHolderEntityAngle::knot_get()
void
PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
diff --git a/src/knot.cpp b/src/knot.cpp
index 59e32a56e..741199098 100644
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -24,7 +24,7 @@
#include "desktop-handles.h"
#include "knot.h"
#include "document.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "message-stack.h"
#include "message-context.h"
#include "event-context.h"
@@ -299,7 +299,8 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
}
g_object_ref(knot);
- tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
switch (event->type) {
case GDK_2BUTTON_PRESS:
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index c7ba0e904..3e49edac5 100644
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
@@ -16,7 +16,7 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "layer-manager.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "ui/view/view.h"
#include "selection.h"
#include "sp-object.h"
@@ -150,7 +150,8 @@ void LayerManager::setCurrentLayer( SPObject* obj )
if ( _desktop->currentRoot() ) {
_desktop->setCurrentLayer( obj );
- if ( prefs_get_int_attribute_limited("options.selection", "layerdeselect", 1, 0, 1) ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/options/selection/layerdeselect", true)) {
sp_desktop_selection( _desktop )->clear();
}
}
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index b2934c2e3..140157fe3 100644
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
@@ -6,7 +6,7 @@
* Diederik van Lierop <mail@diedenrezi.nl>
* And others...
*
- * Copyright (C) 1999-2007 Authors
+ * Copyright (C) 1999-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -17,23 +17,23 @@
#include "line-snapper.h"
#include "snapped-line.h"
#include <gtk/gtk.h>
+#include "snap.h"
Inkscape::LineSnapper::LineSnapper(SnapManager const *sm, Geom::Coord const d) : Snapper(sm, d)
{
-
}
void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &/*f*/,
boost::optional<Geom::Rect> const &/*bbox_to_snap*/,
std::vector<SPItem const *> const */*it*/,
std::vector<Geom::Point> */*unselected_nodes*/) const
{
- if (_snap_enabled == false || getSnapFrom(t) == false) {
+ if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
return;
- }
+ }
/* Get the lines that we will try to snap to */
const LineList lines = _getSnapLines(p);
@@ -58,7 +58,7 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
}
void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &/*f*/,
boost::optional<Geom::Rect> const &/*bbox_to_snap*/,
@@ -66,7 +66,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
std::vector<SPItem const *> const */*it*/) const
{
- if (_snap_enabled == false || getSnapFrom(t) == false) {
+ if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
return;
}
diff --git a/src/line-snapper.h b/src/line-snapper.h
index 7767fe2ea..593e8bd73 100644
--- a/src/line-snapper.h
+++ b/src/line-snapper.h
@@ -7,6 +7,9 @@
*
* Authors:
* Carl Hetherington <inkscape@carlh.net>
+ * Diederik van Lierop <mail@diedenrezi.nl>
+ *
+ * Copyright (C) 1999-2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information.
*/
@@ -22,7 +25,7 @@ public:
LineSnapper(SnapManager const *sm, Geom::Coord const d);
void freeSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
@@ -30,7 +33,7 @@ public:
std::vector<Geom::Point> *unselected_nodes) const;
void constrainedSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index ef886a749..a04100cd3 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -491,7 +491,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem)
std::vector<Geom::PathVector> hp_vec;
if (!SP_IS_SHAPE(lpeitem)) {
- g_print ("How to handle helperpaths for non-shapes?\n");
+ g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
return hp_vec;
}
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 609778b46..8dd1354e2 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -129,12 +129,13 @@ public:
virtual void setup_nodepath(Inkscape::NodePath::Path *np);
+ /// /todo: is this method really necessary? it causes UI inconsistensies... (johan)
virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
- // TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is
+ // /TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is
// created for an item or not. When we allow both at the same time, this needs rethinking!
bool providesKnotholder();
- // TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant
+ // /TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant
// (but spiro lpe still needs it!)
virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index c5cde7025..c3be57981 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -139,13 +139,6 @@ LPEBendPath::resetDefaults(SPItem * item)
bend_path.set_new_value( path.toPwSb(), true );
}
-void
-LPEBendPath::transform_multiply(Geom::Matrix const& postmul, bool set)
-{
- // TODO: implement correct transformation instead of this default behavior
- Effect::transform_multiply(postmul, set);
-}
-
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index 20871bc0f..98421df88 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -39,7 +39,6 @@ public:
virtual void resetDefaults(SPItem * item);
- virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
private:
PathParam bend_path;
diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp
index 34c17a025..4404620be 100644
--- a/src/live_effects/lpe-curvestitch.cpp
+++ b/src/live_effects/lpe-curvestitch.cpp
@@ -179,6 +179,11 @@ LPECurveStitch::resetDefaults(SPItem * item)
}
}
+
+/** /todo check whether this special case is necessary. It seems to "bug" editing behavior:
+ * scaling an object with transforms preserved behaves differently from scaling with
+ * transforms optimized (difference caused by this special method).
+ */
void
LPECurveStitch::transform_multiply(Geom::Matrix const& postmul, bool set)
{
diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp
index fad912df7..553390585 100755
--- a/src/live_effects/lpe-envelope.cpp
+++ b/src/live_effects/lpe-envelope.cpp
@@ -248,13 +248,6 @@ LPEEnvelope::resetDefaults(SPItem * item)
bend_path4.set_new_value( path4.toPwSb(), true );
}
-void
-LPEEnvelope::transform_multiply(Geom::Matrix const& postmul, bool set)
-{
- // TODO: implement correct transformation instead of this default behavior
- Effect::transform_multiply(postmul, set);
-}
-
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-envelope.h b/src/live_effects/lpe-envelope.h
index 282169674..fe1d9561d 100755
--- a/src/live_effects/lpe-envelope.h
+++ b/src/live_effects/lpe-envelope.h
@@ -37,8 +37,6 @@ public:
virtual void resetDefaults(SPItem * item);
- virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
-
private:
PathParam bend_path1;
PathParam bend_path2;
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index 4504f4467..0ff1beccf 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -28,6 +28,8 @@
#include <2geom/path-intersection.h>
#include <2geom/elliptical-arc.h>
+#include <exception>
+
namespace Inkscape {
namespace LivePathEffect {
@@ -171,12 +173,12 @@ namespace LPEKnotNS {
CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom::Path> const &path) : std::vector<CrossingPoint>()
{
using namespace Geom;
- g_print("JF>\nCrossing set content:\n");
+// g_print("JF>\nCrossing set content:\n");
for( unsigned i=0; i<input.size(); i++){
Crossings i_crossings = input[i];
for( unsigned n=0; n<i_crossings.size(); n++ ){
Crossing c = i_crossings[n];
- g_print("JF> (%u,%u) at times (%f,%f) ----->",c.a,c.b,c.ta,c.tb);
+// g_print("JF> (%u,%u) at times (%f,%f) ----->",c.a,c.b,c.ta,c.tb);
unsigned j = c.getOther(i);
if (i<j || (i==j && c.ta<c.tb) ){
CrossingPoint cp;
@@ -195,10 +197,10 @@ CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom:
cp.nj = std::find(input[j].begin(),input[j].end(),c_bar)-input[j].begin();
cp.sign = 1;
push_back(cp);
- g_print("i=%u, ni=%u, j=%u, nj=%u\n",cp.i,cp.ni,cp.j,cp.nj);
+// g_print("i=%u, ni=%u, j=%u, nj=%u\n",cp.i,cp.ni,cp.j,cp.nj);
}
else{
- g_print("\n");
+// g_print("\n");
bool found = false;
for( unsigned ii=0; ii<input.size(); ii++){
Crossings ii_crossings = input[ii];
@@ -207,7 +209,9 @@ CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom:
if (cc.b==c.a && cc.a==c.b && cc.ta==c.tb && cc.tb==c.ta) found = true;
}
}
- assert( found );
+ if (!found) {
+ throw std::exception();
+ }
}
}
}
@@ -384,14 +388,14 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &input_path)
for(unsigned i=0;i<crossingTable.size();i++){
for(unsigned j=0;j<crossingTable[i].size();j++){
- g_print("JF>avant: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb);
+// g_print("JF>avant: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb);
}
}
crossingTable = crossingSet_remove_double(crossingTable);
for(unsigned i=0;i<crossingTable.size();i++){
for(unsigned j=0;j<crossingTable[i].size();j++){
- g_print("JF>apres: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb);
+// g_print("JF>apres: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb);
}
}
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index 2240a0c3d..0e5011e51 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -195,13 +195,6 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con
return output;
}
-void
-LPEPatternAlongPath::transform_multiply(Geom::Matrix const& postmul, bool set)
-{
- // TODO: implement correct transformation instead of this default behavior
- Effect::transform_multiply(postmul, set);
-}
-
LPEFreehandShape::LPEFreehandShape(LivePathEffectObject *lpeobject) : LPEPatternAlongPath(lpeobject)
{
}
diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h
index 10b9e8bc2..5adc049fb 100644
--- a/src/live_effects/lpe-patternalongpath.h
+++ b/src/live_effects/lpe-patternalongpath.h
@@ -32,8 +32,6 @@ public:
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
- virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
-
PathParam pattern;
private:
EnumParam<PAPCopyType> copytype;
diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp
index a95d89398..38957a658 100644
--- a/src/live_effects/lpe-sketch.cpp
+++ b/src/live_effects/lpe-sketch.cpp
@@ -180,17 +180,6 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
Piecewise<D2<SBasis> > output;
-
- //init random parameters.
- parallel_offset.resetRandomizer();
- strokelength_rdm.resetRandomizer();
- strokeoverlap_rdm.resetRandomizer();
- ends_tolerance.resetRandomizer();
- tremble_size.resetRandomizer();
- tgtlength_rdm.resetRandomizer();
-
-
-
// some variables for futur use (for construction lines; compute arclength only once...)
// notations will be : t = path time, s = distance from start along the path.
Piecewise<SBasis> pathlength;
@@ -304,6 +293,18 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
return output;
}
+void
+LPESketch::doBeforeEffect (SPLPEItem *lpeitem)
+{
+ //init random parameters.
+ parallel_offset.resetRandomizer();
+ strokelength_rdm.resetRandomizer();
+ strokeoverlap_rdm.resetRandomizer();
+ ends_tolerance.resetRandomizer();
+ tremble_size.resetRandomizer();
+ tgtlength_rdm.resetRandomizer();
+}
+
/* ######################## */
} //namespace LivePathEffect (setq default-directory "c:/Documents And Settings/jf/Mes Documents/InkscapeSVN")
diff --git a/src/live_effects/lpe-sketch.h b/src/live_effects/lpe-sketch.h
index f4881ac55..bca4e2447 100644
--- a/src/live_effects/lpe-sketch.h
+++ b/src/live_effects/lpe-sketch.h
@@ -27,11 +27,10 @@ public:
LPESketch(LivePathEffectObject *lpeobject);
virtual ~LPESketch();
-// Choose to implement one of the doEffect functions. You can delete or comment out the others.
-// virtual void doEffect (SPCurve * curve);
-// virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> & path_in);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
+ virtual void doBeforeEffect (SPLPEItem *lpeitem);
+
private:
// add the parameters for your effect here:
//PointParam testpointA;
diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp
index 72d96f5a2..0f105ad60 100644
--- a/src/live_effects/lpe-vonkoch.cpp
+++ b/src/live_effects/lpe-vonkoch.cpp
@@ -305,14 +305,6 @@ LPEVonKoch::resetDefaults(SPItem * item)
//generator.set_new_value(paths, true);
}
-void
-LPEVonKoch::transform_multiply(Geom::Matrix const& postmul, bool set)
-{
- // TODO: implement correct transformation instead of this default behavior
- Effect::transform_multiply(postmul, set);
-}
-
-
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h
index 16964f527..7862cdbb5 100644
--- a/src/live_effects/lpe-vonkoch.h
+++ b/src/live_effects/lpe-vonkoch.h
@@ -55,8 +55,6 @@ public:
virtual void doBeforeEffect(SPLPEItem * item);
- virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
-
//Usefull??
// protected:
//virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp
index 79e6857f0..3b1ece2ad 100644
--- a/src/live_effects/lpegroupbbox.cpp
+++ b/src/live_effects/lpegroupbbox.cpp
@@ -13,6 +13,16 @@
namespace Inkscape {
namespace LivePathEffect {
+/**
+ * \brief Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem.
+ *
+ * \pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode )
+ It's not possible to run LPEs on items without their original-d having a bbox.
+ * \param lpeitem This is not allowed to be NULL.
+ * \param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false)
+ * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine.
+ * \post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met.
+ */
void
GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
{
@@ -27,9 +37,14 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
transform = Geom::identity();
}
- Geom::Rect itemBBox = *item->getBounds(transform, SPItem::GEOMETRIC_BBOX); // fixme: fix for when getBounds returns invalid Rect
- boundingbox_X = itemBBox[Geom::X];
- boundingbox_Y = itemBBox[Geom::Y];
+ boost::optional<Geom::Rect> bbox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX);
+ if (bbox) {
+ boundingbox_X = (*bbox)[Geom::X];
+ boundingbox_Y = (*bbox)[Geom::Y];
+ } else {
+ boundingbox_X = Geom::Interval();
+ boundingbox_Y = Geom::Interval();
+ }
}
} // namespace LivePathEffect
diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp
index f522ae56e..9163d1c91 100644
--- a/src/live_effects/lpeobject-reference.cpp
+++ b/src/live_effects/lpeobject-reference.cpp
@@ -11,8 +11,6 @@
#include "enums.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/lpeobject.h"
-
-#include "prefs-utils.h"
#include "uri.h"
namespace Inkscape {
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp
index b001214cf..8439f7086 100644
--- a/src/lpe-tool-context.cpp
+++ b/src/lpe-tool-context.cpp
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
#include "desktop.h"
#include "message-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "shape-editor.h"
#include "selection.h"
#include "desktop-handles.h"
@@ -45,7 +45,7 @@ static void sp_lpetool_context_init(SPLPEToolContext *erc);
static void sp_lpetool_context_dispose(GObject *object);
static void sp_lpetool_context_setup(SPEventContext *ec);
-static void sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_lpetool_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *);
static gint sp_lpetool_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
static gint sp_lpetool_context_root_handler(SPEventContext *ec, GdkEvent *event);
@@ -164,13 +164,15 @@ sp_lpetool_context_setup(SPEventContext *ec)
// TODO temp force:
ec->enableSelectionCue();
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item) {
lc->shape_editor->set_item(item, SH_NODEPATH);
lc->shape_editor->set_item(item, SH_KNOTHOLDER);
}
- if (prefs_get_int_attribute("tools.lpetool", "selcue", 0) != 0) {
+ if (prefs->getBool("/tools/lpetool/selcue")) {
ec->enableSelectionCue();
}
@@ -199,18 +201,18 @@ sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer da
}
static void
-sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_lpetool_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
// FIXME: how to set this correcly? the value from preferences-skeleton.h doesn't seem to get
// read (it wants to set drag = 1)
- lpetool_parent_class->set(ec, key, "drag");
+ // lpetool_parent_class->set(ec, key, "drag");
- /**
+ /*
//pass on up to parent class to handle common attributes.
if ( lpetool_parent_class->set ) {
lpetool_parent_class->set(ec, key, val);
}
- **/
+ */
}
static gint
@@ -279,7 +281,8 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event)
using namespace Inkscape::LivePathEffect;
- int mode = prefs_get_int_attribute("tools.lpetool", "mode", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int mode = prefs->getInt("/tools/lpetool/mode");
EffectType type = lpesubtools[mode];
//bool over_stroke = lc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), true);
@@ -419,11 +422,12 @@ void
lpetool_get_limiting_bbox_corners(SPDocument *document, Geom::Point &A, Geom::Point &B) {
Geom::Coord w = sp_document_width(document);
Geom::Coord h = sp_document_height(document);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double ulx = prefs_get_double_attribute ("tools.lpetool", "bbox_upperleftx", 0);
- double uly = prefs_get_double_attribute ("tools.lpetool", "bbox_upperlefty", 0);
- double lrx = prefs_get_double_attribute ("tools.lpetool", "bbox_lowerrightx", w);
- double lry = prefs_get_double_attribute ("tools.lpetool", "bbox_lowerrighty", h);
+ double ulx = prefs->getDouble("/tools/lpetool/bbox_upperleftx", 0);
+ double uly = prefs->getDouble("/tools/lpetool/bbox_upperlefty", 0);
+ double lrx = prefs->getDouble("/tools/lpetool/bbox_lowerrightx", w);
+ double lry = prefs->getDouble("/tools/lpetool/bbox_lowerrighty", h);
A = Geom::Point(ulx, uly);
B = Geom::Point(lrx, lry);
@@ -441,7 +445,8 @@ lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc)
lc->canvas_bbox = NULL;
}
- if (prefs_get_int_attribute("tools.lpetool", "show_bbox", 1) == 0)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (!prefs->getBool("/tools/lpetool/show_bbox", true))
return;
SPDocument *document = sp_desktop_document(lc->desktop);
@@ -479,10 +484,11 @@ set_pos_and_anchor(SPCanvasText *canvas_text, const Geom::Piecewise<Geom::D2<Geo
void
lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *selection)
{
- bool show = prefs_get_int_attribute ("tools.lpetool", "show_measuring_info", 1) == 1 ? true : false;
if (!selection) {
selection = sp_desktop_selection(lc->desktop);
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool show = prefs->getBool("/tools/lpetool/show_measuring_info", true);
SPPath *path;
SPCurve *curve;
@@ -500,7 +506,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select
if (!show)
sp_canvas_item_hide(SP_CANVAS_ITEM(canvas_text));
- SPUnitId unitid = static_cast<SPUnitId>(prefs_get_int_attribute("tools.lpetool", "unitid", SP_UNIT_PX));
+ SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX));
SPUnit unit = sp_unit_get_by_id(unitid);
lengthval = Geom::length(pwd2);
@@ -528,6 +534,7 @@ lpetool_delete_measuring_items(SPLPEToolContext *lc)
void
lpetool_update_measuring_items(SPLPEToolContext *lc)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPPath *path;
SPCurve *curve;
double lengthval;
@@ -537,7 +544,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc)
path = i->first;
curve = sp_shape_get_curve(SP_SHAPE(path));
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector());
- SPUnitId unitid = static_cast<SPUnitId>(prefs_get_int_attribute("tools.lpetool", "unitid", SP_UNIT_PX));
+ SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX));
SPUnit unit = sp_unit_get_by_id(unitid);
lengthval = Geom::length(pwd2);
gboolean success;
diff --git a/src/main.cpp b/src/main.cpp
index 7dcf9bf95..03beb0734 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -141,10 +141,7 @@ enum {
SP_ARG_EXPORT_EMF,
#endif //WIN32
SP_ARG_EXPORT_TEXT_TO_PATH,
- SP_ARG_EXPORT_FONT,
- SP_ARG_EXPORT_BBOX_PAGE,
SP_ARG_EXTENSIONDIR,
- SP_ARG_FIT_PAGE_TO_DRAWING,
SP_ARG_QUERY_X,
SP_ARG_QUERY_Y,
SP_ARG_QUERY_WIDTH,
@@ -163,8 +160,7 @@ enum {
int sp_main_gui(int argc, char const **argv);
int sp_main_console(int argc, char const **argv);
static void sp_do_export_png(SPDocument *doc);
-static void do_export_ps(SPDocument* doc, gchar const* uri, char const *mime);
-static void do_export_pdf(SPDocument* doc, gchar const* uri, char const *mime);
+static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime);
#ifdef WIN32
static void do_export_emf(SPDocument* doc, gchar const* uri, char const *mime);
#endif //WIN32
@@ -195,7 +191,6 @@ static gchar *sp_export_emf = NULL;
#endif //WIN32
static gboolean sp_export_text_to_path = FALSE;
static gboolean sp_export_font = FALSE;
-static gboolean sp_export_bbox_page = FALSE;
static gboolean sp_query_x = FALSE;
static gboolean sp_query_y = FALSE;
static gboolean sp_query_width = FALSE;
@@ -238,7 +233,6 @@ static void resetCommandlineGlobals() {
#endif //WIN32
sp_export_text_to_path = FALSE;
sp_export_font = FALSE;
- sp_export_bbox_page = FALSE;
sp_query_x = FALSE;
sp_query_y = FALSE;
sp_query_width = FALSE;
@@ -381,16 +375,6 @@ struct poptOption options[] = {
N_("Convert text object to paths on export (EPS)"),
NULL},
- {"export-embed-fonts", 'F',
- POPT_ARG_NONE, &sp_export_font, SP_ARG_EXPORT_FONT,
- N_("Embed fonts on export (Type 1 only) (EPS)"),
- NULL},
-
- {"export-bbox-page", 'B',
- POPT_ARG_NONE, &sp_export_bbox_page, SP_ARG_EXPORT_BBOX_PAGE,
- N_("Export files with the bounding box set to the page size (EPS)"),
- NULL},
-
{"query-x", 'X',
POPT_ARG_NONE, &sp_query_x, SP_ARG_QUERY_X,
// TRANSLATORS: "--query-id" is an Inkscape command line option; see "inkscape --help"
@@ -521,6 +505,26 @@ static int _win32_set_inkscape_env(const Glib::ustring &exePath)
}
#endif
+/**
+ * Add INKSCAPE_EXTENSIONDIR to PYTHONPATH so that extensions in users home
+ * can find inkex.py et al. (Bug #197475)
+ */
+static int set_extensions_env()
+{
+ char *oldenv = getenv("PYTHONPATH");
+ Glib::ustring tmp = INKSCAPE_EXTENSIONDIR;
+ if (oldenv != NULL) {
+#ifdef WIN32
+ tmp += ";";
+#else
+ tmp += ":";
+#endif
+ tmp += oldenv;
+ }
+ setenv("PYTHONPATH", tmp.c_str(), 1);
+
+ return 0;
+}
/**
@@ -552,6 +556,9 @@ main(int argc, char **argv)
rt.setPathInfo();
#endif
+ // Bug #197475
+ set_extensions_env();
+
/**
* Call bindtextdomain() for various machines's paths
*/
@@ -893,18 +900,18 @@ void sp_process_file_list(GSList *fl)
sp_repr_save_file(repr->document(), sp_export_svg, SP_SVG_NS_URI);
}
if (sp_export_ps) {
- do_export_ps(doc, sp_export_ps, "image/x-postscript");
+ do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript");
}
if (sp_export_eps) {
- do_export_ps(doc, sp_export_eps, "image/x-e-postscript");
+ do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript");
}
if (sp_export_pdf) {
- do_export_pdf(doc, sp_export_pdf, "application/pdf");
- }
+ do_export_ps_pdf(doc, sp_export_pdf, "application/pdf");
+ }
#ifdef WIN32
- if (sp_export_emf) {
- do_export_emf(doc, sp_export_emf, "image/x-emf");
- }
+ if (sp_export_emf) {
+ do_export_emf(doc, sp_export_emf, "image/x-emf");
+ }
#endif //WIN32
if (sp_query_all) {
do_query_all (doc);
@@ -981,7 +988,7 @@ int sp_main_shell(char const* command_name)
resetCommandlineGlobals();
g_strfreev(argv);
} else {
- g_warning("problem parsing commandline: %s", useme);
+ g_warning("Cannot parse commandline: %s", useme);
}
}
}
@@ -1023,7 +1030,6 @@ int sp_main_console(int argc, char const **argv)
} else {
sp_process_file_list(fl); // Normal command line invokation
}
- inkscape_unref();
return 0;
}
@@ -1319,77 +1325,14 @@ sp_do_export_png(SPDocument *doc)
/**
- * Perform an export of either PS or EPS.
- *
- * \param doc Document to export.
- * \param uri URI to export to.
- * \param mime MIME type to export as.
- */
-
-static void do_export_ps(SPDocument* doc, gchar const* uri, char const* mime)
-{
- Inkscape::Extension::DB::OutputList o;
- Inkscape::Extension::db.get_output_list(o);
- Inkscape::Extension::DB::OutputList::const_iterator i = o.begin();
- while (i != o.end() && strcmp( (*i)->get_mimetype(), mime ) != 0) {
- i++;
- }
-
- if (i == o.end())
- {
- g_warning ("Could not find an extension to export to MIME type %s.", mime);
- return;
- }
-
- bool old_text_to_path = false;
- bool old_font_embedded = false;
- bool old_bbox_page = false;
-
- try {
- old_text_to_path = (*i)->get_param_bool("textToPath");
- (*i)->set_param_bool("textToPath", sp_export_text_to_path);
- }
- catch (...) {
- g_warning ("Could not set export-text-to-path option for this export.");
- }
-
- try {
- old_font_embedded = (*i)->get_param_bool("fontEmbedded");
- (*i)->set_param_bool("fontEmbedded", sp_export_font);
- }
- catch (...) {
- g_warning ("Could not set export-font option for this export.");
- }
-
- try {
- old_bbox_page = (*i)->get_param_bool("pageBoundingBox");
- (*i)->set_param_bool("pageBoundingBox", sp_export_bbox_page);
- }
- catch (...) {
- g_warning ("Could not set export-bbox-page option for this export.");
- }
-
- (*i)->save(doc, uri);
-
- try {
- (*i)->set_param_bool("textToPath", old_text_to_path);
- (*i)->set_param_bool("fontEmbedded", old_font_embedded);
- (*i)->set_param_bool("pageBoundingBox", old_bbox_page);
- }
- catch (...) {
-
- }
-}
-
-/**
- * Perform a PDF export
+ * Perform a PDF/PS/EPS export
*
* \param doc Document to export.
* \param uri URI to export to.
* \param mime MIME type to export as.
*/
-static void do_export_pdf(SPDocument* doc, gchar const* uri, char const* mime)
+static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime)
{
Inkscape::Extension::DB::OutputList o;
Inkscape::Extension::db.get_output_list(o);
@@ -1415,16 +1358,33 @@ static void do_export_pdf(SPDocument* doc, gchar const* uri, char const* mime)
(*i)->set_param_string ("exportId", "");
}
+ if (sp_export_area_canvas && sp_export_area_drawing) {
+ g_warning ("You cannot use --export-area-canvas and --export-area-drawing at the same time; only the former will take effect.");
+ sp_export_area_drawing = false;
+ }
+
if (sp_export_area_drawing) {
- (*i)->set_param_bool ("exportDrawing", TRUE);
+ (*i)->set_param_bool ("areaDrawing", TRUE);
} else {
- (*i)->set_param_bool ("exportDrawing", FALSE);
+ (*i)->set_param_bool ("areaDrawing", FALSE);
}
if (sp_export_area_canvas) {
- (*i)->set_param_bool ("exportCanvas", TRUE);
+ if (sp_export_eps) {
+ g_warning ("EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the canvas, --export-area-canvas will clip it to drawing.");
+ }
+ (*i)->set_param_bool ("areaCanvas", TRUE);
} else {
- (*i)->set_param_bool ("exportCanvas", FALSE);
+ (*i)->set_param_bool ("areaCanvas", FALSE);
+ }
+
+ if (!sp_export_area_drawing && !sp_export_area_canvas && !sp_export_id) {
+ // neither is set, set canvas as default for ps/pdf and drawing for eps
+ if (sp_export_eps) {
+ try {
+ (*i)->set_param_bool("areaDrawing", TRUE);
+ } catch (...) {}
+ }
}
if (sp_export_text_to_path) {
@@ -1746,7 +1706,7 @@ sp_process_args(poptContext ctx)
GSList *fl = NULL;
gint a;
- while ((a = poptGetNextOpt(ctx)) >= 0) {
+ while ((a = poptGetNextOpt(ctx)) != -1) {
switch (a) {
case SP_ARG_FILE: {
gchar const *fn = poptGetOptArg(ctx);
@@ -1784,6 +1744,11 @@ sp_process_args(poptContext ctx)
}
break;
}
+ case POPT_ERROR_BADOPT: {
+ g_warning ("Invalid option %s", poptBadOption(ctx, 0));
+ exit(1);
+ break;
+ }
default: {
break;
}
diff --git a/src/marker.cpp b/src/marker.cpp
index fded90c4a..37cb8223c 100644
--- a/src/marker.cpp
+++ b/src/marker.cpp
@@ -37,8 +37,7 @@
struct SPMarkerView {
SPMarkerView *next;
unsigned int key;
- unsigned int size;
- NRArenaItem *items[1];
+ std::vector<NRArenaItem *> items;
};
static void sp_marker_class_init (SPMarkerClass *klass);
@@ -479,12 +478,12 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags)
/* As last step set additional transform of arena group */
for (v = marker->views; v != NULL; v = v->next) {
- for (unsigned i = 0 ; i < v->size ; i++) {
+ for (unsigned i = 0 ; i < v->items.size() ; i++) {
if (v->items[i]) {
Geom::Matrix tmp = marker->c2p;
nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &tmp);
}
- }
+ }
}
}
@@ -609,7 +608,7 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size)
for (view = marker->views; view != NULL; view = view->next) {
if (view->key == key) break;
}
- if (view && (view->size != size)) {
+ if (view && (view->items.size() != size)) {
/* Free old view and allocate new */
/* Parent class ::hide method */
((SPItemClass *) parent_class)->hide ((SPItem *) marker, key);
@@ -617,12 +616,15 @@ sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size)
view = NULL;
}
if (!view) {
- view = (SPMarkerView *)g_malloc (sizeof (SPMarkerView) + (size) * sizeof (NRArenaItem *));
- for (i = 0; i < size; i++) view->items[i] = NULL;
+ view = (SPMarkerView *) g_new (SPMarkerView, 1);
+ new (&view->items) std::vector<NRArenaItem *>;
+ view->items.clear();
+ for (i = 0; i < size; i++) {
+ view->items.push_back(NULL);
+ }
view->next = marker->views;
marker->views = view;
view->key = key;
- view->size = size;
}
}
@@ -637,7 +639,7 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent,
{
for (SPMarkerView *v = marker->views; v != NULL; v = v->next) {
if (v->key == key) {
- if (pos >= v->size) {
+ if (pos >= v->items.size()) {
return NULL;
}
if (!v->items[pos]) {
@@ -715,16 +717,17 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro
v->next = view->next;
}
if (destroyitems) {
- for (i = 0; i < view->size; i++) {
+ for (i = 0; i < view->items.size(); i++) {
/* We have to walk through the whole array because there may be hidden items */
if (view->items[i]) nr_arena_item_unref (view->items[i]);
}
}
+ view->items.clear();
g_free (view);
}
const gchar *
-generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move)
+generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move)
{
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
@@ -736,8 +739,8 @@ generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Mat
// stroke width:
//repr->setAttribute("markerUnits", "userSpaceOnUse");
- sp_repr_set_svg_double(repr, "markerWidth", bounds.extent(NR::X));
- sp_repr_set_svg_double(repr, "markerHeight", bounds.extent(NR::Y));
+ sp_repr_set_svg_double(repr, "markerWidth", bounds.dimensions()[Geom::X]);
+ sp_repr_set_svg_double(repr, "markerHeight", bounds.dimensions()[Geom::Y]);
repr->setAttribute("orient", "auto");
diff --git a/src/marker.h b/src/marker.h
index cc7924486..8f9a2889e 100644
--- a/src/marker.h
+++ b/src/marker.h
@@ -90,7 +90,7 @@ NRArenaItem *sp_marker_show_instance (SPMarker *marker, NRArenaItem *parent,
unsigned int key, unsigned int pos,
Geom::Matrix const &base, float linewidth);
void sp_marker_hide (SPMarker *marker, unsigned int key);
-const gchar *generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move);
+const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move);
#endif
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 680d4f0fe..86ffa8e21 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -19,9 +19,7 @@ static char const menus_skeleton[] =
" <template-list/>\n"
" </submenu>\n"
" <verb verb-id=\"FileOpen\" />\n"
-" <submenu name=\"" N_("Open _Recent") "\">\n"
-" <recent-file-list/>\n"
-" </submenu>\n"
+" <recent-file-list/>\n"
" <verb verb-id=\"FileRevert\" />\n"
" <verb verb-id=\"FileSave\" />\n"
" <verb verb-id=\"FileSaveAs\" />\n"
diff --git a/src/node-context.cpp b/src/node-context.cpp
index f16af7035..9ff7257ce 100644
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
@@ -30,7 +30,7 @@
#include "message-context.h"
#include "node-context.h"
#include "pixmaps/cursor-node-d.xpm"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "xml/node-event-vector.h"
#include "style.h"
#include "splivarot.h"
@@ -160,11 +160,11 @@ sp_node_context_setup(SPEventContext *ec)
nc->shape_editor->set_item(item, SH_KNOTHOLDER);
}
- if (prefs_get_int_attribute("tools.nodes", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/nodes/selcue")) {
ec->enableSelectionCue();
}
-
- if (prefs_get_int_attribute("tools.nodes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/nodes/gradientdrag")) {
ec->enableGrDrag();
}
@@ -234,9 +234,10 @@ static gint
sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
{
gint ret = FALSE;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs_get_int_attribute ("tools.nodes", "pathflash_enabled", 0) == 1) {
- guint timeout = prefs_get_int_attribute("tools.nodes", "pathflash_timeout", 500);
+ if (prefs->getBool("/tools/nodes/pathflash_enabled")) {
+ guint timeout = prefs->getInt("/tools/nodes/pathflash_timeout", 500);
if (SP_IS_LPE_ITEM(item)) {
Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
if (lpe && (lpe->providesOwnFlashPaths() ||
@@ -260,12 +261,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
{
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
- double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); // read every time, to make prefs changes really live
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
- double const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000);
+ double const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); // read every time, to make prefs changes really live
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
+ double const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
if ( (nc->flash_tempitem) && (nc->remove_flash_counter <= 0) ) {
desktop->remove_temporary_canvasitem(nc->flash_tempitem);
@@ -498,6 +500,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
ret = TRUE;
}
break;
+ case GDK_A:
+ case GDK_a:
+ if (MOD__SHIFT_ONLY) {
+ nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_AUTO);
+ ret = TRUE;
+ }
+ break;
case GDK_Y:
case GDK_y:
if (MOD__SHIFT_ONLY) {
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index adcfd8d76..bb63a014d 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -21,10 +21,10 @@
#include "display/sodipodi-ctrl.h"
#include "display/sp-canvas-util.h"
#include <glibmm/i18n.h>
-#include <2geom/pathvector.h>
-#include <2geom/sbasis-to-bezier.h>
-#include <2geom/bezier-curve.h>
-#include <2geom/hvlinesegment.h>
+#include "2geom/pathvector.h"
+#include "2geom/sbasis-to-bezier.h"
+#include "2geom/bezier-curve.h"
+#include "2geom/hvlinesegment.h"
#include "helper/units.h"
#include "helper/geom.h"
#include "knot.h"
@@ -42,7 +42,7 @@
#include "selection-chemistry.h"
#include "selection.h"
#include "xml/repr.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-metrics.h"
#include "sp-path.h"
#include "libnr/nr-matrix-ops.h"
@@ -53,7 +53,6 @@
#include <algorithm>
#include <cstring>
#include <cmath>
-#include <string>
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/effect.h"
@@ -63,7 +62,7 @@
#include "display/snap-indicator.h"
#include "snapped-point.h"
-class Geom::Matrix;
+namespace Geom { class Matrix; }
/// \todo
/// evil evil evil. FIXME: conflict of two different Path classes!
@@ -121,6 +120,7 @@ static Inkscape::NodePath::Node *sp_nodepath_set_node_type(Inkscape::NodePath::N
/* Adjust handle placement, if the node or the other handle is moved */
static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adjust);
static void sp_node_adjust_handles(Inkscape::NodePath::Node *node);
+static void sp_node_adjust_handles_auto(Inkscape::NodePath::Node *node);
/* Node event callbacks */
static void node_clicked(SPKnot *knot, guint state, gpointer data);
@@ -284,6 +284,8 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
return NULL;
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
// Set defaults
np->desktop = desktop;
np->object = object;
@@ -294,10 +296,10 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
np->show_handles = show_handles;
np->helper_path = NULL;
np->helper_path_vec = new HelperPathList;
- np->helperpath_rgba = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff);
+ np->helperpath_rgba = prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff);
np->helperpath_width = 1.0;
np->curve = curve->copy();
- np->show_helperpath = (prefs_get_int_attribute ("tools.nodes", "show_helperpath", 0) == 1);
+ np->show_helperpath = prefs->getBool("/tools/nodes/show_helperpath");
if (SP_IS_LPE_ITEM(object)) {
Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(object));
if (lpe && lpe->isVisible() && lpe->showOrigPath()) {
@@ -602,6 +604,9 @@ Inkscape::NodePath::NodeType * parse_nodetypes(gchar const *types, guint length)
case 's':
typestr[pos++] =Inkscape::NodePath::NODE_SMOOTH;
break;
+ case 'a':
+ typestr[pos++] =Inkscape::NodePath::NODE_AUTO;
+ break;
case 'z':
typestr[pos++] =Inkscape::NodePath::NODE_SYMM;
break;
@@ -824,6 +829,9 @@ static gchar *create_typestr(Inkscape::NodePath::Path *np)
case Inkscape::NodePath::NODE_SMOOTH:
code = 's';
break;
+ case Inkscape::NodePath::NODE_AUTO:
+ code = 'a';
+ break;
case Inkscape::NodePath::NODE_SYMM:
code = 'z';
break;
@@ -1053,6 +1061,15 @@ static void sp_nodepath_set_line_type(Inkscape::NodePath::Node *end, NRPathcode
sp_nodepath_set_node_type(end, Inkscape::NodePath::NODE_CUSP);
}
}
+
+ if (start->type == Inkscape::NodePath::NODE_AUTO)
+ start->type = Inkscape::NodePath::NODE_SMOOTH;
+ if (end->type == Inkscape::NodePath::NODE_AUTO)
+ end->type = Inkscape::NodePath::NODE_SMOOTH;
+
+ sp_node_adjust_handle(start, -1);
+ sp_node_adjust_handle(end, 1);
+
} else {
Geom::Point delta = end->pos - start->pos;
start->n.pos = start->pos + delta / 3;
@@ -1066,6 +1083,25 @@ static void sp_nodepath_set_line_type(Inkscape::NodePath::Node *end, NRPathcode
}
}
+static void
+sp_nodepath_update_node_knot(Inkscape::NodePath::Node *node)
+{
+ if (node->type == Inkscape::NodePath::NODE_CUSP) {
+ node->knot->setShape (SP_KNOT_SHAPE_DIAMOND);
+ node->knot->setSize (node->selected? 11 : 9);
+ sp_knot_update_ctrl(node->knot);
+ } else if (node->type == Inkscape::NodePath::NODE_AUTO) {
+ node->knot->setShape (SP_KNOT_SHAPE_CIRCLE);
+ node->knot->setSize (node->selected? 11 : 9);
+ sp_knot_update_ctrl(node->knot);
+ } else {
+ node->knot->setShape (SP_KNOT_SHAPE_SQUARE);
+ node->knot->setSize (node->selected? 9 : 7);
+ sp_knot_update_ctrl(node->knot);
+ }
+}
+
+
/**
* Change node type, and its handles accordingly.
*/
@@ -1082,15 +1118,7 @@ static Inkscape::NodePath::Node *sp_nodepath_set_node_type(Inkscape::NodePath::N
node->type = type;
- if (node->type == Inkscape::NodePath::NODE_CUSP) {
- node->knot->setShape (SP_KNOT_SHAPE_DIAMOND);
- node->knot->setSize (node->selected? 11 : 9);
- sp_knot_update_ctrl(node->knot);
- } else {
- node->knot->setShape (SP_KNOT_SHAPE_SQUARE);
- node->knot->setSize (node->selected? 9 : 7);
- sp_knot_update_ctrl(node->knot);
- }
+ sp_nodepath_update_node_knot(node);
// if one of handles is mouseovered, preserve its position
if (node->p.knot && SP_KNOT_IS_MOUSEOVER(node->p.knot)) {
@@ -1140,6 +1168,13 @@ sp_node_side_is_line (Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeSi
*/
void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeType type)
{
+ if (type == Inkscape::NodePath::NODE_AUTO) {
+ if (node->p.other != NULL)
+ node->code = NR_CURVETO;
+ if (node->n.other != NULL)
+ node->n.other->code = NR_CURVETO;
+ }
+
if (type == Inkscape::NodePath::NODE_SYMM || type == Inkscape::NodePath::NODE_SMOOTH) {
/*
@@ -1215,28 +1250,7 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
node->code = NR_CURVETO;
node->n.other->code = NR_CURVETO;
- Geom::Point leg_prev = node->pos - node->p.other->pos;
- Geom::Point leg_next = node->pos - node->n.other->pos;
-
- double norm_leg_prev = L2(leg_prev);
- double norm_leg_next = L2(leg_next);
-
- Geom::Point delta;
- if (norm_leg_next > 0.0) {
- delta = (norm_leg_prev / norm_leg_next) * leg_next - leg_prev;
- (&delta)->normalize();
- }
-
- if (type == Inkscape::NodePath::NODE_SYMM) {
- double norm_leg_avg = (norm_leg_prev + norm_leg_next) / 2;
- node->p.pos = node->pos + 0.3 * norm_leg_avg * delta;
- node->n.pos = node->pos - 0.3 * norm_leg_avg * delta;
- } else {
- // length of handle is proportional to distance to adjacent node
- node->p.pos = node->pos + 0.3 * norm_leg_prev * delta;
- node->n.pos = node->pos - 0.3 * norm_leg_next * delta;
- }
-
+ sp_node_adjust_handles_auto(node);
} else {
// pull the handle opposite to line segment, making it half-smooth
if (p_is_line && node->n.other) {
@@ -1270,11 +1284,16 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
*/
void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
{
- Geom::Point delta = p - node->pos;
- node->pos = p;
+ if (node->type == Inkscape::NodePath::NODE_AUTO) {
+ node->pos = p;
+ sp_node_adjust_handles_auto(node);
+ } else {
+ Geom::Point delta = p - node->pos;
+ node->pos = p;
- node->p.pos += delta;
- node->n.pos += delta;
+ node->p.pos += delta;
+ node->n.pos += delta;
+ }
Inkscape::NodePath::Node *node_p = NULL;
Inkscape::NodePath::Node *node_n = NULL;
@@ -1285,6 +1304,10 @@ void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
sp_node_adjust_handle(node->p.other, -1);
node_p = node->p.other;
}
+ if (!node->p.other->selected && node->p.other->type == Inkscape::NodePath::NODE_AUTO) {
+ sp_node_adjust_handles_auto(node->p.other);
+ node_p = node->p.other;
+ }
}
if (node->n.other) {
if (node->n.other->code == NR_LINETO) {
@@ -1292,6 +1315,10 @@ void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
sp_node_adjust_handle(node->n.other, 1);
node_n = node->n.other;
}
+ if (!node->n.other->selected && node->n.other->type == Inkscape::NodePath::NODE_AUTO) {
+ sp_node_adjust_handles_auto(node->n.other);
+ node_n = node->n.other;
+ }
}
// this function is only called from batch movers that will update display at the end
@@ -1343,9 +1370,9 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
if (constrained) {
Inkscape::Snapper::ConstraintLine dedicated_constraint = constraint;
dedicated_constraint.setPoint(n->pos);
- s = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(n->pos + delta), dedicated_constraint);
+ s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(n->pos + delta), dedicated_constraint);
} else {
- s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(n->pos + delta));
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(n->pos + delta));
}
if (s.getSnapped() && (s.getDistance() < best)) {
best = s.getDistance();
@@ -1443,7 +1470,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (pressure > 0.5)
alpha = 1/alpha;
- guint profile = prefs_get_int_attribute("tools.nodes", "sculpting_profile", SCULPT_PROFILE_BELL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint profile = prefs->getInt("/tools/nodes/sculpting_profile", SCULPT_PROFILE_BELL);
if (sp_nodepath_selection_get_subpath_count(nodepath) <= 1) {
// Only one subpath has selected nodes:
@@ -2072,6 +2100,15 @@ sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, G
g_return_if_fail(e != NULL);
g_return_if_fail(&e->p != NULL);
+ if (e->type == Inkscape::NodePath::NODE_AUTO) {
+ e->type = Inkscape::NodePath::NODE_SMOOTH;
+ sp_nodepath_update_node_knot (e);
+ }
+ if (e->p.other->type == Inkscape::NodePath::NODE_AUTO) {
+ e->p.other->type = Inkscape::NodePath::NODE_SMOOTH;
+ sp_nodepath_update_node_knot (e->p.other);
+ }
+
/* feel good is an arbitrary parameter that distributes the delta between handles
* if t of the drag point is less than 1/6 distance form the endpoint only
* the corresponding hadle is adjusted. This matches the behavior in GIMP
@@ -3232,6 +3269,10 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj
{
g_assert(node);
+ // nothing to do for auto nodes (sp_node_adjust_handles() does the job)
+ if (node->type == Inkscape::NodePath::NODE_AUTO)
+ return;
+
Inkscape::NodePath::NodeSide *me = sp_node_get_side(node, which_adjust);
Inkscape::NodePath::NodeSide *other = sp_node_opposite_side(node, me);
@@ -3291,6 +3332,11 @@ static void sp_node_adjust_handles(Inkscape::NodePath::Node *node)
if (node->p.other == NULL) return;
if (node->n.other == NULL) return;
+ if (node->type == Inkscape::NodePath::NODE_AUTO) {
+ sp_node_adjust_handles_auto(node);
+ return;
+ }
+
if (sp_node_side_is_line(node, &node->p)) {
sp_node_adjust_handle(node, 1);
return;
@@ -3319,6 +3365,30 @@ static void sp_node_adjust_handles(Inkscape::NodePath::Node *node)
node->n.pos = node->pos + (nlen / (plen + nlen)) * delta;
}
+static void sp_node_adjust_handles_auto(Inkscape::NodePath::Node *node)
+{
+ if (node->p.other == NULL || node->n.other == NULL) {
+ node->p.pos = node->pos;
+ node->n.pos = node->pos;
+ return;
+ }
+
+ Geom::Point leg_prev = to_2geom(node->p.other->pos - node->pos);
+ Geom::Point leg_next = to_2geom(node->n.other->pos - node->pos);
+
+ double norm_leg_prev = Geom::L2(leg_prev);
+ double norm_leg_next = Geom::L2(leg_next);
+
+ Geom::Point delta;
+ if (norm_leg_next > 0.0) {
+ delta = (norm_leg_prev / norm_leg_next) * leg_next - leg_prev;
+ delta.normalize();
+ }
+
+ node->p.pos = node->pos - norm_leg_prev / 3 * delta;
+ node->n.pos = node->pos + norm_leg_next / 3 * delta;
+}
+
/**
* Node event callback.
*/
@@ -3422,6 +3492,10 @@ gboolean node_key(GdkEvent *event)
sp_nodepath_set_node_type(Inkscape::NodePath::Path::active_node,Inkscape::NodePath::NODE_SMOOTH);
ret = TRUE;
break;
+ case GDK_a:
+ sp_nodepath_set_node_type(Inkscape::NodePath::Path::active_node,Inkscape::NodePath::NODE_AUTO);
+ ret = TRUE;
+ break;
case GDK_y:
sp_nodepath_set_node_type(Inkscape::NodePath::Path::active_node,Inkscape::NodePath::NODE_SYMM);
ret = TRUE;
@@ -3451,6 +3525,8 @@ static void node_clicked(SPKnot */*knot*/, guint state, gpointer data)
sp_nodepath_convert_node_type (n,Inkscape::NodePath::NODE_SMOOTH);
} else if (n->type == Inkscape::NodePath::NODE_SMOOTH) {
sp_nodepath_convert_node_type (n,Inkscape::NodePath::NODE_SYMM);
+ } else if (n->type == Inkscape::NodePath::NODE_SYMM) {
+ sp_nodepath_convert_node_type (n,Inkscape::NodePath::NODE_AUTO);
} else {
sp_nodepath_convert_node_type (n,Inkscape::NodePath::NODE_CUSP);
}
@@ -3757,6 +3833,12 @@ static void node_handle_grabbed(SPKnot *knot, guint state, gpointer data)
{
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
+ // convert auto -> smooth when dragging handle
+ if (n->type == Inkscape::NodePath::NODE_AUTO) {
+ n->type = Inkscape::NodePath::NODE_SMOOTH;
+ sp_nodepath_update_node_knot (n);
+ }
+
if (!n->selected) {
sp_nodepath_node_select(n, (state & GDK_SHIFT_MASK), FALSE);
}
@@ -3842,16 +3924,16 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, g
(*p) = n->pos + (scal / linelen) * ndelta;
}
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(*p), Inkscape::Snapper::ConstraintLine(*p, ndelta));
+ s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(*p), Inkscape::Snapper::ConstraintLine(*p, ndelta));
}
} else {
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(*p));
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(*p));
}
}
} else {
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(*p));
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(*p));
}
}
@@ -3870,6 +3952,7 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, g
static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointer data)
{
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::NodePath::NodeSide *me;
Inkscape::NodePath::NodeSide *other;
@@ -3891,7 +3974,7 @@ static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointe
Radial rnew(*p - n->pos);
if (state & GDK_CONTROL_MASK && rnew.a != HUGE_VAL) {
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
/* 0 interpreted as "no snapping". */
// 1. Snap to the closest PI/snaps angle, starting from zero.
@@ -3970,7 +4053,7 @@ static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointe
double degrees = 180 / M_PI * rnew.a;
if (degrees > 180) degrees -= 360;
if (degrees < -180) degrees += 360;
- if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0)
+ if (prefs->getBool("/options/compassangledisplay/value"))
degrees = angle_to_compass (degrees);
GString *length = SP_PX_TO_METRIC_STRING(rnew.r, desktop->namedview->getDefaultMetric());
@@ -4517,7 +4600,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node *
n->knot = sp_knot_new(sp->nodepath->desktop, _("<b>Node</b>: drag to edit the path; with <b>Ctrl</b> to snap to horizontal/vertical; with <b>Ctrl+Alt</b> to snap to handles' directions"));
sp_knot_set_position(n->knot, *pos, 0);
- n->knot->setShape ((n->type == Inkscape::NodePath::NODE_CUSP)? SP_KNOT_SHAPE_DIAMOND : SP_KNOT_SHAPE_SQUARE);
+ n->knot->setShape ((n->type == Inkscape::NodePath::NODE_CUSP)? SP_KNOT_SHAPE_DIAMOND : (n->type == Inkscape::NodePath::NODE_AUTO)? SP_KNOT_SHAPE_CIRCLE : SP_KNOT_SHAPE_SQUARE);
n->knot->setSize ((n->type == Inkscape::NodePath::NODE_CUSP)? 9 : 7);
n->knot->setAnchor (GTK_ANCHOR_CENTER);
n->knot->setFill(NODE_FILL, NODE_FILL_HI, NODE_FILL_HI);
@@ -4757,6 +4840,8 @@ static gchar const *sp_node_type_description(Inkscape::NodePath::Node *node)
case Inkscape::NodePath::NODE_SMOOTH:
// TRANSLATORS: "smooth" is an adjective here
return _("smooth");
+ case Inkscape::NodePath::NODE_AUTO:
+ return _("auto");
case Inkscape::NodePath::NODE_SYMM:
return _("symmetric");
}
@@ -4894,14 +4979,14 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) {
}
}
-/**
+/*
SPCanvasItem *
sp_nodepath_path_to_canvasitem(Inkscape::NodePath::Path *np, SPPath *path) {
return sp_nodepath_make_helper_item(np, sp_path_get_curve_for_edit(path));
}
-**/
+*/
-/**
+/*
SPCanvasItem *
sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color = 0xff0000ff) {
SPCurve *flash_curve = curve->copy();
@@ -4919,10 +5004,11 @@ sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem
SPCanvasItem *
sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
return sp_nodepath_generate_helperpath(desktop, sp_path_get_curve_for_edit(path), SP_ITEM(path),
- prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff));
+ prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff));
}
-**/
+*/
SPCanvasItem *
sp_nodepath_helperpath_from_path(SPDesktop *desktop, SPPath *path) {
@@ -4932,7 +5018,8 @@ sp_nodepath_helperpath_from_path(SPDesktop *desktop, SPPath *path) {
SPCanvasItem * canvasitem = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), flash_curve);
// would be nice if its color could be XORed or something, now it is invisible for red stroked objects...
// unless we also flash the nodes...
- guint32 color = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint32 color = prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvasitem), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_show(canvasitem);
diff --git a/src/nodepath.h b/src/nodepath.h
index 336c9019c..4d05b9f01 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -145,6 +145,8 @@ typedef enum {
NODE_CUSP,
/** This node continuously joins two segments. */
NODE_SMOOTH,
+/** This node has automatic handles. */
+ NODE_AUTO,
/** This node is symmetric. */
NODE_SYMM
} NodeType;
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 63e404e4b..86e1f5302 100644
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -25,7 +25,7 @@
#include "sp-spiral.h"
#include "sp-offset.h"
#include "sp-flowtext.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop-affine.h"
#include "style.h"
#include "desktop.h"
@@ -741,7 +741,8 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p)
void
ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
SPArc *arc = SP_ARC(item);
@@ -772,7 +773,8 @@ ArcKnotHolderEntityStart::knot_get()
void
ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
SPArc *arc = SP_ARC(item);
@@ -1080,7 +1082,8 @@ public:
void
SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
SPSpiral *spiral = SP_SPIRAL(item);
@@ -1122,7 +1125,8 @@ SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &/
void
SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
SPSpiral *spiral = SP_SPIRAL(item);
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index cbf31c271..0458add78 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -25,7 +25,7 @@
#include "sp-use.h"
#include "display/curve.h"
#include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
@@ -46,7 +46,7 @@ Inkscape::SnapCandidate::~SnapCandidate()
Inkscape::ObjectSnapper::ObjectSnapper(SnapManager const *sm, Geom::Coord const d)
: Snapper(sm, d), _snap_to_itemnode(true), _snap_to_itempath(true),
_snap_to_bboxnode(true), _snap_to_bboxpath(true), _snap_to_page_border(false),
- _strict_snapping(true), _include_item_center(false)
+ _strict_snapping(true)
{
_candidates = new std::vector<SnapCandidate>;
_points_to_snap_to = new std::vector<Geom::Point>;
@@ -163,7 +163,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
}
-void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &t,
+void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType const &t,
bool const &first_point) const
{
// Now, let's first collect all points to snap to. If we have a whole bunch of points to snap,
@@ -175,16 +175,17 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &
// Determine the type of bounding box we should snap to
SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
- bool p_is_a_node = t & Inkscape::Snapper::SNAPPOINT_NODE;
- bool p_is_a_bbox = t & Inkscape::Snapper::SNAPPOINT_BBOX;
- bool p_is_a_guide = t & Inkscape::Snapper::SNAPPOINT_GUIDE;
+ bool p_is_a_node = t & Inkscape::SnapPreferences::SNAPPOINT_NODE;
+ bool p_is_a_bbox = t & Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+ bool p_is_a_guide = t & Inkscape::SnapPreferences::SNAPPOINT_GUIDE;
// A point considered for snapping should be either a node, a bbox corner or a guide. Pick only ONE!
- g_assert(!(p_is_a_node && p_is_a_bbox || p_is_a_bbox && p_is_a_guide || p_is_a_node && p_is_a_guide));
+ g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_a_guide) || (p_is_a_node && p_is_a_guide)));
if (_snap_to_bboxnode) {
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- bbox_type = (prefs_bbox == 0)?
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool prefs_bbox = prefs->getBool("/tools/bounding_box");
+ bbox_type = !prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
}
@@ -204,7 +205,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &
//Collect all nodes so we can snap to them
if (_snap_to_itemnode) {
if (!(_strict_snapping && !p_is_a_node) || p_is_a_guide) {
- sp_item_snappoints(root_item, _include_item_center, SnapPointsIter(*_points_to_snap_to));
+ sp_item_snappoints(root_item, SnapPointsIter(*_points_to_snap_to), &_snapmanager->snapprefs);
}
}
@@ -228,7 +229,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &
}
void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
std::vector<Geom::Point> *unselected_nodes) const
@@ -258,7 +259,7 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
}
void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
Geom::Point const &guide_normal) const
{
@@ -275,7 +276,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
Geom::Point p_proj = project_on_linesegment(*k, p, p + Geom::rot90(guide_normal));
Geom::Coord dist = Geom::L2(*k - p_proj); // distance from node to the guide
Geom::Coord dist2 = Geom::L2(p - p_proj); // distance from projection of node on the guide, to the mouse location
- if ((dist < tol && dist2 < tol || getSnapperAlwaysSnap()) && dist < s.getDistance()) {
+ if ((dist < tol && dist2 < tol) || (getSnapperAlwaysSnap() && dist < s.getDistance())) {
s = SnappedPoint(*k, SNAPTARGET_NODE, dist, tol, getSnapperAlwaysSnap(), true);
success = true;
}
@@ -291,7 +292,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
* Returns index of first NR_END bpath in array.
*/
-void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &t,
+void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapPreferences::PointType const &t,
bool const &first_point) const
{
// Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap,
@@ -303,11 +304,12 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
// Determine the type of bounding box we should snap to
SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
- bool p_is_a_node = t & Inkscape::Snapper::SNAPPOINT_NODE;
+ bool p_is_a_node = t & Inkscape::SnapPreferences::SNAPPOINT_NODE;
if (_snap_to_bboxpath) {
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- bbox_type = (prefs_bbox ==0)?
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
+ bbox_type = !prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
}
@@ -389,7 +391,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
}
void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
std::vector<Geom::Point> *unselected_nodes,
@@ -487,7 +489,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve
}
void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
ConstraintLine const &c) const
@@ -545,14 +547,14 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
std::vector<SPItem const *> const *it,
std::vector<Geom::Point> *unselected_nodes) const
{
- if (_snap_enabled == false || getSnapFrom(t) == false ) {
+ if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false ) {
return;
}
@@ -588,14 +590,14 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
}
void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
ConstraintLine const &c,
std::vector<SPItem const *> const *it) const
{
- if (_snap_enabled == false || getSnapFrom(t) == false) {
+ if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
return;
}
@@ -649,7 +651,7 @@ void Inkscape::ObjectSnapper::guideSnap(SnappedConstraints &sc,
// line, or can it be located anywhere?)
_findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity());
- _snapTranslatingGuideToNodes(sc, Inkscape::Snapper::SNAPPOINT_GUIDE, p, guide_normal);
+ _snapTranslatingGuideToNodes(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, guide_normal);
// _snapRotatingGuideToNodes has not been implemented yet.
}
@@ -659,13 +661,13 @@ void Inkscape::ObjectSnapper::guideSnap(SnappedConstraints &sc,
bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const
{
bool snap_to_something = _snap_to_itempath || _snap_to_itemnode || _snap_to_bboxpath || _snap_to_bboxnode || _snap_to_page_border;
- return (_snap_enabled && _snap_from != 0 && snap_to_something);
+ return (_snap_enabled && _snapmanager->snapprefs.getSnapModeBBoxOrNodes() && snap_to_something);
}
bool Inkscape::ObjectSnapper::GuidesMightSnap() const
{
bool snap_to_something = _snap_to_itemnode || _snap_to_bboxnode;
- return (_snap_enabled && (_snap_from & SNAPPOINT_GUIDE) && snap_to_something);
+ return (_snap_enabled && _snapmanager->snapprefs.getSnapModeGuide() && snap_to_something);
}
void Inkscape::ObjectSnapper::_clear_paths() const
diff --git a/src/object-snapper.h b/src/object-snapper.h
index c567e115b..01ef8cf50 100644
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
@@ -66,9 +66,6 @@ public:
bool getSnapToBBoxPath() const {return _snap_to_bboxpath;}
void setSnapToPageBorder(bool s) {_snap_to_page_border = s;}
bool getSnapToPageBorder() const {return _snap_to_page_border;}
- void setIncludeItemCenter(bool s) {_include_item_center = s;}
- bool getIncludeItemCenter() const {return _include_item_center;}
- void setStrictSnapping(bool enabled) {_strict_snapping = enabled;}
void guideSnap(SnappedConstraints &sc,
Geom::Point const &p,
Geom::Point const &guide_normal) const;
@@ -77,7 +74,7 @@ public:
bool GuidesMightSnap() const;
void freeSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
@@ -85,7 +82,7 @@ public:
std::vector<Geom::Point> *unselected_nodes) const;
void constrainedSnap(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
bool const &first_point,
boost::optional<Geom::Rect> const &bbox_to_snap,
@@ -107,35 +104,35 @@ private:
Geom::Matrix const additional_affine) const;
void _snapNodes(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p, // in desktop coordinates
bool const &first_point,
std::vector<Geom::Point> *unselected_nodes) const; // in desktop coordinates
void _snapTranslatingGuideToNodes(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p,
Geom::Point const &guide_normal) const;
- void _collectNodes(Inkscape::Snapper::PointType const &t,
+ void _collectNodes(Inkscape::SnapPreferences::PointType const &t,
bool const &first_point) const;
void _snapPaths(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p, // in desktop coordinates
bool const &first_point,
std::vector<Geom::Point> *unselected_nodes, // in desktop coordinates
SPPath const *selected_path) const;
void _snapPathsConstrained(SnappedConstraints &sc,
- Inkscape::Snapper::PointType const &t,
+ Inkscape::SnapPreferences::PointType const &t,
Geom::Point const &p, // in desktop coordinates
bool const &first_point,
ConstraintLine const &c) const;
bool isUnselectedNode(Geom::Point const &point, std::vector<Geom::Point> const *unselected_nodes) const;
- void _collectPaths(Inkscape::Snapper::PointType const &t,
+ void _collectPaths(Inkscape::SnapPreferences::PointType const &t,
bool const &first_point) const;
void _clear_paths() const;
@@ -154,7 +151,6 @@ private:
//snap bbox corners to nodes, or nodes to bboxes.
//(snapping to grids and guides is not affected by this)
bool _strict_snapping;
- bool _include_item_center;
};
}
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 0dd73bba9..0227e9caf 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -38,18 +38,6 @@
#include <2geom/pathvector.h>
#include "path-chemistry.h"
-/* Helper functions for sp_selected_path_to_curves */
-static void sp_selected_path_to_curves0(SPDesktop *desktop, bool do_document_done, guint32 text_grouping_policy);
-static bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select);
-
-enum {
- /* Not used yet. This is the placeholder of Lauris's idea. */
- SP_TOCURVE_INTERACTIVE = 1 << 0,
- SP_TOCURVE_GROUPING_BY_WORD = 1 << 1,
- SP_TOCURVE_GROUPING_BY_LINE = 1 << 2,
- SP_TOCURVE_GROUPING_BY_WHOLE = 1 << 3
-};
-
void
sp_selected_path_combine(SPDesktop *desktop)
{
@@ -282,12 +270,6 @@ sp_selected_path_break_apart(SPDesktop *desktop)
void
sp_selected_path_to_curves(SPDesktop *desktop, bool interactive)
{
- sp_selected_path_to_curves0(desktop, interactive, interactive ? SP_TOCURVE_INTERACTIVE : 0);
-}
-
-static void
-sp_selected_path_to_curves0(SPDesktop *desktop, bool interactive, guint32 /*text_grouping_policy*/)
-{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (selection->isEmpty()) {
@@ -328,7 +310,7 @@ sp_selected_path_to_curves0(SPDesktop *desktop, bool interactive, guint32 /*text
}
}
-static bool
+bool
sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select)
{
bool did = false;
@@ -427,12 +409,86 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
if (!item)
return NULL;
+ Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document();
+
+ if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ // Special treatment for text: convert each glyph to separate path, then group the paths
+ Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g");
+ g_repr->setAttribute("transform", SP_OBJECT_REPR(item)->attribute("transform"));
+ /* Mask */
+ gchar *mask_str = (gchar *) SP_OBJECT_REPR(item)->attribute("mask");
+ if ( mask_str )
+ g_repr->setAttribute("mask", mask_str);
+ /* Clip path */
+ gchar *clip_path_str = (gchar *) SP_OBJECT_REPR(item)->attribute("clip-path");
+ if ( clip_path_str )
+ g_repr->setAttribute("clip-path", clip_path_str);
+ /* Rotation center */
+ g_repr->setAttribute("inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x"), false);
+ g_repr->setAttribute("inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y"), false);
+ /* Whole text's style */
+ gchar *style_str = sp_style_write_difference(SP_OBJECT_STYLE(item),
+ SP_OBJECT_STYLE(SP_OBJECT_PARENT(item)));
+ g_repr->setAttribute("style", style_str);
+ g_free(style_str);
+ Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin();
+ do {
+ Inkscape::Text::Layout::iterator iter_next = iter;
+ iter_next.nextGlyph(); // iter_next is one glyph ahead from iter
+ if (iter == iter_next)
+ break;
+
+ /* This glyph's style */
+ SPObject const *pos_obj = 0;
+ void *rawptr = 0;
+ te_get_layout(item)->getSourceOfCharacter(iter, &rawptr);
+ if (!rawptr || !SP_IS_OBJECT(rawptr)) // no source for glyph, abort
+ break;
+ pos_obj = SP_OBJECT(rawptr);
+ while (SP_IS_STRING(pos_obj) && SP_OBJECT_PARENT(pos_obj)) {
+ pos_obj = SP_OBJECT_PARENT(pos_obj); // SPStrings don't have style
+ }
+ gchar *style_str = sp_style_write_difference(SP_OBJECT_STYLE(pos_obj),
+ SP_OBJECT_STYLE(SP_OBJECT_PARENT(pos_obj)));
+
+ // get path from iter to iter_next:
+ SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next);
+ iter = iter_next; // shift to next glyph
+ if (!curve) { // error converting this glyph
+ g_free (style_str);
+ continue;
+ }
+ if (curve->is_empty()) { // whitespace glyph?
+ curve->unref();
+ g_free (style_str);
+ continue;
+ }
+
+ Inkscape::XML::Node *p_repr = xml_doc->createElement("svg:path");
+
+ gchar *def_str = sp_svg_write_path(curve->get_pathvector());
+ p_repr->setAttribute("d", def_str);
+ g_free(def_str);
+ curve->unref();
+
+ p_repr->setAttribute("style", style_str);
+ g_free(style_str);
+
+ g_repr->appendChild(p_repr);
+ Inkscape::GC::release(p_repr);
+
+ if (iter == te_get_layout(item)->end())
+ break;
+
+ } while (true);
+
+ return g_repr;
+ }
+
SPCurve *curve = NULL;
if (SP_IS_SHAPE(item)) {
curve = sp_shape_get_curve(SP_SHAPE(item));
- } else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
- curve = te_get_layout(item)->convertToCurves();
- }
+ }
if (!curve)
return NULL;
@@ -445,7 +501,6 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
return NULL;
}
- Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Transformation */
repr->setAttribute("transform", SP_OBJECT_REPR(item)->attribute("transform"));
diff --git a/src/path-chemistry.h b/src/path-chemistry.h
index 27c3b8680..14b2b6ffb 100644
--- a/src/path-chemistry.h
+++ b/src/path-chemistry.h
@@ -20,6 +20,7 @@ void sp_selected_path_break_apart (SPDesktop *desktop);
void sp_selected_path_to_curves (SPDesktop *desktop, bool interactive = true);
Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy);
void sp_selected_path_reverse (SPDesktop *desktop);
+bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select);
#endif
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 9d11df059..eb399d191 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -29,7 +29,7 @@
#include "draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-path.h"
#include "display/curve.h"
#include "pixmaps/cursor-pen.xpm"
@@ -49,7 +49,7 @@ static void sp_pen_context_dispose(GObject *object);
static void sp_pen_context_setup(SPEventContext *ec);
static void sp_pen_context_finish(SPEventContext *ec);
-static void sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_pen_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event);
static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
@@ -193,7 +193,8 @@ sp_pen_context_dispose(GObject *object)
void
sp_pen_context_set_polyline_mode(SPPenContext *const pc) {
- guint mode = prefs_get_int_attribute("tools.freehand.pen", "freehand-mode", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0);
pc->polylines_only = (mode == 2 || mode == 3);
pc->polylines_paraxial = (mode == 3);
}
@@ -233,7 +234,8 @@ sp_pen_context_setup(SPEventContext *ec)
sp_pen_context_set_polyline_mode(pc);
- if (prefs_get_int_attribute("tools.freehand.pen", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/freehand/pen/selcue")) {
ec->enableSelectionCue();
}
}
@@ -275,12 +277,13 @@ sp_pen_context_finish(SPEventContext *ec)
* Callback that sets key to value in pen context.
*/
static void
-sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_pen_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPPenContext *pc = SP_PEN_CONTEXT(ec);
+ Glib::ustring name = val->getEntryName();
- if (!strcmp(key, "mode")) {
- if ( val && !strcmp(val, "drag") ) {
+ if (name == "mode") {
+ if ( val->getString() == "drag" ) {
pc->mode = SP_PEN_CONTEXT_MODE_DRAG;
} else {
pc->mode = SP_PEN_CONTEXT_MODE_CLICK;
@@ -465,7 +468,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
if (pc->npoints == 0) {
if (bevent.state & GDK_CONTROL_MASK) {
- spdc_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state);
+ spdc_create_single_dot(event_context, event_dt, "/tools/freehand/pen", bevent.state);
ret = TRUE;
break;
}
@@ -597,8 +600,8 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent)
Geom::Point const event_w(mevent.x,
mevent.y);
if (pen_within_tolerance) {
- gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
- "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if ( NR::LInfty( event_w - pen_drag_origin_w ) < tolerance ) {
return FALSE; // Do not drag if we're within tolerance from origin.
}
@@ -962,7 +965,8 @@ static gint
pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
{
gint ret = FALSE;
- gdouble const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
switch (get_group0_keyval (&event->key)) {
@@ -1210,7 +1214,8 @@ spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point c
Geom::Point rel = p - pc->p[pc_point_to_compare];
GString *dist = SP_PX_TO_METRIC_STRING(NR::L2(rel), desktop->namedview->getDefaultMetric());
double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI;
- if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0)
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/options/compassangledisplay/value", 0) != 0)
angle = angle_to_compass (angle);
pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str);
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 96313ab37..acc10389c 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -27,7 +27,7 @@
#include "message-context.h"
#include "modifier-fns.h"
#include "sp-path.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "snap.h"
#include "pixmaps/cursor-pencil.xpm"
#include "display/bezier-utils.h"
@@ -130,7 +130,8 @@ sp_pencil_context_init(SPPencilContext *pc)
static void
sp_pencil_context_setup(SPEventContext *ec)
{
- if (prefs_get_int_attribute("tools.freehand.pencil", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/freehand/pencil/selcue")) {
ec->enableSelectionCue();
}
@@ -241,7 +242,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
default:
/* Set first point of sequence */
if (bevent.state & GDK_CONTROL_MASK) {
- spdc_create_single_dot(event_context, from_2geom(p), "tools.freehand.pencil", bevent.state);
+ spdc_create_single_dot(event_context, from_2geom(p), "/tools/freehand/pencil", bevent.state);
ret = true;
break;
}
@@ -259,7 +260,13 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
+ Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, p);
+ if (s.getSnapped()) {
+ s.getPoint(p);
+ pc->pencil_has_snapped_before = true;
+ } else {
+ pc->pencil_has_snapped_before = false;
+ }
} else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
}
@@ -309,8 +316,8 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
SPDrawAnchor *anchor = spdc_test_inside(pc, Geom::Point(mevent.x, mevent.y));
if (pencil_within_tolerance) {
- gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
- "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if ( NR::LInfty( Geom::Point(mevent.x,mevent.y) - pencil_drag_origin_w ) < tolerance ) {
return FALSE; // Do not drag if we're within tolerance from origin.
}
@@ -346,16 +353,25 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
* fixme: I am not sure whether we want to snap to anchors
* in middle of freehand (Lauris)
*/
+ SnapManager &m = dt->namedview->snap_manager;
+
if (anchor) {
p = to_2geom(anchor->dp);
} else if ((mevent.state & GDK_SHIFT_MASK) == 0) {
- SnapManager &m = dt->namedview->snap_manager;
m.setup(dt);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
+ Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, p);
+ if (s.getSnapped()) {
+ s.getPoint(p);
+ pc->pencil_has_snapped_before = true;
+ }
}
- if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context!
- spdc_add_freehand_point(pc, from_2geom(p), mevent.state);
- ret = TRUE;
+ if ( pc->npoints != 0) { // buttonpress may have happened before we entered draw context!
+ if (!(pc->pencil_has_snapped_before && m.snapprefs.getSnapPostponedGlobally())) {
+ // When snapping is enabled but temporarily on hold because the mouse is moving
+ // fast, then we don't want to add nodes off-grid
+ spdc_add_freehand_point(pc, from_2geom(p), mevent.state);
+ ret = TRUE;
+ }
}
if (anchor && !pc->anchor_statusbar) {
@@ -633,7 +649,8 @@ fit_and_split(SPPencilContext *pc)
{
g_assert( pc->npoints > 1 );
- double const tol = prefs_get_double_attribute_limited("tools.freehand.pencil", "tolerance", 10.0, 1.0, 100.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
double const tolerance_sq = 0.02 * square( pc->desktop->w2d().descrim() * tol)
* exp(0.2*tol - 2);
diff --git a/src/pencil-context.h b/src/pencil-context.h
index 87e9b2470..467241b17 100644
--- a/src/pencil-context.h
+++ b/src/pencil-context.h
@@ -30,6 +30,7 @@ struct SPPencilContext : public SPDrawContext {
Geom::Point req_tangent;
bool is_drawing;
+ bool pencil_has_snapped_before;
};
/// The SPPencilContext vtable (empty).
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 6cf1b3feb..c6b547a9e 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -276,6 +276,7 @@ static char const preferences_skeleton[] =
" <group id=\"compassangledisplay\" value=\"0\"/>\n"
" <group id=\"maskobject\" topmost=\"1\" remove=\"1\"/>\n"
" <group id=\"blurquality\" value=\"0\"/>\n"
+" <group id=\"filterquality\" value=\"0\"/>\n"
" <group id=\"showfiltersinfobox\" value=\"1\" />\n"
" <group id=\"startmode\" outline=\"0\"/>\n"
" <group id=\"outlinemode\" value=\"0\"/>\n"
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 54ab79448..e999182c7 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -2,7 +2,7 @@
* @brief Singleton class to access the preferences file - implementation
*/
/* Authors:
- * Krzysztof Kosinski <tweenk.pl@gmail.com>
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
* Copyright (C) 2008 Authors
*
@@ -14,6 +14,10 @@
#include "inkscape.h"
#include "xml/repr.h"
#include "xml/node-observer.h"
+#include "xml/node-iterators.h"
+#include "xml/attribute-record.h"
+#include <cstring>
+#include <vector>
#include <glibmm/fileutils.h>
#include <glibmm/i18n.h>
#include <glib.h>
@@ -24,6 +28,28 @@
namespace Inkscape {
+// private inner class definition
+
+/**
+ * @brief XML - prefs observer bridge
+ *
+ * This is an XML node observer that watches for changes in the XML document storing the preferences.
+ * It is used to implement preference observers.
+ */
+class Preferences::PrefNodeObserver : public XML::NodeObserver {
+public:
+ PrefNodeObserver(Observer &o, Glib::ustring const &filter) :
+ _observer(o),
+ _filter(filter)
+ {}
+ virtual ~PrefNodeObserver() {}
+ virtual void notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared<char>, Util::ptr_shared<char>);
+private:
+ Observer &_observer;
+ Glib::ustring const _filter;
+};
+
+
Preferences::Preferences() :
_prefs_basename(PREFERENCES_FILE_NAME),
_prefs_dir(""),
@@ -35,11 +61,11 @@ Preferences::Preferences() :
gchar *path = profile_path(NULL);
_prefs_dir = path;
g_free(path);
-
+
path = profile_path(_prefs_basename.data());
_prefs_filename = path;
g_free(path);
-
+
_load();
}
@@ -47,6 +73,12 @@ Preferences::~Preferences()
{
// when the preferences are unloaded, save them
save();
+
+ // delete all PrefNodeObservers
+ for (_ObsMap::iterator i = _observer_map.begin(); i != _observer_map.end(); ) {
+ delete (*i++).second; // avoids reference to a deleted key
+ }
+ // unref XML document
Inkscape::GC::release(_prefs_doc);
}
@@ -70,12 +102,12 @@ void Preferences::_loadDefaults()
void Preferences::_load()
{
_loadDefaults();
-
+
Glib::ustring const not_saved = _("Inkscape will run with default settings, "
"and new settings will not be saved. ");
-
+
// NOTE: After we upgrade to Glib 2.16, use Glib::ustring::compose
-
+
// 1. Does the file exist?
if (!g_file_test(_prefs_filename.data(), G_FILE_TEST_EXISTS)) {
// No - we need to create one.
@@ -99,7 +131,7 @@ void Preferences::_load()
g_mkdir(dir, 0755);
g_free(dir);
}
-
+
} else if (!g_file_test(_prefs_dir.data(), G_FILE_TEST_IS_DIR)) {
// The profile dir is not actually a directory
//_errorDialog(Glib::ustring::compose(_("%1 is not a valid directory."),
@@ -121,13 +153,13 @@ void Preferences::_load()
g_free(msg);
return;
}
-
+
// The prefs file was just created.
// We can return now and skip the rest of the load process.
_writable = true;
return;
}
-
+
// Yes, the pref file exists.
// 2. Is it a regular file?
if (!g_file_test(_prefs_filename.data(), G_FILE_TEST_IS_REGULAR)) {
@@ -139,7 +171,7 @@ void Preferences::_load()
g_free(msg);
return;
}
-
+
// 3. Is the file readable?
gchar *prefs_xml = NULL; gsize len = 0;
if (!g_file_get_contents(_prefs_filename.data(), &prefs_xml, &len, NULL)) {
@@ -174,7 +206,7 @@ void Preferences::_load()
Inkscape::GC::release(prefs_read);
return;
}
-
+
// Merge the loaded prefs with defaults.
_prefs_doc->root()->mergeFrom(prefs_read->root(), "id");
Inkscape::GC::release(prefs_read);
@@ -187,255 +219,281 @@ void Preferences::_load()
void Preferences::save()
{
if (!_writable) return; // no-op if the prefs file is not writable
-
+
// sp_repr_save_file uses utf-8 instead of the glib filename encoding.
// I don't know why filenames are kept in utf-8 in Inkscape and then
- // converted to filename encoding when necessary through sepcial functions
+ // converted to filename encoding when necessary through special functions
// - wouldn't it be easier to keep things in the encoding they are supposed
// to be in?
- Glib::ustring utf8name = Glib::filename_from_utf8(_prefs_filename);
+ Glib::ustring utf8name = Glib::filename_to_utf8(_prefs_filename);
if (utf8name.empty()) return;
sp_repr_save_file(_prefs_doc, utf8name.data());
}
-void Preferences::addPrefsObserver(Inkscape::XML::NodeObserver *observer)
-{
- _prefs_doc->addSubtreeObserver(*observer);
-}
-
-
// Now for the meat.
-// Most of the logic is similar to former prefs-utils.cpp
-
/**
- * @brief Check for the existence of a given pref key
- * @param pref_key Preference key to check
- * @return True if the key exists, false otherwise
+ * @brief Get names of all entries in the specified path
+ * @param path Preference path to query
+ * @return A vector containing all entries in the given directory
*/
-bool Preferences::exists(Glib::ustring const &pref_key)
+std::vector<Preferences::Entry> Preferences::getAllEntries(Glib::ustring const &path)
{
- return _getNode(pref_key) != NULL;
+ std::vector<Entry> temp;
+ Inkscape::XML::Node *node = _getNode(path, false);
+ if (!node) return temp;
+
+ // argh - purge this Util::List nonsense from XML classes fast
+ Inkscape::Util::List<Inkscape::XML::AttributeRecord const> alist = node->attributeList();
+ for (; alist; ++alist)
+ temp.push_back( Entry(path + '/' + g_quark_to_string(alist->key), static_cast<void const*>(alist->value.pointer())) );
+ return temp;
}
/**
- * @brief Get the number of sub-preferences of a given pref
- * @param pref_key Preference key to check
- * @return Number of sub-preferences
- *
- * Note: This does not count attributes, only child preferences.
+ * @brief Get the paths to all subdirectories of the specified path
+ * @param path Preference path to query
+ * @return A vector containing absolute paths to all subdirectories in the given path
*/
-unsigned int Preferences::childCount(Glib::ustring const &pref_key)
+std::vector<Glib::ustring> Preferences::getAllDirs(Glib::ustring const &path)
{
- Inkscape::XML::Node *node = _getNode(pref_key);
- return ( node ? node->childCount() : 0 );
-}
-
-/**
- * @brief Get the key of the n-th sub-preference of the specified pref
- * @param father_key Parent key
- * @param n The zero-based index of the pref key to retrieve
- * @return The key of the n-th sub-preference
- */
-Glib::ustring Preferences::getNthChild(Glib::ustring const &father_key, unsigned int n)
-{
- Inkscape::XML::Node *node = _getNode(father_key), *child;
- if (!node) return "";
- child = node->nthChild(n);
- if (!child) return "";
- if (child->attribute("id")) {
- Glib::ustring child_key = father_key;
- child_key += '.';
- child_key += child->attribute("id");
- return child_key;
+ std::vector<Glib::ustring> temp;
+ Inkscape::XML::Node *node = _getNode(path, false);
+ if (!node) return temp;
+
+ for (Inkscape::XML::NodeSiblingIterator i = node->firstChild(); i; ++i) {
+ temp.push_back(path + '/' + i->attribute("id"));
}
- return "";
+ return temp;
}
+// getter methods
-/**
- * @brief Create the preference with the specified key
- * @return True if the node was created, false if it already existed
- *
- * This method is redundant, because the setters automatically create prefs
- * if they don't already exist. It is only left to accomodate some legacy code
- * which manipulates the DOM of the preferences file directly.
- */
-bool Preferences::create(Glib::ustring const &pref_key)
+Preferences::Entry const Preferences::getEntry(Glib::ustring const &pref_path)
{
- if (_getNode(pref_key)) return false;
- _getNode(pref_key, true);
- return true;
+ gchar const *v;
+ _getRawValue(pref_path, v);
+ return Entry(pref_path, v);
}
-// getter methods
+// setter methods
/**
- * @brief Get a boolean attribute of a preference
- * @param pref_key Key of he preference to retrieve
- * @param attr Attribute to retrieve
- * @param def The default value to return if the preference is not set
- * @return The retrieved value
+ * @brief Set a boolean attribute of a preference
+ * @param pref_path Path of the preference to modify
+ * @param value The new value of the pref attribute
*/
-bool Preferences::getBool(Glib::ustring const &pref_key, Glib::ustring const &attr, bool def)
+void Preferences::setBool(Glib::ustring const &pref_path, bool value)
{
- Inkscape::XML::Node *node = _getNode(pref_key);
- if (!node) return def;
- gchar const *rawstr = node->attribute(attr.data());
- if(!rawstr || !rawstr[0]) return def;
- Glib::ustring str = rawstr;
-
- // This is to handle legacy preferences using ints as booleans
- if (str == "true" || str == "1") return true;
- return false;
+ /// @todo Boolean values should be stored as "true" and "false",
+ /// but this is not possible due to an interaction with event contexts.
+ /// Investigate this in depth.
+ _setRawValue(pref_path, ( value ? "1" : "0" ));
}
-
/**
- * @brief Get an integer attribute of a preference
- * @param pref_key Key of he preference to retrieve
- * @param attr Attribute to retrieve
- * @param def The default value to return if the preference is not set
- * @return The retrieved value
+ * @brief Set an integer attribute of a preference
+ * @param pref_path Path of the preference to modify
+ * @param value The new value of the pref attribute
*/
-int Preferences::getInt(Glib::ustring const &pref_key, Glib::ustring const &attr, int def)
+void Preferences::setInt(Glib::ustring const &pref_path, int value)
{
- Inkscape::XML::Node *node = _getNode(pref_key);
- if (!node) return def;
- gchar const *rawstr = node->attribute(attr.data());
- if (!rawstr || !rawstr[0]) return def;
- Glib::ustring str = rawstr;
- // Protection against leftover getInt calls when the value is in fact a boolean
- if (str == "true") return 1;
- if (str == "false") return 0;
- return atoi(str.data());
+ gchar intstr[32];
+ g_snprintf(intstr, 32, "%d", value);
+ _setRawValue(pref_path, intstr);
}
-int Preferences::getIntLimited(Glib::ustring const &pref_key, Glib::ustring const &attr, int def, int min, int max)
+/**
+ * @brief Set a floating point attribute of a preference
+ * @param pref_path Path of the preference to modify
+ * @param value The new value of the pref attribute
+ */
+void Preferences::setDouble(Glib::ustring const &pref_path, double value)
{
- int value = getInt(pref_key, attr, def);
- return ( value >= min && value <= max ? value : def);
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+ g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value);
+ _setRawValue(pref_path, buf);
}
/**
- * @brief Get a floating point attribute of a preference
- * @param pref_key Key of he preference to retrieve
- * @param attr Attribute to retrieve
- * @param def The default value to return if the preference is not set
- * @return The retrieved value
+ * @brief Set a string attribute of a preference
+ * @param pref_path Path of the preference to modify
+ * @param value The new value of the pref attribute
*/
-double Preferences::getDouble(Glib::ustring const &pref_key, Glib::ustring const &attr, double def)
+void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value)
{
- Inkscape::XML::Node *node = _getNode(pref_key);
- if (!node) return def;
- gchar const *str = node->attribute(attr.data());
- if (!str) return def;
- return g_ascii_strtod(str, NULL);
+ _setRawValue(pref_path, value.data());
}
-double Preferences::getDoubleLimited(Glib::ustring const &pref_key, Glib::ustring const &attr, double def, double min, double max)
+void Preferences::setStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
{
- double value = getDouble(pref_key, attr, def);
- return ( value >= min && value <= max ? value : def);
+ gchar *css_str = sp_repr_css_write_string(style);
+ _setRawValue(pref_path, css_str);
+ g_free(css_str);
}
-/**
- * @brief Get a string attribute of a preference
- * @param pref_key Key of he preference to retrieve
- * @param attr Attribute to retrieve
- * @param def The default value to return if the preference is not set
- * @return The retrieved value
- */
-Glib::ustring Preferences::getString(Glib::ustring const &pref_key, Glib::ustring const &attr)
+void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
{
- Inkscape::XML::Node *node = _getNode(pref_key);
- if (!node) return "";
- gchar const *str = node->attribute(attr.data());
- if (!str) return "";
- return Glib::ustring(str);
+ SPCSSAttr *current = getStyle(pref_path);
+ sp_repr_css_merge(current, style);
+ gchar *css_str = sp_repr_css_write_string(current);
+ _setRawValue(pref_path, css_str);
+ g_free(css_str);
+ sp_repr_css_attr_unref(current);
}
-// setter methods
+// Observer stuff
+namespace {
/**
- * @brief Set a boolean attribute of a preference
- * @param pref_key Key of the preference to modify
- * @param attr Attribute to set
- * @param value The new value of the pref attribute
+ * @brief Structure that holds additional information for registered Observers
*/
-void Preferences::setBool(Glib::ustring const &pref_key, Glib::ustring const &attr, bool value)
+struct _ObserverData {
+ Inkscape::XML::Node *_node; ///< Node at which the wrapping PrefNodeObserver is registered
+ bool _is_attr; ///< Whether this Observer watches a single attribute
+};
+
+} // anonymous namespace
+
+Preferences::Observer::Observer(Glib::ustring const &path) :
+ observed_path(path)
{
- /// @todo Boolean values should be stored as "true" and "false",
- /// but this is not possible ude to an interaction with event contexts.
- /// Investigate this in depth.
- Inkscape::XML::Node *node = _getNode(pref_key, true);
- node->setAttribute(attr.data(), ( value ? "1" : "0" ));
}
-/**
- * @brief Set an integer attribute of a preference
- * @param pref_key Key of the preference to modify
- * @param attr Attribute to set
- * @param value The new value of the pref attribute
- */
-void Preferences::setInt(Glib::ustring const &pref_key, Glib::ustring const &attr, int value)
+Preferences::Observer::~Observer()
{
- Inkscape::XML::Node *node = _getNode(pref_key, true);
- gchar intstr[32];
- g_snprintf(intstr, 32, "%d", value);
- node->setAttribute(attr.data(), intstr);
+ // on destruction remove observer to prevent invalid references
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->removeObserver(*this);
}
-/**
- * @brief Set a floating point attribute of a preference
- * @param pref_key Key of the preference to modify
- * @param attr Attribute to set
- * @param value The new value of the pref attribute
- */
-void Preferences::setDouble(Glib::ustring const &pref_key, Glib::ustring const &attr, double value)
+void Preferences::PrefNodeObserver::notifyAttributeChanged(XML::Node &node, GQuark name, Util::ptr_shared<char>, Util::ptr_shared<char> new_value)
{
- Inkscape::XML::Node *node = _getNode(pref_key, true);
- sp_repr_set_svg_double(node, attr.data(), value);
- /*
- gchar dblstr[32];
- g_snprintf(dblstr, 32, "%g", value);
- node->setAttribute(attr, dblstr);
- */
+ // filter out attributes we don't watch
+ gchar const *attr_name = g_quark_to_string(name);
+ if ( !_filter.empty() && _filter != attr_name ) return;
+
+ _ObserverData *d = static_cast<_ObserverData*>(Preferences::_get_pref_observer_data(_observer));
+ Glib::ustring notify_path = _observer.observed_path;
+
+ if (!d->_is_attr) {
+ std::vector<gchar const *> path_fragments;
+ notify_path.reserve(256); // this will make appending operations faster
+
+ // walk the XML tree, saving each of the id attributes in a vector
+ // we terminate when we hit the observer's attachment node, because the path to this node
+ // is already stored in notify_path
+ for (XML::NodeParentIterator n = &node; static_cast<XML::Node*>(n) != d->_node; ++n)
+ path_fragments.push_back(n->attribute("id"));
+ // assemble the elements into a path
+ for (std::vector<gchar const *>::reverse_iterator i = path_fragments.rbegin(); i != path_fragments.rend(); ++i) {
+ notify_path.push_back('/');
+ notify_path.append(*i);
+ }
+
+ // append attribute name
+ notify_path.push_back('/');
+ notify_path.append(attr_name);
+ }
+
+ Entry const val = Preferences::_create_pref_value(notify_path, static_cast<void const*>(new_value.pointer()));
+ _observer.notify(val);
}
/**
- * @brief Set a string attribute of a preference
- * @param pref_key Key of the preference to modify
- * @param attr Attribute to set
- * @param value The new value of the pref attribute
+ * @brief Find the XML node to observe
*/
-void Preferences::setString(Glib::ustring const &pref_key, Glib::ustring const &attr, Glib::ustring const &value)
+XML::Node *Preferences::_findObserverNode(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key, bool create)
+{
+ // first assume that the last path element is an entry.
+ _keySplit(pref_path, node_key, attr_key);
+
+ // find the node corresponding to the "directory".
+ Inkscape::XML::Node *node = _getNode(node_key, create), *child;
+ for (child = node->firstChild(); child; child = child->next()) {
+ // If there is a node with id corresponding to the attr key,
+ // this means that the last part of the path is actually a key (folder).
+ // Change values accordingly.
+ if (attr_key == child->attribute("id")) {
+ node = child;
+ attr_key = "";
+ node_key = pref_path;
+ break;
+ }
+ }
+ return node;
+}
+
+void Preferences::addObserver(Observer &o)
+{
+ // prevent adding the same observer twice
+ if ( _observer_map.find(&o) != _observer_map.end() ) return;
+
+ Glib::ustring node_key, attr_key;
+ Inkscape::XML::Node *node;
+ node = _findObserverNode(o.observed_path, node_key, attr_key, false);
+ if (!node) return;
+
+ // set additional data
+ _ObserverData *d = new _ObserverData;
+ d->_node = node;
+ d->_is_attr = !attr_key.empty();
+ o._data = static_cast<void*>(d);
+
+ _observer_map[&o] = new PrefNodeObserver(o, attr_key);
+
+ // if we watch a single pref, we want to receive notifications only for a single node
+ if (d->_is_attr) {
+ node->addObserver( *(_observer_map[&o]) );
+ } else {
+ node->addSubtreeObserver( *(_observer_map[&o]) );
+ }
+}
+
+void Preferences::removeObserver(Observer &o)
{
- Inkscape::XML::Node *node = _getNode(pref_key, true);
- node->setAttribute(attr.data(), value.data());
+ // prevent removing an observer which was not added
+ if ( _observer_map.find(&o) == _observer_map.end() ) return;
+ Inkscape::XML::Node *node = static_cast<_ObserverData*>(o._data)->_node;
+ delete static_cast<_ObserverData*>(o._data);
+ o._data = NULL;
+
+ node->removeSubtreeObserver( *(_observer_map[&o]) );
+ delete _observer_map[&o];
+ _observer_map.erase(&o);
}
+
/**
* @brief Get the XML node corresponding to the given pref key
* @param pref_key Preference key (path) to get
* @param create Whether to create the corresponding node if it doesn't exist
+ * @param separator The character used to separate parts of the pref key
* @return XML node corresponding to the specified key
*
- * The separator for key components is '.' (a dot). Derived from former
- * inkscape_get_repr().
+ * Derived from former inkscape_get_repr(). Private because it assumes that the backend is
+ * a flat XML file, which may not be the case e.g. if we are using GConf (in future).
*/
Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool create)
{
- Inkscape::XML::Node *node = _prefs_doc->root(), *child = NULL;
- gchar **splits = g_strsplit(pref_key.data(), ".", 0);
- int part_i = 0;
+ // verify path
+ g_assert( pref_key.at(0) == '/' );
+ g_assert( pref_key.find('.') == Glib::ustring::npos );
- while(splits[part_i]) {
+ Inkscape::XML::Node *node = _prefs_doc->root(), *child = NULL;
+ gchar **splits = g_strsplit(pref_key.data(), "/", 0);
+
+ if ( splits == NULL ) return node;
+
+ for (int part_i = 0; splits[part_i]; ++part_i) {
+ // skip empty path segments
+ if (!splits[part_i][0]) continue;
+
for (child = node->firstChild(); child; child = child->next())
if (!strcmp(splits[part_i], child->attribute("id"))) break;
-
+
// If the previous loop found a matching key, child now contains the node
// matching the processed key part. If no node was found then it is NULL.
if (!child) {
@@ -445,7 +503,7 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
child = node->document()->createElement("group");
child->setAttribute("id", splits[part_i]);
node->appendChild(child);
-
+
++part_i;
node = child;
}
@@ -456,13 +514,99 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
}
}
- ++part_i;
node = child;
}
g_strfreev(splits);
return node;
}
+void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
+{
+ // create node and attribute keys
+ Glib::ustring node_key, attr_key;
+ _keySplit(path, node_key, attr_key);
+
+ // retrieve the attribute
+ Inkscape::XML::Node *node = _getNode(node_key, false);
+ if ( node == NULL ) {
+ result = NULL;
+ } else {
+ gchar const *attr = node->attribute(attr_key.data());
+ if ( attr == NULL ) {
+ result = NULL;
+ } else {
+ result = attr;
+ }
+ }
+}
+
+void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value)
+{
+ // create node and attribute keys
+ Glib::ustring node_key, attr_key;
+ _keySplit(path, node_key, attr_key);
+
+ // set the attribute
+ Inkscape::XML::Node *node = _getNode(node_key, true);
+ node->setAttribute(attr_key.data(), value);
+}
+
+// The _extract* methods are where the actual wrok is done - they define how preferences are stored
+// in the XML file.
+
+bool Preferences::_extractBool(Entry const &v)
+{
+ gchar const *s = static_cast<gchar const *>(v._value);
+ if ( !s[0] || !strcmp(s, "0") || !strcmp(s, "false") ) return false;
+ return true;
+}
+
+int Preferences::_extractInt(Entry const &v)
+{
+ gchar const *s = static_cast<gchar const *>(v._value);
+ if ( !strcmp(s, "true") ) return true;
+ if ( !strcmp(s, "false") ) return false;
+ return atoi(s);
+}
+
+double Preferences::_extractDouble(Entry const &v)
+{
+ gchar const *s = static_cast<gchar const *>(v._value);
+ return g_ascii_strtod(s, NULL);
+}
+
+Glib::ustring Preferences::_extractString(Entry const &v)
+{
+ return Glib::ustring(static_cast<gchar const *>(v._value));
+}
+
+SPCSSAttr *Preferences::_extractStyle(Entry const &v)
+{
+ SPCSSAttr *style = sp_repr_css_attr_new();
+ sp_repr_css_attr_add_from_string(style, static_cast<gchar const*>(v._value));
+ return style;
+}
+
+SPCSSAttr *Preferences::_extractInheritedStyle(Entry const &v)
+{
+ // This is the dirtiest extraction method. Generally we ignore whatever was in v._value
+ // and just get the style using sp_repr_css_attr_inherited. To implement this in GConf,
+ // we'll have to walk up the tree and call sp_repr_css_attr_add_from_string
+ Glib::ustring node_key, attr_key;
+ _keySplit(v._pref_path, node_key, attr_key);
+
+ Inkscape::XML::Node *node = _getNode(node_key, false);
+ return sp_repr_css_attr_inherited(node, attr_key.data());
+}
+
+// XML backend helper: Split the path into a node key and an attribute key.
+void Preferences::_keySplit(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key)
+{
+ // everything after the last slash
+ attr_key = pref_path.substr(pref_path.rfind('/') + 1, Glib::ustring::npos);
+ // everything before the last slash
+ node_key = pref_path.substr(0, pref_path.rfind('/'));
+}
void Preferences::_errorDialog(Glib::ustring const &msg, Glib::ustring const &secondary)
{
@@ -477,12 +621,17 @@ void Preferences::_errorDialog(Glib::ustring const &msg, Glib::ustring const &se
}
}
+Preferences::Entry const Preferences::_create_pref_value(Glib::ustring const &path, void const *ptr)
+{
+ return Entry(path, ptr);
+}
+
bool Preferences::use_gui = true;
Preferences *Preferences::_instance = NULL;
} // namespace Inkscape
-
+
/*
Local Variables:
mode:c++
diff --git a/src/preferences.h b/src/preferences.h
index b2a56308c..e39adc228 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -14,72 +14,387 @@
#include <glibmm/ustring.h>
#include <string>
+#include <map>
+#include <vector>
#include <climits>
#include <cfloat>
#include "xml/xml-forward.h"
+class SPCSSAttr;
+
namespace Inkscape {
/**
* @brief Preference storage class
*
* This is a singleton that allows one to access the user preferences stored in
- * the preferences.xml file. The preferences are stored in a tree hierarchy.
- * Each preference is identified by its key, and sections of the key
- * corresponding to the levels of the hierarchy are delimited with dots.
- * Preferences are generally typeless - it's up to the programmer to ensure
- * that a given preference is always accessed as the correct type.
+ * the preferences.xml file. The preferences are stored in a file system-like
+ * hierarchy. They are generally typeless - it's up to the programmer to ensure
+ * that a given preference is always accessed as the correct type. The backend
+ * is not guaranteed to be tolerant to type mismatches.
+ *
+ * Preferences are identified by paths similar to file system paths. Components
+ * of the path are separated by a slash (/). As an additional requirement,
+ * the path must start with a slash, and not contain a trailing slash.
+ * An example of a correct path would be "/options/some_group/some_option".
*
* All preferences are loaded when the first singleton pointer is requested,
* or when the static load() method is called. Before loading, the static
* variable @c use_gui should be set accordingly. To save the preferences,
* the method save() or the static function unload() can be used.
*
- * In future, this could be a virtual base from which specific backends
- * derive (e.g. GConf, Windows registry, flat XML file...)
+ * In future, this will be a virtual base from which specific backends
+ * derive (e.g. GConf, flat XML file...)
*/
class Preferences {
public:
+ // #############################
+ // ## inner class definitions ##
+ // #############################
+
+ class Entry;
+ class Observer;
+
+ /**
+ * @brief Base class for preference observers
+ *
+ * If you want to watch for changes in the preferences, you'll have to
+ * derive a class from this one and override the notify() method.
+ */
+ class Observer {
+ friend class Preferences;
+ public:
+ /**
+ * @brief Constructor.
+ *
+ * Since each Observer is assigned to a single path, the base
+ * constructor takes this path as an argument. This prevents one from
+ * adding a single observer to multiple paths, but this is intentional
+ * to simplify the implementation of observers and notifications.
+ *
+ * After you add the object with Preferences::addObserver(), you will
+ * receive notifications for everything below the attachment point.
+ * You can also specify a single preference as the watch point.
+ * For example, watching the directory "/foo" will give you notifications
+ * about "/foo/some_pref" as well as "/foo/some_dir/other_pref".
+ * Watching the preference "/options/some_group/some_option" will only
+ * generate notifications when this single preference changes.
+ *
+ * @param path Preference path the observer should watch
+ */
+ Observer(Glib::ustring const &path);
+ virtual ~Observer();
+ /**
+ * @brief Notification about a preference change
+ * @param new_val Entry object containing information about
+ * the modified preference
+ */
+ virtual void notify(Preferences::Entry const &new_val) = 0;
+
+ Glib::ustring const observed_path; ///< Path which the observer watches
+ private:
+ void *_data; ///< additional data used by the implementation while the observer is active
+ };
+
+
+ /**
+ * @brief Data type representing a typeless value of a preference
+ *
+ * This is passed to the observer in the notify() method.
+ * To retrieve useful data from it, use its member functions. Setting
+ * any preference using the Preferences class invalidates this object,
+ * so use its get methods before doing so.
+ */
+ class Entry {
+ friend class Preferences; // Preferences class has to access _value
+ public:
+ ~Entry() {}
+ Entry(Entry const &other) : _pref_path(other._pref_path), _value(other._value) {}
+ /**
+ * @brief Check whether the received entry is valid.
+ * @return If false, the default value will be returned by the getters.
+ */
+ bool isValid() const { return _value != NULL; }
+
+ /**
+ * @brief Interpret the preference as a Boolean value.
+ * @param def Default value if the preference is not set
+ */
+ inline bool getBool(bool def=false) const;
+ /**
+ * @brief Interpret the preference as an integer.
+ * @param def Default value if the preference is not set
+ */
+ inline int getInt(int def=0) const;
+ /**
+ * @brief Interpret the preference as a limited integer.
+ *
+ * This method will return the default value if the interpreted value is
+ * larger than @c max or smaller than @c min. Do not use to store
+ * Boolean values as integers.
+ *
+ * @param def Default value if the preference is not set
+ * @param min Minimum value allowed to return
+ * @param max Maximum value allowed to return
+ */
+ inline int getIntLimited(int def=0, int min=INT_MIN, int max=INT_MAX) const;
+ /**
+ * @brief Interpret the preference as a floating point value.
+ * @param def Default value if the preference is not set
+ */
+ inline double getDouble(double def=0.0) const;
+ /**
+ * @brief Interpret the preference as a limited floating point value.
+ *
+ * This method will return the default value if the interpreted value is
+ * larger than @c max or smaller than @c min.
+ *
+ * @param def Default value if the preference is not set
+ * @param min Minimum value allowed to return
+ * @param max Maximum value allowed to return
+ */
+ inline double getDoubleLimited(double def=0.0, double min=DBL_MIN, double max=DBL_MAX) const;
+ /**
+ * @brief Interpret the preference as an UTF-8 string.
+ *
+ * To store a filename, convert it using Glib::filename_to_utf8().
+ */
+ inline Glib::ustring getString() const;
+ /**
+ * @brief Interpret the preference as a CSS style.
+ * @return A CSS style that has to be unrefed when no longer necessary.
+ */
+ inline SPCSSAttr *getStyle() const;
+ /**
+ * @brief Interpret the preference as a CSS style with directory-based
+ * inheritance
+ *
+ * This function will look up the preferences with the same entry name
+ * in ancestor directories and return the inherited CSS style.
+ *
+ * @return Inherited CSS style that has to be unrefed after use.
+ */
+ inline SPCSSAttr *getInheritedStyle() const;
+
+ /**
+ * @brief Get the full path of the preference described by this Entry.
+ */
+ Glib::ustring const &getPath() const { return _pref_path; }
+ /**
+ * @brief Get the last component of the preference's path
+ *
+ * E.g. For "/options/some_group/some_option" it will return "some_option".
+ */
+ Glib::ustring getEntryName() const;
+ private:
+ Entry(Glib::ustring const &path, void const *v) : _pref_path(path), _value(v) {}
+
+ Glib::ustring _pref_path;
+ void const *_value;
+ };
+
// utility methods
+
+ /**
+ * @name Save preferences to the disk.
+ * @{
+ */
+
+ /**
+ * @brief Save all preferences to the hard disk.
+ *
+ * For some backends, the preferences may be saved as they are modified.
+ * Not calling this method doesn't guarantee the preferences are unmodified
+ * the next time Inkscape runs.
+ */
void save();
+ /**
+ * @brief Check whether saving the preferences will have any effect.
+ */
bool isWritable() { return _writable; }
+ /*@}*/
+
+ /**
+ * @name Iterate over directories and entries.
+ * @{
+ */
+
+ /**
+ * @brief Get all entries from the specified directory
+ *
+ * This method will return a vector populated with preference entries
+ * from the specified directory. Subdirectories will not be represented.
+ */
+ std::vector<Entry> getAllEntries(Glib::ustring const &path);
+ /**
+ * @brief Get all subdirectories of the specified directory
+ *
+ * This will return a vector populated with full paths to the subdirectories
+ * present in the specified @c path.
+ */
+ std::vector<Glib::ustring> getAllDirs(Glib::ustring const &path);
+ /*@}*/
- // some helpers
- bool exists(Glib::ustring const &pref_key);
- unsigned int childCount(Glib::ustring const &pref_key);
- Glib::ustring getNthChild(Glib::ustring const &father_path, unsigned int n);
- bool create(Glib::ustring const &pref_key);
-
- // getter methods
- // Note that default values supplied as arguments are last-chance,
- // and are overridden by those in preferences-defaults.h
- bool getBool(Glib::ustring const &pref_path, Glib::ustring const &attr, bool def=false);
- int getInt(Glib::ustring const &pref_path, Glib::ustring const &attr, int def=0);
- int getIntLimited(Glib::ustring const &pref_path, Glib::ustring const &attr, int def=0, int min=INT_MIN, int max=INT_MAX);
- double getDouble(Glib::ustring const &pref_path, Glib::ustring const &attr, double def=0.0);
- double getDoubleLimited(Glib::ustring const &pref_path, Glib::ustring const &attr, double def=0.0, double min=DBL_MIN, double max=DBL_MAX);
- Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &attr);
-
- // setter methods
- void setBool(Glib::ustring const &pref_path, Glib::ustring const &attr, bool value);
- void setInt(Glib::ustring const &pref_path, Glib::ustring const &attr, int value);
- void setDouble(Glib::ustring const &pref_path, Glib::ustring const &attr, double value);
- void setString(Glib::ustring const &pref_path, Glib::ustring const &attr, Glib::ustring const &value);
-
- // do not use this - it is only temporarily public to ease porting old code to this class
- XML::Node *_getNode(Glib::ustring const &pref_path, bool create=false);
+ /**
+ * @name Retrieve data from the preference storage.
+ * @{
+ */
+ /**
+ * @brief Retrieve a Boolean value
+ * @param pref_path Path to the retrieved preference
+ * @param def The default value to return if the preference is not set
+ */
+ bool getBool(Glib::ustring const &pref_path, bool def=false) {
+ return getEntry(pref_path).getBool(def);
+ }
+ /**
+ * @brief Retrieve an integer
+ * @param pref_path Path to the retrieved preference
+ * @param def The default value to return if the preference is not set
+ */
+ int getInt(Glib::ustring const &pref_path, int def=0) {
+ return getEntry(pref_path).getInt(def);
+ }
+ /**
+ * @brief Retrieve a limited integer
+ *
+ * The default value is returned if the actual value is larger than @c max
+ * or smaller than @c min. Do not use to store Boolean values.
+ *
+ * @param pref_path Path to the retrieved preference
+ * @param def The default value to return if the preference is not set
+ * @param min Minimum value to return
+ * @param max Maximum value to return
+ */
+ int getIntLimited(Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX) {
+ return getEntry(pref_path).getIntLimited(def, min, max);
+ }
+ double getDouble(Glib::ustring const &pref_path, double def=0.0) {
+ return getEntry(pref_path).getDouble(def);
+ }
+ /**
+ * @brief Retrieve a limited floating point value
+ *
+ * The default value is returned if the actual value is larger than @c max
+ * or smaller than @c min.
+ *
+ * @param pref_path Path to the retrieved preference
+ * @param def The default value to return if the preference is not set
+ * @param min Minimum value to return
+ * @param max Maximum value to return
+ */
+ double getDoubleLimited(Glib::ustring const &pref_path, double def=0.0, double min=DBL_MIN, double max=DBL_MAX) {
+ return getEntry(pref_path).getDoubleLimited(def, min, max);
+ }
+ /**
+ * @brief Retrieve an UTF-8 string
+ * @param pref_path Path to the retrieved preference
+ */
+ Glib::ustring getString(Glib::ustring const &pref_path) {
+ return getEntry(pref_path).getString();
+ }
+ /**
+ * @brief Retrieve a CSS style
+ * @param pref_path Path to the retrieved preference
+ * @return A CSS style that has to be unrefed after use.
+ */
+ SPCSSAttr *getStyle(Glib::ustring const &pref_path) {
+ return getEntry(pref_path).getStyle();
+ }
+ /**
+ * @brief Retrieve an inherited CSS style
+ *
+ * This method will look up preferences with the same entry name in ancestor
+ * directories and return a style obtained by inheriting properties from
+ * ancestor styles.
+ *
+ * @param pref_path Path to the retrieved preference
+ * @return An inherited CSS style that has to be unrefed after use.
+ */
+ SPCSSAttr *getInheritedStyle(Glib::ustring const &pref_path) {
+ return getEntry(pref_path).getInheritedStyle();
+ }
+ /**
+ * @brief Retrieve a preference entry without specifying its type
+ */
+ Entry const getEntry(Glib::ustring const &pref_path);
+ /*@}*/
- // used for some obscure purpose in sp_desktop_widget_init
- void addPrefsObserver(XML::NodeObserver *observer);
+ /**
+ * @name Update preference values.
+ * @{
+ */
- // singleton accessor
+ /**
+ * @brief Set a Boolean value
+ */
+ void setBool(Glib::ustring const &pref_path, bool value);
+ /**
+ * @brief Set an integer value
+ */
+ void setInt(Glib::ustring const &pref_path, int value);
+ /**
+ * @brief Set a floating point value
+ */
+ void setDouble(Glib::ustring const &pref_path, double value);
+ /**
+ * @brief Set an UTF-8 string value
+ */
+ void setString(Glib::ustring const &pref_path, Glib::ustring const &value);
+ /**
+ * @brief Set a CSS style
+ */
+ void setStyle(Glib::ustring const &pref_path, SPCSSAttr *style);
+ /**
+ * @brief Merge a CSS style with the current preference value
+ *
+ * This method is similar to setStyle(), except that it merges the style
+ * rather than replacing it. This means that if @c style doesn't have
+ * a property set, it is left unchanged in the style stored in
+ * the preferences.
+ */
+ void mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style);
+ /*@}*/
+
+ /**
+ * @name Receive notifications about preference changes.
+ * @{
+ */
+ /**
+ * @brief Register a preference observer
+ */
+ void addObserver(Observer &);
+ /**
+ * @brief Remove an observer an prevent further notifications to it.
+ */
+ void removeObserver(Observer &);
+ /*@}*/
+
+ /**
+ * @name Access and manipulate the Preferences object.
+ */
+
+ /**
+ * @brief Access the singleton Preferences object.
+ */
static Preferences *get() {
if (!_instance) _instance = new Preferences();
return _instance;
}
+ /**
+ * @brief Load the preferences.
+ *
+ * This method is automatically called from get(). It exists to supress
+ * possible compiler warnings over unused variables.
+ */
static void load() {
if (!_instance) _instance = new Preferences();
}
+ /**
+ * @brief Unload all preferences and store them on the hard disk.
+ *
+ * This deletes the singleton object. Calling get() after this function is
+ */
static void unload() {
if(_instance)
{
@@ -87,15 +402,40 @@ public:
_instance = NULL;
}
}
- // this is a static member to reduce dependency bloat for this class
- static bool use_gui; ///< Whether to use GUI error notifications
+
+ /**
+ * @brief Whether to use GUI error notifications
+ *
+ * Set this to false when running Inkscape in command-line mode.
+ * Preference-related warnings will be printed to the console.
+ */
+ static bool use_gui;
+ /*@}*/
+
+protected:
+ /* helper methods used by Entry
+ * This will enable using the same Entry class with different backends.
+ * For now, however, those methods are not virtual. These methods assume
+ * that v._value is not NULL
+ */
+ bool _extractBool(Entry const &v);
+ int _extractInt(Entry const &v);
+ double _extractDouble(Entry const &v);
+ Glib::ustring _extractString(Entry const &v);
+ SPCSSAttr *_extractStyle(Entry const &v);
+ SPCSSAttr *_extractInheritedStyle(Entry const &v);
private:
Preferences();
~Preferences();
void _load();
void _loadDefaults();
+ void _getRawValue(Glib::ustring const &path, gchar const *&result);
+ void _setRawValue(Glib::ustring const &path, gchar const *value);
void _errorDialog(Glib::ustring const &, Glib::ustring const &);
+ void _keySplit(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key);
+ XML::Node *_getNode(Glib::ustring const &pref_path, bool create=false);
+ XML::Node *_findObserverNode(Glib::ustring const &pref_path, Glib::ustring &node_key, Glib::ustring &attr_key, bool create);
// disable copying
Preferences(Preferences const &);
@@ -107,9 +447,86 @@ private:
bool _writable; ///< Will the preferences be saved at exit?
XML::Document *_prefs_doc; ///< XML document storing all the preferences
+ /// Wrapper class for XML node observers
+ class PrefNodeObserver;
+
+ typedef std::map<Observer *, PrefNodeObserver *> _ObsMap;
+ /// Map that keeps track of wrappers assigned to PrefObservers
+ _ObsMap _observer_map;
+
+ // privilege escalation methods for PrefNodeObserver
+ static Entry const _create_pref_value(Glib::ustring const &, void const *ptr);
+ static void *_get_pref_observer_data(Observer &o) { return o._data; }
+
static Preferences *_instance;
+
+friend class PrefNodeObserver;
+friend class Entry;
};
+/* Trivial inline Preferences::Entry functions.
+ * In fact only the _extract* methods do something, the rest is delegation
+ * to avoid duplication of code. There should be no performance hit if
+ * compiled with -finline-functions.
+ */
+
+inline bool Preferences::Entry::getBool(bool def) const
+{
+ if (!this->isValid()) return def;
+ return Inkscape::Preferences::get()->_extractBool(*this);
+}
+
+inline int Preferences::Entry::getInt(int def) const
+{
+ if (!this->isValid()) return def;
+ return Inkscape::Preferences::get()->_extractInt(*this);
+}
+
+inline int Preferences::Entry::getIntLimited(int def, int min, int max) const
+{
+ if (!this->isValid()) return def;
+ int val = Inkscape::Preferences::get()->_extractInt(*this);
+ return ( val >= min && val <= max ? val : def );
+}
+
+inline double Preferences::Entry::getDouble(double def) const
+{
+ if (!this->isValid()) return def;
+ return Inkscape::Preferences::get()->_extractDouble(*this);
+}
+
+inline double Preferences::Entry::getDoubleLimited(double def, double min, double max) const
+{
+ if (!this->isValid()) return def;
+ double val = Inkscape::Preferences::get()->_extractDouble(*this);
+ return ( val >= min && val <= max ? val : def );
+}
+
+inline Glib::ustring Preferences::Entry::getString() const
+{
+ if (!this->isValid()) return "";
+ return Inkscape::Preferences::get()->_extractString(*this);
+}
+
+inline SPCSSAttr *Preferences::Entry::getStyle() const
+{
+ if (!this->isValid()) return NULL;
+ return Inkscape::Preferences::get()->_extractStyle(*this);
+}
+
+inline SPCSSAttr *Preferences::Entry::getInheritedStyle() const
+{
+ if (!this->isValid()) return NULL;
+ return Inkscape::Preferences::get()->_extractInheritedStyle(*this);
+}
+
+inline Glib::ustring Preferences::Entry::getEntryName() const
+{
+ Glib::ustring path_base = _pref_path;
+ path_base.erase(0, path_base.rfind('/') + 1);
+ return path_base;
+}
+
} // namespace Inkscape
#endif // INKSCAPE_PREFSTORE_H
diff --git a/src/prefs-utils.cpp b/src/prefs-utils.cpp
deleted file mode 100644
index 004626ac6..000000000
--- a/src/prefs-utils.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Utility functions for reading and setting preferences
- *
- * Authors:
- * bulia byak <bulia@dr.com>
- *
- * Copyright (C) 2003 authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "prefs-utils.h"
-#include "inkscape.h"
-#include "xml/repr.h"
-
-
-void
-prefs_set_recent_file(gchar const *uri, gchar const *name)
-{
- unsigned const max_documents = prefs_get_int_attribute("options.maxrecentdocuments", "value", 20);
-
- if (uri != NULL) {
- Inkscape::XML::Node *recent = inkscape_get_repr(INKSCAPE, "documents.recent");
- if (recent) {
- // remove excess recent files
- if (recent->childCount() >= max_documents) {
- Inkscape::XML::Node *child = recent->firstChild();
- // count to the last
- for (unsigned i = 0; child && i + 1 < max_documents; ++i) {
- child = child->next();
- }
- // remove all after the last
- while (child) {
- Inkscape::XML::Node *next = child->next();
- sp_repr_unparent(child);
- child = next;
- }
- }
-
- if (max_documents > 0) {
- Inkscape::XML::Node *child = sp_repr_lookup_child(recent, "uri", uri);
- if (child) {
- recent->changeOrder(child, NULL);
- } else {
- child = recent->document()->createElement("document");
- child->setAttribute("uri", uri);
- recent->addChild(child, NULL);
- }
- child->setAttribute("name", name);
- }
- }
- }
-}
-
-gchar const **
-prefs_get_recent_files()
-{
- Inkscape::XML::Node *recent = inkscape_get_repr(INKSCAPE, "documents.recent");
- if (recent) {
- unsigned const docs = recent->childCount();
- gchar const **datalst = (gchar const **) g_malloc(sizeof(gchar *) * ((docs * 2) + 1));
-
- gint i;
- Inkscape::XML::Node *child;
- for (i = 0, child = recent->firstChild();
- child != NULL;
- child = child->next(), i += 2)
- {
- gchar const *uri = child->attribute("uri");
- gchar const *name = child->attribute("name");
- datalst[i] = uri;
- datalst[i + 1] = name;
- }
-
- datalst[i] = NULL;
- return datalst;
- }
-
- return NULL;
-}
-
-/*
- 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:encoding=utf-8:textwidth=99 :
diff --git a/src/prefs-utils.h b/src/prefs-utils.h
deleted file mode 100644
index 60eb694b5..000000000
--- a/src/prefs-utils.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Utility functions for reading and setting preferences
- *
- * Authors:
- * bulia byak <bulia@dr.com>
- *
- * Copyright (C) 2003 authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifndef SEEN_PREFS_UTILS_H
-#define SEEN_PREFS_UTILS_H
-
-#include <glib/gtypes.h>
-#include <glib/gslist.h>
-#include "preferences.h"
-
-inline bool pref_path_exists(gchar const *path){
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->exists(path);
-}
-
-inline unsigned pref_path_number_of_children(gchar const *path){
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->childCount(path);
-}
-
-inline void
-prefs_set_int_attribute(gchar const *path, gchar const *attr, long long int value)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- ps->setInt(path, attr, value);
-}
-
-inline int
-prefs_get_int_attribute(gchar const *path, gchar const *attr, long long int def)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->getInt(path, attr, def);
-}
-
-inline int
-prefs_get_int_attribute_limited(gchar const *path, gchar const *attr, long long int def, long long int min, long long int max)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->getIntLimited(path, attr, def, min, max);
-}
-
-inline void
-prefs_set_double_attribute(gchar const *path, gchar const *attr, double value)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- ps->setDouble(path, attr, value);
-}
-
-inline double
-prefs_get_double_attribute(gchar const *path, gchar const *attr, double def)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->getDouble(path, attr, def);
-}
-
-inline double
-prefs_get_double_attribute_limited(gchar const *path, gchar const *attr, double def, double min, double max)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- return ps->getDoubleLimited(path, attr, def, min, max);
-}
-
-inline void
-prefs_set_string_attribute(gchar const *path, gchar const *attr, gchar const *value)
-{
- Inkscape::Preferences *ps = Inkscape::Preferences::get();
- ps->setString(path, attr, value);
-}
-
-/// @todo Reimplement using Gtk::RecentManager
-void prefs_set_recent_file(const gchar * uri, const gchar * name);
-const gchar ** prefs_get_recent_files(void);
-
-#endif /* !SEEN_PREFS_UTILS_H */
-
-/*
- 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:encoding=utf-8:textwidth=99 :
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index 56d74d901..93e7e8470 100644
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -39,7 +39,7 @@
#include "object-edit.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "context-fns.h"
//static const double goldenratio = 1.61803398874989484820; // golden ratio
@@ -49,7 +49,7 @@ static void sp_rect_context_init(SPRectContext *rect_context);
static void sp_rect_context_dispose(GObject *object);
static void sp_rect_context_setup(SPEventContext *ec);
-static void sp_rect_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_rect_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent *event);
static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
@@ -218,31 +218,29 @@ static void sp_rect_context_setup(SPEventContext *ec)
sp_event_context_read(ec, "rx");
sp_event_context_read(ec, "ry");
- if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/shapes/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
ec->enableGrDrag();
}
rc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
}
-static void sp_rect_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+static void sp_rect_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPRectContext *rc = SP_RECT_CONTEXT(ec);
/* fixme: Proper error handling for non-numeric data. Use a locale-independent function like
* g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */
- if ( strcmp(key, "rx") == 0 ) {
- rc->rx = ( val
- ? g_ascii_strtod (val, NULL)
- : 0.0 );
- } else if ( strcmp(key, "ry") == 0 ) {
- rc->ry = ( val
- ? g_ascii_strtod (val, NULL)
- : 0.0 );
+ Glib::ustring name = val->getEntryName();
+ if ( name == "rx" ) {
+ rc->rx = val->getDoubleLimited(); // prevents NaN and +/-Inf from messing up
+ } else if ( name == "ry" ) {
+ rc->ry = val->getDoubleLimited();
}
}
@@ -279,8 +277,9 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
Inkscape::Selection *selection = sp_desktop_selection (desktop);
SPRectContext *rc = SP_RECT_CONTEXT(event_context);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
switch (event->type) {
@@ -306,7 +305,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt);
rc->center = from_2geom(button_dt);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -476,7 +475,7 @@ static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state)
Inkscape::XML::Node *repr = xml_doc->createElement("svg:rect");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.rect", false);
+ sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/rect", false);
rc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
Inkscape::GC::release(repr);
diff --git a/src/selcue.cpp b/src/selcue.cpp
index 661f0a2e4..241802a87 100644
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
@@ -23,7 +23,7 @@
#include "text-editing.h"
#include "sp-text.h"
#include "sp-flowtext.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "selcue.h"
Inkscape::SelCue::SelCue(SPDesktop *desktop)
@@ -70,15 +70,16 @@ void Inkscape::SelCue::_updateItemBboxes()
}
_text_baselines.clear();
- gint mode = prefs_get_int_attribute ("options.selcue", "value", MARK);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint mode = prefs->getInt("/options/selcue/value", MARK);
if (mode == NONE) {
return;
}
g_return_if_fail(_selection != NULL);
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
+ int prefs_bbox = prefs->getBool("/tools/bounding_box");
+ SPItem::BBoxType bbox_type = !prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 374bf0810..b726243f9 100644
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -35,7 +35,7 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "sp-root.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "tools-switch.h"
#include "message-stack.h"
#include "selection-describer.h"
@@ -47,7 +47,7 @@ static void sp_select_context_init(SPSelectContext *select_context);
static void sp_select_context_dispose(GObject *object);
static void sp_select_context_setup(SPEventContext *ec);
-static void sp_select_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_select_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event);
static gint sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
@@ -179,18 +179,20 @@ sp_select_context_setup(SPEventContext *ec)
sp_event_context_read(ec, "show");
sp_event_context_read(ec, "transform");
- if (prefs_get_int_attribute("tools.select", "gradientdrag", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/select/gradientdrag")) {
ec->enableGrDrag();
}
}
static void
-sp_select_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_select_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPSelectContext *sc = SP_SELECT_CONTEXT(ec);
+ Glib::ustring path = val->getEntryName();
- if (!strcmp(key, "show")) {
- if (val && !strcmp(val, "outline")) {
+ if (path == "show") {
+ if (val->getString() == "outline") {
sc->_seltrans->setShow(Inkscape::SelTrans::SHOW_OUTLINE);
} else {
sc->_seltrans->setShow(Inkscape::SelTrans::SHOW_CONTENT);
@@ -293,7 +295,8 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
SPSelectContext *sc = SP_SELECT_CONTEXT(event_context);
Inkscape::SelTrans *seltrans = sc->_seltrans;
- tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
// make sure we still have valid objects to move around
if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
@@ -400,10 +403,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
SPSelectContext *sc = SP_SELECT_CONTEXT(event_context);
Inkscape::SelTrans *seltrans = sc->_seltrans;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- gdouble const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
- gdouble const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000);
- tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
+ gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
+ tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
// make sure we still have valid objects to move around
if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index d58f7ff25..08449720d 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -260,7 +260,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
std::vector<const gchar *> old_ids;
std::vector<const gchar *> new_ids;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool relink_clones = prefs->getBool("options.relinkclonesonduplicate", "value");
+ bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value");
while (reprs) {
Inkscape::XML::Node *old_repr = (Inkscape::XML::Node *) reprs->data;
@@ -368,9 +368,9 @@ void sp_edit_select_all_full (SPDesktop *dt, bool force_all_layers, bool invert)
g_return_if_fail(SP_IS_GROUP(dt->currentLayer()));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
- bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
+ bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
GSList *items = NULL;
@@ -1182,7 +1182,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
// "clones are unmoved when original is moved" preference
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ int compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
bool prefs_unmoved = (compensation == SP_CLONE_COMPENSATION_UNMOVED);
bool prefs_parallel = (compensation == SP_CLONE_COMPENSATION_PARALLEL);
@@ -1610,9 +1610,9 @@ sp_selection_item_next(SPDesktop *desktop)
Inkscape::Selection *selection = sp_desktop_selection(desktop);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
- bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
+ bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
SPObject *root;
if (PREFS_SELECTION_ALL != inlayer) {
@@ -1640,9 +1640,9 @@ sp_selection_item_prev(SPDesktop *desktop)
Inkscape::Selection *selection = sp_desktop_selection(desktop);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
- bool onlyvisible = prefs->getBool("options.kbselection", "onlyvisible", true);
- bool onlysensitive = prefs->getBool("options.kbselection", "onlysensitive", true);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext) prefs->getInt("/options/kbselection/inlayer", PREFS_SELECTION_LAYER);
+ bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
+ bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
SPObject *root;
if (PREFS_SELECTION_ALL != inlayer) {
@@ -1710,8 +1710,8 @@ void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip)
// take colors from prefs (same as used in outline mode)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
np->helperpath_rgba = clip ?
- prefs->getInt("options.wireframecolors", "clips", 0x00ff00ff) :
- prefs->getInt("options.wireframecolors", "masks", 0x0000ffff);
+ prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff) :
+ prefs->getInt("/options/wireframecolors/masks", 0x0000ffff);
np->helperpath_width = 1.0;
sp_nodepath_show_helperpath(np, true);
}
@@ -2044,7 +2044,7 @@ sp_select_clone_original(SPDesktop *desktop)
if (original) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool highlight = prefs->getBool("options.highlightoriginal", "value");
+ bool highlight = prefs->getBool("/options/highlightoriginal/value");
if (highlight) {
boost::optional<Geom::Rect> a = item->getBounds(sp_item_i2d_affine(item));
boost::optional<Geom::Rect> b = original->getBounds(sp_item_i2d_affine(original));
@@ -2119,7 +2119,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
repr_copies = g_slist_prepend (repr_copies, dup);
}
- NR::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
+ Geom::Rect bounds(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
@@ -2133,8 +2133,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *mark_id = generate_marker(repr_copies, bounds, doc,
( Geom::Matrix(Geom::Translate(desktop->dt2doc(
@@ -2145,7 +2145,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
(void)mark_id;
// restore compensation setting
- prefs->setInt("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
g_slist_free (items);
@@ -2184,8 +2184,8 @@ void sp_selection_to_guides(SPDesktop *desktop)
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool deleteitem = !prefs->getBool("tools", "cvg_keep_objects", 0);
- bool wholegroups = prefs->getBool("tools", "cvg_convert_whole_groups", 0);
+ bool deleteitem = !prefs->getBool("/tools/cvg_keep_objects", 0);
+ bool wholegroups = prefs->getBool("/tools/cvg_convert_whole_groups", 0);
for (GSList const *i = items; i != NULL; i = i->next) {
sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups);
@@ -2257,8 +2257,8 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
// without disturbing clones.
// See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *pat_id = pattern_tile(repr_copies, bounds, doc,
( NR::Matrix(Geom::Translate(desktop->dt2doc(NR::Point(r->min()[NR::X],
@@ -2267,7 +2267,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
parent_transform * move);
// restore compensation setting
- prefs->setInt("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
if (apply) {
Inkscape::XML::Node *rect = xml_doc->createElement("svg:rect");
@@ -2499,8 +2499,8 @@ sp_selection_create_bitmap_copy (SPDesktop *desktop)
// Calculate resolution
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double res;
- int const prefs_res = prefs->getInt("options.createbitmap", "resolution", 0);
- int const prefs_min = prefs->getInt("options.createbitmap", "minsize", 0);
+ int const prefs_res = prefs->getInt("/options/createbitmap/resolution", 0);
+ int const prefs_min = prefs->getInt("/options/createbitmap/minsize", 0);
if (0 < prefs_res) {
// If it's given explicitly in prefs, take it
res = prefs_res;
@@ -2532,11 +2532,11 @@ sp_selection_create_bitmap_copy (SPDesktop *desktop)
// Find out if we have to run an external filter
gchar const *run = NULL;
- Glib::ustring filter = prefs->getString("options.createbitmap", "filter");
+ Glib::ustring filter = prefs->getString("/options/createbitmap/filter");
if (!filter.empty()) {
// filter command is given;
// see if we have a parameter to pass to it
- Glib::ustring param1 = prefs->getString("options.createbitmap", "filter_param1");
+ Glib::ustring param1 = prefs->getString("/options/createbitmap/filter_param1");
if (!param1.empty()) {
if (param1[param1.length() - 1] == '%') {
// if the param string ends with %, interpret it as a percentage of the image's max dimension
@@ -2678,8 +2678,8 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la
GSList *apply_to_items = NULL;
GSList *items_to_delete = NULL;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool topmost = prefs->getBool("options.maskobject", "topmost", true);
- bool remove_original = prefs->getBool("options.maskobject", "remove", true);
+ bool topmost = prefs->getBool("/options/maskobject/topmost", true);
+ bool remove_original = prefs->getBool("/options/maskobject/remove", true);
if (apply_to_layer) {
// all selected items are used for mask, which is applied to a layer
@@ -2782,7 +2782,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool remove_original = prefs->getBool("options.maskobject", "remove", true);
+ bool remove_original = prefs->getBool("/options/maskobject/remove", true);
sp_document_ensure_up_to_date(doc);
gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
diff --git a/src/selection.cpp b/src/selection.cpp
index bd695ff8b..4ed6c0842 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -379,7 +379,7 @@ Inkscape::XML::Node *Selection::singleRepr() {
NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const
{
g_return_val_if_fail (bbox != NULL, NULL);
- bounds(bbox, type);
+ *bbox = NRRect(bounds(type));
return bbox;
}
@@ -441,15 +441,20 @@ boost::optional<Geom::Point> Selection::center() const {
/**
* Compute the list of points in the selection that are to be considered for snapping.
*/
-std::vector<Geom::Point> Selection::getSnapPoints(bool includeItemCenter) const {
+std::vector<Geom::Point> Selection::getSnapPoints(SnapPreferences const *snapprefs) const {
GSList const *items = const_cast<Selection *>(this)->itemList();
+
+ SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
+ snapprefs_dummy.setIncludeItemCenter(false); // locally disable snapping to the item center
+
std::vector<Geom::Point> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
SPItem *this_item = SP_ITEM(iter->data);
- sp_item_snappoints(this_item, false, SnapPointsIter(p));
+ sp_item_snappoints(this_item, SnapPointsIter(p), &snapprefs_dummy);
+
//Include the transformation origin for snapping
- //For a group only the group's origin is considered
- if (includeItemCenter) {
+ //For a selection or group only the overall origin is considered
+ if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) {
p.push_back(this_item->getCenter());
}
}
@@ -457,12 +462,12 @@ std::vector<Geom::Point> Selection::getSnapPoints(bool includeItemCenter) const
return p;
}
-std::vector<Geom::Point> Selection::getSnapPointsConvexHull() const {
+std::vector<Geom::Point> Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const {
GSList const *items = const_cast<Selection *>(this)->itemList();
std::vector<Geom::Point> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
- sp_item_snappoints(SP_ITEM(iter->data), false, SnapPointsIter(p));
+ sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p), snapprefs);
}
std::vector<Geom::Point> pHull;
@@ -521,31 +526,31 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const {
}
guint Selection::numberOfLayers() {
- GSList const *items = const_cast<Selection *>(this)->itemList();
- GSList *layers = NULL;
- for (GSList const *iter = items; iter != NULL; iter = iter->next) {
- SPObject *layer = desktop()->layerForObject(SP_OBJECT(iter->data));
- if (g_slist_find (layers, layer) == NULL) {
- layers = g_slist_prepend (layers, layer);
- }
- }
- guint ret = g_slist_length (layers);
- g_slist_free (layers);
- return ret;
+ GSList const *items = const_cast<Selection *>(this)->itemList();
+ GSList *layers = NULL;
+ for (GSList const *iter = items; iter != NULL; iter = iter->next) {
+ SPObject *layer = desktop()->layerForObject(SP_OBJECT(iter->data));
+ if (g_slist_find (layers, layer) == NULL) {
+ layers = g_slist_prepend (layers, layer);
+ }
+ }
+ guint ret = g_slist_length (layers);
+ g_slist_free (layers);
+ return ret;
}
guint Selection::numberOfParents() {
- GSList const *items = const_cast<Selection *>(this)->itemList();
- GSList *parents = NULL;
- for (GSList const *iter = items; iter != NULL; iter = iter->next) {
- SPObject *parent = SP_OBJECT_PARENT(iter->data);
- if (g_slist_find (parents, parent) == NULL) {
- parents = g_slist_prepend (parents, parent);
- }
- }
- guint ret = g_slist_length (parents);
- g_slist_free (parents);
- return ret;
+ GSList const *items = const_cast<Selection *>(this)->itemList();
+ GSList *parents = NULL;
+ for (GSList const *iter = items; iter != NULL; iter = iter->next) {
+ SPObject *parent = SP_OBJECT_PARENT(iter->data);
+ if (g_slist_find (parents, parent) == NULL) {
+ parents = g_slist_prepend (parents, parent);
+ }
+ }
+ guint ret = g_slist_length (parents);
+ g_slist_free (parents);
+ return ret;
}
}
diff --git a/src/selection.h b/src/selection.h
index 6ae462fc3..88e8ae90d 100644
--- a/src/selection.h
+++ b/src/selection.h
@@ -268,13 +268,13 @@ public:
* @brief Gets the selection's snap points.
* @return Selection's snap points
*/
- std::vector<Geom::Point> getSnapPoints(bool includeItemCenter) const;
+ std::vector<Geom::Point> getSnapPoints(SnapPreferences const *snapprefs) const;
/**
* @brief Gets the snap points of a selection that form a convex hull.
* @return Selection's convex hull points
*/
- std::vector<Geom::Point> getSnapPointsConvexHull() const;
+ std::vector<Geom::Point> getSnapPointsConvexHull(SnapPreferences const *snapprefs) const;
/**
* @brief Connects a slot to be notified of selection changes
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 6ae7948f1..0b1c4f5c9 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -1,9 +1,7 @@
-#define __SELTRANS_C__
-
-/*
- * Helper object for transforming selected items
- *
- * Authors:
+/** @file
+ * @brief Helper object for transforming selected items
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Carl Hetherington <inkscape@carlh.net>
@@ -41,7 +39,7 @@
#include "verbs.h"
#include <glibmm/i18n.h>
#include "display/sp-ctrlline.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "xml/repr.h"
#include "mod360.h"
#include <2geom/angle.h>
@@ -101,8 +99,9 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
_stamp_cache(NULL),
_message_context(desktop->messageStack())
{
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- _snap_bbox_type = (prefs_bbox ==0)?
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int prefs_bbox = prefs->getBool("/tools/bounding_box");
+ _snap_bbox_type = !prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
g_return_if_fail(desktop != NULL);
@@ -287,8 +286,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// Next, get all points to consider for snapping
SnapManager const &m = _desktop->namedview->snap_manager;
_snap_points.clear();
- _snap_points = selection->getSnapPoints(m.getIncludeItemCenter());
- std::vector<Geom::Point> snap_points_hull = selection->getSnapPointsConvexHull();
+ _snap_points = selection->getSnapPoints(&m.snapprefs);
+ std::vector<Geom::Point> snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs);
if (_snap_points.size() > 100) {
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
An average user would rarely ever try to snap such a large number of nodes anyway, because
@@ -815,9 +814,10 @@ gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position,
void Inkscape::SelTrans::_selChanged(Inkscape::Selection */*selection*/)
{
if (!_grabbed) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// reread in case it changed on the fly:
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
- _snap_bbox_type = (prefs_bbox ==0)?
+ int prefs_bbox = prefs->getBool("/tools/bounding_box");
+ _snap_bbox_type = !prefs_bbox ?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
//SPItem::APPROXIMATE_BBOX will be replaced by SPItem::VISUAL_BBOX, as soon as the latter is implemented properly
@@ -932,8 +932,8 @@ gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state)
}
// Snap along a suitable constraint vector from the origin.
- bb = m.constrainedSnapScale(Snapper::SNAPPOINT_BBOX, _bbox_points, default_scale, _origin_for_bboxpoints);
- sn = m.constrainedSnapScale(Snapper::SNAPPOINT_NODE, _snap_points, geom_scale, _origin_for_specpoints);
+ bb = m.constrainedSnapScale(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, default_scale, _origin_for_bboxpoints);
+ sn = m.constrainedSnapScale(SnapPreferences::SNAPPOINT_NODE, _snap_points, geom_scale, _origin_for_specpoints);
/* Choose the smaller difference in scale. Since s[X] == s[Y] we can
** just compare difference in s[X].
@@ -942,8 +942,8 @@ gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state)
sd = sn.getSnapped() ? fabs(sn.getTransformation()[Geom::X] - geom_scale[Geom::X]) : NR_HUGE;
} else {
/* Scale aspect ratio is unlocked */
- bb = m.freeSnapScale(Snapper::SNAPPOINT_BBOX, _bbox_points, default_scale, _origin_for_bboxpoints);
- sn = m.freeSnapScale(Snapper::SNAPPOINT_NODE, _snap_points, geom_scale, _origin_for_specpoints);
+ bb = m.freeSnapScale(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, default_scale, _origin_for_bboxpoints);
+ sn = m.freeSnapScale(SnapPreferences::SNAPPOINT_NODE, _snap_points, geom_scale, _origin_for_specpoints);
/* Pick the snap that puts us closest to the original scale */
bd = bb.getSnapped() ? fabs(Geom::L2(bb.getTransformation()) - Geom::L2(Geom::Point(default_scale[Geom::X], default_scale[Geom::Y]))) : NR_HUGE;
@@ -1031,8 +1031,8 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, Geom
bool symmetrical = state & GDK_CONTROL_MASK;
- bb = m.constrainedSnapStretch(Snapper::SNAPPOINT_BBOX, _bbox_points, Geom::Coord(default_scale[axis]), _origin_for_bboxpoints, Geom::Dim2(axis), symmetrical);
- sn = m.constrainedSnapStretch(Snapper::SNAPPOINT_NODE, _snap_points, Geom::Coord(geom_scale[axis]), _origin_for_specpoints, Geom::Dim2(axis), symmetrical);
+ bb = m.constrainedSnapStretch(SnapPreferences::SNAPPOINT_BBOX, _bbox_points, Geom::Coord(default_scale[axis]), _origin_for_bboxpoints, Geom::Dim2(axis), symmetrical);
+ sn = m.constrainedSnapStretch(SnapPreferences::SNAPPOINT_NODE, _snap_points, Geom::Coord(geom_scale[axis]), _origin_for_specpoints, Geom::Dim2(axis), symmetrical);
if (bb.getSnapped()) {
// We snapped the bbox (which is either visual or geometric)
@@ -1129,8 +1129,9 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P
double radians = atan(skew[dim_a] / scale[dim_a]);
if (state & GDK_CONTROL_MASK) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Snap to defined angle increments
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
if (snaps) {
double sections = floor(radians * snaps / M_PI + .5);
if (fabs(sections) >= snaps / 2) {
@@ -1148,7 +1149,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P
Inkscape::Snapper::ConstraintLine const constraint(component_vectors[dim_b]);
// When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details
Geom::Point const s(skew[dim_a], scale[dim_a]);
- Inkscape::SnappedPoint sn = m.constrainedSnapSkew(Inkscape::Snapper::SNAPPOINT_NODE, _snap_points, constraint, s, _origin, Geom::Dim2(dim_b));
+ Inkscape::SnappedPoint sn = m.constrainedSnapSkew(Inkscape::SnapPreferences::SNAPPOINT_NODE, _snap_points, constraint, s, _origin, Geom::Dim2(dim_b));
if (sn.getSnapped()) {
// We snapped something, so change the skew to reflect it
@@ -1198,7 +1199,8 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state)
* the handle; otherwise it will be relative to the center as set for the selection
*/
- int snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
// rotate affine in rotate
Geom::Point const d1 = _point - _origin;
@@ -1250,7 +1252,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state)
{
SnapManager &m = _desktop->namedview->snap_manager;
m.setup(_desktop);
- m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, pt);
+ m.freeSnapReturnByRef(SnapPreferences::SNAPPOINT_NODE, pt);
if (state & GDK_CONTROL_MASK) {
if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) {
@@ -1358,7 +1360,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
** FIXME: this will snap to more than just the grid, nowadays.
*/
- m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, dxy);
+ m.freeSnapReturnByRef(SnapPreferences::SNAPPOINT_NODE, dxy);
} else if (!shift) {
@@ -1380,12 +1382,12 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
// the constraint-line once. The constraint lines are parallel, but might not be colinear.
// Therefore we will have to set the point through which the constraint-line runs
// individually for each point to be snapped; this will be handled however by _snapTransformed()
- s.push_back(m.constrainedSnapTranslation(Inkscape::Snapper::SNAPPOINT_BBOX,
+ s.push_back(m.constrainedSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_BBOX,
_bbox_points,
Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
dxy));
- s.push_back(m.constrainedSnapTranslation(Inkscape::Snapper::SNAPPOINT_NODE,
+ s.push_back(m.constrainedSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_NODE,
_snap_points,
Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
dxy));
@@ -1399,8 +1401,8 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state)
g_get_current_time(&starttime); */
/* Snap to things with no constraint */
- s.push_back(m.freeSnapTranslation(Inkscape::Snapper::SNAPPOINT_BBOX, _bbox_points, dxy));
- s.push_back(m.freeSnapTranslation(Inkscape::Snapper::SNAPPOINT_NODE, _snap_points, dxy));
+ s.push_back(m.freeSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_BBOX, _bbox_points, dxy));
+ s.push_back(m.freeSnapTranslation(Inkscape::SnapPreferences::SNAPPOINT_NODE, _snap_points, dxy));
/*g_get_current_time(&endtime);
double elapsed = ((((double)endtime.tv_sec - starttime.tv_sec) * G_USEC_PER_SEC + (endtime.tv_usec - starttime.tv_usec))) / 1000.0;
@@ -1471,7 +1473,8 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand
Geom::Point normalized_handle_pos = (visual_handle_pos - new_bbox.min()) * Geom::Scale(new_bbox.dimensions()).inverse();
// Calculate the absolute affine while taking into account the scaling of the stroke width
- int transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool transform_stroke = prefs->getBool("/options/transform/stroke", true);
Geom::Matrix abs_affine = get_scale_transform_with_stroke (*_bbox, _strokewidth, transform_stroke,
new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]);
@@ -1510,11 +1513,12 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineDefault(Geom::Scale const default_
Geom::Point new_bbox_min = _approximate_bbox->min() * abs_affine;
Geom::Point new_bbox_max = _approximate_bbox->max() * abs_affine;
- int transform_stroke = false;
+ bool transform_stroke = false;
gdouble strokewidth = 0;
if ( _snap_bbox_type != SPItem::GEOMETRIC_BBOX) {
- transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ transform_stroke = prefs->getBool("/options/transform/stroke", true);
strokewidth = _strokewidth;
}
@@ -1531,14 +1535,14 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale)
_relative_affine = Geom::Matrix(geom_scale);
_absolute_affine = Geom::Translate(-_origin_for_specpoints) * _relative_affine * Geom::Translate(_origin_for_specpoints);
- bool const transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool const transform_stroke = prefs->getBool("/options/transform/stroke", true);
Geom::Rect visual_bbox = get_visual_bbox(_geometric_bbox, _absolute_affine, _strokewidth, transform_stroke);
// return the new handle position
return visual_bbox.min() + visual_bbox.dimensions() * Geom::Scale(_handle_x, _handle_y);
}
-
/*
Local Variables:
mode:c++
@@ -1548,4 +1552,4 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale)
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 4fe1130bc..04f40929b 100644
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
@@ -25,7 +25,7 @@
#include "live_effects/parameter/pointparam-knotholder.h"
#include "nodepath.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "object-edit.h"
#include "style.h"
#include "display/curve.h"
@@ -241,7 +241,8 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) {
switch(type) {
case SH_NODEPATH:
if (SP_IS_LPE_ITEM(item)) {
- this->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->nodepath = sp_nodepath_new(desktop, item, (prefs->getBool("/tools/nodes/show_handles", true)));
}
if (this->nodepath) {
this->nodepath->shape_editor = this;
@@ -286,8 +287,9 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
this->grab_node = -1;
if (lpeobject) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->nodepath = sp_nodepath_new( desktop, lpeobject,
- (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0),
+ (prefs->getInt("/tools/nodes/show_handles", true)),
key, item);
if (this->nodepath) {
this->nodepath->shape_editor = this;
@@ -377,13 +379,14 @@ bool ShapeEditor::is_over_stroke (Geom::Point event_p, bool remember) {
delta = desktop->d2w(delta);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double stroke_tolerance =
(( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
desktop->current_zoom() *
SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 *
to_2geom(sp_item_i2d_affine(item)).descrim()
: 0.0)
- + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) / to_2geom(sp_item_i2d_affine(item)).descrim();
+ + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100)) / to_2geom(sp_item_i2d_affine(item)).descrim();
bool close = (Geom::L2 (delta) < stroke_tolerance);
if (remember && close) {
diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp
new file mode 100644
index 000000000..f1ad0fd0d
--- /dev/null
+++ b/src/snap-preferences.cpp
@@ -0,0 +1,124 @@
+#define __SNAPPREFERENCES_CPP__
+
+/**
+ * \file snap-preferences.cpp
+ * \brief Storing of snapping preferences
+ *
+ * Authors:
+ * Diederik van Lierop <mail@diedenrezi.nl>
+ *
+ * Copyright (C) 2008 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "inkscape.h"
+#include "snap-preferences.h"
+
+Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_NODE = 0x1;
+Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_BBOX = 0x2;
+Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_GUIDE = 0x4;
+
+
+Inkscape::SnapPreferences::SnapPreferences() :
+ _include_item_center(false),
+ _snap_enabled_globally(true)
+{
+ setSnapFrom(SNAPPOINT_BBOX | SNAPPOINT_NODE, true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab
+}
+
+/*
+ * The snappers have too many parameters to adjust individually. Therefore only
+ * two snapping modes are presented to the user: snapping bounding box corners (to
+ * other bounding boxes, grids or guides), and/or snapping nodes (to other nodes,
+ * paths, grids or guides). To select either of these modes (or both), use the
+ * methods defined below: setSnapModeBBox() and setSnapModeNode().
+ *
+ * */
+
+
+void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled)
+{
+ if (enabled) {
+ _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+ } else {
+ _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_BBOX;
+ }
+}
+
+bool Inkscape::SnapPreferences::getSnapModeBBox() const
+{
+ return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_BBOX);
+}
+
+void Inkscape::SnapPreferences::setSnapModeNode(bool enabled)
+{
+ if (enabled) {
+ _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_NODE;
+ } else {
+ _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_NODE;
+ }
+}
+
+bool Inkscape::SnapPreferences::getSnapModeNode() const
+{
+ return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_NODE);
+}
+
+bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const
+{
+ return (_snap_from & (Inkscape::SnapPreferences::SNAPPOINT_BBOX | Inkscape::SnapPreferences::SNAPPOINT_NODE) );
+}
+
+bool Inkscape::SnapPreferences::getSnapModeAny() const
+{
+ return (_snap_from != 0);
+}
+
+void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled)
+{
+ if (enabled) {
+ _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_GUIDE;
+ } else {
+ _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_GUIDE;
+ }
+}
+
+bool Inkscape::SnapPreferences::getSnapModeGuide() const
+{
+ return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_GUIDE);
+}
+
+/**
+ * Turn on/off snapping of specific point types.
+ * \param t Point type.
+ * \param s true to snap to this point type, otherwise false;
+ */
+void Inkscape::SnapPreferences::setSnapFrom(PointType t, bool s)
+{
+ if (s) {
+ _snap_from |= t;
+ } else {
+ _snap_from &= ~t;
+ }
+}
+
+/**
+ * \param t Point type.
+ * \return true if snapper will snap this type of point, otherwise false.
+ */
+bool Inkscape::SnapPreferences::getSnapFrom(PointType t) const
+{
+ return (_snap_from & t);
+}
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/snap-preferences.h b/src/snap-preferences.h
new file mode 100644
index 000000000..d98cd7cef
--- /dev/null
+++ b/src/snap-preferences.h
@@ -0,0 +1,81 @@
+#ifndef SNAPPREFERENCES_H_
+#define SNAPPREFERENCES_H_
+
+/**
+ * \file snap-preferences.cpp
+ * \brief Storing of snapping preferences
+ *
+ * Authors:
+ * Diederik van Lierop <mail@diedenrezi.nl>
+ *
+ * Copyright (C) 2008 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+namespace Inkscape
+{
+
+class SnapPreferences
+{
+public:
+ SnapPreferences();
+
+ /// Point types to snap.
+ typedef int PointType;
+ static const PointType SNAPPOINT_NODE;
+ static const PointType SNAPPOINT_BBOX;
+ static const PointType SNAPPOINT_GUIDE;
+
+ void setSnapModeBBox(bool enabled);
+ void setSnapModeNode(bool enabled);
+ void setSnapModeGuide(bool enabled);
+ bool getSnapModeBBox() const;
+ bool getSnapModeNode() const;
+ bool getSnapModeBBoxOrNodes() const;
+ bool getSnapModeAny() const;
+ bool getSnapModeGuide() const;
+
+ void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;}
+ void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;}
+ void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;}
+ bool getSnapIntersectionGG() const {return _intersectionGG;}
+ bool getSnapIntersectionCS() const {return _intersectionCS;}
+ bool getSnapSmoothNodes() const {return _smoothNodes;}
+
+ void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;}
+ bool getIncludeItemCenter() const {return _include_item_center;}
+
+ void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;}
+ bool getSnapEnabledGlobally() const {return _snap_enabled_globally;}
+
+ void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;}
+ bool getSnapPostponedGlobally() const {return _snap_postponed_globally;}
+
+ void setSnapFrom(PointType t, bool s);
+ bool getSnapFrom(PointType t) const;
+
+private:
+ bool _include_item_center; //If true, snapping nodes will also snap the item's center
+ bool _intersectionGG;
+ bool _intersectionCS;
+ bool _smoothNodes;
+ bool _snap_enabled_globally; // Toggles ALL snapping
+ bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast
+ PointType _snap_from; ///< bitmap of point types that we will snap from
+
+};
+
+}
+#endif /*SNAPPREFERENCES_H_*/
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/snap.cpp b/src/snap.cpp
index 202dd8e92..6fa99f288 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -46,13 +46,11 @@ using std::vector;
SnapManager::SnapManager(SPNamedView const *v) :
guide(this, 0),
object(this, 0),
- _named_view(v),
- _include_item_center(false),
- _snap_enabled_globally(true)
+ snapprefs(),
+ _named_view(v)
{
}
-
/**
* \return List of snappers that we use.
*/
@@ -93,9 +91,9 @@ SnapManager::getGridSnappers() const
* \return true if one of the snappers will try to snap something.
*/
-bool SnapManager::SomeSnapperMightSnap() const
+bool SnapManager::someSnapperMightSnap() const
{
- if (!_snap_enabled_globally) {
+ if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) {
return false;
}
@@ -108,67 +106,6 @@ bool SnapManager::SomeSnapperMightSnap() const
return (i != s.end());
}
-/*
- * The snappers have too many parameters to adjust individually. Therefore only
- * two snapping modes are presented to the user: snapping bounding box corners (to
- * other bounding boxes, grids or guides), and/or snapping nodes (to other nodes,
- * paths, grids or guides). To select either of these modes (or both), use the
- * methods defined below: setSnapModeBBox() and setSnapModeNode().
- *
- * */
-
-
-void SnapManager::setSnapModeBBox(bool enabled)
-{
- //The default values are being set in sp_namedview_set() (in sp-namedview.cpp)
- guide.setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
-
- for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
- Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
- grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
- }
-
- object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
- //object.setSnapToBBoxNode(enabled); // On second thought, these should be controlled
- //object.setSnapToBBoxPath(enabled); // separately by the snapping prefs dialog
- object.setStrictSnapping(true); //don't snap bboxes to nodes/paths and vice versa
-}
-
-bool SnapManager::getSnapModeBBox() const
-{
- return guide.getSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX);
-}
-
-void SnapManager::setSnapModeNode(bool enabled)
-{
- guide.setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
-
- for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
- Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
- grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
- }
-
- object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
- //object.setSnapToItemNode(enabled); // On second thought, these should be controlled
- //object.setSnapToItemPath(enabled); // separately by the snapping prefs dialog
- object.setStrictSnapping(true);
-}
-
-bool SnapManager::getSnapModeNode() const
-{
- return guide.getSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE);
-}
-
-void SnapManager::setSnapModeGuide(bool enabled)
-{
- object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_GUIDE, enabled);
-}
-
-bool SnapManager::getSnapModeGuide() const
-{
- return object.getSnapFrom(Inkscape::Snapper::SNAPPOINT_GUIDE);
-}
-
/**
* Try to snap a point to any of the specified snappers.
*
@@ -180,7 +117,7 @@ bool SnapManager::getSnapModeGuide() const
* \return Snapped point.
*/
-void SnapManager::freeSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+void SnapManager::freeSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
Geom::Point &p,
bool first_point,
boost::optional<Geom::Rect> const &bbox_to_snap) const
@@ -200,12 +137,12 @@ void SnapManager::freeSnapReturnByRef(Inkscape::Snapper::PointType point_type,
* \return Snapped point.
*/
-Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapPreferences::PointType point_type,
Geom::Point const &p,
bool first_point,
boost::optional<Geom::Rect> const &bbox_to_snap) const
{
- if (!SomeSnapperMightSnap()) {
+ if (!someSnapperMightSnap()) {
return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false);
}
@@ -241,7 +178,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_
// PS: Wether we really find a multiple also depends on the snapping range!
Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t) const
{
- if (!_snap_enabled_globally)
+ if (!snapprefs.getSnapEnabledGlobally()) // No need to check for snapprefs.getSnapPostponedGlobally() here
return t;
//FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
@@ -269,7 +206,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t) const
Geom::Point const t_offset = from_2geom(t) + grid->origin;
SnappedConstraints sc;
// Only the first three parameters are being used for grid snappers
- snapper->freeSnap(sc, Inkscape::Snapper::SNAPPOINT_NODE, t_offset, TRUE, boost::optional<Geom::Rect>(), NULL, NULL);
+ snapper->freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_NODE, t_offset, TRUE, boost::optional<Geom::Rect>(), NULL, NULL);
// Find the best snap for this grid, including intersections of the grid-lines
Inkscape::SnappedPoint s = findBestSnap(t_offset, sc, false);
if (s.getSnapped() && (s.getDistance() < nearest_distance)) {
@@ -299,7 +236,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t) const
* \return Snapped point.
*/
-void SnapManager::constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+void SnapManager::constrainedSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
Geom::Point &p,
Inkscape::Snapper::ConstraintLine const &constraint,
bool first_point,
@@ -321,13 +258,13 @@ void SnapManager::constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_
* \return Snapped point.
*/
-Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::PointType point_type,
Geom::Point const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
bool first_point,
boost::optional<Geom::Rect> const &bbox_to_snap) const
{
- if (!SomeSnapperMightSnap()) {
+ if (!someSnapperMightSnap()) {
return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false);
}
@@ -358,8 +295,8 @@ void SnapManager::guideSnap(Geom::Point &p, Geom::Point const &guide_normal) con
{
// This method is used to snap a guide to nodes, while dragging the guide around
- if (!(object.GuidesMightSnap() && _snap_enabled_globally)) {
- return;
+ if ( !(object.GuidesMightSnap() && snapprefs.getSnapEnabledGlobally()) || snapprefs.getSnapPostponedGlobally() ) {
+ return;
}
SnappedConstraints sc;
@@ -387,7 +324,7 @@ void SnapManager::guideSnap(Geom::Point &p, Geom::Point const &guide_normal) con
*/
Inkscape::SnappedPoint SnapManager::_snapTransformed(
- Inkscape::Snapper::PointType type,
+ Inkscape::SnapPreferences::PointType type,
std::vector<Geom::Point> const &points,
bool constrained,
Inkscape::Snapper::ConstraintLine const &constraint,
@@ -405,7 +342,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
/* Quick check to see if we have any snappers that are enabled
** Also used to globally disable all snapping
*/
- if (SomeSnapperMightSnap() == false) {
+ if (someSnapperMightSnap() == false) {
g_assert(points.size() > 0);
return Inkscape::SnappedPoint();
}
@@ -653,7 +590,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed(
* \return Snapped translation, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::freeSnapTranslation(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::freeSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Point const &tr) const
{
@@ -673,7 +610,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslation(Inkscape::Snapper::Point
* \return Snapped translation, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
Geom::Point const &tr) const
@@ -693,7 +630,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapTranslation(Inkscape::Snapper
* \return Snapped scale, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::freeSnapScale(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::freeSnapScale(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Scale const &s,
Geom::Point const &o) const
@@ -714,7 +651,7 @@ Inkscape::SnappedPoint SnapManager::freeSnapScale(Inkscape::Snapper::PointType p
* \return Snapped scale, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Scale const &s,
Geom::Point const &o) const
@@ -737,7 +674,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapScale(Inkscape::Snapper::Poin
* \return Snapped stretch, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Coord const &s,
Geom::Point const &o,
@@ -760,7 +697,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapStretch(Inkscape::Snapper::Po
* \return Snapped skew, if a snap occurred, and a flag indicating whether a snap occurred.
*/
-Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::Snapper::PointType point_type,
+Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
Geom::Point const &s,
@@ -774,7 +711,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::Snapper::Point
// NOT the case for example when rotating or skewing. The bounding box itself cannot possibly rotate or skew,
// so it's corners have a different transformation. The snappers cannot handle this, therefore snapping
// of bounding boxes is not allowed here.
- g_assert(!(point_type & Inkscape::Snapper::SNAPPOINT_BBOX));
+ g_assert(!(point_type & Inkscape::SnapPreferences::SNAPPOINT_BBOX));
return _snapTransformed(point_type, p, true, constraint, SKEW, s, o, d, false);
}
@@ -805,7 +742,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
sp_list.push_back(Inkscape::SnappedPoint(closestCurve));
}
- if (_intersectionCS) {
+ if (snapprefs.getSnapIntersectionCS()) {
// search for the closest snapped intersection of curves
Inkscape::SnappedPoint closestCurvesIntersection;
if (getClosestIntersectionCS(sc.curves, p, closestCurvesIntersection)) {
@@ -849,7 +786,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
}
// search for the closest snapped intersection of grid with guide lines
- if (_intersectionGG) {
+ if (snapprefs.getSnapIntersectionGG()) {
Inkscape::SnappedPoint closestGridGuidePoint;
if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) {
closestGridGuidePoint.setTarget(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION);
diff --git a/src/snap.h b/src/snap.h
index df0860274..624f7adac 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -27,6 +27,7 @@
#include "guide-snapper.h"
#include "object-snapper.h"
+#include "snap-preferences.h"
class SPNamedView;
@@ -45,19 +46,19 @@ public:
typedef std::list<const Inkscape::Snapper*> SnapperList;
- bool SomeSnapperMightSnap() const;
+ bool someSnapperMightSnap() const;
void setup(SPDesktop const *desktop, bool snapindicator = true, SPItem const *item_to_ignore = NULL, std::vector<Geom::Point> *unselected_nodes = NULL);
void setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes = NULL);
// freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a
// point if snapping has occured (by overwriting p); otherwise p is untouched
- void freeSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+ void freeSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
Geom::Point &p,
bool first_point = true,
boost::optional<Geom::Rect> const &bbox_to_snap = boost::optional<Geom::Rect>()) const;
- Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint freeSnap(Inkscape::SnapPreferences::PointType point_type,
Geom::Point const &p,
bool first_point = true,
boost::optional<Geom::Rect> const &bbox_to_snap = boost::optional<Geom::Rect>() ) const;
@@ -66,13 +67,13 @@ public:
// constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a
// point, by overwriting p, if snapping has occured; otherwise p is untouched
- void constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+ void constrainedSnapReturnByRef(Inkscape::SnapPreferences::PointType point_type,
Geom::Point &p,
Inkscape::Snapper::ConstraintLine const &constraint,
bool first_point = true,
boost::optional<Geom::Rect> const &bbox_to_snap = boost::optional<Geom::Rect>()) const;
- Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint constrainedSnap(Inkscape::SnapPreferences::PointType point_type,
Geom::Point const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
bool first_point = true,
@@ -80,33 +81,33 @@ public:
void guideSnap(Geom::Point &p, Geom::Point const &guide_normal) const;
- Inkscape::SnappedPoint freeSnapTranslation(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint freeSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Point const &tr) const;
- Inkscape::SnappedPoint constrainedSnapTranslation(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint constrainedSnapTranslation(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
Geom::Point const &tr) const;
- Inkscape::SnappedPoint freeSnapScale(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint freeSnapScale(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Scale const &s,
Geom::Point const &o) const;
- Inkscape::SnappedPoint constrainedSnapScale(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint constrainedSnapScale(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Scale const &s,
Geom::Point const &o) const;
- Inkscape::SnappedPoint constrainedSnapStretch(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint constrainedSnapStretch(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Geom::Coord const &s,
Geom::Point const &o,
Geom::Dim2 d,
bool uniform) const;
- Inkscape::SnappedPoint constrainedSnapSkew(Inkscape::Snapper::PointType point_type,
+ Inkscape::SnappedPoint constrainedSnapSkew(Inkscape::SnapPreferences::PointType point_type,
std::vector<Geom::Point> const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
Geom::Point const &s, // s[0] = skew factor, s[1] = scale factor
@@ -115,6 +116,7 @@ public:
Inkscape::GuideSnapper guide; ///< guide snapper
Inkscape::ObjectSnapper object; ///< snapper to other objects
+ Inkscape::SnapPreferences snapprefs;
SnapperList getSnappers() const;
SnapperList getGridSnappers() const;
@@ -123,64 +125,24 @@ public:
SPNamedView const *getNamedView() const {return _named_view;}
SPDocument *getDocument() const;
- void setSnapModeBBox(bool enabled);
- void setSnapModeNode(bool enabled);
- void setSnapModeGuide(bool enabled);
- bool getSnapModeBBox() const;
- bool getSnapModeNode() const;
- bool getSnapModeGuide() const;
-
- void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;}
- void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;}
- bool getSnapIntersectionGG() {return _intersectionGG;}
- bool getSnapIntersectionCS() {return _intersectionCS;}
-
- void setIncludeItemCenter(bool enabled) {
- _include_item_center = enabled;
- // also store a local copy in the object-snapper instead of passing it through many functions
- object.setIncludeItemCenter(enabled);
- }
-
- bool getIncludeItemCenter() const {
- return _include_item_center;
- }
-
- void setSnapEnabledGlobally(bool enabled) {
- _snap_enabled_globally = enabled;
- }
-
- bool getSnapEnabledGlobally() const {
- return _snap_enabled_globally;
- }
-
- void toggleSnapEnabledGlobally() {
- _snap_enabled_globally = !_snap_enabled_globally;
- }
-
protected:
SPNamedView const *_named_view;
private:
-
- enum Transformation {
+ enum Transformation {
TRANSLATION,
SCALE,
STRETCH,
SKEW
};
- bool _include_item_center; //If true, snapping nodes will also snap the item's center
- bool _intersectionGG;
- bool _intersectionCS;
- bool _snap_enabled_globally; //Toggles ALL snapping
-
std::vector<SPItem const *> *_items_to_ignore;
SPItem const *_item_to_ignore;
SPDesktop const *_desktop;
bool _snapindicator;
std::vector<Geom::Point> *_unselected_nodes;
- Inkscape::SnappedPoint _snapTransformed(Inkscape::Snapper::PointType type,
+ Inkscape::SnappedPoint _snapTransformed(Inkscape::SnapPreferences::PointType type,
std::vector<Geom::Point> const &points,
bool constrained,
Inkscape::Snapper::ConstraintLine const &constraint,
diff --git a/src/snapper.cpp b/src/snapper.cpp
index 51ffaa42d..7e4568160 100644
--- a/src/snapper.cpp
+++ b/src/snapper.cpp
@@ -14,20 +14,17 @@
#include "inkscape.h"
#include "desktop.h"
-Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_BBOX = 0x1;
-Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_NODE = 0x2;
-Inkscape::Snapper::PointType const Inkscape::Snapper::SNAPPOINT_GUIDE = 0x4;
-
/**
* Construct new Snapper for named view.
* \param nv Named view.
* \param d Snap tolerance.
*/
-Inkscape::Snapper::Snapper(SnapManager const *sm, Geom::Coord const t) : _snapmanager(sm), _snap_enabled(true), _snapper_tolerance(t)
+Inkscape::Snapper::Snapper(SnapManager const *sm, Geom::Coord const t) :
+ _snapmanager(sm),
+ _snap_enabled(true),
+ _snapper_tolerance(t)
{
g_assert(_snapmanager != NULL);
-
- setSnapFrom(SNAPPOINT_BBOX | SNAPPOINT_NODE, true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab
}
/**
@@ -53,29 +50,6 @@ bool Inkscape::Snapper::getSnapperAlwaysSnap() const
}
/**
- * Turn on/off snapping of specific point types.
- * \param t Point type.
- * \param s true to snap to this point type, otherwise false;
- */
-void Inkscape::Snapper::setSnapFrom(PointType t, bool s)
-{
- if (s) {
- _snap_from |= t;
- } else {
- _snap_from &= ~t;
- }
-}
-
-/**
- * \param t Point type.
- * \return true if snapper will snap this type of point, otherwise false.
- */
-bool Inkscape::Snapper::getSnapFrom(PointType t) const
-{
- return (_snap_from & t);
-}
-
-/**
* \param s true to enable this snapper, otherwise false.
*/
diff --git a/src/snapper.h b/src/snapper.h
index 97068bf10..7ad548ab4 100644
--- a/src/snapper.h
+++ b/src/snapper.h
@@ -21,6 +21,7 @@
#include "snapped-point.h"
#include "snapped-line.h"
#include "snapped-curve.h"
+#include "snap-preferences.h"
struct SnappedConstraints {
std::list<Inkscape::SnappedPoint> points;
@@ -40,19 +41,10 @@ namespace Inkscape
class Snapper
{
public:
- Snapper() {}
- Snapper(SnapManager const *sm, ::Geom::Coord const d);
- virtual ~Snapper() {}
-
- /// Point types to snap.
- typedef int PointType;
- static const PointType SNAPPOINT_NODE;
- static const PointType SNAPPOINT_BBOX;
- static const PointType SNAPPOINT_GUIDE;
-
- void setSnapFrom(PointType t, bool s);
- bool getSnapFrom(PointType t) const;
-
+ Snapper() {}
+ Snapper(SnapManager const *sm, ::Geom::Coord const t);
+ virtual ~Snapper() {}
+
void setSnapperTolerance(Geom::Coord t);
Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
@@ -60,13 +52,14 @@ public:
/**
* \return true if this Snapper will snap at least one kind of point.
*/
- virtual bool ThisSnapperMightSnap() const {return (_snap_enabled && _snap_from != 0);} // will likely be overridden by derived classes
+ //virtual bool ThisSnapperMightSnap() const;
+ virtual bool ThisSnapperMightSnap() const {return _snap_enabled;} // will likely be overridden by derived classes
void setEnabled(bool s);
bool getEnabled() const {return _snap_enabled;}
virtual void freeSnap(SnappedConstraints &/*sc*/,
- PointType const &/*t*/,
+ SnapPreferences::PointType const &/*t*/,
Geom::Point const &/*p*/,
bool const &/*first_point*/,
boost::optional<Geom::Rect> const &/*bbox_to_snap*/,
@@ -104,7 +97,7 @@ public:
};
virtual void constrainedSnap(SnappedConstraints &/*sc*/,
- PointType const &/*t*/,
+ SnapPreferences::PointType const &/*t*/,
Geom::Point const &/*p*/,
bool const &/*first_point*/,
boost::optional<Geom::Rect> const &/*bbox_to_snap*/,
@@ -112,15 +105,14 @@ public:
std::vector<SPItem const *> const */*it*/) const {};
protected:
- SnapManager const *_snapmanager;
- int _snap_from; ///< bitmap of point types that we will snap from
- bool _snap_enabled; ///< true if this snapper is enabled, otherwise false
+ SnapManager const *_snapmanager;
+
+ bool _snap_enabled; ///< true if this snapper is enabled, otherwise false
private:
Geom::Coord _snapper_tolerance; ///< snap tolerance in desktop coordinates
// must be private to enforce the usage of getTolerance(), which retrieves
// the tolerance in screen pixels (making it zoom independent)
-
};
}
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index a9833e053..e1284f61e 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -72,7 +72,7 @@ static void sp_genericellipse_init(SPGenericEllipse *ellipse);
static void sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags);
-static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_genericellipse_set_shape(SPShape *shape);
static void sp_genericellipse_update_patheffect (SPLPEItem *lpeitem, bool write);
@@ -248,7 +248,7 @@ static void sp_genericellipse_set_shape(SPShape *shape)
curve->unref();
}
-static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
g_assert(item != NULL);
g_assert(SP_IS_GENERICELLIPSE(item));
@@ -859,11 +859,11 @@ sp_arc_position_set(SPArc *arc, gdouble x, gdouble y, gdouble rx, gdouble ry)
ge->rx.computed = rx;
ge->ry.computed = ry;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs->getDouble("tools.shapes.arc", "start", 0.0) != 0)
- ge->start = prefs->getDouble("tools.shapes.arc", "start", 0.0);
- if (prefs->getDouble("tools.shapes.arc", "end", 0.0) != 0)
- ge->end = prefs->getDouble("tools.shapes.arc", "end", 0.0);
- if (!prefs->getBool("tools.shapes.arc", "open"))
+ if (prefs->getDouble("/tools/shapes/arc/start", 0.0) != 0)
+ ge->start = prefs->getDouble("/tools/shapes/arc/start", 0.0);
+ if (prefs->getDouble("/tools/shapes/arc/end", 0.0) != 0)
+ ge->end = prefs->getDouble("/tools/shapes/arc/end", 0.0);
+ if (!prefs->getBool("/tools/shapes/arc/open"))
ge->closed = 1;
else
ge->closed = 0;
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index dcaa59ea0..83c13ca05 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -363,7 +363,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx)
dbox.y0 = 0.0;
dbox.x1 = sp_document_width(SP_OBJECT_DOCUMENT(item));
dbox.y1 = sp_document_height(SP_OBJECT_DOCUMENT(item));
- NR::Matrix const ctm (sp_item_i2d_affine(item));
+ Geom::Matrix const ctm (sp_item_i2d_affine(item));
group->layout.print(ctx, &pbox, &dbox, &bbox, ctm);
}
@@ -533,9 +533,9 @@ SPFlowtext::getAsText()
Inkscape::XML::Node *repr = xml_doc->createElement("svg:text");
repr->setAttribute("xml:space", "preserve");
repr->setAttribute("style", SP_OBJECT_REPR(this)->attribute("style"));
- NR::Point anchor_point = this->layout.characterAnchorPoint(this->layout.begin());
- sp_repr_set_svg_double(repr, "x", anchor_point[NR::X]);
- sp_repr_set_svg_double(repr, "y", anchor_point[NR::Y]);
+ Geom::Point anchor_point = this->layout.characterAnchorPoint(this->layout.begin());
+ sp_repr_set_svg_double(repr, "x", anchor_point[Geom::X]);
+ sp_repr_set_svg_double(repr, "y", anchor_point[Geom::Y]);
for (Inkscape::Text::Layout::iterator it = this->layout.begin() ; it != this->layout.end() ; ) {
Inkscape::XML::Node *line_tspan = xml_doc->createElement("svg:tspan");
@@ -547,7 +547,7 @@ SPFlowtext::getAsText()
while (it != it_line_end) {
Inkscape::XML::Node *span_tspan = xml_doc->createElement("svg:tspan");
- NR::Point anchor_point = this->layout.characterAnchorPoint(it);
+ Geom::Point anchor_point = this->layout.characterAnchorPoint(it);
// use kerning to simulate justification and whatnot
Inkscape::Text::Layout::iterator it_span_end = it;
it_span_end.nextStartOfSpan();
@@ -574,9 +574,9 @@ SPFlowtext::getAsText()
attrs.dx[0] = 0.0;
TextTagAttributes(attrs).writeTo(span_tspan);
if (set_x)
- sp_repr_set_svg_double(span_tspan, "x", anchor_point[NR::X]); // FIXME: this will pick up the wrong end of counter-directional runs
+ sp_repr_set_svg_double(span_tspan, "x", anchor_point[Geom::X]); // FIXME: this will pick up the wrong end of counter-directional runs
if (set_y)
- sp_repr_set_svg_double(span_tspan, "y", anchor_point[NR::Y]);
+ sp_repr_set_svg_double(span_tspan, "y", anchor_point[Geom::Y]);
SPObject *source_obj = 0;
void *rawptr = 0;
@@ -672,7 +672,7 @@ bool SPFlowtext::has_internal_frame()
}
-SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p0, NR::Point p1)
+SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, Geom::Point p1)
{
SPDocument *doc = sp_desktop_document (desktop);
@@ -695,14 +695,14 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p0, N
p0 = sp_desktop_dt2root_xy_point(desktop, p0);
p1 = sp_desktop_dt2root_xy_point(desktop, p1);
- using NR::X;
- using NR::Y;
- NR::Coord const x0 = MIN(p0[X], p1[X]);
- NR::Coord const y0 = MIN(p0[Y], p1[Y]);
- NR::Coord const x1 = MAX(p0[X], p1[X]);
- NR::Coord const y1 = MAX(p0[Y], p1[Y]);
- NR::Coord const w = x1 - x0;
- NR::Coord const h = y1 - y0;
+ using Geom::X;
+ using Geom::Y;
+ Geom::Coord const x0 = MIN(p0[X], p1[X]);
+ Geom::Coord const y0 = MIN(p0[Y], p1[Y]);
+ Geom::Coord const x1 = MAX(p0[X], p1[X]);
+ Geom::Coord const y1 = MAX(p0[Y], p1[Y]);
+ Geom::Coord const w = x1 - x0;
+ Geom::Coord const h = y1 - y0;
sp_rect_position_set(SP_RECT(rect), x0, y0, w, h);
SP_OBJECT(rect)->updateRepr();
diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h
index 144157dc9..8889c7a56 100644
--- a/src/sp-flowtext.h
+++ b/src/sp-flowtext.h
@@ -7,7 +7,7 @@
#include "sp-item.h"
#include "display/nr-arena-forward.h"
-
+#include <2geom/forward.h>
#include "libnrtype/Layout-TNG.h"
#define SP_TYPE_FLOWTEXT (sp_flowtext_get_type ())
@@ -32,9 +32,9 @@ struct SPFlowtext : public SPItem {
Inkscape::Text::Layout layout;
/** discards the NRArena objects representing this text. */
- void _clearFlow(NRArenaGroup* in_arena);
+ void _clearFlow(NRArenaGroup* in_arena);
- double par_indent;
+ double par_indent;
private:
/** Recursively walks the xml tree adding tags and their contents. */
@@ -47,12 +47,12 @@ private:
};
struct SPFlowtextClass {
- SPItemClass parent_class;
+ SPItemClass parent_class;
};
GType sp_flowtext_get_type (void);
-SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, NR::Point p1, NR::Point p2);
+SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p1, Geom::Point p2);
#endif
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 561e0e62c..bbb85cb78 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -114,7 +114,7 @@ static void sp_guide_class_init(SPGuideClass *gc)
static void sp_guide_init(SPGuide *guide)
{
- guide->normal_to_line = component_vectors[NR::Y];
+ guide->normal_to_line = component_vectors[Geom::Y];
guide->point_on_line = Geom::Point(0.,0.);
guide->color = 0x0000ff7f;
guide->hicolor = 0xff00007f;
@@ -185,9 +185,9 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
{
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
- guide->normal_to_line = component_vectors[NR::Y];
+ guide->normal_to_line = component_vectors[Geom::Y];
} else if (value && !strcmp(value, "vertical")) {
- guide->normal_to_line = component_vectors[NR::X];
+ guide->normal_to_line = component_vectors[Geom::X];
} else if (value) {
gchar ** strarray = g_strsplit(value, ",", 2);
double newx, newy;
@@ -200,11 +200,11 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
guide->normal_to_line = direction;
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = component_vectors[NR::X];
+ guide->normal_to_line = component_vectors[Geom::X];
}
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = component_vectors[NR::X];
+ guide->normal_to_line = component_vectors[Geom::X];
}
sp_guide_set_normal(*guide, guide->normal_to_line, false);
}
@@ -332,7 +332,7 @@ void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive)
g_assert_not_reached();
}
-Geom::Point sp_guide_position_from_pt(SPGuide const *guide, NR::Point const &pt)
+Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt)
{
return -(pt - guide->point_on_line);
}
@@ -409,17 +409,17 @@ void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line,
*/
char *sp_guide_description(SPGuide const *guide)
{
- using NR::X;
- using NR::Y;
+ using Geom::X;
+ using Geom::Y;
GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric());
GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric());
- if ( guide->normal_to_line == component_vectors[X] ||
- guide->normal_to_line == -component_vectors[X]) {
+ if ( are_near(guide->normal_to_line, component_vectors[X]) ||
+ are_near(guide->normal_to_line, -component_vectors[X]) ) {
return g_strdup_printf(_("vertical, at %s"), position_string_x->str);
- } else if ( guide->normal_to_line == component_vectors[Y] ||
- guide->normal_to_line == -component_vectors[Y]) {
+ } else if ( are_near(guide->normal_to_line, component_vectors[Y]) ||
+ are_near(guide->normal_to_line, -component_vectors[Y]) ) {
return g_strdup_printf(_("horizontal, at %s"), position_string_y->str);
} else {
double const radians = guide->angle();
diff --git a/src/sp-guide.h b/src/sp-guide.h
index 78c795f83..593e4583f 100644
--- a/src/sp-guide.h
+++ b/src/sp-guide.h
@@ -14,7 +14,7 @@
#include <vector>
#include "display/display-forward.h"
-#include "libnr/nr-point.h"
+#include <2geom/point.h>
#include "sp-object.h"
#include "sp-guide-attachment.h"
@@ -26,7 +26,7 @@
/* Represents the constraint on p that dot(g.direction, p) == g.position. */
struct SPGuide : public SPObject {
- NR::Point normal_to_line;
+ Geom::Point normal_to_line;
Geom::Point point_on_line;
guint32 color;
@@ -53,7 +53,7 @@ void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler);
void sp_guide_hide(SPGuide *guide, SPCanvas *canvas);
void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive);
-Geom::Point sp_guide_position_from_pt(SPGuide const *guide, NR::Point const &pt);
+Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt);
double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt);
void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 57f8804d9..c9ee25632 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -53,7 +53,7 @@
#include "color-profile.h"
//#define DEBUG_LCMS
#ifdef DEBUG_LCMS
-#include "prefs-utils.h"
+#include "preferences.h"
#include <gtk/gtkmessagedialog.h>
#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
@@ -74,7 +74,7 @@ static Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Doc
static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_image_print (SPItem * item, SPPrintContext *ctx);
static gchar * sp_image_description (SPItem * item);
-static void sp_image_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_image_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static NRArenaItem *sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static Geom::Matrix sp_image_set_transform (SPItem *item, Geom::Matrix const &xform);
static void sp_image_set_curve(SPImage *image);
@@ -102,10 +102,11 @@ extern "C"
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
- gint dump = prefs_get_int_attribute_limited("options.scislac", #key, 0, 0, 1);\
- gint dumpD = prefs_get_int_attribute_limited("options.scislac", #key"D", 0, 0, 1);\
- gint dumpD2 = prefs_get_int_attribute_limited("options.scislac", #key"D2", 0, 0, 1);\
- dumpD &= ( (update_in_progress == 0) || dumpD2 );\
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
+ bool dump = prefs->getBool("/options/scislac/" #key);\
+ bool dumpD = prefs->getBool("/options/scislac/" #key "D");\
+ bool dumpD2 = prefs->getBool("/options/scislac/" #key "D2");\
+ dumpD &&= ( (update_in_progress == 0) || dumpD2 );\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
@@ -1293,7 +1294,7 @@ sp_image_update_canvas_image (SPImage *image)
}
}
-static void sp_image_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_image_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
/* An image doesn't have any nodes to snap, but still we want to be able snap one image
to another. Therefore we will create some snappoints at the corner, similar to a rect. If
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 45410960c..d0338f369 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -34,7 +34,6 @@
#include "sp-item-transform.h"
#include "sp-root.h"
#include "sp-use.h"
-#include "prefs-utils.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-path.h"
@@ -69,7 +68,7 @@ static gchar * sp_group_description (SPItem * item);
static Geom::Matrix sp_group_set_transform(SPItem *item, Geom::Matrix const &xform);
static NRArenaItem *sp_group_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_group_hide (SPItem * item, unsigned int key);
-static void sp_group_snappoints (SPItem const *item, SnapPointsIter p);
+static void sp_group_snappoints (SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_group_update_patheffect(SPLPEItem *lpeitem, bool write);
static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup);
@@ -79,105 +78,105 @@ static SPLPEItemClass * parent_class;
GType
sp_group_get_type (void)
{
- static GType group_type = 0;
- if (!group_type) {
- GTypeInfo group_info = {
- sizeof (SPGroupClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) sp_group_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (SPGroup),
- 16, /* n_preallocs */
- (GInstanceInitFunc) sp_group_init,
- NULL, /* value_table */
- };
- group_type = g_type_register_static (SP_TYPE_LPE_ITEM, "SPGroup", &group_info, (GTypeFlags)0);
- }
- return group_type;
+ static GType group_type = 0;
+ if (!group_type) {
+ GTypeInfo group_info = {
+ sizeof (SPGroupClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) sp_group_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (SPGroup),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) sp_group_init,
+ NULL, /* value_table */
+ };
+ group_type = g_type_register_static (SP_TYPE_LPE_ITEM, "SPGroup", &group_info, (GTypeFlags)0);
+ }
+ return group_type;
}
static void
sp_group_class_init (SPGroupClass *klass)
{
- GObjectClass * object_class;
- SPObjectClass * sp_object_class;
- SPItemClass * item_class;
- SPLPEItemClass * lpe_item_class;
-
- object_class = (GObjectClass *) klass;
- sp_object_class = (SPObjectClass *) klass;
- item_class = (SPItemClass *) klass;
- lpe_item_class = (SPLPEItemClass *) klass;
-
- parent_class = (SPLPEItemClass *)g_type_class_ref (SP_TYPE_LPE_ITEM);
-
- object_class->dispose = sp_group_dispose;
-
- sp_object_class->child_added = sp_group_child_added;
- sp_object_class->remove_child = sp_group_remove_child;
- sp_object_class->order_changed = sp_group_order_changed;
- sp_object_class->update = sp_group_update;
- sp_object_class->modified = sp_group_modified;
- sp_object_class->set = sp_group_set;
- sp_object_class->write = sp_group_write;
- sp_object_class->release = sp_group_release;
- sp_object_class->build = sp_group_build;
-
- item_class->bbox = sp_group_bbox;
- item_class->print = sp_group_print;
- item_class->description = sp_group_description;
+ GObjectClass * object_class;
+ SPObjectClass * sp_object_class;
+ SPItemClass * item_class;
+ SPLPEItemClass * lpe_item_class;
+
+ object_class = (GObjectClass *) klass;
+ sp_object_class = (SPObjectClass *) klass;
+ item_class = (SPItemClass *) klass;
+ lpe_item_class = (SPLPEItemClass *) klass;
+
+ parent_class = (SPLPEItemClass *)g_type_class_ref (SP_TYPE_LPE_ITEM);
+
+ object_class->dispose = sp_group_dispose;
+
+ sp_object_class->child_added = sp_group_child_added;
+ sp_object_class->remove_child = sp_group_remove_child;
+ sp_object_class->order_changed = sp_group_order_changed;
+ sp_object_class->update = sp_group_update;
+ sp_object_class->modified = sp_group_modified;
+ sp_object_class->set = sp_group_set;
+ sp_object_class->write = sp_group_write;
+ sp_object_class->release = sp_group_release;
+ sp_object_class->build = sp_group_build;
+
+ item_class->bbox = sp_group_bbox;
+ item_class->print = sp_group_print;
+ item_class->description = sp_group_description;
item_class->set_transform = sp_group_set_transform;
- item_class->show = sp_group_show;
- item_class->hide = sp_group_hide;
- item_class->snappoints = sp_group_snappoints;
+ item_class->show = sp_group_show;
+ item_class->hide = sp_group_hide;
+ item_class->snappoints = sp_group_snappoints;
- lpe_item_class->update_patheffect = sp_group_update_patheffect;
+ lpe_item_class->update_patheffect = sp_group_update_patheffect;
}
static void
sp_group_init (SPGroup *group)
{
- group->_layer_mode = SPGroup::GROUP;
+ group->_layer_mode = SPGroup::GROUP;
group->group = new CGroup(group);
- new (&group->_display_modes) std::map<unsigned int, SPGroup::LayerMode>();
+ new (&group->_display_modes) std::map<unsigned int, SPGroup::LayerMode>();
}
static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
- sp_object_read_attr(object, "inkscape:groupmode");
+ sp_object_read_attr(object, "inkscape:groupmode");
- if (((SPObjectClass *)parent_class)->build) {
- ((SPObjectClass *)parent_class)->build(object, document, repr);
- }
+ if (((SPObjectClass *)parent_class)->build) {
+ ((SPObjectClass *)parent_class)->build(object, document, repr);
+ }
}
static void sp_group_release(SPObject *object) {
- if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) {
- sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "layer", object);
- }
- if (((SPObjectClass *)parent_class)->release) {
- ((SPObjectClass *)parent_class)->release(object);
- }
+ if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) {
+ sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "layer", object);
+ }
+ if (((SPObjectClass *)parent_class)->release) {
+ ((SPObjectClass *)parent_class)->release(object);
+ }
}
static void
sp_group_dispose(GObject *object)
{
- SP_GROUP(object)->_display_modes.~map();
+ SP_GROUP(object)->_display_modes.~map();
delete SP_GROUP(object)->group;
}
static void
sp_group_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
- SPItem *item;
+ SPItem *item;
- item = SP_ITEM (object);
+ item = SP_ITEM (object);
- if (((SPObjectClass *) (parent_class))->child_added)
- (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
+ if (((SPObjectClass *) (parent_class))->child_added)
+ (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
SP_GROUP(object)->group->onChildAdded(child);
}
@@ -187,8 +186,8 @@ sp_group_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XM
static void
sp_group_remove_child (SPObject * object, Inkscape::XML::Node * child)
{
- if (((SPObjectClass *) (parent_class))->remove_child)
- (* ((SPObjectClass *) (parent_class))->remove_child) (object, child);
+ if (((SPObjectClass *) (parent_class))->remove_child)
+ (* ((SPObjectClass *) (parent_class))->remove_child) (object, child);
SP_GROUP(object)->group->onChildRemoved(child);
}
@@ -196,8 +195,8 @@ sp_group_remove_child (SPObject * object, Inkscape::XML::Node * child)
static void
sp_group_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
{
- if (((SPObjectClass *) (parent_class))->order_changed)
- (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref);
+ if (((SPObjectClass *) (parent_class))->order_changed)
+ (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref);
SP_GROUP(object)->group->onOrderChanged(child, old_ref, new_ref);
}
@@ -309,22 +308,22 @@ sp_group_set_transform(SPItem *item, Geom::Matrix const &xform)
}
static void sp_group_set(SPObject *object, unsigned key, char const *value) {
- SPGroup *group = SP_GROUP(object);
-
- switch (key) {
- case SP_ATTR_INKSCAPE_GROUPMODE:
- if ( value && !strcmp(value, "layer") ) {
- group->setLayerMode(SPGroup::LAYER);
- } else {
- group->setLayerMode(SPGroup::GROUP);
- }
- break;
- default: {
- if (((SPObjectClass *) (parent_class))->set) {
- (* ((SPObjectClass *) (parent_class))->set)(object, key, value);
- }
- }
- }
+ SPGroup *group = SP_GROUP(object);
+
+ switch (key) {
+ case SP_ATTR_INKSCAPE_GROUPMODE:
+ if ( value && !strcmp(value, "layer") ) {
+ group->setLayerMode(SPGroup::LAYER);
+ } else {
+ group->setLayerMode(SPGroup::GROUP);
+ }
+ break;
+ default: {
+ if (((SPObjectClass *) (parent_class))->set) {
+ (* ((SPObjectClass *) (parent_class))->set)(object, key, value);
+ }
+ }
+ }
}
static NRArenaItem *
@@ -339,39 +338,39 @@ sp_group_hide (SPItem *item, unsigned int key)
SP_GROUP(item)->group->hide(key);
}
-static void sp_group_snappoints (SPItem const *item, SnapPointsIter p)
+static void sp_group_snappoints (SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
- for (SPObject const *o = sp_object_first_child(SP_OBJECT(item));
- o != NULL;
- o = SP_OBJECT_NEXT(o))
- {
- if (SP_IS_ITEM(o)) {
- sp_item_snappoints(SP_ITEM(o), false, p);
- }
- }
+ for (SPObject const *o = sp_object_first_child(SP_OBJECT(item));
+ o != NULL;
+ o = SP_OBJECT_NEXT(o))
+ {
+ if (SP_IS_ITEM(o)) {
+ sp_item_snappoints(SP_ITEM(o), p, snapprefs);
+ }
+ }
}
void
sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
{
- g_return_if_fail (group != NULL);
- g_return_if_fail (SP_IS_GROUP (group));
+ g_return_if_fail (group != NULL);
+ g_return_if_fail (SP_IS_GROUP (group));
- SPDocument *doc = SP_OBJECT_DOCUMENT (group);
- SPObject *root = SP_DOCUMENT_ROOT (doc);
- SPObject *defs = SP_OBJECT (SP_ROOT (root)->defs);
+ SPDocument *doc = SP_OBJECT_DOCUMENT (group);
+ SPObject *root = SP_DOCUMENT_ROOT (doc);
+ SPObject *defs = SP_OBJECT (SP_ROOT (root)->defs);
- SPItem *gitem = SP_ITEM (group);
- Inkscape::XML::Node *grepr = SP_OBJECT_REPR (gitem);
+ SPItem *gitem = SP_ITEM (group);
+ Inkscape::XML::Node *grepr = SP_OBJECT_REPR (gitem);
- g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch"));
+ g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch"));
// this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse
sp_item_adjust_paint_recursive (gitem, NR::identity(), NR::identity(), false);
- SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
- Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
+ SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
+ Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
if (SP_IS_BOX3D(gitem)) {
group = box3d_convert_to_group(SP_BOX3D(gitem));
@@ -380,122 +379,122 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(group), false);
- /* Step 1 - generate lists of children objects */
- GSList *items = NULL;
- GSList *objects = NULL;
- for (SPObject *child = sp_object_first_child(SP_OBJECT(group)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
-
- if (SP_IS_ITEM (child)) {
-
- SPItem *citem = SP_ITEM (child);
-
- /* Merging of style */
- // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
- // it here _before_ the new transform is set, so as to use the pre-transform bbox
- sp_item_adjust_paint_recursive (citem, NR::identity(), NR::identity(), false);
-
- sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem));
- /*
- * fixme: We currently make no allowance for the case where child is cloned
- * and the group has any style settings.
- *
- * (This should never occur with documents created solely with the current
- * version of inkscape without using the XML editor: we usually apply group
- * style changes to children rather than to the group itself.)
- *
- * If the group has no style settings, then
- * sp_style_merge_from_dying_parent should be a no-op. Otherwise (i.e. if
- * we change the child's style to compensate for its parent going away)
- * then those changes will typically be reflected in any clones of child,
- * whereas we'd prefer for Ungroup not to affect the visual appearance.
- *
- * The only way of preserving styling appearance in general is for child to
- * be put into a new group -- a somewhat surprising response to an Ungroup
- * command. We could add a new groupmode:transparent that would mostly
- * hide the existence of such groups from the user (i.e. editing behaves as
- * if the transparent group's children weren't in a group), though that's
- * extra complication & maintenance burden and this case is rare.
- */
-
- child->updateRepr();
-
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
-
- // Merging transform
- Geom::Matrix ctrans;
- Geom::Matrix const g(gitem->transform);
- if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) &&
- SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) {
- // make sure a clone's effective transform is the same as was under group
- ctrans = g.inverse() * citem->transform * g;
- } else {
- ctrans = citem->transform * g;
- }
-
- // FIXME: constructing a transform that would fully preserve the appearance of a
- // textpath if it is ungrouped with its path seems to be impossible in general
- // case. E.g. if the group was squeezed, to keep the ungrouped textpath squeezed
- // as well, we'll need to relink it to some "virtual" path which is inversely
- // stretched relative to the actual path, and then squeeze the textpath back so it
- // would both fit the actual path _and_ be squeezed as before. It's a bummer.
-
- // This is just a way to temporarily remember the transform in repr. When repr is
- // reattached outside of the group, the transform will be written more properly
- // (i.e. optimized into the object if the corresponding preference is set)
- gchar *affinestr=sp_svg_transform_write(ctrans);
- nrepr->setAttribute("transform", affinestr);
+ /* Step 1 - generate lists of children objects */
+ GSList *items = NULL;
+ GSList *objects = NULL;
+ for (SPObject *child = sp_object_first_child(SP_OBJECT(group)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+
+ if (SP_IS_ITEM (child)) {
+
+ SPItem *citem = SP_ITEM (child);
+
+ /* Merging of style */
+ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
+ // it here _before_ the new transform is set, so as to use the pre-transform bbox
+ sp_item_adjust_paint_recursive (citem, NR::identity(), NR::identity(), false);
+
+ sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem));
+ /*
+ * fixme: We currently make no allowance for the case where child is cloned
+ * and the group has any style settings.
+ *
+ * (This should never occur with documents created solely with the current
+ * version of inkscape without using the XML editor: we usually apply group
+ * style changes to children rather than to the group itself.)
+ *
+ * If the group has no style settings, then
+ * sp_style_merge_from_dying_parent should be a no-op. Otherwise (i.e. if
+ * we change the child's style to compensate for its parent going away)
+ * then those changes will typically be reflected in any clones of child,
+ * whereas we'd prefer for Ungroup not to affect the visual appearance.
+ *
+ * The only way of preserving styling appearance in general is for child to
+ * be put into a new group -- a somewhat surprising response to an Ungroup
+ * command. We could add a new groupmode:transparent that would mostly
+ * hide the existence of such groups from the user (i.e. editing behaves as
+ * if the transparent group's children weren't in a group), though that's
+ * extra complication & maintenance burden and this case is rare.
+ */
+
+ child->updateRepr();
+
+ Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
+
+ // Merging transform
+ Geom::Matrix ctrans;
+ Geom::Matrix const g(gitem->transform);
+ if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) &&
+ SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) {
+ // make sure a clone's effective transform is the same as was under group
+ ctrans = g.inverse() * citem->transform * g;
+ } else {
+ ctrans = citem->transform * g;
+ }
+
+ // FIXME: constructing a transform that would fully preserve the appearance of a
+ // textpath if it is ungrouped with its path seems to be impossible in general
+ // case. E.g. if the group was squeezed, to keep the ungrouped textpath squeezed
+ // as well, we'll need to relink it to some "virtual" path which is inversely
+ // stretched relative to the actual path, and then squeeze the textpath back so it
+ // would both fit the actual path _and_ be squeezed as before. It's a bummer.
+
+ // This is just a way to temporarily remember the transform in repr. When repr is
+ // reattached outside of the group, the transform will be written more properly
+ // (i.e. optimized into the object if the corresponding preference is set)
+ gchar *affinestr=sp_svg_transform_write(ctrans);
+ nrepr->setAttribute("transform", affinestr);
g_free(affinestr);
- items = g_slist_prepend (items, nrepr);
+ items = g_slist_prepend (items, nrepr);
- } else {
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
- objects = g_slist_prepend (objects, nrepr);
- }
- }
+ } else {
+ Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
+ objects = g_slist_prepend (objects, nrepr);
+ }
+ }
- /* Step 2 - clear group */
- // remember the position of the group
- gint pos = SP_OBJECT_REPR(group)->position();
+ /* Step 2 - clear group */
+ // remember the position of the group
+ gint pos = SP_OBJECT_REPR(group)->position();
- // the group is leaving forever, no heir, clones should take note; its children however are going to reemerge
- SP_OBJECT (group)->deleteObject(true, false);
+ // the group is leaving forever, no heir, clones should take note; its children however are going to reemerge
+ SP_OBJECT (group)->deleteObject(true, false);
- /* Step 3 - add nonitems */
- if (objects) {
- Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild();
- while (objects) {
+ /* Step 3 - add nonitems */
+ if (objects) {
+ Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild();
+ while (objects) {
Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data;
if (!sp_repr_is_meta_element(repr))
SP_OBJECT_REPR(defs)->addChild(repr, last_def);
Inkscape::GC::release(repr);
- objects = g_slist_remove (objects, objects->data);
- }
- }
-
- /* Step 4 - add items */
- while (items) {
- Inkscape::XML::Node *repr = (Inkscape::XML::Node *) items->data;
- // add item
+ objects = g_slist_remove (objects, objects->data);
+ }
+ }
+
+ /* Step 4 - add items */
+ while (items) {
+ Inkscape::XML::Node *repr = (Inkscape::XML::Node *) items->data;
+ // add item
prepr->appendChild(repr);
- // restore position; since the items list was prepended (i.e. reverse), we now add
- // all children at the same pos, which inverts the order once again
- repr->setPosition(pos > 0 ? pos : 0);
+ // restore position; since the items list was prepended (i.e. reverse), we now add
+ // all children at the same pos, which inverts the order once again
+ repr->setPosition(pos > 0 ? pos : 0);
- // fill in the children list if non-null
- SPItem *item = (SPItem *) doc->getObjectByRepr(repr);
+ // fill in the children list if non-null
+ SPItem *item = (SPItem *) doc->getObjectByRepr(repr);
- sp_item_write_transform(item, repr, item->transform, NULL, false);
+ sp_item_write_transform(item, repr, item->transform, NULL, false);
- Inkscape::GC::release(repr);
- if (children && SP_IS_ITEM (item))
- *children = g_slist_prepend (*children, item);
+ Inkscape::GC::release(repr);
+ if (children && SP_IS_ITEM (item))
+ *children = g_slist_prepend (*children, item);
- items = g_slist_remove (items, items->data);
- }
+ items = g_slist_remove (items, items->data);
+ }
- if (do_done)
- sp_document_done (doc, SP_VERB_NONE, _("Ungroup"));
+ if (do_done)
+ sp_document_done (doc, SP_VERB_NONE, _("Ungroup"));
}
/*
@@ -506,72 +505,72 @@ GSList *
sp_item_group_item_list (SPGroup * group)
{
GSList *s;
- SPObject *o;
+ SPObject *o;
- g_return_val_if_fail (group != NULL, NULL);
- g_return_val_if_fail (SP_IS_GROUP (group), NULL);
+ g_return_val_if_fail (group != NULL, NULL);
+ g_return_val_if_fail (SP_IS_GROUP (group), NULL);
- s = NULL;
+ s = NULL;
- for ( o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
- if (SP_IS_ITEM (o)) {
- s = g_slist_prepend (s, o);
- }
- }
+ for ( o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
+ if (SP_IS_ITEM (o)) {
+ s = g_slist_prepend (s, o);
+ }
+ }
- return g_slist_reverse (s);
+ return g_slist_reverse (s);
}
SPObject *
sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name)
{
- SPObject *child;
- child = (ref) ? SP_OBJECT_NEXT(ref) : sp_object_first_child(SP_OBJECT(group));
- while ( child && strcmp (SP_OBJECT_REPR(child)->name(), name) ) {
- child = SP_OBJECT_NEXT(child);
- }
- return child;
+ SPObject *child;
+ child = (ref) ? SP_OBJECT_NEXT(ref) : sp_object_first_child(SP_OBJECT(group));
+ while ( child && strcmp (SP_OBJECT_REPR(child)->name(), name) ) {
+ child = SP_OBJECT_NEXT(child);
+ }
+ return child;
}
void SPGroup::setLayerMode(LayerMode mode) {
- if ( _layer_mode != mode ) {
- if ( mode == LAYER ) {
- sp_document_add_resource(SP_OBJECT_DOCUMENT(this), "layer", this);
- } else {
- sp_document_remove_resource(SP_OBJECT_DOCUMENT(this), "layer", this);
- }
- _layer_mode = mode;
- _updateLayerMode();
- }
+ if ( _layer_mode != mode ) {
+ if ( mode == LAYER ) {
+ sp_document_add_resource(SP_OBJECT_DOCUMENT(this), "layer", this);
+ } else {
+ sp_document_remove_resource(SP_OBJECT_DOCUMENT(this), "layer", this);
+ }
+ _layer_mode = mode;
+ _updateLayerMode();
+ }
}
SPGroup::LayerMode SPGroup::layerDisplayMode(unsigned int dkey) const {
- std::map<unsigned int, LayerMode>::const_iterator iter;
- iter = _display_modes.find(dkey);
- if ( iter != _display_modes.end() ) {
- return (*iter).second;
- } else {
- return GROUP;
- }
+ std::map<unsigned int, LayerMode>::const_iterator iter;
+ iter = _display_modes.find(dkey);
+ if ( iter != _display_modes.end() ) {
+ return (*iter).second;
+ } else {
+ return GROUP;
+ }
}
void SPGroup::setLayerDisplayMode(unsigned int dkey, SPGroup::LayerMode mode) {
- if ( layerDisplayMode(dkey) != mode ) {
- _display_modes[dkey] = mode;
- _updateLayerMode(dkey);
- }
+ if ( layerDisplayMode(dkey) != mode ) {
+ _display_modes[dkey] = mode;
+ _updateLayerMode(dkey);
+ }
}
void SPGroup::_updateLayerMode(unsigned int display_key) {
- SPItemView *view;
- for ( view = this->display ; view ; view = view->next ) {
- if ( !display_key || view->key == display_key ) {
- NRArenaGroup *arena_group=NR_ARENA_GROUP(view->arenaitem);
- if (arena_group) {
- nr_arena_group_set_transparent(arena_group, effectiveLayerMode(view->key) == SPGroup::LAYER);
- }
- }
- }
+ SPItemView *view;
+ for ( view = this->display ; view ; view = view->next ) {
+ if ( !display_key || view->key == display_key ) {
+ NRArenaGroup *arena_group=NR_ARENA_GROUP(view->arenaitem);
+ if (arena_group) {
+ nr_arena_group_set_transparent(arena_group, effectiveLayerMode(view->key) == SPGroup::LAYER);
+ }
+ }
+ }
}
void SPGroup::translateChildItems(Geom::Translate const &tr)
@@ -654,7 +653,7 @@ void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
SPObject *object = SP_OBJECT(_group);
for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
}
}
@@ -685,7 +684,7 @@ void CGroup::onModified(guint flags) {
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
SPObject *object = SP_OBJECT(_group);
for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
}
}
@@ -832,7 +831,7 @@ sp_group_update_patheffect (SPLPEItem *lpeitem, bool write)
}
}
}
-
+
if (sp_lpe_item_has_path_effect(lpeitem) && sp_lpe_item_path_effects_enabled(lpeitem)) {
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); it++)
{
@@ -841,7 +840,7 @@ sp_group_update_patheffect (SPLPEItem *lpeitem, bool write)
lpeobj->get_lpe()->doBeforeEffect(lpeitem);
}
}
-
+
sp_group_perform_patheffect(SP_GROUP(lpeitem), SP_GROUP(lpeitem));
}
}
@@ -856,16 +855,19 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup)
sp_group_perform_patheffect(SP_GROUP(subitem), topgroup);
} else if (SP_IS_SHAPE(subitem)) {
SPCurve * c = sp_shape_get_curve(SP_SHAPE(subitem));
- sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
- sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
-
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
-
- gchar *str = sp_svg_write_path(c->get_pathvector());
- repr->setAttribute("d", str);
- g_free(str);
-
- c->unref();
+ // only run LPEs when the shape has a curve defined
+ if (c) {
+ sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
+ sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
+
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
+
+ gchar *str = sp_svg_write_path(c->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+
+ c->unref();
+ }
}
}
}
diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp
index a51674c3a..5cc169221 100644
--- a/src/sp-item-notify-moveto.cpp
+++ b/src/sp-item-notify-moveto.cpp
@@ -25,7 +25,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin
g_return_if_fail( dir_lensq != 0 );
std::vector<Geom::Point> snappoints;
- sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
+ sp_item_snappoints(&item, SnapPointsIter(snappoints), NULL);
g_return_if_fail( snappoint_ix < int(snappoints.size()) );
double const pos0 = dot(dir, snappoints[snappoint_ix]);
diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp
index d10e1d543..6d7ab2fda 100644
--- a/src/sp-item-rm-unsatisfied-cns.cpp
+++ b/src/sp-item-rm-unsatisfied-cns.cpp
@@ -15,7 +15,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item)
return;
}
std::vector<Geom::Point> snappoints;
- sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
+ sp_item_snappoints(&item, SnapPointsIter(snappoints), NULL);
for (unsigned i = item.constraints.size(); i--;) {
g_assert( i < item.constraints.size() );
SPGuideConstraint const &cn = item.constraints[i];
diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp
index 55846f4b7..f7329bd45 100644
--- a/src/sp-item-update-cns.cpp
+++ b/src/sp-item-update-cns.cpp
@@ -10,7 +10,7 @@ using std::vector;
void sp_item_update_cns(SPItem &item, SPDesktop const &desktop)
{
std::vector<Geom::Point> snappoints;
- sp_item_snappoints(&item, true, SnapPointsIter(snappoints));
+ sp_item_snappoints(&item, SnapPointsIter(snappoints), NULL);
/* TODO: Implement the ordering. */
vector<SPGuideConstraint> found_cns;
satisfied_guide_cns(desktop, snappoints, found_cns);
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index c993a6163..99f543328 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -49,7 +49,7 @@
#include "sp-pattern.h"
#include "sp-switch.h"
#include "gradient-chemistry.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "conn-avoid-ref.h"
#include "conditions.h"
#include "sp-filter-reference.h"
@@ -90,7 +90,7 @@ static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags);
static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static gchar *sp_item_private_description(SPItem *item);
-static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem);
static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view);
@@ -721,6 +721,10 @@ sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape
return repr;
}
+/**
+ * \return There is no guarantee that the return value will contain a rectangle.
+ If this item does not have a boundingbox, it might well be empty.
+ */
boost::optional<Geom::Rect> SPItem::getBounds(Geom::Matrix const &transform,
SPItem::BBoxType type,
unsigned int /*dkey*/) const
@@ -746,7 +750,10 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transf
/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
* unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the
* transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups,
- * clones), in turn, call this function in their bbox methods. */
+ * clones), in turn, call this function in their bbox methods.
+ * \retval bbox Note that there is no guarantee that bbox will contain a rectangle when the
+ * function returns. If this item does not have a boundingbox, this might well be empty.
+ */
void
sp_item_invoke_bbox_full(SPItem const *item, boost::optional<Geom::Rect> &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear)
{
@@ -931,7 +938,7 @@ boost::optional<Geom::Rect> sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType
return rect;
}
-static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
/* This will only be called if the derived class doesn't override this.
* see for example sp_genericellipse_snappoints in sp-ellipse.cpp
@@ -952,7 +959,7 @@ static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p)
}
-void sp_item_snappoints(SPItem const *item, bool includeItemCenter, SnapPointsIter p)
+void sp_item_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
g_assert (item != NULL);
g_assert (SP_IS_ITEM(item));
@@ -960,11 +967,11 @@ void sp_item_snappoints(SPItem const *item, bool includeItemCenter, SnapPointsIt
// Get the snappoints of the item
SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item);
if (item_class.snappoints) {
- item_class.snappoints(item, p);
+ item_class.snappoints(item, p, snapprefs);
}
// Get the snappoints at the item's center
- if (includeItemCenter) {
+ if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) {
*p = item->getCenter();
}
@@ -981,7 +988,7 @@ void sp_item_snappoints(SPItem const *item, bool includeItemCenter, SnapPointsIt
if (SP_IS_ITEM(child)) {
std::vector<Geom::Point> p_clip_or_mask;
// Please note the recursive call here!
- sp_item_snappoints(SP_ITEM(child), includeItemCenter, SnapPointsIter(p_clip_or_mask));
+ sp_item_snappoints(SP_ITEM(child), SnapPointsIter(p_clip_or_mask), snapprefs);
// Take into account the transformation of the item being clipped or masked
for (std::vector<Geom::Point>::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); p_orig++) {
// All snappoints are in desktop coordinates, but the item's transformation is
@@ -1409,26 +1416,27 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co
advertized_transform = sp_item_transform_repr (item).inverse() * transform;
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (compensate) {
// recursively compensate for stroke scaling, depending on user preference
- if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) {
+ if (!prefs->getBool("/options/transform/stroke", true)) {
double const expansion = 1. / advertized_transform.descrim();
sp_item_adjust_stroke_width_recursive(item, expansion);
}
// recursively compensate rx/ry of a rect if requested
- if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) {
+ if (!prefs->getBool("/options/transform/rectcorners", true)) {
sp_item_adjust_rects_recursive(item, advertized_transform);
}
// recursively compensate pattern fill if it's not to be transformed
- if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) {
+ if (!prefs->getBool("/options/transform/pattern", true)) {
sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), true);
}
/// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well
/// recursively compensate gradient fill if it's not to be transformed
- if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) {
+ if (!prefs->getBool("/options/transform/gradient", true)) {
sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), false);
} else {
// this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
@@ -1438,7 +1446,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co
} // endif(compensate)
- gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0);
+ gint preserve = prefs->getBool("/options/preservetransform/value", 0);
Geom::Matrix transform_attr (transform);
if ( // run the object's set_transform (i.e. embed transform) only if:
((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method
@@ -1727,7 +1735,8 @@ sp_item_convert_to_guides(SPItem *item) {
SPNamedView *nv = sp_desktop_namedview(dt);
(void)nv;
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
diff --git a/src/sp-item.h b/src/sp-item.h
index a900c4b87..cd0a376bb 100644
--- a/src/sp-item.h
+++ b/src/sp-item.h
@@ -25,6 +25,7 @@
#include <libnr/nr-rect.h>
#include <2geom/forward.h>
#include <libnr/nr-convert2geom.h>
+#include <snap-preferences.h>
class SPGuideConstraint;
struct SPClipPathReference;
@@ -195,7 +196,7 @@ struct SPItemClass {
/** Write to an iterator the points that should be considered for snapping
* as the item's `nodes'.
*/
- void (* snappoints) (SPItem const *item, SnapPointsIter p);
+ void (* snappoints) (SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
/** Apply the transform optimally, and return any residual transformation */
Geom::Matrix (* set_transform)(SPItem *item, Geom::Matrix const &transform);
@@ -228,7 +229,7 @@ unsigned int sp_item_display_key_new(unsigned int numkeys);
NRArenaItem *sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
void sp_item_invoke_hide(SPItem *item, unsigned int key);
-void sp_item_snappoints(SPItem const *item, bool includeItemCenter, SnapPointsIter p);
+void sp_item_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
void sp_item_adjust_pattern(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false);
void sp_item_adjust_gradient(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false);
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index 5ab9e27d6..0fe02e01d 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -309,11 +309,17 @@ void sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
{
LivePathEffectObject *lpeobj = (*it)->lpeobject;
if (!lpeobj) {
+ /** \todo Investigate the cause of this.
+ * For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found.
+ */
g_warning("sp_lpe_item_perform_path_effect - NULL lpeobj in list!");
return;
}
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
if (!lpe) {
+ /** \todo Investigate the cause of this.
+ * Not sure, but I think this can happen when an unknown effect type is specified...
+ */
g_warning("sp_lpe_item_perform_path_effect - lpeobj without lpe!");
return;
}
@@ -335,8 +341,10 @@ void sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
}
catch (std::exception & e) {
g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what());
- SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
- _("An exception occurred during execution of the Path Effect.") );
+ if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
+ _("An exception occurred during execution of the Path Effect.") );
+ }
}
}
}
@@ -362,11 +370,13 @@ sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write)
PathEffectList lpelist = sp_lpe_item_get_effect_list(lpeitem);
std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
for (i = lpelist.begin(); i != lpelist.end(); ++i) {
- Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->get_lpe();
- if (dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)) {
- if (!lpe->isVisible()) {
- // we manually disable text for LPEPathLength
- dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)->hideCanvasText();
+ if ((*i)->lpeobject) {
+ Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->get_lpe();
+ if (dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)) {
+ if (!lpe->isVisible()) {
+ // we manually disable text for LPEPathLength
+ dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)->hideCanvasText();
+ }
}
}
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 006e3a140..a73c178c7 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -30,7 +30,7 @@
#include "sp-guide.h"
#include "sp-item-group.h"
#include "sp-namedview.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop.h"
#include "conn-avoid-ref.h" // for defaultConnSpacing.
@@ -251,6 +251,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
sp_object_read_attr(object, "inkscape:snap-nodes");
sp_object_read_attr(object, "inkscape:snap-guide");
sp_object_read_attr(object, "inkscape:snap-center");
+ sp_object_read_attr(object, "inkscape:snap-smooth-nodes");
sp_object_read_attr(object, "inkscape:snap-intersection-grid-guide");
sp_object_read_attr(object, "inkscape:snap-intersection-paths");
sp_object_read_attr(object, "inkscape:object-paths");
@@ -454,7 +455,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
- nv->snap_manager.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE);
+ nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_INDICATOR:
@@ -462,27 +463,31 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_BBOX:
- nv->snap_manager.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_NODES:
- nv->snap_manager.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE);
+ nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_CENTER:
- nv->snap_manager.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.snapprefs.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
+ case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES:
+ nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
case SP_ATTR_INKSCAPE_SNAP_GUIDE:
- nv->snap_manager.setSnapModeGuide(value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE:
- nv->snap_manager.setSnapIntersectionGG(value ? sp_str_to_bool(value) : TRUE);
+ nv->snap_manager.snapprefs.setSnapIntersectionGG(value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS:
- nv->snap_manager.setSnapIntersectionCS(value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.snapprefs.setSnapIntersectionCS(value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_OBJECT_PATHS:
@@ -582,22 +587,12 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des
if (!grid) {
//create grid object
Inkscape::GridType gridtype = Inkscape::CanvasGrid::getGridTypeFromSVGName(repr->attribute("type"));
- SPDocument *doc = NULL;
- if (desktop)
- doc = sp_desktop_document(desktop);
- else
- doc = sp_desktop_document(static_cast<SPDesktop*>(nv->views->data));
- if (!doc) {
+ if (!nv->document) {
g_warning("sp_namedview_add_grid - how come doc is null here?!");
return NULL;
}
- grid = Inkscape::CanvasGrid::NewGrid(nv, repr, doc, gridtype);
+ grid = Inkscape::CanvasGrid::NewGrid(nv, repr, nv->document, gridtype);
nv->grids = g_slist_append(nv->grids, grid);
- //Initialize the snapping parameters for the new grid
- bool enabled_node = nv->snap_manager.getSnapModeNode();
- bool enabled_bbox = nv->snap_manager.getSnapModeBBox();
- grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled_node);
- grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled_bbox);
}
if (!desktop) {
@@ -742,8 +737,8 @@ void SPNamedView::show(SPDesktop *desktop)
void sp_namedview_window_from_document(SPDesktop *desktop)
{
SPNamedView *nv = desktop->namedview;
- gint geometry_from_file =
- (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool geometry_from_file = prefs->getBool("/options/savewindowgeometry/value");
// restore window size and position stored with the document
if (geometry_from_file) {
@@ -810,8 +805,8 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
void sp_namedview_document_from_window(SPDesktop *desktop)
{
- gint save_geometry_in_file =
- (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0);
Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview);
Geom::Rect const r = desktop->get_display_area();
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 877bc6823..c91b0ad0d 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -31,7 +31,7 @@
#include "livarot/Shape.h"
#include "enums.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-text.h"
#include "sp-offset.h"
#include "sp-use-reference.h"
@@ -83,7 +83,7 @@ static void sp_offset_update (SPObject * object, SPCtx * ctx, guint flags);
static void sp_offset_release (SPObject * object);
static gchar *sp_offset_description (SPItem * item);
-static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_offset_set_shape (SPShape * shape);
static void refresh_offset_source(SPOffset* offset);
@@ -241,7 +241,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
gchar const *oldA = object->repr->attribute("inkscape:href");
if (oldA) {
size_t lA = strlen(oldA);
- char *nA=(char*)malloc((lA+1)*sizeof(char));
+ char *nA=(char*)malloc((1+lA+1)*sizeof(char));
memcpy(nA+1,oldA,lA*sizeof(char));
nA[0]='#';
nA[lA+1]=0;
@@ -718,10 +718,10 @@ sp_offset_set_shape(SPShape *shape)
/**
* Virtual snappoints function.
*/
-static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
if (((SPItemClass *) parent_class)->snappoints) {
- ((SPItemClass *) parent_class)->snappoints (item, p);
+ ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs);
}
}
@@ -885,7 +885,7 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
}
while (cb >= 0 && pb >= 0 && pb != fb);
}
- }
+ }
}
// loop over the edges to try to improve the distance
for (int i = 0; i < theRes->numberOfEdges(); i++)
@@ -895,7 +895,7 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
NR::Point nx = ex - sx;
double len = sqrt (dot(nx,nx));
if (len > 0.0001)
- {
+ {
NR::Point pxsx=px-sx;
double ab = dot(nx,pxsx);
if (ab > 0 && ab < len * len)
@@ -908,7 +908,7 @@ sp_offset_distance_to_original (SPOffset * offset, NR::Point px)
arSet = true;
}
}
- }
+ }
}
if (arSet || ptSet)
{
@@ -1023,7 +1023,8 @@ sp_offset_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPOffset *offse
static void
sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset *self)
{
- guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL);
if (mode == SP_CLONE_COMPENSATION_NONE) return;
Geom::Matrix m(*mp);
@@ -1055,7 +1056,8 @@ sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset
static void
sp_offset_delete_self(SPObject */*deleted*/, SPOffset *offset)
{
- guint const mode = prefs_get_int_attribute("options.cloneorphans", "value", SP_CLONE_ORPHANS_UNLINK);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint const mode = prefs->getInt("/options/cloneorphans/value", SP_CLONE_ORPHANS_UNLINK);
if (mode == SP_CLONE_ORPHANS_UNLINK) {
// leave it be. just forget about the source
diff --git a/src/sp-offset.h b/src/sp-offset.h
index 1ccffd0ff..0e1a9d4e5 100644
--- a/src/sp-offset.h
+++ b/src/sp-offset.h
@@ -4,7 +4,7 @@
/** \file
* SPOffset class.
*
- * Authors:
+ * Authors:
* Mitsuru Oka <oka326@parkcity.ne.jp>
* Lauris Kaplinski <lauris@kaplinski.com>
* (of the sp-spiral.h upon which this file was created)
@@ -31,52 +31,52 @@ class SPUseReference;
/**
* SPOffset class.
*
- * An offset is defined by curve and radius. The original curve is kept as
- * a path in a sodipodi:original attribute. It's not possible to change
+ * An offset is defined by curve and radius. The original curve is kept as
+ * a path in a sodipodi:original attribute. It's not possible to change
* the original curve.
*
* SPOffset is a derivative of SPShape, much like the SPSpiral or SPRect.
- * The goal is to have a source shape (= originalPath), an offset (= radius)
- * and compute the offset of the source by the radius. To get it to work,
- * one needs to know what the source is and what the radius is, and how it's
- * stored in the xml representation. The object itself is a "path" element,
- * to get lots of shape functionality for free. The source is the easy part:
- * it's stored in a "inkscape:original" attribute in the path. In case of
+ * The goal is to have a source shape (= originalPath), an offset (= radius)
+ * and compute the offset of the source by the radius. To get it to work,
+ * one needs to know what the source is and what the radius is, and how it's
+ * stored in the xml representation. The object itself is a "path" element,
+ * to get lots of shape functionality for free. The source is the easy part:
+ * it's stored in a "inkscape:original" attribute in the path. In case of
* "linked" offset, as they've been dubbed, there is an additional
- * "inkscape:href" that contains the id of an element of the svg.
- * When built, the object will attach a listener vector to that object and
- * rebuild the "inkscape:original" whenever the href'd object changes. This
- * is of course grossly inefficient, and also does not react to changes
- * to the href'd during context stuff (like changing the shape of a star by
- * dragging control points) unless the path of that object is changed during
- * the context (seems to be the case for SPEllipse). The computation of the
- * offset is done in sp_offset_set_shape(), a function that is called whenever
+ * "inkscape:href" that contains the id of an element of the svg.
+ * When built, the object will attach a listener vector to that object and
+ * rebuild the "inkscape:original" whenever the href'd object changes. This
+ * is of course grossly inefficient, and also does not react to changes
+ * to the href'd during context stuff (like changing the shape of a star by
+ * dragging control points) unless the path of that object is changed during
+ * the context (seems to be the case for SPEllipse). The computation of the
+ * offset is done in sp_offset_set_shape(), a function that is called whenever
* a change occurs to the offset (change of source or change of radius).
- * just like the sp-star and other, this path derivative can make control
- * points, or more precisely one control point, that's enough to define the
+ * just like the sp-star and other, this path derivative can make control
+ * points, or more precisely one control point, that's enough to define the
* radius (look in object-edit).
*/
struct SPOffset : public SPShape {
- void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker
- char *original; ///< SVG description of the source path
- float rad; ///< offset radius
-
- /// for interactive setting of the radius
- bool knotSet;
- NR::Point knot;
-
- bool sourceDirty;
- bool isUpdating;
-
- gchar *sourceHref;
- SPUseReference *sourceRef;
- Inkscape::XML::Node *sourceRepr; ///< the repr associated with that id
- SPObject *sourceObject;
-
- sigc::connection _modified_connection;
- sigc::connection _delete_connection;
- sigc::connection _changed_connection;
- sigc::connection _transformed_connection;
+ void *originalPath; ///< will be a livarot Path, just don't declare it here to please the gcc linker
+ char *original; ///< SVG description of the source path
+ float rad; ///< offset radius
+
+ /// for interactive setting of the radius
+ bool knotSet;
+ NR::Point knot;
+
+ bool sourceDirty;
+ bool isUpdating;
+
+ gchar *sourceHref;
+ SPUseReference *sourceRef;
+ Inkscape::XML::Node *sourceRepr; ///< the repr associated with that id
+ SPObject *sourceObject;
+
+ sigc::connection _modified_connection;
+ sigc::connection _delete_connection;
+ sigc::connection _changed_connection;
+ sigc::connection _transformed_connection;
};
/// The SPOffset vtable.
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 16e3bec40..404612be3 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -42,7 +42,6 @@
#include "inkscape.h"
#include "style.h"
#include "message-stack.h"
-#include "prefs-utils.h"
#include "selection.h"
#define noPATH_VERBOSE
@@ -383,34 +382,34 @@ sp_path_set_transform(SPItem *item, Geom::Matrix const &xform)
return Geom::identity();
}
+
static void
sp_path_update_patheffect(SPLPEItem *lpeitem, bool write)
{
SPShape * const shape = (SPShape *) lpeitem;
SPPath * const path = (SPPath *) lpeitem;
- if (sp_lpe_item_has_path_effect(lpeitem) && sp_lpe_item_path_effects_enabled(lpeitem)) {
- if (path->original_curve) {
- SPCurve *curve = path->original_curve->copy();
- sp_shape_set_curve_insync(shape, curve, TRUE);
- sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
- SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- curve->unref();
-
- if (write) {
- // could also do SP_OBJECT(shape)->updateRepr(); but only the d attribute needs updating.
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
- if ( shape->curve != NULL ) {
- gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
- repr->setAttribute("d", str);
- g_free(str);
- } else {
- repr->setAttribute("d", NULL);
- }
+ if (path->original_curve) {
+ // if a path does not have an lpeitem applied, then reset the curve to the original_curve.
+ // This is very important for LPEs on groups to work properly!
+ SPCurve *curve = path->original_curve->copy();
+ sp_shape_set_curve_insync(shape, curve, TRUE);
+ sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
+ SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); // this might be optimized in future for the case when this path is in a group with lpe applied (and will therefore have its curve change again when the group LPE is applied)
+ curve->unref();
+
+ if (write) {
+ // could also do SP_OBJECT(shape)->updateRepr(); but only the d attribute needs updating.
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
+ if ( shape->curve != NULL ) {
+ gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+ } else {
+ repr->setAttribute("d", NULL);
}
}
}
- // else: do nothing.
}
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 36e64614e..ab0ea3d72 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -30,7 +30,7 @@
#include <glibmm/i18n.h>
#include "xml/repr.h"
#include "sp-guide.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#define noRECT_VERBOSE
@@ -47,7 +47,7 @@ static Geom::Matrix sp_rect_set_transform(SPItem *item, Geom::Matrix const &xfor
static void sp_rect_convert_to_guides(SPItem *item);
static void sp_rect_set_shape(SPShape *shape);
-static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static SPShapeClass *parent_class;
@@ -546,7 +546,7 @@ sp_rect_get_visible_height(SPRect *rect)
/**
* Sets the snappoint p to the unrounded corners of the rectangle
*/
-static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
/* This method overrides sp_shape_snappoints, which is the default for any shape. The default method
returns all eight points along the path of a rounded rectangle, but not the real corners. Snapping
@@ -572,7 +572,8 @@ void
sp_rect_convert_to_guides(SPItem *item) {
SPRect *rect = SP_RECT(item);
- if (prefs_get_int_attribute("tools.shapes.rect", "convertguides", 1) == 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) {
sp_item_convert_to_guides(SP_ITEM(rect));
return;
}
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index bdffd821c..fb3bb9e6a 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -37,7 +37,7 @@
#include "style.h"
#include "marker.h"
#include "sp-path.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "attributes.h"
#include "live_effects/lpeobject.h"
@@ -67,7 +67,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
void sp_shape_print (SPItem * item, SPPrintContext * ctx);
static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_shape_hide (SPItem *item, unsigned int key);
-static void sp_shape_snappoints (SPItem const *item, SnapPointsIter p);
+static void sp_shape_snappoints (SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai);
@@ -251,7 +251,6 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
* that the appropriate marker objects are present (or absent) to
* match the style.
*/
- /* TODO: It would be nice if this could be done at an earlier level */
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
sp_shape_set_marker (object, i, object->style->marker[i].value);
}
@@ -287,7 +286,6 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
if (sp_shape_has_markers (shape)) {
/* Dimension marker views */
for (SPItemView *v = item->display; v != NULL; v = v->next) {
-
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
if (shape->marker[i]) {
sp_marker_show_dimension ((SPMarker *) shape->marker[i],
@@ -477,7 +475,6 @@ sp_shape_modified (SPObject *object, unsigned int flags)
static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPShape const *shape = SP_SHAPE (item);
-
if (shape->curve) {
NRRect cbbox;
@@ -612,7 +609,8 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
if (!shape->curve) return;
- gint add_comments = prefs_get_int_attribute_limited ("printing.debug", "add-label-comments", 0, 0, 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint add_comments = prefs->getBool("/printing/debug/add-label-comments");
if (add_comments) {
gchar * comment = g_strdup_printf("begin '%s'",
SP_OBJECT(item)->defaultLabel());
@@ -731,39 +729,47 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
static NRArenaItem *
sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/)
{
- SPObject *object = SP_OBJECT(item);
- SPShape *shape = SP_SHAPE(item);
+ SPObject *object = SP_OBJECT(item);
+ SPShape *shape = SP_SHAPE(item);
+
+ NRArenaItem *arenaitem = NRArenaShape::create(arena);
+ NRArenaShape * const s = NR_ARENA_SHAPE(arenaitem);
+ nr_arena_shape_set_style(s, object->style);
+ nr_arena_shape_set_path(s, shape->curve, false);
+ boost::optional<Geom::Rect> paintbox = item->getBounds(Geom::identity());
+ if (paintbox) {
+ s->setPaintBox(*paintbox);
+ }
- NRArenaItem *arenaitem = NRArenaShape::create(arena);
- NRArenaShape * const s = NR_ARENA_SHAPE(arenaitem);
- nr_arena_shape_set_style(s, object->style);
- nr_arena_shape_set_path(s, shape->curve, false);
- boost::optional<Geom::Rect> paintbox = item->getBounds(Geom::identity());
- if (paintbox) {
- s->setPaintBox(*paintbox);
- }
+ /* This stanza checks that an object's marker style agrees with
+ * the marker objects it has allocated. sp_shape_set_marker ensures
+ * that the appropriate marker objects are present (or absent) to
+ * match the style.
+ */
+ for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
+ sp_shape_set_marker (object, i, object->style->marker[i].value);
+ }
- if (sp_shape_has_markers (shape)) {
+ if (sp_shape_has_markers (shape)) {
- /* Dimension the marker views */
- if (!arenaitem->key) {
- NR_ARENA_ITEM_SET_KEY (arenaitem, sp_item_display_key_new (SP_MARKER_LOC_QTY));
- }
+ /* provide key and dimension the marker views */
+ if (!arenaitem->key) {
+ NR_ARENA_ITEM_SET_KEY (arenaitem, sp_item_display_key_new (SP_MARKER_LOC_QTY));
+ }
- for (int i = 0; i < SP_MARKER_LOC_QTY; i++) {
- if (shape->marker[i]) {
- sp_marker_show_dimension ((SPMarker *) shape->marker[i],
- NR_ARENA_ITEM_GET_KEY (arenaitem) + i - SP_MARKER_LOC,
- sp_shape_number_of_markers (shape, i));
- }
+ for (int i = 0; i < SP_MARKER_LOC_QTY; i++) {
+ if (shape->marker[i]) {
+ sp_marker_show_dimension ((SPMarker *) shape->marker[i],
+ NR_ARENA_ITEM_GET_KEY (arenaitem) + i - SP_MARKER_LOC,
+ sp_shape_number_of_markers (shape, i));
}
+ }
+ /* Update marker views */
+ sp_shape_update_marker_view (shape, arenaitem);
+ }
- /* Update marker views */
- sp_shape_update_marker_view (shape, arenaitem);
- }
-
- return arenaitem;
+ return arenaitem;
}
/**
@@ -1019,7 +1025,7 @@ sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner)
/**
* Return all nodes in a path that are to be considered for snapping
*/
-static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
g_assert(item != NULL);
g_assert(SP_IS_SHAPE(item));
@@ -1050,14 +1056,11 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p)
Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2);
- // Only add cusp nodes. TODO: Shouldn't this be a preference instead?
- if (nodetype == Geom::NODE_NONE) {
+ // Depending on the snapping preferences, either add only cusp nodes, or add add both cusp and smooths nodes
+ if (snapprefs->getSnapSmoothNodes() || nodetype == Geom::NODE_NONE || nodetype == Geom::NODE_CUSP) {
*p = from_2geom(curve_it1->finalPoint() * i2d);
}
- if (nodetype == Geom::NODE_CUSP) {
- *p = from_2geom(curve_it1->finalPoint() * i2d);
- }
-
+
++curve_it1;
++curve_it2;
}
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 7b741a940..9a3708d4b 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -36,7 +36,7 @@ static void sp_spiral_set (SPObject *object, unsigned int key, const gchar *valu
static void sp_spiral_update (SPObject *object, SPCtx *ctx, guint flags);
static gchar * sp_spiral_description (SPItem * item);
-static void sp_spiral_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_spiral_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_spiral_set_shape (SPShape *shape);
static void sp_spiral_update_patheffect (SPLPEItem *lpeitem, bool write);
@@ -494,10 +494,10 @@ sp_spiral_position_set (SPSpiral *spiral,
/**
* Virtual snappoints callback.
*/
-static void sp_spiral_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_spiral_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
if (((SPItemClass *) parent_class)->snappoints) {
- ((SPItemClass *) parent_class)->snappoints (item, p);
+ ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs);
}
}
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index d86e3de48..f5649e19f 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -39,7 +39,7 @@ static void sp_star_set (SPObject *object, unsigned int key, const gchar *value)
static void sp_star_update (SPObject *object, SPCtx *ctx, guint flags);
static gchar * sp_star_description (SPItem * item);
-static void sp_star_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_star_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_star_set_shape (SPShape *shape);
static void sp_star_update_patheffect (SPLPEItem *lpeitem, bool write);
@@ -520,10 +520,10 @@ sp_star_position_set (SPStar *star, gint sides, NR::Point center, gdouble r1, gd
/* fixme: We should use all corners of star (Lauris) */
-static void sp_star_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_star_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
if (((SPItemClass *) parent_class)->snappoints) {
- ((SPItemClass *) parent_class)->snappoints (item, p);
+ ((SPItemClass *) parent_class)->snappoints (item, p, snapprefs);
}
}
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index dd57428ef..eae9dd088 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -74,7 +74,7 @@ static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &t
static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags);
static void sp_text_hide (SPItem *item, unsigned key);
static char *sp_text_description (SPItem *item);
-static void sp_text_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_text_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static Geom::Matrix sp_text_set_transform(SPItem *item, Geom::Matrix const &xform);
static void sp_text_print (SPItem *item, SPPrintContext *gpc);
@@ -428,7 +428,7 @@ sp_text_description(SPItem *item)
return ret;
}
-static void sp_text_snappoints(SPItem const *item, SnapPointsIter p)
+static void sp_text_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
// the baseline anchor of the first char
Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item);
diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp
index 347a82427..b2188c0d5 100644
--- a/src/sp-use-reference.cpp
+++ b/src/sp-use-reference.cpp
@@ -16,7 +16,7 @@
#include "display/curve.h"
#include "livarot/Path.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-shape.h"
#include "sp-text.h"
#include "uri.h"
@@ -141,7 +141,8 @@ sp_usepath_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUsePath *off
static void
sp_usepath_move_compensate(Geom::Matrix const *mp, SPItem *original, SPUsePath *self)
{
- guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL);
if (mode == SP_CLONE_COMPENSATION_NONE) {
return;
}
@@ -183,7 +184,8 @@ sp_usepath_move_compensate(Geom::Matrix const *mp, SPItem *original, SPUsePath *
static void
sp_usepath_delete_self(SPObject */*deleted*/, SPUsePath *offset)
{
- guint const mode = prefs_get_int_attribute("options.cloneorphans", "value", SP_CLONE_ORPHANS_UNLINK);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint const mode = prefs->getInt("/options/cloneorphans/value", SP_CLONE_ORPHANS_UNLINK);
if (mode == SP_CLONE_ORPHANS_UNLINK) {
// leave it be. just forget about the source
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 12066f925..91b90502a 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -32,7 +32,7 @@
#include "uri.h"
#include "print.h"
#include "xml/repr.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "style.h"
#include "sp-symbol.h"
#include "sp-use.h"
@@ -52,7 +52,7 @@ static void sp_use_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_use_modified(SPObject *object, guint flags);
static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
-static void sp_use_snappoints(SPItem const *item, SnapPointsIter p);
+static void sp_use_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
static void sp_use_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_use_description(SPItem *item);
static NRArenaItem *sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags);
@@ -471,7 +471,8 @@ sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self
return;
}
- guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL);
// user wants no compensation
if (mode == SP_CLONE_COMPENSATION_NONE)
return;
@@ -556,7 +557,8 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self)
return;
}
- guint const mode = prefs_get_int_attribute("options.cloneorphans", "value",
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ guint const mode = prefs->getInt("/options/cloneorphans/value",
SP_CLONE_ORPHANS_UNLINK);
if (mode == SP_CLONE_ORPHANS_UNLINK) {
@@ -739,7 +741,7 @@ sp_use_get_original(SPUse *use)
}
static void
-sp_use_snappoints(SPItem const *item, SnapPointsIter p)
+sp_use_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
g_assert (item != NULL);
g_assert (SP_IS_ITEM(item));
@@ -751,7 +753,7 @@ sp_use_snappoints(SPItem const *item, SnapPointsIter p)
SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(root);
if (item_class.snappoints) {
- item_class.snappoints(root, p);
+ item_class.snappoints(root, p, snapprefs);
}
}
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index 1e341e3d1..57ff80209 100644
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
@@ -39,14 +39,14 @@
#include "object-edit.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "context-fns.h"
static void sp_spiral_context_class_init(SPSpiralContextClass * klass);
static void sp_spiral_context_init(SPSpiralContext *spiral_context);
static void sp_spiral_context_dispose(GObject *object);
static void sp_spiral_context_setup(SPEventContext *ec);
-static void sp_spiral_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_spiral_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event);
@@ -217,11 +217,11 @@ sp_spiral_context_setup(SPEventContext *ec)
sc->sel_changed_connection.disconnect();
sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_spiral_context_selection_changed), (gpointer)sc));
- if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/shapes/selcue")) {
ec->enableSelectionCue();
}
-
- if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
ec->enableGrDrag();
}
@@ -229,19 +229,17 @@ sp_spiral_context_setup(SPEventContext *ec)
}
static void
-sp_spiral_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_spiral_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPSpiralContext *sc = SP_SPIRAL_CONTEXT(ec);
-
- if (!strcmp(key, "expansion")) {
- sc->exp = (val) ? g_ascii_strtod(val, NULL) : 1.0;
- sc->exp = CLAMP(sc->exp, 0.0, 1000.0);
- } else if (!strcmp(key, "revolution")) {
- sc->revo = (val) ? g_ascii_strtod(val, NULL) : 3.0;
- sc->revo = CLAMP(sc->revo, 0.05, 40.0);
- } else if (!strcmp(key, "t0")) {
- sc->t0 = (val) ? g_ascii_strtod(val, NULL) : 0.0;
- sc->t0 = CLAMP(sc->t0, 0.0, 0.999);
+ Glib::ustring name = val->getEntryName();
+
+ if (name == "expansion") {
+ sc->exp = CLAMP(val->getDouble(), 0.0, 1000.0);
+ } else if (name == "revolution") {
+ sc->revo = CLAMP(val->getDouble(3.0), 0.05, 40.0);
+ } else if (name == "t0") {
+ sc->t0 = CLAMP(val->getDouble(), 0.0, 0.999);
}
}
@@ -254,7 +252,8 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
Inkscape::Selection *selection = sp_desktop_selection (desktop);
SPSpiralContext *sc = SP_SPIRAL_CONTEXT(event_context);
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
@@ -268,7 +267,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
Geom::Point pt2g = to_2geom(sc->center);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
sc->center = from_2geom(pt2g);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -299,7 +298,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, sc->item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt);
sp_spiral_drag(sc, from_2geom(motion_dt), event->motion.state);
gobble_motion_events(GDK_BUTTON1_MASK);
@@ -415,7 +414,8 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
if (!sc->item) {
@@ -429,7 +429,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
repr->setAttribute("sodipodi:type", "spiral");
/* Set style */
- sp_desktop_apply_style_tool(desktop, repr, "tools.shapes.spiral", false);
+ sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/spiral", false);
sc->item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
Inkscape::GC::release(repr);
@@ -442,7 +442,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, sc->item);
Geom::Point pt2g = to_2geom(p);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
Geom::Point const p0 = to_2geom(sp_desktop_dt2root_xy_point(desktop, sc->center));
Geom::Point const p1 = to_2geom(sp_desktop_dt2root_xy_point(desktop, from_2geom(pt2g)));
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index dc19ac761..a3a4ce59f 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -41,7 +41,7 @@
#include "display/canvas-bpath.h"
#include "display/curve.h"
#include <glibmm/i18n.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "xml/repr.h"
#include "xml/repr-sorting.h"
@@ -958,14 +958,16 @@ sp_selected_path_outline(SPDesktop *desktop)
void
sp_selected_path_offset(SPDesktop *desktop)
{
- double prefOffset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
sp_selected_path_do_offset(desktop, true, prefOffset);
}
void
sp_selected_path_inset(SPDesktop *desktop)
{
- double prefOffset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", 1.0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
sp_selected_path_do_offset(desktop, false, prefOffset);
}
@@ -1090,9 +1092,8 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
}
{
- double prefOffset = 1.0;
- prefOffset = prefs_get_double_attribute("options.defaultoffsetwidth", "value", prefOffset);
- o_width = prefOffset;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
}
if (o_width < 0.01)
@@ -1635,65 +1636,66 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
float angleLimit, bool breakableAngles,
bool modifySelection)
{
- bool simplifyIndividualPaths =
- (bool) prefs_get_int_attribute("options.simplifyindividualpaths", "value", 0);
-
- gchar *simplificationType;
- if (simplifyIndividualPaths) {
- simplificationType = _("Simplifying paths (separately):");
- } else {
- simplificationType = _("Simplifying paths:");
- }
-
- bool didSomething = false;
-
- boost::optional<Geom::Rect> selectionBbox = selection->bounds();
- if (!selectionBbox) {
- return false;
- }
- gdouble selectionSize = L2(selectionBbox->dimensions());
-
- gdouble simplifySize = selectionSize;
-
- int pathsSimplified = 0;
- int totalPathCount = g_slist_length(items);
-
- // set "busy" cursor
- desktop->setWaitingCursor();
-
- for (; items != NULL; items = items->next) {
- SPItem *item = (SPItem *) items->data;
-
- if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item)))
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool simplifyIndividualPaths = prefs->getBool("/options/simplifyindividualpaths/value");
+
+ gchar *simplificationType;
+ if (simplifyIndividualPaths) {
+ simplificationType = _("Simplifying paths (separately):");
+ } else {
+ simplificationType = _("Simplifying paths:");
+ }
+
+ bool didSomething = false;
+
+ boost::optional<Geom::Rect> selectionBbox = selection->bounds();
+ if (!selectionBbox) {
+ return false;
+ }
+ gdouble selectionSize = L2(selectionBbox->dimensions());
+
+ gdouble simplifySize = selectionSize;
+
+ int pathsSimplified = 0;
+ int totalPathCount = g_slist_length(items);
+
+ // set "busy" cursor
+ desktop->setWaitingCursor();
+
+ for (; items != NULL; items = items->next) {
+ SPItem *item = (SPItem *) items->data;
+
+ if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item)))
continue;
- if (simplifyIndividualPaths) {
- boost::optional<Geom::Rect> itemBbox = item->getBounds(sp_item_i2d_affine(item));
- if (itemBbox) {
- simplifySize = L2(itemBbox->dimensions());
- } else {
- simplifySize = 0;
- }
- }
-
- pathsSimplified++;
-
- if (pathsSimplified % 20 == 0) {
- gchar *message = g_strdup_printf(_("%s <b>%d</b> of <b>%d</b> paths simplified..."), simplificationType, pathsSimplified, totalPathCount);
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, message);
- }
-
- didSomething |= sp_selected_path_simplify_item(desktop, selection, item,
- threshold, justCoalesce, angleLimit, breakableAngles, simplifySize, modifySelection);
- }
-
- desktop->clearWaitingCursor();
-
- if (pathsSimplified > 20) {
- desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, g_strdup_printf(_("<b>%d</b> paths simplified."), pathsSimplified));
- }
-
- return didSomething;
+ if (simplifyIndividualPaths) {
+ boost::optional<Geom::Rect> itemBbox = item->getBounds(sp_item_i2d_affine(item));
+ if (itemBbox) {
+ simplifySize = L2(itemBbox->dimensions());
+ } else {
+ simplifySize = 0;
+ }
+ }
+
+ pathsSimplified++;
+
+ if (pathsSimplified % 20 == 0) {
+ gchar *message = g_strdup_printf(_("%s <b>%d</b> of <b>%d</b> paths simplified..."),
+ simplificationType, pathsSimplified, totalPathCount);
+ desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, message);
+ }
+
+ didSomething |= sp_selected_path_simplify_item(desktop, selection, item,
+ threshold, justCoalesce, angleLimit, breakableAngles, simplifySize, modifySelection);
+ }
+
+ desktop->clearWaitingCursor();
+
+ if (pathsSimplified > 20) {
+ desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, g_strdup_printf(_("<b>%d</b> paths simplified."), pathsSimplified));
+ }
+
+ return didSomething;
}
void
@@ -1732,10 +1734,10 @@ static gdouble simplifyMultiply = 1.0;
void
sp_selected_path_simplify(SPDesktop *desktop)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble simplifyThreshold =
- prefs_get_double_attribute("options.simplifythreshold", "value", 0.003);
- bool simplifyJustCoalesce =
- (bool) prefs_get_int_attribute("options.simplifyjustcoalesce", "value", 0);
+ prefs->getDouble("/options/simplifythreshold/value", 0.003);
+ bool simplifyJustCoalesce = prefs->getBool("/options/simplifyjustcoalesce/value", 0);
//Get the current time
GTimeVal currentTimeVal;
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 97577bcba..6bb0a6f2d 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -38,7 +38,7 @@
#include "pixmaps/cursor-star.xpm"
#include "sp-metrics.h"
#include <glibmm/i18n.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include "object-edit.h"
@@ -51,7 +51,7 @@ static void sp_star_context_init (SPStarContext * star_context);
static void sp_star_context_dispose (GObject *object);
static void sp_star_context_setup (SPEventContext *ec);
-static void sp_star_context_set (SPEventContext *ec, const gchar *key, const gchar *val);
+static void sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_star_context_root_handler (SPEventContext *ec, GdkEvent *event);
static void sp_star_drag (SPStarContext * sc, NR::Point p, guint state);
@@ -226,11 +226,12 @@ sp_star_context_setup (SPEventContext *ec)
sc->sel_changed_connection.disconnect();
sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_star_context_selection_changed), (gpointer)sc));
- if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/shapes/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
ec->enableGrDrag();
}
@@ -238,24 +239,21 @@ sp_star_context_setup (SPEventContext *ec)
}
static void
-sp_star_context_set (SPEventContext *ec, const gchar *key, const gchar *val)
+sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPStarContext *sc = SP_STAR_CONTEXT (ec);
- if (!strcmp (key, "magnitude")) {
- sc->magnitude = (val) ? atoi (val) : 5;
- sc->magnitude = CLAMP (sc->magnitude, 3, 1024);
- } else if (!strcmp (key, "proportion")) {
- sc->proportion = (val) ? g_ascii_strtod (val, NULL) : 0.5;
- sc->proportion = CLAMP (sc->proportion, 0.01, 2.0);
- } else if (!strcmp (key, "isflatsided")) {
- if (val && !strcmp(val, "true"))
- sc->isflatsided = true;
- else
- sc->isflatsided = false;
- } else if (!strcmp (key, "rounded")) {
- sc->rounded = (val) ? g_ascii_strtod (val, NULL) : 0.0;
- } else if (!strcmp (key, "randomized")) {
- sc->randomized = (val) ? g_ascii_strtod (val, NULL) : 0.0;
+ Glib::ustring path = val->getEntryName();
+
+ if (path == "magnitude") {
+ sc->magnitude = CLAMP (val->getInt(5), 3, 1024);
+ } else if (path == "proportion") {
+ sc->proportion = CLAMP (val->getDouble(0.5), 0.01, 2.0);
+ } else if (path == "isflatsided") {
+ sc->isflatsided = val->getBool();
+ } else if (path == "rounded") {
+ sc->rounded = val->getDouble();
+ } else if (path == "randomized") {
+ sc->randomized = val->getDouble();
}
}
@@ -265,10 +263,11 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPStarContext *sc = SP_STAR_CONTEXT (event_context);
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
@@ -284,7 +283,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true);
Geom::Point pt2g = to_2geom(sc->center);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
sc->center = from_2geom(pt2g);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -426,7 +425,8 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- int const snaps = prefs_get_int_attribute ("options.rotationsnapsperpi", "value", 12);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
if (!sc->item) {
@@ -440,7 +440,7 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
repr->setAttribute("sodipodi:type", "star");
/* Set style */
- sp_desktop_apply_style_tool(desktop, repr, "tools.shapes.star", false);
+ sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/star", false);
sc->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
Inkscape::GC::release(repr);
@@ -454,7 +454,7 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, sc->item);
Geom::Point pt2g = to_2geom(p);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
Geom::Point const p0 = to_2geom(sp_desktop_dt2root_xy_point(desktop, sc->center));
Geom::Point const p1 = to_2geom(sp_desktop_dt2root_xy_point(desktop, from_2geom(pt2g)));
diff --git a/src/style.cpp b/src/style.cpp
index 966764800..a5b25e6ff 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -1,9 +1,9 @@
#define __SP_STYLE_C__
-/** \file
- * SVG stylesheets implementation.
- *
- * Authors:
+/** @file
+ * @brief SVG stylesheets implementation.
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Peter Moulder <pmoulder@mail.csse.monash.edu.au>
* bulia byak <buliabyak@users.sf.net>
@@ -41,9 +41,11 @@
#include "style.h"
#include "svg/css-ostringstream.h"
#include "xml/repr.h"
+#include "xml/simple-document.h"
#include "unit-constants.h"
#include "2geom/isnan.h"
#include "macros.h"
+#include "preferences.h"
#include "sp-filter-reference.h"
@@ -790,15 +792,33 @@ sp_style_read_from_object(SPStyle *style, SPObject *object)
/**
- * Read style properties from repr only.
+ * Read style properties from preferences.
+ * @param style The style to write to
+ * @param path Preferences directory from which the style should be read
*/
void
-sp_style_read_from_repr(SPStyle *style, Inkscape::XML::Node *repr)
+sp_style_read_from_prefs(SPStyle *style, Glib::ustring const &path)
{
g_return_if_fail(style != NULL);
- g_return_if_fail(repr != NULL);
+ g_return_if_fail(path != "");
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- sp_style_read(style, NULL, repr);
+ // not optimal: we reconstruct the node based on the prefs, then pass it to
+ // sp_style_read for actual processing.
+ Inkscape::XML::SimpleDocument *tempdoc = new Inkscape::XML::SimpleDocument;
+ Inkscape::XML::Node *tempnode = tempdoc->createElement("temp");
+
+ std::vector<Inkscape::Preferences::Entry> attrs = prefs->getAllEntries(path);
+ for (std::vector<Inkscape::Preferences::Entry>::iterator i = attrs.begin(); i != attrs.end(); ++i) {
+ tempnode->setAttribute(i->getEntryName().data(), i->getString().data());
+ }
+
+ sp_style_read(style, NULL, tempnode);
+
+ Inkscape::GC::release(tempnode);
+ Inkscape::GC::release(tempdoc);
+ delete tempdoc;
}
diff --git a/src/style.h b/src/style.h
index 47ba6955e..d5ccc4901 100644
--- a/src/style.h
+++ b/src/style.h
@@ -3,8 +3,8 @@
/** \file
* SPStyle - a style object for SPItem objects
- *
- * Authors:
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
@@ -382,7 +382,7 @@ SPStyle *sp_style_unref(SPStyle *style);
void sp_style_read_from_object(SPStyle *style, SPObject *object);
-void sp_style_read_from_repr(SPStyle *style, Inkscape::XML::Node *repr);
+void sp_style_read_from_prefs(SPStyle *style, Glib::ustring const &path);
void sp_style_merge_from_style_string(SPStyle *style, gchar const *p);
diff --git a/src/svg-view.cpp b/src/svg-view.cpp
index c406e70a5..bd86d5477 100644
--- a/src/svg-view.cpp
+++ b/src/svg-view.cpp
@@ -100,7 +100,7 @@ SPSVGView::doRescale (bool event)
}
if (_drawing) {
- sp_canvas_item_affine_absolute (_drawing, NR::Matrix(Geom::Scale(_hscale, _vscale)));
+ sp_canvas_item_affine_absolute (_drawing, Geom::Scale(_hscale, _vscale));
}
if (event) {
diff --git a/src/svg/css-ostringstream.cpp b/src/svg/css-ostringstream.cpp
index 362eb7662..a6eb2783e 100644
--- a/src/svg/css-ostringstream.cpp
+++ b/src/svg/css-ostringstream.cpp
@@ -1,6 +1,6 @@
#include "svg/css-ostringstream.h"
#include "svg/strip-trailing-zeros.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include <glib/gmessages.h>
#include <glib/gstrfuncs.h>
@@ -14,7 +14,8 @@ Inkscape::CSSOStringStream::CSSOStringStream()
/* This one is (currently) needed though, as we currently use ostr.precision as a sort of
variable for storing the desired precision: see our two precision methods and our operator<<
methods for float and double. */
- ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ ostr.precision(prefs->getInt("/options/svgoutput/numericprecision", 8));
}
static void
diff --git a/src/svg/path-string.cpp b/src/svg/path-string.cpp
index 6f6a1f20f..c0e33fddd 100644
--- a/src/svg/path-string.cpp
+++ b/src/svg/path-string.cpp
@@ -15,7 +15,7 @@
#include "svg/path-string.h"
#include "svg/stringstream.h"
#include "svg/svg.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include <algorithm>
// 1<=numericprecision<=16, doubles are only accurate upto (slightly less than) 16 digits (and less than one digit doesn't make sense)
@@ -27,11 +27,12 @@ int Inkscape::SVG::PathString::numericprecision;
int Inkscape::SVG::PathString::minimumexponent;
Inkscape::SVG::PathString::PathString() :
- allow_relative_coordinates(0 != prefs_get_int_attribute("options.svgoutput", "allowrelativecoordinates", 1)),
- force_repeat_commands(0 != prefs_get_int_attribute("options.svgoutput", "forcerepeatcommands", 0))
+ allow_relative_coordinates(Inkscape::Preferences::get()->getBool("/options/svgoutput/allowrelativecoordinates", true)),
+ force_repeat_commands(Inkscape::Preferences::get()->getBool("/options/svgoutput/forcerepeatcommands"))
{
- numericprecision = std::max<int>(minprec,std::min<int>(maxprec,prefs_get_int_attribute("options.svgoutput", "numericprecision", 8)));
- minimumexponent = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ numericprecision = std::max<int>(minprec,std::min<int>(maxprec, prefs->getInt("/options/svgoutput/numericprecision", 8)));
+ minimumexponent = prefs->getInt("/options/svgoutput/minimumexponent", -8);
}
void Inkscape::SVG::PathString::_appendOp(char abs_op, char rel_op) {
diff --git a/src/svg/stringstream.cpp b/src/svg/stringstream.cpp
index 62e20961a..6b9e512a1 100644
--- a/src/svg/stringstream.cpp
+++ b/src/svg/stringstream.cpp
@@ -1,6 +1,6 @@
#include "svg/stringstream.h"
#include "svg/strip-trailing-zeros.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include <2geom/point.h>
Inkscape::SVGOStringStream::SVGOStringStream()
@@ -13,7 +13,8 @@ Inkscape::SVGOStringStream::SVGOStringStream()
/* This one is (currently) needed though, as we currently use ostr.precision as a sort of
variable for storing the desired precision: see our two precision methods and our operator<<
methods for float and double. */
- ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ ostr.precision(prefs->getInt("/options/svgoutput/numericprecision", 8));
}
Inkscape::SVGOStringStream &
diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp
index 2445135c3..2b9a79d3d 100644
--- a/src/svg/svg-affine.cpp
+++ b/src/svg/svg-affine.cpp
@@ -28,7 +28,7 @@
#include <2geom/angle.h>
#include <libnr/nr-convert2geom.h>
#include "svg.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#ifndef M_PI
# define M_PI 3.14159265358979323846
@@ -194,15 +194,14 @@ sp_svg_transform_write(NR::Matrix const &transform)
gchar *
sp_svg_transform_write(NR::Matrix const *transform)
{
- double e;
-
if (!transform) {
return NULL;
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- e = 0.000001 * NR::expansion(*transform);
- int prec = prefs_get_int_attribute("options.svgoutput", "numericprecision", 8);
- int min_exp = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8);
+ double e = 0.000001 * NR::expansion(*transform);
+ int prec = prefs->getInt("/options/svgoutput/numericprecision", 8);
+ int min_exp = prefs->getInt("/options/svgoutput/minimumexponent", -8);
/* fixme: We could use t1 * t1 + t2 * t2 here instead */
if (NR_DF_TEST_CLOSE ((*transform)[1], 0.0, e) && NR_DF_TEST_CLOSE ((*transform)[2], 0.0, e)) {
diff --git a/src/svg/svg-color-test.h b/src/svg/svg-color-test.h
index dbefa1af5..d249c675c 100644
--- a/src/svg/svg-color-test.h
+++ b/src/svg/svg-color-test.h
@@ -2,7 +2,7 @@
#include <cassert>
#include <cstdlib>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "svg/svg-color.h"
#include "svg/svg-icc-color.h"
@@ -18,12 +18,13 @@ class SVGColorTest : public CxxTest::TestSuite
public:
void check_rgb24(unsigned const rgb24)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
char css[8];
- prefs_set_int_attribute("options.svgoutput", "usenamedcolors", 0);
+ prefs->setBool("/options/svgoutput/usenamedcolors", false);
sp_svg_write_color(css, sizeof(css), rgb24 << 8);
TS_ASSERT_EQUALS(sp_svg_read_color(css, 0xff),
rgb24 << 8);
- prefs_set_int_attribute("options.svgoutput", "usenamedcolors", 1);
+ prefs->setBool("/options/svgoutput/usenamedcolors", true);
sp_svg_write_color(css, sizeof(css), rgb24 << 8);
TS_ASSERT_EQUALS(sp_svg_read_color(css, 0xff),
rgb24 << 8);
diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp
index e1f87fdb9..9040d6e43 100644
--- a/src/svg/svg-color.cpp
+++ b/src/svg/svg-color.cpp
@@ -32,7 +32,7 @@
#include <errno.h>
#include "strneq.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "svg-color.h"
#include "svg-icc-color.h"
@@ -431,8 +431,9 @@ sp_svg_write_color(gchar *buf, unsigned const buflen, guint32 const rgba32)
{
g_assert(8 <= buflen);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
unsigned const rgb24 = rgba32 >> 8;
- if (prefs_get_int_attribute("options.svgoutput", "usenamedcolors", 0)) {
+ if (prefs->getBool("/options/svgoutput/usenamedcolors")) {
rgb24_to_css(buf, rgb24);
} else {
g_snprintf(buf, buflen, "#%06x", rgb24);
diff --git a/src/svg/svg-path-geom-test.h b/src/svg/svg-path-geom-test.h
index 32a2ed231..7358c6d69 100644
--- a/src/svg/svg-path-geom-test.h
+++ b/src/svg/svg-path-geom-test.h
@@ -3,7 +3,7 @@
#include "2geom/curves.h"
#include "2geom/pathvector.h"
#include "svg/svg.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "streq.h"
#include <stdio.h>
#include <string>
@@ -391,11 +391,12 @@ public:
void testMinexpPrecision() {
Geom::PathVector pv;
char * path_str;
- // Default values
- prefs_set_int_attribute("options.svgoutput", "allowrelativecoordinates", 1);
- prefs_set_int_attribute("options.svgoutput", "forcerepeatcommands", 0);
- prefs_set_int_attribute("options.svgoutput", "numericprecision", 8);
- prefs_set_int_attribute("options.svgoutput", "minimumexponent", -8);
+ // Default values
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/options/svgoutput/allowrelativecoordinates", true);
+ prefs->setBool("/options/svgoutput/forcerepeatcommands", false);
+ prefs->setInt("/options/svgoutput/numericprecision", 8);
+ prefs->setInt("/options/svgoutput/minimumexponent", -8);
pv = sp_svg_read_pathv("M 123456781,1.23456781e-8 L 123456782,1.23456782e-8 L 123456785,1.23456785e-8 L 10123456400,1.23456785e-8 L 123456789,1.23456789e-8 L 123456789,101.234564e-8 L 123456789,1.23456789e-8");
path_str = sp_svg_write_path(pv);
TS_ASSERT_RELATION( streq_rel , "m 123456780,1.2345678e-8 0,0 10,1e-15 9999999210,0 -9999999210,0 0,9.99999921e-7 0,-9.99999921e-7" , path_str );
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 08f0cf0d9..e277ff584 100644
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -44,7 +44,7 @@
#include "object-edit.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "rubberband.h"
#include "sp-metrics.h"
#include "context-fns.h"
@@ -137,7 +137,7 @@ sp_text_context_init(SPTextContext *tc)
tc->imc = NULL;
tc->text = NULL;
- tc->pdoc = NR::Point(0, 0);
+ tc->pdoc = Geom::Point(0, 0);
new (&tc->text_sel_start) Inkscape::Text::Layout::iterator();
new (&tc->text_sel_end) Inkscape::Text::Layout::iterator();
new (&tc->text_selection_quads) std::vector<SPCanvasItem*>();
@@ -285,10 +285,11 @@ sp_text_context_setup(SPEventContext *ec)
sp_text_context_selection_changed(sp_desktop_selection(desktop), tc);
- if (prefs_get_int_attribute("tools.text", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/text/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.text", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/text/gradientdrag")) {
ec->enableGrDrag();
}
}
@@ -360,12 +361,12 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !event_context->space_panning) {
// find out clicked item, disregarding groups
- item_ungrouped = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE);
+ item_ungrouped = desktop->item_at_point(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);
if (tc->text) {
// find out click point in document coordinates
- NR::Point p = desktop->w2d(NR::Point(event->button.x, event->button.y));
+ Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y));
// set the cursor closest to that point
tc->text_sel_start = tc->text_sel_end = sp_te_get_position_by_coords(tc->text, p);
// update display
@@ -413,7 +414,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
Inkscape::Text::Layout const *layout = te_get_layout(tc->text);
if (!layout) break;
// find out click point in document coordinates
- NR::Point p = desktop->w2d(NR::Point(event->button.x, event->button.y));
+ Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y));
// set the cursor closest to that point
Inkscape::Text::Layout::iterator new_end = sp_te_get_position_by_coords(tc->text, p);
if (tc->dragging == 2) {
@@ -442,7 +443,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
break;
}
// find out item under mouse, disregarding groups
- item_ungrouped = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE);
+ item_ungrouped = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE);
if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) {
sp_canvas_item_show(tc->indicator);
boost::optional<Geom::Rect> ibbox = sp_item_bbox_desktop(item_ungrouped);
@@ -490,10 +491,10 @@ sp_text_context_setup_text(SPTextContext *tc)
rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
/* Set style */
- sp_desktop_apply_style_tool(SP_EVENT_CONTEXT_DESKTOP(ec), rtext, "tools.text", true);
+ sp_desktop_apply_style_tool(SP_EVENT_CONTEXT_DESKTOP(ec), rtext, "/tools/text", true);
- sp_repr_set_svg_double(rtext, "x", tc->pdoc[NR::X]);
- sp_repr_set_svg_double(rtext, "y", tc->pdoc[NR::Y]);
+ sp_repr_set_svg_double(rtext, "x", tc->pdoc[Geom::X]);
+ sp_repr_set_svg_double(rtext, "y", tc->pdoc[Geom::Y]);
/* Create <tspan> */
Inkscape::XML::Node *rtspan = xml_doc->createElement("svg:tspan");
@@ -604,7 +605,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
sp_text_context_validate_cursor_iterators(tc);
- event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -619,7 +621,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
event_context->yp = (gint) event->button.y;
event_context->within_tolerance = true;
- NR::Point const button_pt(event->button.x, event->button.y);
+ Geom::Point const button_pt(event->button.x, event->button.y);
tc->p0 = desktop->w2d(button_pt);
Inkscape::Rubberband::get(desktop)->start(desktop, tc->p0);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -654,15 +656,15 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
// motion notify coordinates as given (no snapping back to origin)
event_context->within_tolerance = false;
- NR::Point const motion_pt(event->motion.x, event->motion.y);
- NR::Point const p = desktop->w2d(motion_pt);
+ Geom::Point const motion_pt(event->motion.x, event->motion.y);
+ Geom::Point const p = desktop->w2d(motion_pt);
Inkscape::Rubberband::get(desktop)->move(p);
gobble_motion_events(GDK_BUTTON1_MASK);
// status text
- GString *xs = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[NR::X]), desktop->namedview->getDefaultMetric());
- GString *ys = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[NR::Y]), desktop->namedview->getDefaultMetric());
+ GString *xs = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::X]), desktop->namedview->getDefaultMetric());
+ GString *ys = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::Y]), desktop->namedview->getDefaultMetric());
event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s &#215; %s"), xs->str, ys->str);
g_string_free(xs, FALSE);
g_string_free(ys, FALSE);
@@ -682,7 +684,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
if (tc->creating && event_context->within_tolerance) {
/* Button 1, set X & Y & new item */
sp_desktop_selection(desktop)->clear();
- NR::Point dtp = desktop->w2d(NR::Point(event->button.x, event->button.y));
+ Geom::Point dtp = desktop->w2d(Geom::Point(event->button.x, event->button.y));
tc->pdoc = sp_desktop_dt2root_xy_point(desktop, dtp);
tc->show = TRUE;
@@ -694,19 +696,19 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
// Cursor height is defined by the new text object's font size; it needs to be set
// articifically here, for the text object does not exist yet:
double cursor_height = sp_desktop_get_font_size_tool(desktop);
- sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp + NR::Point(0, cursor_height));
+ sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp + Geom::Point(0, cursor_height));
event_context->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync
event_context->within_tolerance = false;
} else if (tc->creating) {
- NR::Point const button_pt(event->button.x, event->button.y);
- NR::Point p1 = desktop->w2d(button_pt);
+ Geom::Point const button_pt(event->button.x, event->button.y);
+ Geom::Point p1 = desktop->w2d(button_pt);
double cursor_height = sp_desktop_get_font_size_tool(desktop);
- if (fabs(p1[NR::Y] - tc->p0[NR::Y]) > cursor_height) {
+ if (fabs(p1[Geom::Y] - tc->p0[Geom::Y]) > cursor_height) {
// otherwise even one line won't fit; most probably a slip of hand (even if bigger than tolerance)
SPItem *ft = create_flowtext_with_internal_frame (desktop, tc->p0, p1);
/* Set style */
- sp_desktop_apply_style_tool(desktop, SP_OBJECT_REPR(ft), "tools.text", true);
+ sp_desktop_apply_style_tool(desktop, SP_OBJECT_REPR(ft), "/tools/text", true);
sp_desktop_selection(desktop)->set(ft);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created."));
sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
@@ -1020,9 +1022,9 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT)
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*-10, 0));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*-10, 0));
else
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*-1, 0));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*-1, 0));
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
sp_document_maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT,
@@ -1045,9 +1047,9 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT)
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*10, 0));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*10, 0));
else
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(mul*1, 0));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*1, 0));
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
sp_document_maybe_done(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT,
@@ -1070,9 +1072,9 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT)
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*-10));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*-10));
else
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*-1));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*-1));
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
sp_document_maybe_done(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT,
@@ -1096,9 +1098,9 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
gint mul = 1 + gobble_key_events(
get_group0_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT)
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*10));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*10));
else
- sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, NR::Point(0, mul*1));
+ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*1));
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
sp_document_maybe_done(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT,
@@ -1584,7 +1586,7 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see)
// scroll to show cursor
if (scroll_to_see) {
Geom::Point const center = SP_EVENT_CONTEXT(tc)->desktop->get_display_area().midpoint();
- if (NR::L2(d0 - center) > NR::L2(d1 - center))
+ if (Geom::L2(d0 - center) > Geom::L2(d1 - center))
// unlike mouse moves, here we must scroll all the way at first shot, so we override the autoscrollspeed
SP_EVENT_CONTEXT(tc)->desktop->scroll_to_point(d0, 1.0);
else
diff --git a/src/text-context.h b/src/text-context.h
index 8441cb04b..b9068e497 100644
--- a/src/text-context.h
+++ b/src/text-context.h
@@ -20,7 +20,7 @@
#include "event-context.h"
#include <display/display-forward.h>
-#include <libnr/nr-point.h>
+#include <2geom/point.h>
#include "libnrtype/Layout-TNG.h"
#define SP_TYPE_TEXT_CONTEXT (sp_text_context_get_type ())
@@ -35,48 +35,48 @@ class SPCanvasArena;
struct SPTextContext : public SPEventContext {
- sigc::connection sel_changed_connection;
- sigc::connection sel_modified_connection;
- sigc::connection style_set_connection;
- sigc::connection style_query_connection;
+ sigc::connection sel_changed_connection;
+ sigc::connection sel_modified_connection;
+ sigc::connection style_set_connection;
+ sigc::connection style_query_connection;
- GtkIMContext *imc;
+ GtkIMContext *imc;
- SPItem *text; // the text we're editing, or NULL if none selected
+ SPItem *text; // the text we're editing, or NULL if none selected
- /* Text item position in root coordinates */
- NR::Point pdoc;
- /* Insertion point position */
- Inkscape::Text::Layout::iterator text_sel_start;
- Inkscape::Text::Layout::iterator text_sel_end;
+ /* Text item position in root coordinates */
+ Geom::Point pdoc;
+ /* Insertion point position */
+ Inkscape::Text::Layout::iterator text_sel_start;
+ Inkscape::Text::Layout::iterator text_sel_end;
- gchar uni[9];
- bool unimode;
- guint unipos;
+ gchar uni[9];
+ bool unimode;
+ guint unipos;
- SPCanvasItem *cursor;
- SPCanvasItem *indicator;
- SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
- std::vector<SPCanvasItem*> text_selection_quads;
- gint timeout;
- guint show : 1;
- guint phase : 1;
- guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
+ SPCanvasItem *cursor;
+ SPCanvasItem *indicator;
+ SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
+ std::vector<SPCanvasItem*> text_selection_quads;
+ gint timeout;
+ guint show : 1;
+ guint phase : 1;
+ guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
- guint over_text : 1; // true if cursor is over a text object
+ guint over_text : 1; // true if cursor is over a text object
- guint dragging : 2; // dragging selection over text
+ guint dragging : 2; // dragging selection over text
- guint creating : 1; // dragging rubberband to create flowtext
- SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
- NR::Point p0; // initial point if the flowtext rect
+ guint creating : 1; // dragging rubberband to create flowtext
+ SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
+ Geom::Point p0; // initial point if the flowtext rect
- /* Preedit String */
- gchar* preedit_string;
+ /* Preedit String */
+ gchar* preedit_string;
};
struct SPTextContextClass {
- SPEventContextClass parent_class;
+ SPEventContextClass parent_class;
};
/* Standard Gtk function */
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 11b0f0fe4..be427715e 100644
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -105,7 +105,7 @@ sp_te_get_cursor_coords (SPItem const *item, Inkscape::Text::Layout::iterator co
Inkscape::Text::Layout const *layout = te_get_layout(item);
double height, rotation;
layout->queryCursorShape(position, p0, height, rotation);
- p1 = Geom::Point(p0[NR::X] + height * sin(rotation), p0[NR::Y] - height * cos(rotation));
+ p1 = Geom::Point(p0[Geom::X] + height * sin(rotation), p0[Geom::Y] - height * cos(rotation));
}
SPStyle const * sp_te_style_at_position(SPItem const *text, Inkscape::Text::Layout::iterator const &position)
diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp
index da03ab7bf..f10b86f64 100644
--- a/src/tools-switch.cpp
+++ b/src/tools-switch.cpp
@@ -59,58 +59,34 @@
static char const *const tool_names[] = {
NULL,
- "tools.select",
- "tools.nodes",
- "tools.tweak",
- "tools.shapes.rect",
- "tools.shapes.3dbox",
- "tools.shapes.arc",
- "tools.shapes.star",
- "tools.shapes.spiral",
- "tools.freehand.pencil",
- "tools.freehand.pen",
- "tools.calligraphic",
- "tools.text",
- "tools.gradient",
- "tools.zoom",
- "tools.dropper",
- "tools.connector",
- "tools.paintbucket",
- "tools.eraser",
- "tools.lpetool",
- NULL
-};
-
-static char const *const tool_ids[] = {
- NULL,
- "select",
- "nodes",
- "tweak",
- "rect",
- "3dbox",
- "arc",
- "star",
- "spiral",
- "pencil",
- "pen",
- "calligraphic",
- "text",
- "gradient",
- "zoom",
- "dropper",
- "connector",
- "paintbucket",
- "eraser",
- "lpetool",
+ "/tools/select",
+ "/tools/nodes",
+ "/tools/tweak",
+ "/tools/shapes/rect",
+ "/tools/shapes/3dbox",
+ "/tools/shapes/arc",
+ "/tools/shapes/star",
+ "/tools/shapes/spiral",
+ "/tools/freehand/pencil",
+ "/tools/freehand/pen",
+ "/tools/calligraphic",
+ "/tools/text",
+ "/tools/gradient",
+ "/tools/zoom",
+ "/tools/dropper",
+ "/tools/connector",
+ "/tools/paintbucket",
+ "/tools/eraser",
+ "/tools/lpetool",
NULL
};
static int
-tools_id2num(char const *id)
+tools_prefpath2num(char const *id)
{
int i = 1;
- while (tool_ids[i]) {
- if (strcmp(tool_ids[i], id) == 0)
+ while (tool_names[i]) {
+ if (strcmp(tool_names[i], id) == 0)
return i;
else i++;
}
@@ -121,16 +97,16 @@ tools_id2num(char const *id)
int
tools_isactive(SPDesktop *dt, unsigned num)
{
- g_assert( num < G_N_ELEMENTS(tool_ids) );
+ g_assert( num < G_N_ELEMENTS(tool_names) );
if (SP_IS_EVENT_CONTEXT(dt->event_context))
- return (!strcmp(dt->event_context->prefs_repr->attribute("id"), tool_ids[num]));
+ return dt->event_context->pref_observer->observed_path == tool_names[num];
else return FALSE;
}
int
tools_active(SPDesktop *dt)
{
- return (tools_id2num(dt->event_context->prefs_repr->attribute("id")));
+ return tools_prefpath2num(dt->event_context->pref_observer->observed_path.data());
}
void
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index df10ca7a1..f8e88b53a 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -70,7 +70,7 @@
#include "livarot/Shape.h"
#include <2geom/isnan.h>
#include <2geom/transforms.h>
-#include "prefs-utils.h"
+#include "preferences.h"
#include "style.h"
#include "box3d.h"
#include "sp-item-transform.h"
@@ -89,7 +89,7 @@ static void sp_tweak_context_init(SPTweakContext *ddc);
static void sp_tweak_context_dispose(GObject *object);
static void sp_tweak_context_setup(SPEventContext *ec);
-static void sp_tweak_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static void sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val);
static gint sp_tweak_context_root_handler(SPEventContext *ec, GdkEvent *event);
static SPEventContextClass *parent_class;
@@ -274,9 +274,8 @@ sp_tweak_context_style_set(SPCSSAttr const *css, SPTweakContext *tc)
if (tc->mode == TWEAK_MODE_COLORPAINT) { // intercept color setting only in this mode
// we cannot store properties with uris
css = sp_css_attr_unset_uris ((SPCSSAttr *) css);
-
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.tweak"), (SPCSSAttr *) css, "style");
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/tweak/style", const_cast<SPCSSAttr*>(css));
return true;
}
return false;
@@ -325,44 +324,42 @@ sp_tweak_context_setup(SPEventContext *ec)
tc->style_set_connection = ec->desktop->connectSetStyle( // catch style-setting signal in this tool
sigc::bind(sigc::ptr_fun(&sp_tweak_context_style_set), tc)
);
-
- if (prefs_get_int_attribute("tools.tweak", "selcue", 0) != 0) {
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/tweak/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.tweak", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/tweak/gradientdrag")) {
ec->enableGrDrag();
}
}
static void
-sp_tweak_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val)
{
SPTweakContext *tc = SP_TWEAK_CONTEXT(ec);
+ Glib::ustring path = val->getEntryName();
- if (!strcmp(key, "width")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.1 );
- tc->width = CLAMP(dval, -1000.0, 1000.0);
- } else if (!strcmp(key, "mode")) {
- gint64 const dval = ( val ? g_ascii_strtoll (val, NULL, 10) : 0 );
- tc->mode = dval;
+ if (path == "width") {
+ tc->width = CLAMP(val->getDouble(0.1), -1000.0, 1000.0);
+ } else if (path == "mode") {
+ tc->mode = val->getInt();
sp_tweak_update_cursor(tc, false);
- } else if (!strcmp(key, "fidelity")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.0 );
- tc->fidelity = CLAMP(dval, 0.0, 1.0);
- } else if (!strcmp(key, "force")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 1.0 );
- tc->force = CLAMP(dval, 0, 1.0);
- } else if (!strcmp(key, "usepressure")) {
- tc->usepressure = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "doh")) {
- tc->do_h = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "dos")) {
- tc->do_s = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "dol")) {
- tc->do_l = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "doo")) {
- tc->do_o = (val && strcmp(val, "0"));
+ } else if (path == "fidelity") {
+ tc->fidelity = CLAMP(val->getDouble(), 0.0, 1.0);
+ } else if (path == "force") {
+ tc->force = CLAMP(val->getDouble(1.0), 0, 1.0);
+ } else if (path == "usepressure") {
+ tc->usepressure = val->getBool();
+ } else if (path == "doh") {
+ tc->do_h = val->getBool();
+ } else if (path == "dos") {
+ tc->do_s = val->getBool();
+ } else if (path == "dol") {
+ tc->do_l = val->getBool();
+ } else if (path == "doo") {
+ tc->do_o = val->getBool();
}
}
@@ -411,6 +408,19 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
selection->add(item);
}
+ if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ GSList *items = g_slist_prepend (NULL, item);
+ GSList *selected = NULL;
+ GSList *to_select = NULL;
+ SPDocument *doc = SP_OBJECT_DOCUMENT(item);
+ sp_item_list_to_curves (items, &selected, &to_select);
+ g_slist_free (items);
+ SPObject* newObj = doc->getObjectByRepr((Inkscape::XML::Node *) to_select->data);
+ g_slist_free (to_select);
+ item = (SPItem *) newObj;
+ selection->add(item);
+ }
+
if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item)) {
for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child)) {
@@ -520,7 +530,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
}
}
- } else if (SP_IS_PATH(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ } else if (SP_IS_PATH(item) || SP_IS_SHAPE(item)) {
Inkscape::XML::Node *newrepr = NULL;
gint pos = 0;
@@ -1038,10 +1048,28 @@ sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point v
SPItem *item_at_point = SP_EVENT_CONTEXT(tc)->desktop->item_at_point(event_p, TRUE);
bool do_fill = false, do_stroke = false, do_opacity = false;
- guint32 fill_goal = sp_desktop_get_color_tool(desktop, "tools.tweak", true, &do_fill);
- guint32 stroke_goal = sp_desktop_get_color_tool(desktop, "tools.tweak", false, &do_stroke);
- double opacity_goal = sp_desktop_get_master_opacity_tool(desktop, "tools.tweak", &do_opacity);
+ guint32 fill_goal = sp_desktop_get_color_tool(desktop, "/tools/tweak", true, &do_fill);
+ guint32 stroke_goal = sp_desktop_get_color_tool(desktop, "/tools/tweak", false, &do_stroke);
+ double opacity_goal = sp_desktop_get_master_opacity_tool(desktop, "/tools/tweak", &do_opacity);
if (reverse) {
+#if 0
+ // HSL inversion
+ float hsv[3];
+ float rgb[3];
+ sp_color_rgb_to_hsv_floatv (hsv,
+ SP_RGBA32_R_F(fill_goal),
+ SP_RGBA32_G_F(fill_goal),
+ SP_RGBA32_B_F(fill_goal));
+ sp_color_hsv_to_rgb_floatv (rgb, hsv[0]<.5? hsv[0]+.5 : hsv[0]-.5, 1 - hsv[1], 1 - hsv[2]);
+ fill_goal = SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1);
+ sp_color_rgb_to_hsv_floatv (hsv,
+ SP_RGBA32_R_F(stroke_goal),
+ SP_RGBA32_G_F(stroke_goal),
+ SP_RGBA32_B_F(stroke_goal));
+ sp_color_hsv_to_rgb_floatv (rgb, hsv[0]<.5? hsv[0]+.5 : hsv[0]-.5, 1 - hsv[1], 1 - hsv[2]);
+ stroke_goal = SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1);
+#else
+ // RGB inversion
fill_goal = SP_RGBA32_U_COMPOSE(
(255 - SP_RGBA32_R_U(fill_goal)),
(255 - SP_RGBA32_G_U(fill_goal)),
@@ -1052,6 +1080,7 @@ sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point v
(255 - SP_RGBA32_G_U(stroke_goal)),
(255 - SP_RGBA32_B_U(stroke_goal)),
(255 - SP_RGBA32_A_U(stroke_goal)));
+#endif
opacity_goal = 1 - opacity_goal;
}
@@ -1111,11 +1140,12 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift)
void
sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Juggling about so that prefs have the old value but tc->mode and the button show new mode:
- gint now_mode = prefs_get_int_attribute("tools.tweak", "mode", 0);
+ gint now_mode = prefs->getInt("/tools/tweak/mode", 0);
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode);
// button has changed prefs, restore
- prefs_set_int_attribute("tools.tweak", "mode", now_mode);
+ prefs->setInt("/tools/tweak/mode", now_mode);
// changing prefs changed tc->mode, restore back :)
tc->mode = mode;
sp_tweak_update_cursor (tc, with_shift);
@@ -1453,7 +1483,8 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
}
break;
- case GDK_KEY_RELEASE:
+ case GDK_KEY_RELEASE: {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
switch (get_group0_keyval(&event->key)) {
case GDK_Shift_L:
case GDK_Shift_R:
@@ -1461,13 +1492,14 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
break;
case GDK_Control_L:
case GDK_Control_R:
- sp_tweak_switch_mode (tc, prefs_get_int_attribute("tools.tweak", "mode", 0), MOD__SHIFT);
+ sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT);
tc->_message_context->clear();
break;
default:
- sp_tweak_switch_mode (tc, prefs_get_int_attribute("tools.tweak", "mode", 0), MOD__SHIFT);
+ sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT);
break;
}
+ }
default:
break;
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 09521008b..e76af958f 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -863,7 +863,7 @@ bool ClipboardManagerImpl::_pasteImage()
strftime(image_filename, 128, "inkscape_pasted_image_%Y%m%d_%H%M%S.png", localtime( &rawtime ));
/// @todo Check whether the encoding is correct here
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- std::string save_folder = Glib::filename_from_utf8(prefs->getString("dialogs.save_as", "path"));
+ std::string save_folder = Glib::filename_from_utf8(prefs->getString("/dialogs/save_as/path"));
gchar *image_path = g_build_filename(save_folder.data(), image_filename, NULL);
img->save(image_path, "png");
diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp
index aa93ffed9..98ad9dc7b 100644
--- a/src/ui/context-menu.cpp
+++ b/src/ui/context-menu.cpp
@@ -50,11 +50,13 @@ sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu)
#include "document.h"
#include "desktop-handles.h"
#include "selection.h"
-
+#include "selection-chemistry.h"
#include "dialogs/item-properties.h"
#include "dialogs/object-attributes.h"
#include "sp-path.h"
+#include "sp-clippath.h"
+#include "sp-mask.h"
static void sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu);
@@ -85,7 +87,10 @@ sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *m
static void sp_item_properties(GtkMenuItem *menuitem, SPItem *item);
static void sp_item_select_this(GtkMenuItem *menuitem, SPItem *item);
static void sp_item_create_link(GtkMenuItem *menuitem, SPItem *item);
-
+static void sp_set_mask(GtkMenuItem *menuitem, SPItem *item);
+static void sp_release_mask(GtkMenuItem *menuitem, SPItem *item);
+static void sp_set_clip(GtkMenuItem *menuitem, SPItem *item);
+static void sp_release_clip(GtkMenuItem *menuitem, SPItem *item);
/* Generate context menu item section */
static void
@@ -123,6 +128,51 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item));
gtk_widget_show(w);
gtk_menu_append(GTK_MENU(m), w);
+ /* Set mask */
+ w = gtk_menu_item_new_with_mnemonic(_("Set Mask"));
+ gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
+ gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_mask), item);
+ if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) {
+ gtk_widget_set_sensitive(w, FALSE);
+ } else {
+ gtk_widget_set_sensitive(w, TRUE);
+ }
+ gtk_widget_show(w);
+ gtk_menu_append(GTK_MENU(m), w);
+ /* Release mask */
+ w = gtk_menu_item_new_with_mnemonic(_("Release Mask"));
+ gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
+ gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_mask), item);
+ if (item && item->mask_ref && item->mask_ref->getObject()) {
+ gtk_widget_set_sensitive(w, TRUE);
+ } else {
+ gtk_widget_set_sensitive(w, FALSE);
+ }
+ gtk_widget_show(w);
+ gtk_menu_append(GTK_MENU(m), w);
+ /* Set Clip */
+ w = gtk_menu_item_new_with_mnemonic(_("Set Clip"));
+ gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
+ gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_clip), item);
+ if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) {
+ gtk_widget_set_sensitive(w, FALSE);
+ } else {
+ gtk_widget_set_sensitive(w, TRUE);
+ }
+ gtk_widget_show(w);
+ gtk_menu_append(GTK_MENU(m), w);
+ /* Release Clip */
+ w = gtk_menu_item_new_with_mnemonic(_("Release Clip"));
+ gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
+ gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_clip), item);
+ if (item && item->clip_ref && item->clip_ref->getObject()) {
+ gtk_widget_set_sensitive(w, TRUE);
+ } else {
+ gtk_widget_set_sensitive(w, FALSE);
+ }
+ gtk_widget_show(w);
+ gtk_menu_append(GTK_MENU(m), w);
+
}
static void
@@ -140,6 +190,63 @@ sp_item_properties(GtkMenuItem *menuitem, SPItem *item)
sp_item_dialog();
}
+
+static void
+sp_set_mask(GtkMenuItem *menuitem, SPItem *item)
+{
+ SPDesktop *desktop;
+
+ g_assert(SP_IS_ITEM(item));
+
+ desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
+ g_return_if_fail(desktop != NULL);
+
+ sp_selection_set_mask(desktop, false, false);
+}
+
+
+static void
+sp_release_mask(GtkMenuItem *menuitem, SPItem *item)
+{
+ SPDesktop *desktop;
+
+ g_assert(SP_IS_ITEM(item));
+
+ desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
+ g_return_if_fail(desktop != NULL);
+
+ sp_selection_unset_mask(desktop, false);
+}
+
+
+static void
+sp_set_clip(GtkMenuItem *menuitem, SPItem *item)
+{
+ SPDesktop *desktop;
+
+ g_assert(SP_IS_ITEM(item));
+
+ desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
+ g_return_if_fail(desktop != NULL);
+
+ sp_selection_set_mask(desktop, true, false);
+}
+
+
+static void
+sp_release_clip(GtkMenuItem *menuitem, SPItem *item)
+{
+ SPDesktop *desktop;
+
+ g_assert(SP_IS_ITEM(item));
+
+ desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
+ g_return_if_fail(desktop != NULL);
+
+ sp_selection_unset_mask(desktop, true);
+}
+
+
static void
sp_item_select_this(GtkMenuItem *menuitem, SPItem *item)
{
@@ -322,12 +429,12 @@ sp_image_image_properties(GtkMenuItem */*menuitem*/, SPAnchor *anchor)
static gchar* getImageEditorName() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gchar* value = 0;
- Glib::ustring choices = prefs->getString("options.bitmapeditor", "choices");
+ Glib::ustring choices = prefs->getString("/options/bitmapeditor/choices");
if (!choices.empty()) {
gchar** splits = g_strsplit(choices.data(), ",", 0);
gint numIems = g_strv_length(splits);
- int setting = prefs->getIntLimited("options.bitmapeditor", "value", 0, 0, numIems);
+ int setting = prefs->getIntLimited("/options/bitmapeditor/value", 0, 0, numIems);
value = g_strdup(splits[setting]);
g_strfreev(splits);
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 9a17ed20c..261a586b4 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief AboutBox - the Inkscape about dialog
- *
- * Authors:
+/** @file
+ * @brief Inkscape About box - implementation
+ */
+/* Authors:
* Derek P. Moore <derekm@hackunix.org>
* MenTaLguY <mental@rydia.net>
* Kees Cook <kees@outflux.net>
diff --git a/src/ui/dialog/aboutbox.h b/src/ui/dialog/aboutbox.h
index ebd7e0a53..622b1324f 100644
--- a/src/ui/dialog/aboutbox.h
+++ b/src/ui/dialog/aboutbox.h
@@ -1,10 +1,10 @@
-/**
- * \brief About Widget - Adds the "about" doc to the Gnome::UI::About Class
+/** @file
+ * @brief Inkscape About box
*
* The standard Gnome::UI::About class doesn't include a place to stuff
* a renderable View that holds the classic Inkscape "about.svg".
- *
- * Author:
+ */
+/* Author:
* Kees Cook <kees@outflux.net>
*
* Copyright (C) 2005 Kees Cook
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index b8b59230a..367a744c7 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief Align and Distribute dialog
- *
- * Authors:
+/** @file
+ * @brief Align and Distribute dialog - implementation
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Aubanel MONNIER <aubi@libertysurf.fr>
* Frank Felfe <innerspace@iname.com>
@@ -39,7 +39,7 @@
#include "desktop-handles.h"
#include "macros.h"
#include "sp-item-transform.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "enums.h"
#include "sp-text.h"
@@ -122,7 +122,8 @@ private :
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (!selection) return;
- bool sel_as_group = (prefs_get_int_attribute("dialogs.align", "sel-as-groups", 0) != 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups");
using Inkscape::Util::GSListConstIterator;
std::list<SPItem *> selected;
@@ -211,8 +212,8 @@ private :
// a selected original, they will be unmoved too, possibly contrary to user's
// expecation. However this is a minor point compared to making align/distribute always
// work as expected, and "unmoved" is the default option anyway.
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
bool changed = false;
boost::optional<Geom::Rect> b;
@@ -239,7 +240,7 @@ private :
}
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
if (changed) {
sp_document_done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
@@ -339,8 +340,9 @@ private :
std::sort(sorted.begin(), sorted.end());
// see comment in ActionAlign above
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
unsigned int len = sorted.size();
bool changed = false;
@@ -397,7 +399,7 @@ private :
}
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
if (changed) {
sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
@@ -497,8 +499,9 @@ private :
if (!_dialog.getDesktop()) return;
// see comment in ActionAlign above
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
// xGap and yGap are the minimum space required between bounding rectangles.
double const xGap = removeOverlapXGap.get_value();
@@ -507,7 +510,7 @@ private :
xGap, yGap);
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Remove overlaps"));
@@ -531,13 +534,14 @@ private :
if (!_dialog.getDesktop()) return;
// see comment in ActionAlign above
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ 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());
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Arrange connector network"));
@@ -561,13 +565,14 @@ private :
if (!_dialog.getDesktop()) return;
// see comment in ActionAlign above
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ 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());
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Unclump"));
@@ -615,8 +620,9 @@ private :
}
// see comment in ActionAlign above
- int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
+ prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
for (std::list<SPItem *>::iterator it(selected.begin());
it != selected.end();
@@ -631,13 +637,13 @@ private :
double y = _dialog.randomize_bbox->min()[Geom::Y] + (*item_box)[Geom::Y].extent()/2 +
g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box)[Geom::Y].extent());
// displacement is the new center minus old:
- NR::Point t = NR::Point (x, y) - 0.5*(item_box->max() + item_box->min());
+ Geom::Point t = Geom::Point (x, y) - 0.5*(item_box->max() + item_box->min());
sp_item_move_rel(*it, Geom::Translate(t));
}
}
// restore compensation setting
- prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
_("Randomize positions"));
@@ -783,7 +789,7 @@ void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selecti
AlignAndDistribute::AlignAndDistribute()
- : UI::Widget::Panel ("", "dialogs.align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE),
+ : UI::Widget::Panel ("", "/dialogs/align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE),
randomize_bbox(),
_alignFrame(_("Align")),
_distributeFrame(_("Distribute")),
@@ -798,6 +804,7 @@ AlignAndDistribute::AlignAndDistribute()
_anchorLabel(_("Relative to: ")),
_selgrpLabel(_("Treat selection as group: "))
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
//Instanciate the align buttons
addAlignButton("al_left_out",
@@ -917,7 +924,7 @@ AlignAndDistribute::AlignAndDistribute()
_combo.append_text(_("Drawing"));
_combo.append_text(_("Selection"));
- _combo.set_active(prefs_get_int_attribute("dialogs.align", "align-to", 6));
+ _combo.set_active(prefs->getInt("/dialogs/align/align-to", 6));
_combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change));
_anchorBox.pack_start(_anchorLabel);
@@ -925,7 +932,7 @@ AlignAndDistribute::AlignAndDistribute()
_selgrpBox.pack_start(_selgrpLabel);
_selgrpBox.pack_start(_selgrp);
- _selgrp.set_active(prefs_get_int_attribute("dialogs.align", "sel-as-groups", 0));
+ _selgrp.set_active(prefs->getBool("/dialogs/align/sel-as-groups"));
_selgrp.signal_toggled().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_selgrp_toggled));
_alignBox.pack_start(_anchorBox);
@@ -972,15 +979,15 @@ AlignAndDistribute::~AlignAndDistribute()
}
void AlignAndDistribute::on_ref_change(){
-
- prefs_set_int_attribute("dialogs.align", "align-to", _combo.get_active_row_number());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/dialogs/align/align-to", _combo.get_active_row_number());
//Make blink the master
}
void AlignAndDistribute::on_selgrp_toggled(){
-
- prefs_set_int_attribute("dialogs.align", "sel-as-groups", _selgrp.get_active());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/dialogs/align/sel-as-groups", _selgrp.get_active());
//Make blink the master
}
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index e2bb68fe5..3d6b5984e 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -1,7 +1,7 @@
-/**
- * \brief Align and Distribute dialog
- *
- * Authors:
+/** @file
+ * @brief Align and Distribute dialog
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Aubanel MONNIER <aubi@libertysurf.fr>
* Frank Felfe <innerspace@iname.com>
diff --git a/src/ui/dialog/behavior.h b/src/ui/dialog/behavior.h
index 4b5fe06b8..fbe42c2fb 100644
--- a/src/ui/dialog/behavior.h
+++ b/src/ui/dialog/behavior.h
@@ -1,7 +1,7 @@
-/**
- * \brief Dialog behavior interface
- *
- * Author:
+/** @file
+ * @brief Dialog behavior interface
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 227814cd1..e73200a1f 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -45,6 +45,7 @@
#include "ui/dialog/floating-behavior.h"
#include "ui/dialog/dock-behavior.h"
+#include "preferences.h"
namespace Inkscape {
namespace UI {
@@ -84,7 +85,8 @@ DialogManager::DialogManager() {
using namespace Behavior;
using namespace Inkscape::UI::Dialogs; // temporary
- int dialogs_type = prefs_get_int_attribute_limited ("options.dialogtype", "value", DOCK, 0, 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int dialogs_type = prefs->getIntLimited("/options/dialogtype/value", DOCK, 0, 1);
if (dialogs_type == FLOATING) {
@@ -150,7 +152,8 @@ DialogManager::~DialogManager() {
DialogManager &DialogManager::getInstance()
{
- int dialogs_type = prefs_get_int_attribute_limited ("options.dialogtype", "value", DOCK, 0, 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int dialogs_type = prefs->getIntLimited("/options/dialogtype/value", DOCK, 0, 1);
/* Use singleton behavior for floating dialogs */
if (dialogs_type == FLOATING) {
diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h
index 80070f19c..a97b58ce3 100644
--- a/src/ui/dialog/dialog-manager.h
+++ b/src/ui/dialog/dialog-manager.h
@@ -1,8 +1,8 @@
-/**
- * \brief Object for managing a set of dialogs, including their signals and
+/** @file
+ * @brief Object for managing a set of dialogs, including their signals and
* construction/caching/destruction of them.
- *
- * Author:
+ */
+/* Author:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Jon Phillips <jon@rejon.org>
*
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 1361b4977..2b39eb3c9 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -1,8 +1,7 @@
-/**
- * \brief Base class for dialogs in Inkscape. This class provides certain
- * common behaviors and styles wanted of all dialogs in the application.
- *
- * Authors:
+/** @file
+ * @brief Base class for dialogs in Inkscape - implementation
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* buliabyak@gmail.com
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
@@ -30,7 +29,7 @@
#include "dialog-manager.h"
#include "modifier-fns.h"
#include "shortcuts.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "interface.h"
#include "verbs.h"
@@ -206,10 +205,11 @@ Dialog::read_geometry()
{
_user_hidden = false;
- int x = prefs_get_int_attribute (_prefs_path, "x", -1000);
- int y = prefs_get_int_attribute (_prefs_path, "y", -1000);
- int w = prefs_get_int_attribute (_prefs_path, "w", 0);
- int h = prefs_get_int_attribute (_prefs_path, "h", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int x = prefs->getInt(_prefs_path + "/x", -1000);
+ int y = prefs->getInt(_prefs_path + "/y", -1000);
+ int w = prefs->getInt(_prefs_path + "/w", 0);
+ int h = prefs->getInt(_prefs_path + "/h", 0);
// g_print ("read %d %d %d %d\n", x, y, w, h);
@@ -245,10 +245,11 @@ Dialog::save_geometry()
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (_prefs_path, "x", x);
- prefs_set_int_attribute (_prefs_path, "y", y);
- prefs_set_int_attribute (_prefs_path, "w", w);
- prefs_set_int_attribute (_prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/x", x);
+ prefs->setInt(_prefs_path + "/y", y);
+ prefs->setInt(_prefs_path + "/w", w);
+ prefs->setInt(_prefs_path + "/h", h);
}
diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h
index a1229fb94..1a59a236c 100644
--- a/src/ui/dialog/dialog.h
+++ b/src/ui/dialog/dialog.h
@@ -1,9 +1,7 @@
-/**
- * \brief Base class for dialogs in Inkscape. This class provides certain common behaviors and
- * styles wanted of all dialogs in the application. Fundamental parts of the dialog's
- * behavior is controlled by a Dialog::Behavior subclass instance connected to the dialog.
- *
- * Author:
+/** @file
+ * @brief Base class for dialogs in Inkscape
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Gustav Broberg <broberg@kth.se>
*
@@ -38,6 +36,12 @@ void sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpoi
gboolean sp_retransientize_again(gpointer dlgPtr);
void sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr);
+/**
+ * @brief Base class for Inkscape dialogs
+ * This class provides certain common behaviors and styles wanted of all dialogs
+ * in the application. Fundamental parts of the dialog's behavior are controlled by
+ * a Dialog::Behavior subclass instance connected to the dialog.
+ */
class Dialog {
public:
@@ -83,7 +87,7 @@ public:
bool retransientize_suppress; // when true, do not retransientize (prevents races when switching new windows too fast)
protected:
- const char *_prefs_path;
+ Glib::ustring const _prefs_path;
int _verb_num;
Glib::ustring _title;
Glib::ustring _apply_label;
diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp
index 6f3df89da..6b7a9b697 100644
--- a/src/ui/dialog/dock-behavior.cpp
+++ b/src/ui/dialog/dock-behavior.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief A dockable dialog implementation.
- *
- * Author:
+/** @file
+ * @brief A dockable dialog implementation.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
@@ -22,7 +22,7 @@
#include "ui/widget/dock.h"
#include "verbs.h"
#include "dialog.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "dialogs/dialog-events.h"
#include <gtkmm/invisible.h>
@@ -44,7 +44,7 @@ DockBehavior::DockBehavior(Dialog &dialog) :
(Inkscape::Verb::get(dialog._verb_num)->get_image() ?
Inkscape::Verb::get(dialog._verb_num)->get_image() : ""),
static_cast<Widget::DockItem::State>(
- prefs_get_int_attribute (_dialog._prefs_path, "state",
+ Inkscape::Preferences::get()->getInt(_dialog._prefs_path + "/state",
UI::Widget::DockItem::DOCKED_STATE)))
{
// Connect signals
@@ -178,7 +178,8 @@ DockBehavior::_onHide()
{
_dialog.save_geometry();
_dialog._user_hidden = true;
- prefs_set_int_attribute (_dialog._prefs_path, "state", _dock_item.getPrevState());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_dialog._prefs_path + "/state", _dock_item.getPrevState());
}
void
@@ -186,7 +187,8 @@ DockBehavior::_onStateChanged(Widget::DockItem::State /*prev_state*/,
Widget::DockItem::State new_state)
{
// TODO probably need to avoid window calls unless the state is different. Check.
- prefs_set_int_attribute (_dialog._prefs_path, "state", new_state);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_dialog._prefs_path + "/state", new_state);
if (new_state == Widget::DockItem::FLOATING_STATE) {
if (Gtk::Window *floating_win = _dock_item.getWindow())
@@ -210,13 +212,15 @@ DockBehavior::onShowF12()
void
DockBehavior::onShutdown()
{
- prefs_set_int_attribute (_dialog._prefs_path, "state", _dock_item.getPrevState());
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_dialog._prefs_path + "/state", _dock_item.getPrevState());
}
void
DockBehavior::onDesktopActivated(SPDesktop *desktop)
{
- gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint transient_policy = prefs->getIntLimited( "/options/transientpolicy/value", 1, 0, 2);
#ifdef WIN32 // Win32 special code to enable transient dialogs
transient_policy = 2;
diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h
index d873bfb0a..7f0d0ece0 100644
--- a/src/ui/dialog/dock-behavior.h
+++ b/src/ui/dialog/dock-behavior.h
@@ -1,7 +1,7 @@
-/**
- * \brief A dockable dialog implementation.
- *
- * Author:
+/** @file
+ * @brief A dockable dialog implementation.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp
index 5956cfb9b..32838309a 100644
--- a/src/ui/dialog/document-metadata.cpp
+++ b/src/ui/dialog/document-metadata.cpp
@@ -1,8 +1,7 @@
-/** \file
- *
- * Document metadata dialog, Gtkmm-style
- *
- * Authors:
+/** @file
+ * @brief Document metadata dialog, Gtkmm-style
+ */
+/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
@@ -67,9 +66,8 @@ DocumentMetadata::getInstance()
DocumentMetadata::DocumentMetadata()
- : UI::Widget::Panel ("", "dialogs.documentmetadata", SP_VERB_DIALOG_METADATA),
- _page_metadata1(1, 1), _page_metadata2(1, 1),
- _prefs_path("dialogs.documentmetadata")
+ : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA),
+ _page_metadata1(1, 1), _page_metadata2(1, 1)
{
hide();
_tt.enable();
@@ -255,9 +253,9 @@ on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h
index 1b5c08ce1..7f718e9f7 100644
--- a/src/ui/dialog/document-metadata.h
+++ b/src/ui/dialog/document-metadata.h
@@ -1,7 +1,7 @@
/** \file
* \brief Document Metadata dialog
- *
- * Authors:
+ */
+/* Authors:
* Ralf Stephan <ralf@ark.in-berlin.de>
* Bryce W. Harrington <bryce@bryceharrington.org>
*
@@ -62,7 +62,6 @@ protected:
RDElist _rdflist;
Licensor _licensor;
- gchar const *_prefs_path;
Registry _wr;
private:
@@ -80,9 +79,9 @@ private:
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index a2d5b50ed..7c738c503 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1,8 +1,7 @@
-/** \file
- *
- * Document properties dialog, Gtkmm-style
- *
- * Authors:
+/** @file
+ * @brief Document properties dialog, Gtkmm-style
+ */
+/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
@@ -28,7 +27,7 @@
#include "xml/node-event-vector.h"
#include "helper/units.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape.h"
#include "verbs.h"
@@ -81,7 +80,7 @@ DocumentProperties::getInstance()
}
DocumentProperties::DocumentProperties()
- : UI::Widget::Panel ("", "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
+ : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
_page_page(1, 1, true, true), _page_guides(1, 1),
_page_snap(1, 1), _page_snap_dtls(1, 1),
//---------------------------------------------------------------
@@ -115,6 +114,7 @@ DocumentProperties::DocumentProperties()
//---------------------------------------------------------------
//Applies to both nodes and guides, but not to bboxes, that's why its located here
_rcbic( _("Rotation _center"), _("Consider the rotation center of an object when snapping"), "inkscape:snap-center", _wr),
+ _rcbsm( _("_Smooth nodes"), _("Snap to smooth nodes too, instead of only snapping to cusp nodes"), "inkscape:snap-smooth-nodes", _wr),
_rcbsigg(_("_Grid with guides"), _("Snap to grid-guide intersections"), "inkscape:snap-intersection-grid-guide", _wr),
_rcbsils(_("_Paths"), _("Snap to intersections of paths ('snap to paths' must be enabled, see the previous tab)"),
"inkscape:snap-intersection-paths", _wr),
@@ -123,9 +123,8 @@ DocumentProperties::DocumentProperties()
//TRANSLATORS: In Grid|_New translate only the word _New. It ref to grid
_grids_button_new(Q_("Grid|_New"), _("Create new grid.")),
_grids_button_remove(_("_Remove"), _("Remove selected grid.")),
- _grids_label_def("", Gtk::ALIGN_LEFT),
+ _grids_label_def("", Gtk::ALIGN_LEFT)
//---------------------------------------------------------------
- _prefs_path("dialogs.documentoptions")
{
_tt.enable();
_getContents()->set_spacing (4);
@@ -376,6 +375,7 @@ DocumentProperties::build_snap_dtls()
0, 0,
label_m, 0,
0, &_rcbic,
+ 0, &_rcbsm
};
attach_all(_page_snap_dtls.table(), array, G_N_ELEMENTS(array));
@@ -496,12 +496,13 @@ DocumentProperties::update()
//-----------------------------------------------------------snap
- _rcbsnbb.setActive (nv->snap_manager.getSnapModeBBox());
- _rcbsnn.setActive (nv->snap_manager.getSnapModeNode());
- _rcbsng.setActive (nv->snap_manager.getSnapModeGuide());
- _rcbic.setActive (nv->snap_manager.getIncludeItemCenter());
- _rcbsigg.setActive (nv->snap_manager.getSnapIntersectionGG());
- _rcbsils.setActive (nv->snap_manager.getSnapIntersectionCS());
+ _rcbsnbb.setActive (nv->snap_manager.snapprefs.getSnapModeBBox());
+ _rcbsnn.setActive (nv->snap_manager.snapprefs.getSnapModeNode());
+ _rcbsng.setActive (nv->snap_manager.snapprefs.getSnapModeGuide());
+ _rcbic.setActive (nv->snap_manager.snapprefs.getIncludeItemCenter());
+ _rcbsm.setActive (nv->snap_manager.snapprefs.getSnapSmoothNodes());
+ _rcbsigg.setActive (nv->snap_manager.snapprefs.getSnapIntersectionGG());
+ _rcbsils.setActive (nv->snap_manager.snapprefs.getSnapIntersectionCS());
_rcbsnop.setActive(nv->snap_manager.object.getSnapToItemPath());
_rcbsnon.setActive(nv->snap_manager.object.getSnapToItemNode());
_rcbsnbbp.setActive(nv->snap_manager.object.getSnapToBBoxPath());
@@ -513,7 +514,7 @@ DocumentProperties::update()
_rsu_gusn.setValue (nv->guidetolerance);
- _rcbs.setActive (nv->snap_manager.getSnapEnabledGlobally());
+ _rcbs.setActive (nv->snap_manager.snapprefs.getSnapEnabledGlobally());
_rcbsi.setActive (nv->snapindicator);
//-----------------------------------------------------------grids page
@@ -666,9 +667,9 @@ DocumentProperties::onRemoveGrid()
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index a8750a32b..ab70b0d07 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -1,7 +1,7 @@
/** \file
* \brief Document Properties dialog
- *
- * Authors:
+ */
+/* Authors:
* Ralf Stephan <ralf@ark.in-berlin.de>
* Bryce W. Harrington <bryce@bryceharrington.org>
*
@@ -78,7 +78,7 @@ protected:
RegisteredCheckButton _rcbsnon, _rcbsnbbp, _rcbsnbbn, _rcbsnpb;
ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn;
//---------------------------------------------------------------
- RegisteredCheckButton _rcbic;
+ RegisteredCheckButton _rcbic, _rcbsm;
RegisteredCheckButton _rcbsigg, _rcbsils;
//---------------------------------------------------------------
Gtk::Notebook _grids_notebook;
@@ -91,8 +91,6 @@ protected:
Gtk::HBox _grids_space;
//---------------------------------------------------------------
- gchar const *_prefs_path;
-
Gtk::HBox& _createPageTabLabel(const Glib::ustring& label, const char *label_image);
private:
@@ -114,9 +112,9 @@ private:
Local Variables:
mode:c++
c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp
index a92087668..c2f3426fd 100644
--- a/src/ui/dialog/extension-editor.cpp
+++ b/src/ui/dialog/extension-editor.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief Extension editor dialog
- *
- * Authors:
+/** @file
+ * @brief Extension editor dialog
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Ted Gould <ted@gould.cx>
*
@@ -43,7 +43,7 @@ namespace Dialog {
a new extension is selected, the notebooks are changed appropriately.
*/
ExtensionEditor::ExtensionEditor()
- : UI::Widget::Panel ("", "dialogs.extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR)
+ : UI::Widget::Panel ("", "/dialogs/extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR)
{
_notebook_info.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
_notebook_help.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
@@ -85,7 +85,7 @@ ExtensionEditor::ExtensionEditor()
Inkscape::Extension::db.foreach(dbfunc, this);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring defaultext = prefs->getString("dialogs.extensioneditor", "selected-extension");
+ Glib::ustring defaultext = prefs->getString("/dialogs/extensioneditor/selected-extension");
if (defaultext.empty()) defaultext = "org.inkscape.input.svg";
this->setExtension(defaultext);
@@ -137,7 +137,7 @@ ExtensionEditor::on_pagelist_selection_changed (void)
/* Set the selection in the preferences */
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("dialogs.extensioneditor", "selected-extension", id);
+ prefs->setString("/dialogs/extensioneditor/selected-extension", id);
/* Adjust the dialog's title */
gchar title[500];
diff --git a/src/ui/dialog/extension-editor.h b/src/ui/dialog/extension-editor.h
index cfda36856..fe171f60c 100644
--- a/src/ui/dialog/extension-editor.h
+++ b/src/ui/dialog/extension-editor.h
@@ -1,7 +1,7 @@
-/**
- * \brief Extension editor
- *
- * Authors:
+/** @file
+ * @brief Extension editor dialog
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Ted Gould <ted@gould.cx>
*
diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp
index b1ea5dfee..172edf8a5 100644
--- a/src/ui/dialog/filedialog.cpp
+++ b/src/ui/dialog/filedialog.cpp
@@ -1,7 +1,7 @@
-/**
- * Implementation of the file dialog interfaces defined in filedialog.h
- *
- * Authors:
+/** @file
+ * @brief Implementation of the file dialog interfaces defined in filedialog.h
+ */
+/* Authors:
* Bob Jamison
* Joel Holdsworth
* Other dudes from The Inkscape Organization
@@ -194,4 +194,4 @@ void FileSaveDialog::appendExtension(Glib::ustring& path, Inkscape::Extension::O
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/filedialog.h b/src/ui/dialog/filedialog.h
index eda8c4eb4..52dcd1b23 100644
--- a/src/ui/dialog/filedialog.h
+++ b/src/ui/dialog/filedialog.h
@@ -1,10 +1,7 @@
-#ifndef __FILE_DIALOG_H__
-#define __FILE_DIALOG_H__
-/**
- * Defines the FileOpenDialog, FileSaveDialog, and FileExportDialog
- * and their supporting classes.
- *
- * Authors:
+/** @file
+ * @brief Virtual base definitions for native file dialogs
+ */
+/* Authors:
* Bob Jamison <rwjj@earthlink.net>
* Joel Holdsworth
* Inkscape Guys
@@ -16,6 +13,9 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#ifndef __FILE_DIALOG_H__
+#define __FILE_DIALOG_H__
+
#include <glibmm.h>
#include <vector>
#include <set>
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 541eb388b..379d43fbf 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -1,7 +1,7 @@
-/**
- * Implementation of the file dialog interfaces defined in filedialogimpl.h
- *
- * Authors:
+/** @file
+ * @brief Implementation of the file dialog interfaces defined in filedialogimpl.h
+ */
+/* Authors:
* Bob Jamison
* Joel Holdsworth
* Bruno Dilly
@@ -24,6 +24,7 @@
#include "interface.h"
#include "io/sys.h"
#include "path-prefix.h"
+#include "preferences.h"
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
@@ -570,9 +571,8 @@ SVGPreview::~SVGPreview()
void FileDialogBaseGtk::internalSetup()
{
- bool enablePreview =
- (bool)prefs_get_int_attribute( preferenceBase.c_str(),
- "enable_preview", 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool enablePreview = prefs->getBool( preferenceBase + "/enable_preview", true);
previewCheckbox.set_label( Glib::ustring(_("Enable preview")) );
previewCheckbox.set_active( enablePreview );
@@ -594,9 +594,9 @@ void FileDialogBaseGtk::internalSetup()
void FileDialogBaseGtk::cleanup( bool showConfirmed )
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if ( showConfirmed )
- prefs_set_int_attribute( preferenceBase.c_str(),
- "enable_preview", previewCheckbox.get_active() );
+ prefs->setBool( preferenceBase + "/enable_preview", previewCheckbox.get_active() );
}
@@ -643,7 +643,7 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow,
const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title) :
- FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "dialogs.open")
+ FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "/dialogs/open")
{
@@ -851,7 +851,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow,
const Glib::ustring &title,
const Glib::ustring &/*default_key*/,
const gchar* docTitle) :
- FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
+ FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/save_as")
{
FileSaveDialog::myDocTitle = docTitle;
@@ -887,9 +887,9 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow,
//createFilterMenu();
//###### Do we want the .xxx extension automatically added?
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically")));
- fileTypeCheckbox.set_active( (bool)prefs_get_int_attribute("dialogs.save_as",
- "append_extension", 1) );
+ fileTypeCheckbox.set_active(prefs->getBool("/dialogs/save_as/append_extension", true));
createFileTypeMenu();
fileTypeComboBox.set_size_request(200,40);
@@ -1071,27 +1071,23 @@ FileSaveDialogImplGtk::show()
set_preview_widget_active(false);
hide();
- if (b == Gtk::RESPONSE_OK)
- {
+ if (b == Gtk::RESPONSE_OK) {
updateNameAndExtension();
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
// Store changes of the "Append filename automatically" checkbox back to preferences.
- prefs_set_int_attribute("dialogs.save_as", "append_extension", fileTypeCheckbox.get_active());
+ prefs->setBool("/dialogs/save_as/append_extension", fileTypeCheckbox.get_active());
// Store the last used save-as filetype to preferences.
- prefs_set_string_attribute("dialogs.save_as", "default",
- ( extension != NULL ? extension->get_id() : "" ));
+ prefs->setString("/dialogs/save_as/default", ( extension != NULL ? extension->get_id() : "" ));
cleanup( true );
return TRUE;
- }
- else
- {
+ } else {
cleanup( false );
-
return FALSE;
- }
+ }
}
@@ -1314,7 +1310,7 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &/*default_key*/ ) :
- FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
+ FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/export"),
sourceX0Spinner("X0", _("Left edge of source")),
sourceY0Spinner("Y0", _("Top edge of source")),
sourceX1Spinner("X1", _("Right edge of source")),
@@ -1325,7 +1321,8 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow,
destHeightSpinner("Height", _("Destination height")),
destDPISpinner("DPI", _("Resolution (dots per inch)"))
{
- append_extension = (bool)prefs_get_int_attribute("dialogs.save_as", "append_extension", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ append_extension = prefs->getBool("/dialogs/save_as/append_extension", true);
/* One file at a time */
set_select_multiple(false);
@@ -1534,9 +1531,9 @@ FileExportDialogImpl::show()
// FIXME: Why do we have more code
append_extension = checkbox.get_active();
- prefs_set_int_attribute("dialogs.save_as", "append_extension", append_extension);
- prefs_set_string_attribute("dialogs.save_as", "default",
- ( extension != NULL ? extension->get_id() : "" ));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/dialogs/save_as/append_extension", append_extension);
+ prefs->setBool("/dialogs/save_as/default", ( extension != NULL ? extension->get_id() : "" ));
*/
return TRUE;
}
@@ -1580,4 +1577,4 @@ FileExportDialogImpl::getFilename()
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h
index 5137b8481..1ac259221 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.h
+++ b/src/ui/dialog/filedialogimpl-gtkmm.h
@@ -1,9 +1,9 @@
#ifndef __FILE_DIALOGIMPL_H__
#define __FILE_DIALOGIMPL_H__
-/**
- * Implementation of the file dialog interfaces defined in filedialogimpl.h
- *
- * Authors:
+/** @file
+ * @brief Implementation of the file dialog interfaces defined in filedialogimpl.h
+ */
+/* Authors:
* Bob Jamison
* Joel Holdsworth
* Bruno Dilly
@@ -39,18 +39,13 @@
//Another hack
#include <gtk/gtkentry.h>
#include <gtk/gtkexpander.h>
-#ifdef WITH_GNOME_VFS
-# include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized
-#endif
//Inkscape includes
-#include "prefs-utils.h"
-#include <extension/input.h>
-#include <extension/output.h>
-#include <extension/db.h>
+#include "extension/input.h"
+#include "extension/output.h"
+#include "extension/db.h"
#include "inkscape.h"
#include "svg-view-widget.h"
-#include "gc-core.h"
//For export dialog
#include "ui/widget/scalar-unit.h"
@@ -192,7 +187,7 @@ public:
protected:
void cleanup( bool showConfirmed );
- Glib::ustring preferenceBase;
+ Glib::ustring const preferenceBase;
/**
* What type of 'open' are we? (open, import, place, etc)
*/
@@ -571,9 +566,9 @@ private:
};
-}
-}
-}
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
#endif /*__FILE_DIALOGIMPL_H__*/
@@ -586,4 +581,4 @@ private:
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index e1479d3b4..77a42df99 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -1,7 +1,7 @@
-/**
- * Implementation of the file dialog interfaces defined in filedialog.h for Win32
- *
- * Authors:
+/** @file
+ * @brief Implementation of native file dialogs for Win32
+ */
+/* Authors:
* Joel Holdsworth
* The Inkscape Organization
*
@@ -29,7 +29,6 @@
//Inkscape includes
#include "inkscape.h"
-#include "prefs-utils.h"
#include <dialogs/dialog-events.h>
#include <extension/input.h>
#include <extension/output.h>
@@ -1710,4 +1709,4 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h
index 3a0c3775b..bb026169a 100644
--- a/src/ui/dialog/filedialogimpl-win32.h
+++ b/src/ui/dialog/filedialogimpl-win32.h
@@ -1,7 +1,7 @@
-/**
- * Implementation of the file dialog interfaces defined in filedialog.h for Win32
- *
- * Authors:
+/** @file
+ * @brief Implementation of native file dialogs for Win32
+ */
+/* Authors:
* Joel Holdsworth
* The Inkscape Organization
*
@@ -367,4 +367,4 @@ private:
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index 50b2a5c79..a05c20b36 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -1,8 +1,9 @@
-/**
- * \brief Fill and Stroke dialog,
- * based on sp_object_properties_dialog
+/** @file
+ * @brief Fill and Stroke dialog - implementation
*
- * Authors:
+ * Based on the old sp_object_properties_dialog.
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Gustav Broberg <broberg@kth.se>
*
@@ -11,10 +12,6 @@
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include "desktop-handles.h"
#include "desktop-style.h"
#include "document.h"
@@ -39,7 +36,7 @@ namespace UI {
namespace Dialog {
FillAndStroke::FillAndStroke()
- : UI::Widget::Panel ("", "dialogs.fillstroke", SP_VERB_DIALOG_FILL_STROKE),
+ : UI::Widget::Panel ("", "/dialogs/fillstroke", SP_VERB_DIALOG_FILL_STROKE),
_page_fill(1, 1, true, true),
_page_stroke_paint(1, 1, true, true),
_page_stroke_style(1, 1, true, true),
diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h
index 37aa4ccc8..7dc892fea 100644
--- a/src/ui/dialog/fill-and-stroke.h
+++ b/src/ui/dialog/fill-and-stroke.h
@@ -1,8 +1,7 @@
-/**
- * \brief Fill and Stroke dialog
- * based on sp_object_properties_dialog
- *
- * Authors:
+/** @file
+ * @brief Fill and Stroke dialog
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Gustav Broberg <broberg@kth.se>
*
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 06bc0dd73..d31331a0d 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief Filter Effects dialog
- *
- * Authors:
+/** @file
+ * @brief Filter Effects dialog
+ */
+/* Authors:
* Nicholas Bishop <nicholasbishop@gmail.org>
* Rodrigo Kumpera <kumpera@gmail.com>
* Felipe C. da S. Sanches <felipe.sanches@gmail.com>
@@ -663,7 +663,7 @@ private:
//# Get the current directory for finding files
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring open_path;
- Glib::ustring attr = prefs->getString("dialogs.open", "path");
+ Glib::ustring attr = prefs->getString("/dialogs/open/path");
if (!attr.empty())
open_path = attr;
@@ -708,7 +708,7 @@ private:
open_path = fileName;
open_path.append(G_DIR_SEPARATOR_S);
- prefs->setString("dialogs.open", "path", open_path);
+ prefs->setString("/dialogs/open/path", open_path);
_entry.set_text(fileName);
}
@@ -2090,7 +2090,7 @@ int FilterEffectsDialog::PrimitiveList::primitive_count() const
/*** FilterEffectsDialog ***/
FilterEffectsDialog::FilterEffectsDialog()
- : UI::Widget::Panel("", "dialogs.filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS),
+ : UI::Widget::Panel("", "/dialogs/filtereffects", SP_VERB_DIALOG_FILTER_EFFECTS),
_add_primitive_type(FPConverter),
_add_primitive(_("Add Effect:")),
_empty_settings(_("No effect selected"), Gtk::ALIGN_LEFT),
@@ -2297,7 +2297,7 @@ void FilterEffectsDialog::add_primitive()
void FilterEffectsDialog::update_primitive_infobox()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs->getBool("options.showfiltersinfobox", "value", true)){
+ if (prefs->getBool("/options/showfiltersinfobox/value", true)){
_infobox_icon.show();
_infobox_desc.show();
} else {
@@ -2482,7 +2482,7 @@ void FilterEffectsDialog::update_settings_view()
_empty_settings.show();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs->getBool("options.showfiltersinfobox", "value", true)){
+ if (prefs->getBool("/options/showfiltersinfobox/value", true)){
_infobox_icon.show();
_infobox_desc.show();
} else {
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 9e39de2bb..0522b7a99 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -1,7 +1,7 @@
-/**
- * \brief Filter Effects dialog
- *
- * Authors:
+/** @file
+ * @brief Filter Effects dialog
+ */
+/* Authors:
* Nicholas Bishop <nicholasbishop@gmail.com>
* Rodrigo Kumpera <kumpera@gmail.com>
*
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index f59f2504c..b86234521 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -22,13 +22,12 @@
#include "helper/window.h"
#include "macros.h"
#include "inkscape.h"
-#include "document.h"
#include "desktop.h"
+#include "document.h"
#include "selection.h"
#include "desktop-handles.h"
#include "dialogs/dialog-events.h"
-#include "prefs-utils.h"
#include "verbs.h"
#include "interface.h"
#include "sp-text.h"
@@ -49,7 +48,7 @@
#include "sp-use.h"
#include "sp-image.h"
#include "sp-offset.h"
-#include <xml/repr.h>
+#include "xml/repr.h"
namespace Inkscape {
@@ -57,7 +56,7 @@ namespace UI {
namespace Dialog {
Find::Find()
- : UI::Widget::Panel("", "dialogs.find", SP_VERB_DIALOG_FIND),
+ : UI::Widget::Panel("", "/dialogs/find", SP_VERB_DIALOG_FIND),
_entry_text(_("_Text: "), _("Find objects by their text content (exact or partial match)")),
_entry_id(_("_ID: "), _("Find objects by the value of the id attribute (exact or partial match)")),
_entry_style(_("_Style: "), _("Find objects by the value of the style attribute (exact or partial match)")),
diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h
index 2d79b37ad..891df221f 100644
--- a/src/ui/dialog/find.h
+++ b/src/ui/dialog/find.h
@@ -1,7 +1,7 @@
-/**
- * \brief Find dialog
- *
- * Authors:
+/** @file
+ * @brief Find dialog
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
*
* Copyright (C) 2004, 2005 Authors
@@ -18,42 +18,14 @@
#include "ui/widget/button.h"
#include "ui/widget/entry.h"
#include <gtkmm/separator.h>
+#include <glib.h>
-#include "message-stack.h"
-#include "helper/window.h"
-#include "macros.h"
-#include "inkscape.h"
-#include "document.h"
-#include "desktop.h"
-#include "selection.h"
-#include "desktop-handles.h"
-
-#include "dialogs/dialog-events.h"
-#include "prefs-utils.h"
-#include "verbs.h"
-#include "interface.h"
-#include "sp-text.h"
-#include "sp-flowtext.h"
-#include "text-editing.h"
-#include "sp-tspan.h"
-#include "selection-chemistry.h"
-#include "sp-defs.h"
-#include "sp-rect.h"
-#include "sp-ellipse.h"
-#include "sp-star.h"
-#include "sp-spiral.h"
-#include "sp-path.h"
-#include "sp-line.h"
-#include "sp-polyline.h"
-#include "sp-item-group.h"
-#include "sp-use.h"
-#include "sp-image.h"
-#include "sp-offset.h"
-#include <xml/repr.h>
-
-using namespace Inkscape::UI::Widget;
+class SPItem;
+class SPObject;
namespace Inkscape {
+class Selection;
+
namespace UI {
namespace Dialog {
@@ -66,29 +38,29 @@ public:
protected:
// Widgets:
- Entry _entry_text;
- Entry _entry_id;
- Entry _entry_style;
- Entry _entry_attribute;
-
- CheckButton _check_search_selection;
- CheckButton _check_search_layer;
- CheckButton _check_include_hidden;
- CheckButton _check_include_locked;
+ Inkscape::UI::Widget::Entry _entry_text;
+ Inkscape::UI::Widget::Entry _entry_id;
+ Inkscape::UI::Widget::Entry _entry_style;
+ Inkscape::UI::Widget::Entry _entry_attribute;
+
+ Inkscape::UI::Widget::CheckButton _check_search_selection;
+ Inkscape::UI::Widget::CheckButton _check_search_layer;
+ Inkscape::UI::Widget::CheckButton _check_include_hidden;
+ Inkscape::UI::Widget::CheckButton _check_include_locked;
// Type checkbutton widgets...
- CheckButton _check_all;
- CheckButton _check_all_shapes;
- CheckButton _check_rects;
- CheckButton _check_ellipses;
- CheckButton _check_stars;
- CheckButton _check_spirals;
- CheckButton _check_paths;
- CheckButton _check_texts;
- CheckButton _check_groups;
- CheckButton _check_clones;
- CheckButton _check_images;
- CheckButton _check_offsets;
+ Inkscape::UI::Widget::CheckButton _check_all;
+ Inkscape::UI::Widget::CheckButton _check_all_shapes;
+ Inkscape::UI::Widget::CheckButton _check_rects;
+ Inkscape::UI::Widget::CheckButton _check_ellipses;
+ Inkscape::UI::Widget::CheckButton _check_stars;
+ Inkscape::UI::Widget::CheckButton _check_spirals;
+ Inkscape::UI::Widget::CheckButton _check_paths;
+ Inkscape::UI::Widget::CheckButton _check_texts;
+ Inkscape::UI::Widget::CheckButton _check_groups;
+ Inkscape::UI::Widget::CheckButton _check_clones;
+ Inkscape::UI::Widget::CheckButton _check_images;
+ Inkscape::UI::Widget::CheckButton _check_offsets;
// Button-click handlers
void onClear();
@@ -115,8 +87,8 @@ private:
Find(Find const &d);
Find& operator=(Find const &d);
- Button _button_clear;
- Button _button_find;
+ Inkscape::UI::Widget::Button _button_clear;
+ Inkscape::UI::Widget::Button _button_find;
};
} // namespace Dialog
diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp
index 9f5571b4b..19147f2c7 100644
--- a/src/ui/dialog/floating-behavior.cpp
+++ b/src/ui/dialog/floating-behavior.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief A floating dialog implementation.
- *
- * Author:
+/** @file
+ * @brief Floating dialog implementation.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
@@ -21,7 +21,7 @@
#include "desktop.h"
#include "dialogs/dialog-events.h"
#include "interface.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "verbs.h"
namespace Inkscape {
@@ -35,9 +35,9 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) :
#if GTK_VERSION_GE(2, 12)
,_dialog_active(_d->property_is_active())
,_steps(0)
- ,_trans_focus(prefs_get_double_attribute_limited("dialogs.transparency", "on-focus", 0.95, 0.0, 1.0))
- ,_trans_blur(prefs_get_double_attribute_limited("dialogs.transparency", "on-blur", 0.50, 0.0, 1.0))
- ,_trans_time(prefs_get_int_attribute_limited("dialogs.transparency", "animate-time", 100, 0, 5000))
+ ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0))
+ ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0))
+ ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000))
#endif
{
hide();
@@ -65,28 +65,30 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) :
zero so that the transition happens instantaneously. This occurs on
windows as opacity changes cause flicker there.
*/
-void FloatingBehavior::_focus_event (void) {
- _steps = 0;
- _trans_focus = prefs_get_double_attribute_limited("dialogs.transparency", "on-focus", 0.95, 0.0, 1.0);
- _trans_blur = prefs_get_double_attribute_limited("dialogs.transparency", "on-blur", 0.50, 0.0, 1.0);
- _trans_time = prefs_get_int_attribute_limited("dialogs.transparency", "animate-time", 100, 0, 5000);
-
- if (_trans_time != 0) {
- float diff = _trans_focus - _trans_blur;
- if (diff < 0.0) diff *= -1.0;
-
- while (diff > 0.05) {
- _steps++;
- diff = diff / 2.0;
- }
+void FloatingBehavior::_focus_event (void)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _steps = 0;
+ _trans_focus = prefs->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0);
+ _trans_blur = prefs->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0);
+ _trans_time = prefs->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000);
+
+ if (_trans_time != 0) {
+ float diff = _trans_focus - _trans_blur;
+ if (diff < 0.0) diff *= -1.0;
+
+ while (diff > 0.05) {
+ _steps++;
+ diff = diff / 2.0;
+ }
- if (_steps != 0) {
- Glib::signal_timeout().connect(sigc::mem_fun(this, &FloatingBehavior::_trans_timer), _trans_time / _steps);
- }
- }
- _trans_timer();
+ if (_steps != 0) {
+ Glib::signal_timeout().connect(sigc::mem_fun(this, &FloatingBehavior::_trans_timer), _trans_time / _steps);
+ }
+ }
+ _trans_timer();
- return;
+ return;
}
/** \brief Move the opacity of a window towards our goal
@@ -177,7 +179,8 @@ FloatingBehavior::onShutdown() {}
void
FloatingBehavior::onDesktopActivated (SPDesktop *desktop)
{
- gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint transient_policy = prefs->getIntLimited("/options/transientpolicy/value", 1, 0, 2);
#ifdef WIN32 // Win32 special code to enable transient dialogs
transient_policy = 2;
diff --git a/src/ui/dialog/floating-behavior.h b/src/ui/dialog/floating-behavior.h
index 0ab2d6981..0360ccf49 100644
--- a/src/ui/dialog/floating-behavior.h
+++ b/src/ui/dialog/floating-behavior.h
@@ -1,7 +1,7 @@
-/**
- * \brief A floating dialog implementation.
- *
- * Author:
+/** @file
+ * @brief A floating dialog implementation.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index e2e717c53..d06d3a406 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief Inkscape Preferences dialog
- *
- * Authors:
+/** @file
+ * @brief Inkscape Preferences dialog - implementation
+ */
+/* Authors:
* Carl Hetherington
* Marco Scholten
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
@@ -28,7 +28,7 @@
#include "unit-constants.h"
#include <iostream>
#include "enums.h"
-#include "inkscape.h"
+// #include "inkscape.h"
#include "desktop-handles.h"
#include "message-stack.h"
#include "style.h"
@@ -37,6 +37,7 @@
#include "xml/repr.h"
#include "ui/widget/style-swatch.h"
#include "display/nr-filter-gaussian.h"
+#include "display/nr-filter-types.h"
#include "color-profile-fns.h"
#include "display/canvas-grid.h"
@@ -45,7 +46,7 @@ namespace UI {
namespace Dialog {
InkscapePreferences::InkscapePreferences()
- : UI::Widget::Panel ("", "dialogs.preferences", SP_VERB_DIALOG_DISPLAY),
+ : UI::Widget::Panel ("", "/dialogs/preferences", SP_VERB_DIALOG_DISPLAY),
_max_dialog_width(0),
_max_dialog_height(0),
_current_page(0)
@@ -153,18 +154,18 @@ Gtk::TreeModel::iterator InkscapePreferences::AddPage(DialogPage& p, Glib::ustri
void InkscapePreferences::initPageMouse()
{
this->AddPage(_page_mouse, _("Mouse"), PREFS_PAGE_MOUSE);
- _mouse_sens.init ( "options.cursortolerance", "value", 0.0, 30.0, 1.0, 1.0, 8.0, true, false);
+ _mouse_sens.init ( "/options/cursortolerance/value", 0.0, 30.0, 1.0, 1.0, 8.0, true, false);
_page_mouse.add_line( false, _("Grab sensitivity:"), _mouse_sens, _("pixels"),
_("How close on the screen you need to be to an object to be able to grab it with mouse (in screen pixels)"), false);
- _mouse_thres.init ( "options.dragtolerance", "value", 0.0, 20.0, 1.0, 1.0, 4.0, true, false);
+ _mouse_thres.init ( "/options/dragtolerance/value", 0.0, 20.0, 1.0, 1.0, 4.0, true, false);
_page_mouse.add_line( false, _("Click/drag threshold:"), _mouse_thres, _("pixels"),
_("Maximum mouse drag (in screen pixels) which is considered a click, not a drag"), false);
- _mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "options.useextinput", "value", true);
+ _mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "/options/useextinput/value", true);
_page_mouse.add_line(true, "",_mouse_use_ext_input, "",
_("Use the capabilities of a tablet or other pressure-sensitive device. Disable this only if you have problems with the tablet (you can still use it as a mouse)"));
- _mouse_switch_on_ext_input.init( _("Switch tool based on tablet device (requires restart)"), "options.switchonextinput", "value", false);
+ _mouse_switch_on_ext_input.init( _("Switch tool based on tablet device (requires restart)"), "/options/switchonextinput/value", false);
_page_mouse.add_line(true, "",_mouse_switch_on_ext_input, "",
_("Change tool as different devices are used on the tablet (pen, eraser, mouse)"));
}
@@ -172,27 +173,27 @@ void InkscapePreferences::initPageMouse()
void InkscapePreferences::initPageScrolling()
{
this->AddPage(_page_scrolling, _("Scrolling"), PREFS_PAGE_SCROLLING);
- _scroll_wheel.init ( "options.wheelscroll", "value", 0.0, 1000.0, 1.0, 1.0, 40.0, true, false);
+ _scroll_wheel.init ( "/options/wheelscroll/value", 0.0, 1000.0, 1.0, 1.0, 40.0, true, false);
_page_scrolling.add_line( false, _("Mouse wheel scrolls by:"), _scroll_wheel, _("pixels"),
_("One mouse wheel notch scrolls by this distance in screen pixels (horizontally with Shift)"), false);
_page_scrolling.add_group_header( _("Ctrl+arrows"));
- _scroll_arrow_px.init ( "options.keyscroll", "value", 0.0, 1000.0, 1.0, 1.0, 10.0, true, false);
+ _scroll_arrow_px.init ( "/options/keyscroll/value", 0.0, 1000.0, 1.0, 1.0, 10.0, true, false);
_page_scrolling.add_line( true, _("Scroll by:"), _scroll_arrow_px, _("pixels"),
_("Pressing Ctrl+arrow key scrolls by this distance (in screen pixels)"), false);
- _scroll_arrow_acc.init ( "options.scrollingacceleration", "value", 0.0, 5.0, 0.01, 1.0, 0.35, false, false);
+ _scroll_arrow_acc.init ( "/options/scrollingacceleration/value", 0.0, 5.0, 0.01, 1.0, 0.35, false, false);
_page_scrolling.add_line( true, _("Acceleration:"), _scroll_arrow_acc, "",
_("Pressing and holding Ctrl+arrow will gradually speed up scrolling (0 for no acceleration)"), false);
_page_scrolling.add_group_header( _("Autoscrolling"));
- _scroll_auto_speed.init ( "options.autoscrollspeed", "value", 0.0, 5.0, 0.01, 1.0, 0.7, false, false);
+ _scroll_auto_speed.init ( "/options/autoscrollspeed/value", 0.0, 5.0, 0.01, 1.0, 0.7, false, false);
_page_scrolling.add_line( true, _("Speed:"), _scroll_auto_speed, "",
_("How fast the canvas autoscrolls when you drag beyond canvas edge (0 to turn autoscroll off)"), false);
- _scroll_auto_thres.init ( "options.autoscrolldistance", "value", -600.0, 600.0, 1.0, 1.0, -10.0, true, false);
+ _scroll_auto_thres.init ( "/options/autoscrolldistance/value", -600.0, 600.0, 1.0, 1.0, -10.0, true, false);
_page_scrolling.add_line( true, _("Threshold:"), _scroll_auto_thres, _("pixels"),
_("How far (in screen pixels) you need to be from the canvas edge to trigger autoscroll; positive is outside the canvas, negative is within the canvas"), false);
- _scroll_space.init ( _("Left mouse button pans when Space is pressed"), "options.spacepans", "value", false);
+ _scroll_space.init ( _("Left mouse button pans when Space is pressed"), "/options/spacepans/value", false);
_page_scrolling.add_line( false, "", _scroll_space, "",
_("When on, pressing and holding Space and dragging with left mouse button pans canvas (as in Adobe Illustrator). When off, Space temporarily switches to Selector tool (default)."));
- _wheel_zoom.init ( _("Mouse wheel zooms by default"), "options.wheelzooms", "value", false);
+ _wheel_zoom.init ( _("Mouse wheel zooms by default"), "/options/wheelzooms/value", false);
_page_scrolling.add_line( false, "", _wheel_zoom, "",
_("When on, mouse wheel zooms without Ctrl and scrolls canvas with Ctrl; when off, it zooms with Ctrl and scrolls without Ctrl."));
}
@@ -201,28 +202,28 @@ void InkscapePreferences::initPageSteps()
{
this->AddPage(_page_steps, _("Steps"), PREFS_PAGE_STEPS);
- _steps_arrow.init ( "options.nudgedistance", "value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
+ _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
//nudgedistance is limited to 1000 in select-context.cpp: use the same limit here
_page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, _("px"),
_("Pressing an arrow key moves selected object(s) or node(s) by this distance (in px units)"), false);
- _steps_scale.init ( "options.defaultscale", "value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
+ _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
//defaultscale is limited to 1000 in select-context.cpp: use the same limit here
_page_steps.add_line( false, _("> and < scale by:"), _steps_scale, _("px"),
_("Pressing > or < scales selection up or down by this increment (in px units)"), false);
- _steps_inset.init ( "options.defaultoffsetwidth", "value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false);
+ _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false);
_page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, _("px"),
_("Inset and Outset commands displace the path by this distance (in px units)"), false);
- _steps_compass.init ( _("Compass-like display of angles"), "options.compassangledisplay", "value", true);
+ _steps_compass.init ( _("Compass-like display of angles"), "/options/compassangledisplay/value", true);
_page_steps.add_line( false, "", _steps_compass, "",
_("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise"));
int const num_items = 17;
Glib::ustring labels[num_items] = {"90", "60", "45", "36", "30", "22.5", "18", "15", "12", "10", "7.5", "6", "3", "2", "1", "0.5", _("None")};
int values[num_items] = {2, 3, 4, 5, 6, 8, 10, 12, 15, 18, 24, 30, 60, 90, 180, 360, 0};
_steps_rot_snap.set_size_request(_sb_width);
- _steps_rot_snap.init("options.rotationsnapsperpi", "value", labels, values, num_items, 12);
+ _steps_rot_snap.init("/options/rotationsnapsperpi/value", labels, values, num_items, 12);
_page_steps.add_line( false, _("Rotation snaps every:"), _steps_rot_snap, _("degrees"),
_("Rotating with Ctrl pressed snaps every that much degrees; also, pressing [ or ] rotates by this amount"), false);
- _steps_zoom.init ( "options.zoomincrement", "value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true);
+ _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true);
_page_steps.add_line( false, _("Zoom in/out by:"), _steps_zoom, _("%"),
_("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false);
}
@@ -230,34 +231,34 @@ void InkscapePreferences::initPageSteps()
void InkscapePreferences::AddSelcueCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value)
{
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
- cb->init ( _("Show selection cue"), prefs_path, "selcue", def_value);
+ cb->init ( _("Show selection cue"), prefs_path + "/selcue", def_value);
p.add_line( false, "", *cb, "", _("Whether selected objects display a selection cue (the same as in selector)"));
}
void InkscapePreferences::AddGradientCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value)
{
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
- cb->init ( _("Enable gradient editing"), prefs_path, "gradientdrag", def_value);
+ cb->init ( _("Enable gradient editing"), prefs_path + "/gradientdrag", def_value);
p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls"));
}
void InkscapePreferences::AddConvertGuidesCheckbox(DialogPage &p, Glib::ustring const &prefs_path, bool def_value) {
PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
- cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path, "convertguides", def_value);
+ cb->init ( _("Conversion to guides uses edges instead of bounding box"), prefs_path + "/convertguides", def_value);
p.add_line( false, "", *cb, "", _("Converting an object to guides places these along the object's true edges (imitating the object's shape), not along the bounding box."));
}
void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value)
{
PrefSpinButton* sb = Gtk::manage( new PrefSpinButton);
- sb->init ( prefs_path, "dot-size", 0.0, 1000.0, 0.1, 10.0, def_value, false, false);
+ sb->init ( prefs_path + "/dot-size", 0.0, 1000.0, 0.1, 10.0, def_value, false, false);
p.add_line( false, _("Ctrl+click dot size:"), *sb, _("times current stroke width"),
_("Size of dots created with Ctrl+click (relative to current stroke width)"),
false );
}
-void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch)
+void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL)
@@ -285,24 +286,22 @@ void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch)
if (!css) return;
// only store text style for the text tool
- if (!g_strrstr ((const gchar *) prefs_path, "text")) {
+ if (prefs_path == "/tools/text") {
css = sp_css_attr_unset_text (css);
}
// we cannot store properties with uris - they will be invalid in other documents
css = sp_css_attr_unset_uris (css);
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, prefs_path), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle(prefs_path + "/style", css);
sp_repr_css_attr_unref (css);
// update the swatch
if (swatch) {
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path);
- if (tool_repr) {
- SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style");
- swatch->setStyle (css);
- sp_repr_css_attr_unref(css);
- }
+ SPCSSAttr *css = prefs->getInheritedStyle(prefs_path + "/style");
+ swatch->setStyle (css);
+ sp_repr_css_attr_unref(css);
}
}
@@ -313,14 +312,14 @@ void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const
else
p.add_group_header( _("Create new objects with:"));
PrefRadioButton* current = Gtk::manage( new PrefRadioButton);
- current->init ( _("Last used style"), prefs_path, "usecurrent", 1, true, 0);
+ current->init ( _("Last used style"), prefs_path + "/usecurrent", 1, true, 0);
p.add_line( true, "", *current, "",
_("Apply the style you last set on an object"));
PrefRadioButton* own = Gtk::manage( new PrefRadioButton);
Gtk::HBox* hb = Gtk::manage( new Gtk::HBox);
Gtk::Alignment* align = Gtk::manage( new Gtk::Alignment);
- own->init ( _("This tool's own style:"), prefs_path, "usecurrent", 0, false, current);
+ own->init ( _("This tool's own style:"), prefs_path + "/usecurrent", 0, false, current);
align->set(0,0,0,0);
align->add(*own);
hb->add(*align);
@@ -328,17 +327,16 @@ void InkscapePreferences::AddNewObjectsStyle(DialogPage &p, Glib::ustring const
p.add_line( true, "", *hb, "", "");
// style swatch
- Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path.c_str());
Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"),true));
StyleSwatch *swatch = 0;
- if (tool_repr) {
- SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style");
- swatch = new StyleSwatch(css, _("This tool's style of new objects"));
- hb->add(*swatch);
- sp_repr_css_attr_unref(css);
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ SPCSSAttr *css = prefs->getStyle(prefs_path + "/style");
+ swatch = new StyleSwatch(css, _("This tool's style of new objects"));
+ hb->add(*swatch);
+ sp_repr_css_attr_unref(css);
- button->signal_clicked().connect( sigc::bind( sigc::ptr_fun(StyleFromSelectionToTool), prefs_path.c_str(), swatch) );
+ button->signal_clicked().connect( sigc::bind( sigc::ptr_fun(StyleFromSelectionToTool), prefs_path, swatch) );
own->changed_signal.connect( sigc::mem_fun(*button, &Gtk::Button::set_sensitive) );
p.add_line( true, "", *button, "",
_("Remember the style of the (first) selected object as this tool's style"));
@@ -350,167 +348,167 @@ void InkscapePreferences::initPageTools()
_path_tools = _page_list.get_model()->get_path(iter_tools);
_page_tools.add_group_header( _("Bounding box to use:"));
- _t_bbox_visual.init ( _("Visual bounding box"), "tools", "bounding_box", "0", false, 0); // 0 means visual
+ _t_bbox_visual.init ( _("Visual bounding box"), "/tools/bounding_box", 0, false, 0); // 0 means visual
_page_tools.add_line( true, "", _t_bbox_visual, "",
_("This bounding box includes stroke width, markers, filter margins, etc."));
- _t_bbox_geometric.init ( _("Geometric bounding box"), "tools", "bounding_box", "1", true, &_t_bbox_visual); // 1 means geometric
+ _t_bbox_geometric.init ( _("Geometric bounding box"), "/tools/bounding_box", 1, true, &_t_bbox_visual); // 1 means geometric
_page_tools.add_line( true, "", _t_bbox_geometric, "",
_("This bounding box includes only the bare path"));
_page_tools.add_group_header( _("Conversion to guides:"));
- _t_cvg_keep_objects.init ( _("Keep objects after conversion to guides"), "tools", "cvg_keep_objects", false);
+ _t_cvg_keep_objects.init ( _("Keep objects after conversion to guides"), "/tools/cvg_keep_objects", false);
_page_tools.add_line( true, "", _t_cvg_keep_objects, "",
_("When converting an object to guides, don't delete the object after the conversion."));
- _t_cvg_convert_whole_groups.init ( _("Treat groups as a single object"), "tools", "cvg_convert_whole_groups", false);
+ _t_cvg_convert_whole_groups.init ( _("Treat groups as a single object"), "/tools/cvg_convert_whole_groups", false);
_page_tools.add_line( true, "", _t_cvg_convert_whole_groups, "",
_("Treat groups as a single object during conversion to guides rather than converting each child separately."));
- _calligrapy_use_abs_size.init ( _("Width is in absolute units"), "tools.calligraphic", "abs_width", false);
- _calligrapy_keep_selected.init ( _("Select new path"), "tools.calligraphic", "keep_selected", true);
- _connector_ignore_text.init( _("Don't attach connectors to text objects"), "tools.connector", "ignoretext", true);
+ _calligrapy_use_abs_size.init ( _("Width is in absolute units"), "/tools/calligraphic/abs_width", false);
+ _calligrapy_keep_selected.init ( _("Select new path"), "/tools/calligraphic/keep_selected", true);
+ _connector_ignore_text.init( _("Don't attach connectors to text objects"), "/tools/connector/ignoretext", true);
//Selector
this->AddPage(_page_selector, _("Selector"), iter_tools, PREFS_PAGE_TOOLS_SELECTOR);
- AddSelcueCheckbox(_page_selector, "tools.select", false);
+ AddSelcueCheckbox(_page_selector, "/tools/select", false);
_page_selector.add_group_header( _("When transforming, show:"));
- _t_sel_trans_obj.init ( _("Objects"), "tools.select", "show", "content", true, 0);
+ _t_sel_trans_obj.init ( _("Objects"), "/tools/select/show", "content", true, 0);
_page_selector.add_line( true, "", _t_sel_trans_obj, "",
_("Show the actual objects when moving or transforming"));
- _t_sel_trans_outl.init ( _("Box outline"), "tools.select", "show", "outline", false, &_t_sel_trans_obj);
+ _t_sel_trans_outl.init ( _("Box outline"), "/tools/select/show", "outline", false, &_t_sel_trans_obj);
_page_selector.add_line( true, "", _t_sel_trans_outl, "",
_("Show only a box outline of the objects when moving or transforming"));
_page_selector.add_group_header( _("Per-object selection cue:"));
- _t_sel_cue_none.init ( _("None"), "options.selcue", "value", Inkscape::SelCue::NONE, false, 0);
+ _t_sel_cue_none.init ( _("None"), "/options/selcue/value", Inkscape::SelCue::NONE, false, 0);
_page_selector.add_line( true, "", _t_sel_cue_none, "",
_("No per-object selection indication"));
- _t_sel_cue_mark.init ( _("Mark"), "options.selcue", "value", Inkscape::SelCue::MARK, true, &_t_sel_cue_none);
+ _t_sel_cue_mark.init ( _("Mark"), "/options/selcue/value", Inkscape::SelCue::MARK, true, &_t_sel_cue_none);
_page_selector.add_line( true, "", _t_sel_cue_mark, "",
_("Each selected object has a diamond mark in the top left corner"));
- _t_sel_cue_box.init ( _("Box"), "options.selcue", "value", Inkscape::SelCue::BBOX, false, &_t_sel_cue_none);
+ _t_sel_cue_box.init ( _("Box"), "/options/selcue/value", Inkscape::SelCue::BBOX, false, &_t_sel_cue_none);
_page_selector.add_line( true, "", _t_sel_cue_box, "",
_("Each selected object displays its bounding box"));
//Node
this->AddPage(_page_node, _("Node"), iter_tools, PREFS_PAGE_TOOLS_NODE);
- AddSelcueCheckbox(_page_node, "tools.nodes", true);
- AddGradientCheckbox(_page_node, "tools.nodes", true);
+ AddSelcueCheckbox(_page_node, "/tools/nodes", true);
+ AddGradientCheckbox(_page_node, "/tools/nodes", true);
_page_node.add_group_header( _("Path outline:"));
- _t_node_pathoutline_color.init(_("Path outline color"), "tools.nodes", "highlight_color", 0xff0000ff);
+ _t_node_pathoutline_color.init(_("Path outline color"), "/tools/nodes/highlight_color", 0xff0000ff);
_page_node.add_line( false, _("Path outline color"), _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false);
- _t_node_pathflash_enabled.init ( _("Path outline flash on mouse-over"), "tools.nodes", "pathflash_enabled", false);
+ _t_node_pathflash_enabled.init ( _("Path outline flash on mouse-over"), "/tools/nodes/pathflash_enabled", false);
_page_node.add_line( true, "", _t_node_pathflash_enabled, "", _("When hovering over a path, briefly flash its outline."));
- _t_node_pathflash_timeout.init("tools.nodes", "pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false);
+ _t_node_pathflash_timeout.init("/tools/nodes/pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false);
_page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds). Specify 0 to have the outline shown until mouse leaves the path."), false);
//Tweak
this->AddPage(_page_tweak, _("Tweak"), iter_tools, PREFS_PAGE_TOOLS_TWEAK);
- this->AddNewObjectsStyle(_page_tweak, "tools.tweak", _("Paint objects with:"));
- AddSelcueCheckbox(_page_tweak, "tools.tweak", true);
- AddGradientCheckbox(_page_tweak, "tools.tweak", false);
+ this->AddNewObjectsStyle(_page_tweak, "/tools/tweak", _("Paint objects with:"));
+ AddSelcueCheckbox(_page_tweak, "/tools/tweak", true);
+ AddGradientCheckbox(_page_tweak, "/tools/tweak", false);
//Zoom
this->AddPage(_page_zoom, _("Zoom"), iter_tools, PREFS_PAGE_TOOLS_ZOOM);
- AddSelcueCheckbox(_page_zoom, "tools.zoom", true);
- AddGradientCheckbox(_page_zoom, "tools.zoom", false);
+ AddSelcueCheckbox(_page_zoom, "/tools/zoom", true);
+ AddGradientCheckbox(_page_zoom, "/tools/zoom", false);
//Shapes
Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES);
_path_shapes = _page_list.get_model()->get_path(iter_shapes);
- this->AddSelcueCheckbox(_page_shapes, "tools.shapes", true);
- this->AddGradientCheckbox(_page_shapes, "tools.shapes", true);
+ this->AddSelcueCheckbox(_page_shapes, "/tools/shapes", true);
+ this->AddGradientCheckbox(_page_shapes, "/tools/shapes", true);
//Rectangle
this->AddPage(_page_rectangle, _("Rectangle"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_RECT);
- this->AddNewObjectsStyle(_page_rectangle, "tools.shapes.rect");
- this->AddConvertGuidesCheckbox(_page_rectangle, "tools.shapes.rect", true);
+ this->AddNewObjectsStyle(_page_rectangle, "/tools/shapes/rect");
+ this->AddConvertGuidesCheckbox(_page_rectangle, "/tools/shapes/rect", true);
//3D box
this->AddPage(_page_3dbox, _("3D Box"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_3DBOX);
- this->AddNewObjectsStyle(_page_3dbox, "tools.shapes.3dbox");
- this->AddConvertGuidesCheckbox(_page_3dbox, "tools.shapes.3dbox", true);
+ this->AddNewObjectsStyle(_page_3dbox, "/tools/shapes/3dbox");
+ this->AddConvertGuidesCheckbox(_page_3dbox, "/tools/shapes/3dbox", true);
//ellipse
this->AddPage(_page_ellipse, _("Ellipse"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
- this->AddNewObjectsStyle(_page_ellipse, "tools.shapes.arc");
+ this->AddNewObjectsStyle(_page_ellipse, "/tools/shapes/arc");
//star
this->AddPage(_page_star, _("Star"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_STAR);
- this->AddNewObjectsStyle(_page_star, "tools.shapes.star");
+ this->AddNewObjectsStyle(_page_star, "/tools/shapes/star");
//spiral
this->AddPage(_page_spiral, _("Spiral"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
- this->AddNewObjectsStyle(_page_spiral, "tools.shapes.spiral");
+ this->AddNewObjectsStyle(_page_spiral, "/tools/shapes/spiral");
//Pencil
this->AddPage(_page_pencil, _("Pencil"), iter_tools, PREFS_PAGE_TOOLS_PENCIL);
- this->AddSelcueCheckbox(_page_pencil, "tools.freehand.pencil", true);
- this->AddNewObjectsStyle(_page_pencil, "tools.freehand.pencil");
- this->AddDotSizeSpinbutton(_page_pencil, "tools.freehand.pencil", 3.0);
+ this->AddSelcueCheckbox(_page_pencil, "/tools/freehand/pencil", true);
+ this->AddNewObjectsStyle(_page_pencil, "/tools/freehand/pencil");
+ this->AddDotSizeSpinbutton(_page_pencil, "/tools/freehand/pencil", 3.0);
//Pen
this->AddPage(_page_pen, _("Pen"), iter_tools, PREFS_PAGE_TOOLS_PEN);
- this->AddSelcueCheckbox(_page_pen, "tools.freehand.pen", true);
- this->AddNewObjectsStyle(_page_pen, "tools.freehand.pen");
- this->AddDotSizeSpinbutton(_page_pen, "tools.freehand.pen", 3.0);
+ this->AddSelcueCheckbox(_page_pen, "/tools/freehand/pen", true);
+ this->AddNewObjectsStyle(_page_pen, "/tools/freehand/pen");
+ this->AddDotSizeSpinbutton(_page_pen, "/tools/freehand/pen", 3.0);
//Calligraphy
this->AddPage(_page_calligraphy, _("Calligraphy"), iter_tools, PREFS_PAGE_TOOLS_CALLIGRAPHY);
- this->AddSelcueCheckbox(_page_calligraphy, "tools.calligraphic", false);
- this->AddNewObjectsStyle(_page_calligraphy, "tools.calligraphic");
+ this->AddSelcueCheckbox(_page_calligraphy, "/tools/calligraphic", false);
+ this->AddNewObjectsStyle(_page_calligraphy, "/tools/calligraphic");
_page_calligraphy.add_line( false, "", _calligrapy_use_abs_size, "",
_("If on, pen width is in absolute units (px) independent of zoom; otherwise pen width depends on zoom so that it looks the same at any zoom"));
_page_calligraphy.add_line( false, "", _calligrapy_keep_selected, "",
_("If on, each newly created object will be selected (deselecting previous selection)"));
//Paint Bucket
this->AddPage(_page_paintbucket, _("Paint Bucket"), iter_tools, PREFS_PAGE_TOOLS_PAINTBUCKET);
- this->AddSelcueCheckbox(_page_paintbucket, "tools.paintbucket", false);
- this->AddNewObjectsStyle(_page_paintbucket, "tools.paintbucket");
+ this->AddSelcueCheckbox(_page_paintbucket, "/tools/paintbucket", false);
+ this->AddNewObjectsStyle(_page_paintbucket, "/tools/paintbucket");
//Eraser
this->AddPage(_page_eraser, _("Eraser"), iter_tools, PREFS_PAGE_TOOLS_ERASER);
- this->AddNewObjectsStyle(_page_eraser, "tools.eraser");
+ this->AddNewObjectsStyle(_page_eraser, "/tools/eraser");
//LPETool
this->AddPage(_page_lpetool, _("LPE Tool"), iter_tools, PREFS_PAGE_TOOLS_LPETOOL);
- this->AddNewObjectsStyle(_page_lpetool, "tools.lpetool");
+ this->AddNewObjectsStyle(_page_lpetool, "/tools/lpetool");
//Text
this->AddPage(_page_text, _("Text"), iter_tools, PREFS_PAGE_TOOLS_TEXT);
- this->AddSelcueCheckbox(_page_text, "tools.text", true);
- this->AddGradientCheckbox(_page_text, "tools.text", true);
- this->AddNewObjectsStyle(_page_text, "tools.text");
+ this->AddSelcueCheckbox(_page_text, "/tools/text", true);
+ this->AddGradientCheckbox(_page_text, "/tools/text", true);
+ this->AddNewObjectsStyle(_page_text, "/tools/text");
//Gradient
this->AddPage(_page_gradient, _("Gradient"), iter_tools, PREFS_PAGE_TOOLS_GRADIENT);
- this->AddSelcueCheckbox(_page_gradient, "tools.gradient", true);
+ this->AddSelcueCheckbox(_page_gradient, "/tools/gradient", true);
//Connector
this->AddPage(_page_connector, _("Connector"), iter_tools, PREFS_PAGE_TOOLS_CONNECTOR);
- this->AddSelcueCheckbox(_page_connector, "tools.connector", true);
+ this->AddSelcueCheckbox(_page_connector, "/tools/connector", true);
_page_connector.add_line(false, "", _connector_ignore_text, "",
_("If on, connector attachment points will not be shown for text objects"));
//Dropper
this->AddPage(_page_dropper, _("Dropper"), iter_tools, PREFS_PAGE_TOOLS_DROPPER);
- this->AddSelcueCheckbox(_page_dropper, "tools.dropper", true);
- this->AddGradientCheckbox(_page_dropper, "tools.dropper", true);
+ this->AddSelcueCheckbox(_page_dropper, "/tools/dropper", true);
+ this->AddGradientCheckbox(_page_dropper, "/tools/dropper", true);
}
void InkscapePreferences::initPageWindows()
{
- _win_save_geom.init ( _("Save and restore window geometry for each document"), "options.savewindowgeometry", "value", 1, true, 0);
- _win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "options.savewindowgeometry", "value", 2, false, &_win_save_geom);
- _win_save_geom_off.init ( _("Don't save window geometry"), "options.savewindowgeometry", "value", 0, false, &_win_save_geom);
+ _win_save_geom.init ( _("Save and restore window geometry for each document"), "/options/savewindowgeometry/value", 1, true, 0);
+ _win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "/options/savewindowgeometry/value", 2, false, &_win_save_geom);
+ _win_save_geom_off.init ( _("Don't save window geometry"), "/options/savewindowgeometry/value", 0, false, &_win_save_geom);
- _win_dockable.init ( _("Dockable"), "options.dialogtype", "value", 1, true, 0);
- _win_floating.init ( _("Floating"), "options.dialogtype", "value", 0, false, &_win_dockable);
+ _win_dockable.init ( _("Dockable"), "/options/dialogtype/value", 1, true, 0);
+ _win_floating.init ( _("Floating"), "/options/dialogtype/value", 0, false, &_win_dockable);
- _win_hide_task.init ( _("Dialogs are hidden in taskbar"), "options.dialogsskiptaskbar", "value", true);
- _win_zoom_resize.init ( _("Zoom when window is resized"), "options.stickyzoom", "value", false);
- _win_show_close.init ( _("Show close button on dialogs"), "dialogs", "showclose", false);
- _win_ontop_none.init ( _("None"), "options.transientpolicy", "value", 0, false, 0);
- _win_ontop_normal.init ( _("Normal"), "options.transientpolicy", "value", 1, true, &_win_ontop_none);
- _win_ontop_agressive.init ( _("Aggressive"), "options.transientpolicy", "value", 2, false, &_win_ontop_none);
+ _win_hide_task.init ( _("Dialogs are hidden in taskbar"), "/options/dialogsskiptaskbar/value", true);
+ _win_zoom_resize.init ( _("Zoom when window is resized"), "/options/stickyzoom/value", false);
+ _win_show_close.init ( _("Show close button on dialogs"), "/dialogs/showclose", false);
+ _win_ontop_none.init ( _("None"), "/options/transientpolicy/value", 0, false, 0);
+ _win_ontop_normal.init ( _("Normal"), "/options/transientpolicy/value", 1, true, &_win_ontop_none);
+ _win_ontop_agressive.init ( _("Aggressive"), "/options/transientpolicy/value", 2, false, &_win_ontop_none);
_page_windows.add_group_header( _("Saving window geometry (size and position):"));
_page_windows.add_line( true, "", _win_save_geom_off, "",
@@ -539,11 +537,11 @@ void InkscapePreferences::initPageWindows()
#if GTK_VERSION_GE(2, 12)
_page_windows.add_group_header( _("Dialog Transparency:"));
- _win_trans_focus.init("dialogs.transparency", "on-focus", 0.5, 1.0, 0.01, 0.1, 1.0, false, false);
+ _win_trans_focus.init("/dialogs/transparency/on-focus", 0.5, 1.0, 0.01, 0.1, 1.0, false, false);
_page_windows.add_line( true, _("Opacity when focused:"), _win_trans_focus, "", "");
- _win_trans_blur.init("dialogs.transparency", "on-blur", 0.0, 1.0, 0.01, 0.1, 0.5, false, false);
+ _win_trans_blur.init("/dialogs/transparency/on-blur", 0.0, 1.0, 0.01, 0.1, 0.5, false, false);
_page_windows.add_line( true, _("Opacity when unfocused:"), _win_trans_blur, "", "");
- _win_trans_time.init("dialogs.transparency", "animate-time", 0, 1000, 10, 100, 100, true, false);
+ _win_trans_time.init("/dialogs/transparency/animate-time", 0, 1000, 10, 100, 100, true, false);
_page_windows.add_line( true, _("Time of opacity change animation:"), _win_trans_time, "ms", "");
#endif
@@ -561,15 +559,15 @@ void InkscapePreferences::initPageWindows()
void InkscapePreferences::initPageClones()
{
- _clone_option_parallel.init ( _("Move in parallel"), "options.clonecompensation", "value",
+ _clone_option_parallel.init ( _("Move in parallel"), "/options/clonecompensation/value",
SP_CLONE_COMPENSATION_PARALLEL, true, 0);
- _clone_option_stay.init ( _("Stay unmoved"), "options.clonecompensation", "value",
+ _clone_option_stay.init ( _("Stay unmoved"), "/options/clonecompensation/value",
SP_CLONE_COMPENSATION_UNMOVED, false, &_clone_option_parallel);
- _clone_option_transform.init ( _("Move according to transform"), "options.clonecompensation", "value",
+ _clone_option_transform.init ( _("Move according to transform"), "/options/clonecompensation/value",
SP_CLONE_COMPENSATION_NONE, false, &_clone_option_parallel);
- _clone_option_unlink.init ( _("Are unlinked"), "options.cloneorphans", "value",
+ _clone_option_unlink.init ( _("Are unlinked"), "/options/cloneorphans/value",
SP_CLONE_ORPHANS_UNLINK, true, 0);
- _clone_option_delete.init ( _("Are deleted"), "options.cloneorphans", "value",
+ _clone_option_delete.init ( _("Are deleted"), "/options/cloneorphans/value",
SP_CLONE_ORPHANS_DELETE, false, &_clone_option_unlink);
_page_clones.add_group_header( _("When the original moves, its clones and linked offsets:"));
@@ -587,7 +585,7 @@ void InkscapePreferences::initPageClones()
_page_clones.add_group_header( _("When duplicating original+clones:"));
- _clone_relink_on_duplicate.init ( _("Relink duplicated clones"), "options.relinkclonesonduplicate", "value", false);
+ _clone_relink_on_duplicate.init ( _("Relink duplicated clones"), "/options/relinkclonesonduplicate/value", false);
_page_clones.add_line(true, "", _clone_relink_on_duplicate, "",
_("When duplicating a selection containing both a clone and its original (possibly in groups), relink the duplicated clone to the duplicated original instead of the old original"));
@@ -597,10 +595,10 @@ void InkscapePreferences::initPageClones()
void InkscapePreferences::initPageMasks()
{
- _mask_mask_on_top.init ( _("When applying, use the topmost selected object as clippath/mask"), "options.maskobject", "topmost", true);
+ _mask_mask_on_top.init ( _("When applying, use the topmost selected object as clippath/mask"), "/options/maskobject/topmost", true);
_page_mask.add_line(true, "", _mask_mask_on_top, "",
_("Uncheck this to use the bottom selected object as the clipping path or mask"));
- _mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "options.maskobject", "remove", true);
+ _mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "/options/maskobject/remove", true);
_page_mask.add_line(true, "", _mask_mask_remove, "",
_("After applying, remove the object used as the clipping path or mask from the drawing"));
this->AddPage(_page_mask, _("Clippaths and masks"), PREFS_PAGE_MASKS);
@@ -608,12 +606,12 @@ void InkscapePreferences::initPageMasks()
void InkscapePreferences::initPageTransforms()
{
- _trans_scale_stroke.init ( _("Scale stroke width"), "options.transform", "stroke", true);
- _trans_scale_corner.init ( _("Scale rounded corners in rectangles"), "options.transform", "rectcorners", false);
- _trans_gradient.init ( _("Transform gradients"), "options.transform", "gradient", true);
- _trans_pattern.init ( _("Transform patterns"), "options.transform", "pattern", false);
- _trans_optimized.init ( _("Optimized"), "options.preservetransform", "value", 0, true, 0);
- _trans_preserved.init ( _("Preserved"), "options.preservetransform", "value", 1, false, &_trans_optimized);
+ _trans_scale_stroke.init ( _("Scale stroke width"), "/options/transform/stroke", true);
+ _trans_scale_corner.init ( _("Scale rounded corners in rectangles"), "/options/transform/rectcorners", false);
+ _trans_gradient.init ( _("Transform gradients"), "/options/transform/gradient", true);
+ _trans_pattern.init ( _("Transform patterns"), "/options/transform/pattern", false);
+ _trans_optimized.init ( _("Optimized"), "/options/preservetransform/value", 0, true, 0);
+ _trans_preserved.init ( _("Preserved"), "/options/preservetransform/value", 1, false, &_trans_optimized);
_page_transforms.add_line( false, "", _trans_scale_stroke, "",
_("When scaling objects, scale the stroke width by the same proportion"));
@@ -634,15 +632,16 @@ void InkscapePreferences::initPageTransforms()
void InkscapePreferences::initPageFilters()
{
- _blur_quality_best.init ( _("Best quality (slowest)"), "options.blurquality", "value",
+ /* blur quality */
+ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value",
BLUR_QUALITY_BEST, false, 0);
- _blur_quality_better.init ( _("Better quality (slower)"), "options.blurquality", "value",
+ _blur_quality_better.init ( _("Better quality (slower)"), "/options/blurquality/value",
BLUR_QUALITY_BETTER, false, &_blur_quality_best);
- _blur_quality_normal.init ( _("Average quality"), "options.blurquality", "value",
+ _blur_quality_normal.init ( _("Average quality"), "/options/blurquality/value",
BLUR_QUALITY_NORMAL, true, &_blur_quality_best);
- _blur_quality_worse.init ( _("Lower quality (faster)"), "options.blurquality", "value",
+ _blur_quality_worse.init ( _("Lower quality (faster)"), "/options/blurquality/value",
BLUR_QUALITY_WORSE, false, &_blur_quality_best);
- _blur_quality_worst.init ( _("Lowest quality (fastest)"), "options.blurquality", "value",
+ _blur_quality_worst.init ( _("Lowest quality (fastest)"), "/options/blurquality/value",
BLUR_QUALITY_WORST, false, &_blur_quality_best);
_page_filters.add_group_header( _("Gaussian blur quality for display:"));
@@ -657,7 +656,32 @@ void InkscapePreferences::initPageFilters()
_page_filters.add_line( true, "", _blur_quality_worst, "",
_("Lowest quality (considerable artifacts), but display is fastest"));
- _show_filters_info_box.init( _("Show filter primitives infobox"), "options.showfiltersinfobox", "value", true);
+ /* filter quality */
+ _filter_quality_best.init ( _("Best quality (slowest)"), "/options/filterquality/value",
+ NR::FILTER_QUALITY_BEST, false, 0);
+ _filter_quality_better.init ( _("Better quality (slower)"), "/options/filterquality/value",
+ NR::FILTER_QUALITY_BETTER, false, &_filter_quality_best);
+ _filter_quality_normal.init ( _("Average quality"), "/options/filterquality/value",
+ NR::FILTER_QUALITY_NORMAL, true, &_filter_quality_best);
+ _filter_quality_worse.init ( _("Lower quality (faster)"), "/options/filterquality/value",
+ NR::FILTER_QUALITY_WORSE, false, &_filter_quality_best);
+ _filter_quality_worst.init ( _("Lowest quality (fastest)"), "/options/filterquality/value",
+ NR::FILTER_QUALITY_WORST, false, &_filter_quality_best);
+
+ _page_filters.add_group_header( _("Filter effects quality for display:"));
+ _page_filters.add_line( true, "", _filter_quality_best, "",
+ _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)"));
+ _page_filters.add_line( true, "", _filter_quality_better, "",
+ _("Better quality, but slower display"));
+ _page_filters.add_line( true, "", _filter_quality_normal, "",
+ _("Average quality, acceptable display speed"));
+ _page_filters.add_line( true, "", _filter_quality_worse, "",
+ _("Lower quality (some artifacts), but display is faster"));
+ _page_filters.add_line( true, "", _filter_quality_worst, "",
+ _("Lowest quality (considerable artifacts), but display is fastest"));
+
+ /* show infobox */
+ _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true);
_page_filters.add_line(true, "", _show_filters_info_box, "",
_("Show icons and descriptions for the filter primitives available at the filter effects dialog."));
@@ -667,12 +691,12 @@ void InkscapePreferences::initPageFilters()
void InkscapePreferences::initPageSelecting()
{
- _sel_all.init ( _("Select in all layers"), "options.kbselection", "inlayer", PREFS_SELECTION_ALL, false, 0);
- _sel_current.init ( _("Select only within current layer"), "options.kbselection", "inlayer", PREFS_SELECTION_LAYER, true, &_sel_all);
- _sel_recursive.init ( _("Select in current layer and sublayers"), "options.kbselection", "inlayer", PREFS_SELECTION_LAYER_RECURSIVE, false, &_sel_all);
- _sel_hidden.init ( _("Ignore hidden objects and layers"), "options.kbselection", "onlyvisible", true);
- _sel_locked.init ( _("Ignore locked objects and layers"), "options.kbselection", "onlysensitive", true);
- _sel_layer_deselects.init ( _("Deselect upon layer change"), "options.selection", "layerdeselect", true);
+ _sel_all.init ( _("Select in all layers"), "/options/kbselection/inlayer", PREFS_SELECTION_ALL, false, 0);
+ _sel_current.init ( _("Select only within current layer"), "/options/kbselection/inlayer", PREFS_SELECTION_LAYER, true, &_sel_all);
+ _sel_recursive.init ( _("Select in current layer and sublayers"), "/options/kbselection/inlayer", PREFS_SELECTION_LAYER_RECURSIVE, false, &_sel_all);
+ _sel_hidden.init ( _("Ignore hidden objects and layers"), "/options/kbselection/onlyvisible", true);
+ _sel_locked.init ( _("Ignore locked objects and layers"), "/options/kbselection/onlysensitive", true);
+ _sel_layer_deselects.init ( _("Deselect upon layer change"), "/options/selection/layerdeselect", true);
_page_select.add_group_header( _("Ctrl+A, Tab, Shift+Tab:"));
_page_select.add_line( true, "", _sel_all, "",
@@ -695,16 +719,16 @@ void InkscapePreferences::initPageSelecting()
void InkscapePreferences::initPageImportExport()
{
- _importexport_export.init("dialogs.export.defaultxdpi", "value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
+ _importexport_export.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
_page_importexport.add_line( false, _("Default export resolution:"), _importexport_export, _("dpi"),
_("Default bitmap resolution (in dots per inch) in the Export dialog"), false);
- _importexport_ocal_url.init("options.ocalurl", "str", true, g_strdup_printf("openclipart.org"));
+ _importexport_ocal_url.init("/options/ocalurl/str", true, g_strdup_printf("openclipart.org"));
_page_importexport.add_line( false, _("Open Clip Art Library Server Name:"), _importexport_ocal_url, "",
_("The server name of the Open Clip Art Library webdav server. It's used by the Import and Export to OCAL function."), true);
- _importexport_ocal_username.init("options.ocalusername", "str", true);
+ _importexport_ocal_username.init("/options/ocalusername/str", true);
_page_importexport.add_line( false, _("Open Clip Art Library Username:"), _importexport_ocal_username, "",
_("The username used to log into Open Clip Art Library."), true);
- _importexport_ocal_password.init("options.ocalpassword", "str", false);
+ _importexport_ocal_password.init("/options/ocalpassword/str", false);
_page_importexport.add_line( false, _("Open Clip Art Library Password:"), _importexport_ocal_password, "",
_("The password used to log into Open Clip Art Library."), true);
@@ -717,13 +741,13 @@ static void profileComboChanged( Gtk::ComboBoxText* combo )
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int rowNum = combo->get_active_row_number();
if ( rowNum < 1 ) {
- prefs->setString("options.displayprofile", "uri", "");
+ prefs->setString("/options/displayprofile/uri", "");
} else {
Glib::ustring active = combo->get_active_text();
Glib::ustring path = get_path_for_profile(active);
if ( !path.empty() ) {
- prefs->setString("options.displayprofile", "uri", path);
+ prefs->setString("/options/displayprofile/uri", path);
}
}
}
@@ -735,7 +759,7 @@ static void proofComboChanged( Gtk::ComboBoxText* combo )
if ( !path.empty() ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("options.softproof", "uri", path);
+ prefs->setString("/options/softproof/uri", path);
}
}
@@ -748,7 +772,7 @@ static void gamutColorChanged( Gtk::ColorButton* btn ) {
gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("options.softproof", "gamutcolor", tmp);
+ prefs->setString("/options/softproof/gamutcolor", tmp);
g_free(tmp);
}
#endif // ENABLE_LCMS
@@ -771,7 +795,7 @@ void InkscapePreferences::initPageCMS()
_page_cms.add_line( false, _("Display profile:"), _cms_display_profile, "",
_("The ICC profile to use to calibrate display output."), false);
- _cms_from_display.init( _("Retrieve profile from display"), "options.displayprofile", "from_display", false);
+ _cms_from_display.init( _("Retrieve profile from display"), "/options/displayprofile/from_display", false);
_page_cms.add_line( false, "", _cms_from_display, "",
#ifdef GDK_WINDOWING_X11
_("Retrieve profiles from those attached to displays via XICC."), false);
@@ -780,21 +804,21 @@ void InkscapePreferences::initPageCMS()
#endif // GDK_WINDOWING_X11
- _cms_intent.init("options.displayprofile", "intent", intentLabels, intentValues, numIntents, 0);
+ _cms_intent.init("/options/displayprofile/intent", intentLabels, intentValues, numIntents, 0);
_page_cms.add_line( false, _("Display rendering intent:"), _cms_intent, "",
_("The rendering intent to use to calibrate display output."), false);
_page_cms.add_group_header( _("Proofing"));
- _cms_softproof.init( _("Simulate output on screen"), "options.softproof", "enable", false);
+ _cms_softproof.init( _("Simulate output on screen"), "/options/softproof/enable", false);
_page_cms.add_line( false, "", _cms_softproof, "",
_("Simulates output of target device."), false);
- _cms_gamutwarn.init( _("Mark out of gamut colors"), "options.softproof", "gamutwarn", false);
+ _cms_gamutwarn.init( _("Mark out of gamut colors"), "/options/softproof/gamutwarn", false);
_page_cms.add_line( false, "", _cms_gamutwarn, "",
_("Highlights colors that are out of gamut for the target device."), false);
- Glib::ustring colorStr = prefs->getString("options.softproof", "gamutcolor");
+ Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr);
_cms_gamutcolor.set_color( tmpColor );
_page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "",
@@ -803,15 +827,15 @@ void InkscapePreferences::initPageCMS()
_page_cms.add_line( false, _("Device profile:"), _cms_proof_profile, "",
_("The ICC profile to use to simulate device output."), false);
- _cms_proof_intent.init("options.softproof", "intent", intentLabels, intentValues, numIntents, 0);
+ _cms_proof_intent.init("/options/softproof/intent", intentLabels, intentValues, numIntents, 0);
_page_cms.add_line( false, _("Device rendering intent:"), _cms_proof_intent, "",
_("The rendering intent to use to calibrate display output."), false);
- _cms_proof_blackpoint.init( _("Black point compensation"), "options.softproof", "bpc", false);
+ _cms_proof_blackpoint.init( _("Black point compensation"), "/options/softproof/bpc", false);
_page_cms.add_line( false, "", _cms_proof_blackpoint, "",
_("Enables black point compensation."), false);
- _cms_proof_preserveblack.init( _("Preserve black"), "options.softproof", "preserveblack", false);
+ _cms_proof_preserveblack.init( _("Preserve black"), "/options/softproof/preserveblack", false);
_page_cms.add_line( false, "", _cms_proof_preserveblack,
#if defined(cmsFLAGS_PRESERVEBLACK)
"",
@@ -828,7 +852,7 @@ void InkscapePreferences::initPageCMS()
#if ENABLE_LCMS
{
std::vector<Glib::ustring> names = ::Inkscape::colorprofile_get_display_names();
- Glib::ustring current = prefs->getString( "options.displayprofile", "uri" );
+ Glib::ustring current = prefs->getString( "/options/displayprofile/uri" );
gint index = 0;
_cms_display_profile.append_text(_("<none>"));
@@ -846,7 +870,7 @@ void InkscapePreferences::initPageCMS()
}
names = ::Inkscape::colorprofile_get_softproof_names();
- current = prefs->getString("options.softproof", "uri");
+ current = prefs->getString("/options/softproof/uri");
index = 0;
for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) {
_cms_proof_profile.append_text( *it );
@@ -883,7 +907,7 @@ void InkscapePreferences::initPageGrids()
{
_page_grids.add_group_header( _("Major grid line emphasizing"));
- _grids_no_emphasize_on_zoom.init( _("Don't emphasize gridlines when zoomed out"), "options.grids", "no_emphasize_when_zoomedout", false);
+ _grids_no_emphasize_on_zoom.init( _("Don't emphasize gridlines when zoomed out"), "/options/grids/no_emphasize_when_zoomedout", false);
_page_grids.add_line( false, "", _grids_no_emphasize_on_zoom, "", _("If set and zoomed out, the gridlines will be shown in normal color instead of major grid line color."), false);
_page_grids.add_group_header( _("Default grid settings"));
@@ -891,44 +915,44 @@ void InkscapePreferences::initPageGrids()
_page_grids.add_line( false, "", _grids_notebook, "", "", false);
_grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));
_grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
- _grids_xy_units.init("options.grids.xy", "units");
+ _grids_xy_units.init("/options/grids/units");
_grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);
- _grids_xy_origin_x.init("options.grids.xy", "origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
- _grids_xy_origin_y.init("options.grids.xy", "origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
+ _grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
+ _grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
_grids_xy.add_line( false, _("Origin X:"), _grids_xy_origin_x, "", _("X coordinate of grid origin"), false);
_grids_xy.add_line( false, _("Origin Y:"), _grids_xy_origin_y, "", _("Y coordinate of grid origin"), false);
- _grids_xy_spacing_x.init("options.grids.xy", "spacing_x", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
- _grids_xy_spacing_y.init("options.grids.xy", "spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
+ _grids_xy_spacing_x.init("/options/grids/xy/spacing_x", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
+ _grids_xy_spacing_y.init("/options/grids/xy/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
_grids_xy.add_line( false, _("Spacing X:"), _grids_xy_spacing_x, "", _("Distance between vertical grid lines"), false);
_grids_xy.add_line( false, _("Spacing Y:"), _grids_xy_spacing_y, "", _("Distance between horizontal grid lines"), false);
- _grids_xy_color.init(_("Grid line color:"), "options.grids.xy", "color", 0x0000ff20);
+ _grids_xy_color.init(_("Grid line color:"), "/options/grids/xy/color", 0x0000ff20);
_grids_xy.add_line( false, _("Grid line color:"), _grids_xy_color, "", _("Color used for normal grid lines"), false);
- _grids_xy_empcolor.init(_("Major grid line color:"), "options.grids.xy", "empcolor", 0x0000ff40);
+ _grids_xy_empcolor.init(_("Major grid line color:"), "/options/grids/xy/empcolor", 0x0000ff40);
_grids_xy.add_line( false, _("Major grid line color:"), _grids_xy_empcolor, "", _("Color used for major (highlighted) grid lines"), false);
- _grids_xy_empspacing.init("options.grids.xy", "empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
+ _grids_xy_empspacing.init("/options/grids/xy/empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
_grids_xy.add_line( false, _("Major grid line every:"), _grids_xy_empspacing, "", "", false);
- _grids_xy_dotted.init( _("Show dots instead of lines"), "options.grids.xy", "dotted", false);
+ _grids_xy_dotted.init( _("Show dots instead of lines"), "/options/grids/xy/dotted", false);
_grids_xy.add_line( false, "", _grids_xy_dotted, "", _("If set, display dots at gridpoints instead of gridlines"), false);
// CanvasAxonomGrid properties:
- _grids_axonom_units.init("options.grids.axonom", "units");
+ _grids_axonom_units.init("/options/grids/axonom/units");
_grids_axonom.add_line( false, _("Grid units:"), _grids_axonom_units, "", "", false);
- _grids_axonom_origin_x.init("options.grids.axonom", "origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
- _grids_axonom_origin_y.init("options.grids.axonom", "origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
+ _grids_axonom_origin_x.init("/options/grids/axonom/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
+ _grids_axonom_origin_y.init("/options/grids/axonom/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
_grids_axonom.add_line( false, _("Origin X:"), _grids_axonom_origin_x, "", _("X coordinate of grid origin"), false);
_grids_axonom.add_line( false, _("Origin Y:"), _grids_axonom_origin_y, "", _("Y coordinate of grid origin"), false);
- _grids_axonom_spacing_y.init("options.grids.axonom", "spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
+ _grids_axonom_spacing_y.init("/options/grids/axonom/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false);
_grids_axonom.add_line( false, _("Spacing Y:"), _grids_axonom_spacing_y, "", _("Base length of z-axis"), false);
- _grids_axonom_angle_x.init("options.grids.axonom", "angle_x", -360.0, 360.0, 1.0, 10.0, 30.0, false, false);
- _grids_axonom_angle_z.init("options.grids.axonom", "angle_z", -360.0, 360.0, 1.0, 10.0, 30.0, false, false);
+ _grids_axonom_angle_x.init("/options/grids/axonom/angle_x", -360.0, 360.0, 1.0, 10.0, 30.0, false, false);
+ _grids_axonom_angle_z.init("/options/grids/axonom/angle_z", -360.0, 360.0, 1.0, 10.0, 30.0, false, false);
_grids_axonom.add_line( false, _("Angle X:"), _grids_axonom_angle_x, "", _("Angle of x-axis"), false);
_grids_axonom.add_line( false, _("Angle Z:"), _grids_axonom_angle_z, "", _("Angle of z-axis"), false);
- _grids_axonom_color.init(_("Grid line color:"), "options.grids.axonom", "color", 0x0000ff20);
+ _grids_axonom_color.init(_("Grid line color:"), "/options/grids/axonom/color", 0x0000ff20);
_grids_axonom.add_line( false, _("Grid line color:"), _grids_axonom_color, "", _("Color used for normal grid lines"), false);
- _grids_axonom_empcolor.init(_("Major grid line color:"), "options.grids.axonom", "empcolor", 0x0000ff40);
+ _grids_axonom_empcolor.init(_("Major grid line color:"), "/options/grids/axonom/empcolor", 0x0000ff40);
_grids_axonom.add_line( false, _("Major grid line color:"), _grids_axonom_empcolor, "", _("Color used for major (highlighted) grid lines"), false);
- _grids_axonom_empspacing.init("options.grids.axonom", "empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
+ _grids_axonom_empspacing.init("/options/grids/axonom/empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
_grids_axonom.add_line( false, _("Major grid line every:"), _grids_axonom_empspacing, "", "", false);
this->AddPage(_page_grids, _("Grids"), PREFS_PAGE_GRIDS);
@@ -936,31 +960,31 @@ void InkscapePreferences::initPageGrids()
void InkscapePreferences::initPageSVGOutput()
{
- _svgoutput_usenamedcolors.init( _("Use named colors"), "options.svgoutput", "usenamedcolors", false);
+ _svgoutput_usenamedcolors.init( _("Use named colors"), "/options/svgoutput/usenamedcolors", false);
_page_svgoutput.add_line( false, "", _svgoutput_usenamedcolors, "", _("If set, write the CSS name of the color when available (e.g. 'red' or 'magenta') instead of the numeric value"), false);
_page_svgoutput.add_group_header( _("XML formatting"));
- _svgoutput_inlineattrs.init( _("Inline attributes"), "options.svgoutput", "inlineattrs", false);
+ _svgoutput_inlineattrs.init( _("Inline attributes"), "/options/svgoutput/inlineattrs", false);
_page_svgoutput.add_line( false, "", _svgoutput_inlineattrs, "", _("Put attributes on the same line as the element tag"), false);
- _svgoutput_indent.init("options.svgoutput", "indent", 0.0, 1000.0, 1.0, 2.0, 2.0, true, false);
+ _svgoutput_indent.init("/options/svgoutput/indent", 0.0, 1000.0, 1.0, 2.0, 2.0, true, false);
_page_svgoutput.add_line( false, _("Indent, spaces:"), _svgoutput_indent, "", _("The number of spaces to use for indenting nested elements; set to 0 for no indentation"), false);
_page_svgoutput.add_group_header( _("Path data"));
- _svgoutput_allowrelativecoordinates.init( _("Allow relative coordinates"), "options.svgoutput", "allowrelativecoordinates", true);
+ _svgoutput_allowrelativecoordinates.init( _("Allow relative coordinates"), "/options/svgoutput/allowrelativecoordinates", true);
_page_svgoutput.add_line( false, "", _svgoutput_allowrelativecoordinates, "", _("If set, relative coordinates may be used in path data"), false);
- _svgoutput_forcerepeatcommands.init( _("Force repeat commands"), "options.svgoutput", "forcerepeatcommands", false);
+ _svgoutput_forcerepeatcommands.init( _("Force repeat commands"), "/options/svgoutput/forcerepeatcommands", false);
_page_svgoutput.add_line( false, "", _svgoutput_forcerepeatcommands, "", _("Force repeating of the same path command (for example, 'L 1,2 L 3,4' instead of 'L 1,2 3,4')"), false);
_page_svgoutput.add_group_header( _("Numbers"));
- _svgoutput_numericprecision.init("options.svgoutput", "numericprecision", 1.0, 16.0, 1.0, 2.0, 8.0, true, false);
+ _svgoutput_numericprecision.init("/options/svgoutput/numericprecision", 1.0, 16.0, 1.0, 2.0, 8.0, true, false);
_page_svgoutput.add_line( false, _("Numeric precision:"), _svgoutput_numericprecision, "", _("How many digits to write after the decimal dot"), false);
- _svgoutput_minimumexponent.init("options.svgoutput", "minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false);
+ _svgoutput_minimumexponent.init("/options/svgoutput/minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false);
_page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero."), false);
this->AddPage(_page_svgoutput, _("SVG output"), PREFS_PAGE_SVGOUTPUT);
@@ -971,19 +995,19 @@ void InkscapePreferences::initPageUI()
Glib::ustring sizeLabels[] = {_("Normal"), _("Medium"), _("Small")};
int sizeValues[] = {0, 1, 2};
- _misc_small_toolbar.init( "toolbox", "small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 );
+ _misc_small_toolbar.init( "/toolbox/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 );
_page_ui.add_line( false, _("Commands bar icon size"), _misc_small_toolbar, "",
_("Set the size for the commands toolbar to use (requires restart)"), false);
- _misc_small_secondary.init( "toolbox", "secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1 );
+ _misc_small_secondary.init( "/toolbox/secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1 );
_page_ui.add_line( false, _("Tool controls bar icon size"), _misc_small_secondary, "",
_("Set the size for the secondary toolbar to use (requires restart)"), false);
- _misc_small_tools.init( "toolbox.tools", "small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 );
+ _misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 );
_page_ui.add_line( false, _("Main toolbar icon size"), _misc_small_tools, "",
_("Set the size for the main tools to use (requires restart)"), false);
- _misc_recent.init("options.maxrecentdocuments", "value", 0.0, 1000.0, 1.0, 1.0, 1.0, true, false);
+ _misc_recent.init("/options/maxrecentdocuments/value", 0.0, 1000.0, 1.0, 1.0, 1.0, true, false);
_page_ui.add_line( false, _("Maximum documents in Open Recent:"), _misc_recent, "",
_("The maximum length of the Open Recent list in the File menu"), false);
@@ -998,13 +1022,13 @@ void InkscapePreferences::initPageUI()
void InkscapePreferences::initPageAutosave()
{
// Autosave options
- _autosave_autosave_enable.init( _("Enable autosave (requires restart)"), "options.autosave", "enable", false);
+ _autosave_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false);
_page_autosave.add_line(false, "", _autosave_autosave_enable, "", _("Automatically save the current document(s) at a given interval, thus minimizing loss in case of a crash"), false);
- _autosave_autosave_interval.init("options.autosave", "interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false);
+ _autosave_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false);
_page_autosave.add_line(true, _("Interval (in minutes):"), _autosave_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false);
- _autosave_autosave_path.init("options.autosave", "path", true);
+ _autosave_autosave_path.init("/options/autosave/path", true);
_page_autosave.add_line(true, _("Path:"), _autosave_autosave_path, "", _("The directory where autosaves will be written"), false);
- _autosave_autosave_max.init("options.autosave", "max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false);
+ _autosave_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false);
_page_autosave.add_line(true, _("Maximum number of autosaves:"), _autosave_autosave_max, "", _("Maximum number of autosaved files; use this to limit the storage space used"), false);
/* When changing the interval or enabling/disabling the autosave function,
@@ -1012,9 +1036,7 @@ void InkscapePreferences::initPageAutosave()
*
* FIXME!
* the inkscape_autosave_init should be called AFTER the values have been changed
- * (which cannot be guaranteed from here)
- *
- * For now, autosave-settings will not change until restart
+ * (which cannot be guaranteed from here) - use a PrefObserver somewhere
*/
/*
_autosave_autosave_enable.signal_toggled().connect( sigc::ptr_fun(inkscape_autosave_init), TRUE );
@@ -1032,15 +1054,15 @@ void InkscapePreferences::initPageBitmaps()
Glib::ustring labels[] = {_("None"), _("2x2"), _("4x4"), _("8x8"), _("16x16")};
int values[] = {0, 1, 2, 3, 4};
_misc_overs_bitmap.set_size_request(_sb_width);
- _misc_overs_bitmap.init("options.bitmapoversample", "value", labels, values, G_N_ELEMENTS(values), 1);
+ _misc_overs_bitmap.init("/options/bitmapoversample/value", labels, values, G_N_ELEMENTS(values), 1);
_page_bitmaps.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false);
}
- _misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "options.bitmapautoreload", "value", true);
+ _misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "/options/bitmapautoreload/value", true);
_page_bitmaps.add_line( false, "", _misc_bitmap_autoreload, "",
_("Automatically reload linked images when file is changed on disk"));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring choices = prefs->getString("options.bitmapeditor", "choices");
+ Glib::ustring choices = prefs->getString("/options/bitmapeditor/choices");
if (!choices.empty()) {
gchar** splits = g_strsplit(choices.data(), ",", 0);
gint numIems = g_strv_length(splits);
@@ -1051,13 +1073,13 @@ void InkscapePreferences::initPageBitmaps()
values[i] = i;
labels[i] = splits[i];
}
- _misc_bitmap_editor.init("options.bitmapeditor", "value", labels, values, numIems, 0);
+ _misc_bitmap_editor.init("/options/bitmapeditor/value", labels, values, numIems, 0);
_page_bitmaps.add_line( false, _("Bitmap editor:"), _misc_bitmap_editor, "", "", false);
g_strfreev(splits);
}
- _bitmap_copy_res.init("options.createbitmap", "resolution", 1.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
+ _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
_page_bitmaps.add_line( false, _("Resolution for Create Bitmap Copy:"), _bitmap_copy_res, _("dpi"),
_("Resolution used by the Create Bitmap Copy command"), false);
@@ -1067,23 +1089,23 @@ void InkscapePreferences::initPageBitmaps()
void InkscapePreferences::initPageMisc()
{
- _misc_comment.init( _("Add label comments to printing output"), "printing.debug", "show-label-comments", false);
+ _misc_comment.init( _("Add label comments to printing output"), "/printing/debug/show-label-comments", false);
_page_misc.add_line( false, "", _misc_comment, "",
_("When on, a comment will be added to the raw print output, marking the rendered output for an object with its label"), true);
- _misc_forkvectors.init( _("Prevent sharing of gradient definitions"), "options.forkgradientvectors", "value", true);
+ _misc_forkvectors.init( _("Prevent sharing of gradient definitions"), "/options/forkgradientvectors/value", true);
_page_misc.add_line( false, "", _misc_forkvectors, "",
_("When on, shared gradient definitions are automatically forked on change; uncheck to allow sharing of gradient definitions so that editing one object may affect other objects using the same gradient"), true);
- _misc_simpl.init("options.simplifythreshold", "value", 0.0001, 1.0, 0.0001, 0.0010, 0.0010, false, false);
+ _misc_simpl.init("/options/simplifythreshold/value", 0.0001, 1.0, 0.0001, 0.0010, 0.0010, false, false);
_page_misc.add_line( false, _("Simplification threshold:"), _misc_simpl, "",
_("How strong is the Simplify command by default. If you invoke this command several times in quick succession, it will act more and more aggressively; invoking it again after a pause restores the default threshold."), false);
- _misc_latency_skew.init("debug.latency", "skew", 0.5, 2.0, 0.01, 0.10, 1.0, false, false);
+ _misc_latency_skew.init("/debug/latency/skew", 0.5, 2.0, 0.01, 0.10, 1.0, false, false);
_page_misc.add_line( false, _("Latency skew:"), _misc_latency_skew, _("(requires restart)"),
_("Factor by which the event clock is skewed from the actual time (0.9766 on some systems)."), false);
- _misc_namedicon_delay.init( _("Pre-render named icons"), "options.iconrender", "named_nodelay", false);
+ _misc_namedicon_delay.init( _("Pre-render named icons"), "/options/iconrender/named_nodelay", false);
_page_misc.add_line( false, "", _misc_namedicon_delay, "",
_("When on, named icons will be rendered before displaying the ui. This is for working around bugs in GTK+ named icon notification"), true);
@@ -1108,7 +1130,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter)
{
Gtk::TreeModel::Row row = *iter;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int desired_page = prefs->getInt("dialogs.preferences", "page", 0);
+ int desired_page = prefs->getInt("/dialogs/preferences/page", 0);
if (desired_page == row[_page_list_columns._col_id])
{
if (desired_page >= PREFS_PAGE_TOOLS && desired_page <= PREFS_PAGE_TOOLS_DROPPER)
@@ -1133,7 +1155,7 @@ void InkscapePreferences::on_pagelist_selection_changed()
Gtk::TreeModel::Row row = *iter;
_current_page = row[_page_list_columns._col_page];
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("dialogs.preferences", "page", row[_page_list_columns._col_id]);
+ prefs->setInt("/dialogs/preferences/page", row[_page_list_columns._col_id]);
_page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>");
_page_frame.add(*_current_page);
_current_page->show();
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 02794d0e2..98ecda855 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -1,7 +1,7 @@
-/**
- * brief Inkscape Preferences dialog
- *
- * Authors:
+/** @file
+ * @brief Inkscape Preferences dialog
+ */
+/* Authors:
* Carl Hetherington
* Marco Scholten
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
@@ -158,6 +158,7 @@ protected:
PrefCheckButton _mask_mask_remove;
PrefRadioButton _blur_quality_best, _blur_quality_better, _blur_quality_normal, _blur_quality_worse, _blur_quality_worst;
+ PrefRadioButton _filter_quality_best, _filter_quality_better, _filter_quality_normal, _filter_quality_worse, _filter_quality_worst;
PrefCheckButton _show_filters_info_box;
PrefCheckButton _trans_scale_stroke, _trans_scale_corner, _trans_gradient,_trans_pattern;
diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp
index 25f123797..ae8594e50 100644
--- a/src/ui/dialog/input.cpp
+++ b/src/ui/dialog/input.cpp
@@ -1,4 +1,37 @@
+/** @file
+ * @brief Input devices dialog (new) - implementation
+ */
+/* Author:
+ * Jon A. Cruz
+ *
+ * Copyright (C) 2008 Author
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+#include <map>
+#include <set>
+#include <glib/gprintf.h>
+#include <glibmm/i18n.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/enums.h>
+#include <gtkmm/eventbox.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/image.h>
+#include <gtkmm/menubar.h>
+#include <gtkmm/notebook.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/progressbar.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/treemodel.h>
+#include <gtkmm/treemodelcolumn.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/treeview.h>
+
+#include "ui/widget/panel.h"
+#include "device-manager.h"
+
+#include "input.h"
/* XPM */
static char const * core_xpm[] = {
@@ -282,35 +315,6 @@ static char const * axis_on_xpm[] = {
" .................... ",
" "};
-
-
-
-
-#include <map>
-#include <set>
-#include <glib/gprintf.h>
-#include <glibmm/i18n.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/enums.h>
-#include <gtkmm/eventbox.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/image.h>
-#include <gtkmm/menubar.h>
-#include <gtkmm/notebook.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/progressbar.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/treemodel.h>
-#include <gtkmm/treemodelcolumn.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/treeview.h>
-
-#include "ui/widget/panel.h"
-#include "device-manager.h"
-
-#include "input.h"
-
using Inkscape::InputDevice;
namespace Inkscape {
diff --git a/src/ui/dialog/input.h b/src/ui/dialog/input.h
index b3cd97a44..38666f52c 100644
--- a/src/ui/dialog/input.h
+++ b/src/ui/dialog/input.h
@@ -1,3 +1,12 @@
+/** @file
+ * @brief Input devices dialog (new)
+ */
+/* Author:
+ * Jon A. Cruz
+ *
+ * Copyright (C) 2008 Author
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
#ifndef INKSCAPE_UI_DIALOG_INPUT_H
#define INKSCAPE_UI_DIALOG_INPUT_H
@@ -16,7 +25,7 @@ class InputDialog : public UI::Widget::Panel
public:
static InputDialog &getInstance();
- InputDialog() : UI::Widget::Panel("", "dialogs.inputdevices2", SP_VERB_DIALOG_INPUT2) {}
+ InputDialog() : UI::Widget::Panel("", "/dialogs/inputdevices2", SP_VERB_DIALOG_INPUT2) {}
virtual ~InputDialog() {}
};
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 73d26b67e..8a7e0adeb 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -1,13 +1,12 @@
-/**
- * \brief LivePathEffect dialog
- *
- * Authors:
+/** @file
+ * @brief Live Path Effect editing dialog - implementation
+ */
+/* Authors:
* Johan Engelen <j.b.c.engelen@utwente.nl>
* Steren Giannini <steren.giannini@gmail.com>
* Bastien Bouclet <bgkweb@gmail.com>
*
- * Copyright (C) 2007 Author
- *
+ * Copyright (C) 2007 Authors
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -68,7 +67,7 @@ static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint
*/
LivePathEffectEditor::LivePathEffectEditor()
- : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
+ : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
lpe_list_locked(false),
combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
effectwidget(NULL),
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index 49db74fca..370bd599a 100644
--- a/src/ui/dialog/livepatheffect-editor.h
+++ b/src/ui/dialog/livepatheffect-editor.h
@@ -1,11 +1,10 @@
-/**
- * \brief LivePathEffect dialog
- *
- * Author:
+/** @file
+ * @brief Live Path Effect editing dialog
+ */
+/* Author:
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
* Copyright (C) 2007 Author
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp
index 1931976d6..a80c7b449 100644
--- a/src/ui/dialog/memory.cpp
+++ b/src/ui/dialog/memory.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief Memory statistics dialog
- *
- * Authors:
+/** @file
+ * @brief Memory statistics dialog
+ */
+/* Authors:
* MenTaLguY <mental@rydia.net>
*
* Copyright (C) 2005
@@ -204,7 +204,7 @@ void Memory::Private::stop_update_task() {
}
Memory::Memory()
- : UI::Widget::Panel ("", "dialogs.memory", SP_VERB_HELP_MEMORY, _("Recalculate")),
+ : UI::Widget::Panel ("", "/dialogs/memory", SP_VERB_HELP_MEMORY, _("Recalculate")),
_private(*(new Memory::Private()))
{
_getContents()->add(_private.view);
diff --git a/src/ui/dialog/memory.h b/src/ui/dialog/memory.h
index 6f832f3e1..48dcc8f09 100644
--- a/src/ui/dialog/memory.h
+++ b/src/ui/dialog/memory.h
@@ -1,11 +1,10 @@
-/**
- * \brief Memory statistics dialog
- *
- * Authors:
+/** @file
+ * @brief Memory statistics dialog
+ */
+/* Authors:
* MenTaLguY <mental@rydia.net>
*
* Copyright 2005 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp
index 7eaf23f50..958256310 100644
--- a/src/ui/dialog/messages.cpp
+++ b/src/ui/dialog/messages.cpp
@@ -1,9 +1,7 @@
-/*
- * A very simple dialog for displaying Inkscape messages. Messages
- * sent to g_log(), g_warning(), g_message(), ets, are routed here,
- * in order to avoid messing with the startup console.
- *
- * Authors:
+/** @file
+ * @brief Messages dialog - implementation
+ */
+/* Authors:
* Bob Jamison
* Other dudes from The Inkscape Organization
*
@@ -46,7 +44,7 @@ void Messages::clear()
* Constructor
*/
Messages::Messages()
- : UI::Widget::Panel("", "dialogs.messages", SP_VERB_DIALOG_DEBUG)
+ : UI::Widget::Panel("", "/dialogs/messages", SP_VERB_DIALOG_DEBUG)
{
Gtk::Box *contents = _getContents();
@@ -183,6 +181,13 @@ void Messages::releaseLogMessages()
} //namespace UI
} //namespace Inkscape
-//#########################################################################
-//## E N D O F F I L E
-//#########################################################################
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/messages.h b/src/ui/dialog/messages.h
index 8dcb718cc..b0a9d812b 100644
--- a/src/ui/dialog/messages.h
+++ b/src/ui/dialog/messages.h
@@ -1,16 +1,15 @@
-/*
- * \brief Messages Dialog
+/** @file
+ * @brief Messages dialog
*
* A very simple dialog for displaying Inkscape messages. Messages
* sent to g_log(), g_warning(), g_message(), ets, are routed here,
* in order to avoid messing with the startup console.
- *
- * Authors:
+ */
+/* Authors:
* Bob Jamison
* Other dudes from The Inkscape Organization
*
* Copyright (C) 2004, 2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index de22c16d6..ba572336c 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -1,7 +1,7 @@
-/**
- * Implementation of the ocal dialog interfaces defined in ocaldialog.h
- *
- * Authors:
+/** @file
+ * @brief Open Clip Art Library integration dialogs - implementation
+ */
+/* Authors:
* Bruno Dilly
* Other dudes from The Inkscape Organization
*
@@ -309,7 +309,7 @@ void FileListViewText::on_cursor_changed()
//Inkscape::Preferences *prefs = Inkscape::Preferences::get();
//Glib::ustring fileUrl = "dav://"; //dav url
- //fileUrl.append(prefs->getString("options.ocalurl", "str"));
+ //fileUrl.append(prefs->getString("/options/ocalurl/str"));
//fileUrl.append("/dav.php/");
//fileUrl.append(get_text(posArray[0], 3)); //author dir
//fileUrl.append("/");
@@ -425,7 +425,7 @@ void FileImportFromOCALDialog::searchTagEntryChangedCallback()
Glib::ustring searchTag = searchTagEntry->get_text();
// create the ocal uri to get rss feed
Glib::ustring uri = "http://";
- uri.append(prefs->getString("options.ocalurl", "str"));
+ uri.append(prefs->getString("/options/ocalurl/str"));
uri.append("/media/feed/rss/");
uri.append(searchTag);
if (!Glib::get_charset()) //If we are not utf8
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
index 0953e76bc..75d57fc59 100644
--- a/src/ui/dialog/ocaldialogs.h
+++ b/src/ui/dialog/ocaldialogs.h
@@ -1,17 +1,16 @@
-#ifndef __OCAL_DIALOG_H__
-#define __OCAL_DIALOG_H__
-/**
- * Defines the FileExportToOCALDialog, FileImportFromOCALDialog and
- * FileExportToOCALPasswordDialog and their supporting classes.
- *
- * Authors:
+/** @file
+ * @brief Open Clip Art Library integration dialogs
+ */
+/* Authors:
* Bruno Dilly <bruno.dilly@gmail.com>
* Inkscape Guys
*
* Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+
+#ifndef __OCAL_DIALOG_H__
+#define __OCAL_DIALOG_H__
#include <glibmm.h>
#include <vector>
@@ -45,7 +44,6 @@
#endif
//Inkscape includes
-#include "prefs-utils.h"
#include <extension/input.h>
#include <extension/output.h>
#include <extension/db.h>
diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h
index eebd323d6..f087f40e4 100644
--- a/src/ui/dialog/panel-dialog.h
+++ b/src/ui/dialog/panel-dialog.h
@@ -1,11 +1,10 @@
-/**
- * \brief A panel holding dialog
- *
- * Authors:
+/** @file
+ * @brief A panel holding dialog
+ */
+/* Authors:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -23,7 +22,7 @@
#include "dialogs/swatches.h"
#include "ui/dialog/floating-behavior.h"
#include "ui/dialog/dock-behavior.h"
-#include "prefs-utils.h"
+#include "preferences.h"
namespace Inkscape {
namespace UI {
@@ -147,7 +146,8 @@ PanelDialog<B>::PanelDialog(Panel &panel, char const *prefs_path, int const verb
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
- if (prefs_get_int_attribute ("dialogs", "showclose", 0) || !apply_label.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/showclose") || !apply_label.empty()) {
// TODO: make the order of buttons obey the global preference
if (!apply_label.empty()) {
panel.addResponseButton(apply_label, Gtk::RESPONSE_APPLY);
@@ -198,7 +198,8 @@ PanelDialog<Behavior::FloatingBehavior>::PanelDialog(Panel &panel, char const *p
_document_replaced_connection =
desktop->connectDocumentReplaced(sigc::mem_fun(*this, &PanelDialog::_propagateDocumentReplaced));
- if (prefs_get_int_attribute ("dialogs", "showclose", 0) || !apply_label.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/showclose") || !apply_label.empty()) {
// TODO: make the order of buttons obey the global preference
if (!apply_label.empty()) {
panel.addResponseButton(apply_label, Gtk::RESPONSE_APPLY);
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index 9e848bd6a..b2094f540 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -1,11 +1,10 @@
-/**
- * \brief Print dialog
- *
- * Authors:
+/** @file
+ * @brief Print dialog
+ */
+/* Authors:
* Kees Cook <kees@outflux.net>
*
* Copyright (C) 2007 Kees Cook
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -260,3 +259,14 @@ Gtk::PrintOperationResult Print::run(Gtk::PrintOperationAction, Gtk::Window &par
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/print.h b/src/ui/dialog/print.h
index f6c69bdb8..ea89ebdf2 100644
--- a/src/ui/dialog/print.h
+++ b/src/ui/dialog/print.h
@@ -1,11 +1,10 @@
-/**
- * \brief Print dialog
- *
- * Authors:
+/** @file
+ * @brief Print dialog
+ */
+/* Authors:
* Kees Cook <kees@outflux.net>
*
* Copyright (C) 2007 Kees Cook
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp
index 7b299b700..0e8a23baf 100644
--- a/src/ui/dialog/scriptdialog.cpp
+++ b/src/ui/dialog/scriptdialog.cpp
@@ -1,7 +1,7 @@
-/**
- * Dialog for executing and monitoring script execution
- *
- * Author:
+/** @file
+ * @brief Dialog for executing and monitoring script execution
+ */
+/* Author:
* Bob Jamison
*
* Copyright (C) 2004-2008 Authors
@@ -270,9 +270,13 @@ ScriptDialog &ScriptDialog::getInstance()
} //namespace UI
} //namespace Inkscape
-//#########################################################################
-//## E N D O F F I L E
-//#########################################################################
-
-
-
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/scriptdialog.h b/src/ui/dialog/scriptdialog.h
index 780d44a92..d0021ce68 100644
--- a/src/ui/dialog/scriptdialog.h
+++ b/src/ui/dialog/scriptdialog.h
@@ -1,10 +1,10 @@
-#ifndef __SCRIPTDIALOG_H__
-#define __SCRIPTDIALOG_H__
-/*
- * This dialog is for launching scripts whose main purpose if
- * the scripting of Inkscape itself.
+/** @file
+ * @brief Script dialog
*
- * Authors:
+ * This dialog is for launching scripts whose main purpose is
+ * the scripting of Inkscape itself.
+ */
+/* Authors:
* Bob Jamison
* Other dudes from The Inkscape Organization
*
@@ -13,6 +13,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#ifndef __SCRIPTDIALOG_H__
+#define __SCRIPTDIALOG_H__
#include "ui/widget/panel.h"
#include "verbs.h"
@@ -35,7 +37,7 @@ class ScriptDialog : public UI::Widget::Panel
* Constructor
*/
ScriptDialog() :
- UI::Widget::Panel("", "dialogs.script", SP_VERB_DIALOG_SCRIPT)
+ UI::Widget::Panel("", "/dialogs/script", SP_VERB_DIALOG_SCRIPT)
{}
@@ -62,8 +64,15 @@ class ScriptDialog : public UI::Widget::Panel
} //namespace UI
} //namespace Inkscape
-
-
-
#endif /* __DEBUGDIALOG_H__ */
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp
index b378c0b5a..b9a44fd98 100644
--- a/src/ui/dialog/session-player.cpp
+++ b/src/ui/dialog/session-player.cpp
@@ -1,11 +1,10 @@
-/**
- * Whiteboard session playback control dialog
- *
- * Authors:
+/** @file
+ * @brief Whiteboard session playback control dialog - implementation
+ */
+/* Authors:
* David Yip <yipdw@rose-hulman.edu>
*
* Copyright (c) 2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -228,3 +227,14 @@ SessionPlaybackDialogImpl::_respCallback(int resp)
}
}
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/session-player.h b/src/ui/dialog/session-player.h
index fd2945bb0..52377a73f 100644
--- a/src/ui/dialog/session-player.h
+++ b/src/ui/dialog/session-player.h
@@ -1,11 +1,10 @@
-/**
- * Whiteboard session playback control dialog
- *
- * Authors:
+/** @file
+ * @brief Whiteboard session playback control dialog
+ */
+/* Authors:
* David Yip <yipdw@rose-hulman.edu>
*
* Copyright (c) 2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -38,7 +37,7 @@ namespace Dialog {
class SessionPlaybackDialog : public Dialog {
public:
- SessionPlaybackDialog() : Dialog("dialogs.session_playback", SP_VERB_DIALOG_WHITEBOARD_SESSIONPLAYBACK)
+ SessionPlaybackDialog() : Dialog("/dialogs/session_playback", SP_VERB_DIALOG_WHITEBOARD_SESSIONPLAYBACK)
{
}
@@ -122,3 +121,14 @@ private:
}
#endif
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index fa81e84ca..6a27f6048 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -1,11 +1,10 @@
-/**
- * \brief SVG Fonts dialog
- *
- * Authors:
+/** @file
+ * @brief SVG Fonts dialog - implementation
+ */
+/* Authors:
* Felipe C. da S. Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2008 Authors
- *
* Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information.
*/
@@ -249,12 +248,12 @@ Gtk::VBox* SvgFontsDialog::global_settings_tab(){
Gtk::VBox* global_vbox = Gtk::manage(new Gtk::VBox());
AttrEntry* familyname;
- familyname = new AttrEntry(this, (gchar*) "Family Name", SP_PROP_FONT_FAMILY);
+ familyname = new AttrEntry(this, (gchar*) _("Family Name:"), SP_PROP_FONT_FAMILY);
global_vbox->add(*familyname);
- global_vbox->add(*AttrCombo((gchar*) "Style", SP_PROP_FONT_STYLE));
- global_vbox->add(*AttrCombo((gchar*) "Variant", SP_PROP_FONT_VARIANT));
- global_vbox->add(*AttrCombo((gchar*) "Weight", SP_PROP_FONT_WEIGHT));
+ global_vbox->add(*AttrCombo((gchar*) _("Style:"), SP_PROP_FONT_STYLE));
+ global_vbox->add(*AttrCombo((gchar*) _("Variant:"), SP_PROP_FONT_VARIANT));
+ global_vbox->add(*AttrCombo((gchar*) _("Weight:"), SP_PROP_FONT_WEIGHT));
//Set Width (horiz_adv_x):
Gtk::HBox* setwidth_hbox = Gtk::manage(new Gtk::HBox());
@@ -271,8 +270,8 @@ Gtk::VBox* SvgFontsDialog::global_settings_tab(){
Gtk::VBox* SvgFontsDialog::glyphs_tab(){
Gtk::VBox* glyphs_vbox = Gtk::manage(new Gtk::VBox());
- glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Glyph Name", SP_ATTR_GLYPH_NAME));
- glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Unicode", SP_ATTR_UNICODE));
+ glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) _("Glyph Name:"), SP_ATTR_GLYPH_NAME));
+ glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) _("Unicode:"), SP_ATTR_UNICODE));
//glyphs_vbox->add(*AttrSpin((gchar*) "Horizontal Advance"), SP_ATTR_HORIZ_ADV_X);
//glyphs_vbox->add(*AttrCombo((gchar*) "Missing Glyph"), SP_ATTR_); ?
return glyphs_vbox;
@@ -309,7 +308,7 @@ Gtk::VBox* SvgFontsDialog::kerning_tab(){
}
SvgFontsDialog::SvgFontsDialog()
- : UI::Widget::Panel("", "dialogs.svgfonts", SP_VERB_DIALOG_SVG_FONTS)
+ : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS)
{
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(_font_list);
diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h
index 8502a3468..f7d13a714 100644
--- a/src/ui/dialog/svg-fonts-dialog.h
+++ b/src/ui/dialog/svg-fonts-dialog.h
@@ -1,11 +1,10 @@
-/**
- * \brief SVG Fonts dialog
- *
- * Authors:
+/** @file
+ * @brief SVG Fonts dialog
+ */
+/* Authors:
* Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2008 Authors
- *
* Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information.
*/
diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp
index 84d7978fb..6ec2da5de 100644
--- a/src/ui/dialog/tracedialog.cpp
+++ b/src/ui/dialog/tracedialog.cpp
@@ -1,8 +1,7 @@
-/*
- * A simple dialog for setting the parameters for autotracing a
- * bitmap <image> into an svg <path>
- *
- * Authors:
+/** @file
+ * @brief Bitmap tracing settings dialog - implementation
+ */
+/* Authors:
* Bob Jamison <rjamison@titan.com>
* Stéphane Gimenez <dev@gim.name>
* Other dudes from The Inkscape Organization
diff --git a/src/ui/dialog/tracedialog.h b/src/ui/dialog/tracedialog.h
index 0933aee3b..9dc084cd6 100644
--- a/src/ui/dialog/tracedialog.h
+++ b/src/ui/dialog/tracedialog.h
@@ -1,18 +1,16 @@
-#ifndef __TRACEDIALOG_H__
-#define __TRACEDIALOG_H__
-/*
- * A simple dialog for setting the parameters for autotracing a
- * bitmap <image> into an svg <path>
- *
- * Authors:
+/** @file
+ * @brief Bitmap tracing settings dialog
+ */
+/* Authors:
* Bob Jamison
* Other dudes from The Inkscape Organization
*
* Copyright (C) 2004, 2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#ifndef __TRACEDIALOG_H__
+#define __TRACEDIALOG_H__
#include "verbs.h"
#include "ui/widget/panel.h"
@@ -34,7 +32,7 @@ public:
* Constructor
*/
TraceDialog() :
- UI::Widget::Panel("", "dialogs.trace", SP_VERB_SELECTION_TRACE)
+ UI::Widget::Panel("", "/dialogs/trace", SP_VERB_SELECTION_TRACE)
{}
@@ -56,8 +54,15 @@ public:
} //namespace UI
} //namespace Inkscape
-
-
-
#endif /* __TRACEDIALOG_H__ */
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 5927dc740..899053cc9 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -1,12 +1,11 @@
-/**
- * \brief Object Transformation dialog
- *
- * Authors:
+/** @file
+ * \brief Transform dialog - implementation
+ */
+/* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* buliabyak@gmail.com
*
* Copyright (C) 2004, 2005 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -26,7 +25,7 @@
#include "selection.h"
#include "selection-chemistry.h"
#include "verbs.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "sp-item-transform.h"
#include "macros.h"
#include "sp-item.h"
@@ -74,7 +73,7 @@ void on_selection_modified( Inkscape::Application */*inkscape*/,
*
*/
Transformation::Transformation()
- : UI::Widget::Panel ("", "dialogs.transformation", SP_VERB_DIALOG_TRANSFORM),
+ : UI::Widget::Panel ("", "/dialogs/transformation", SP_VERB_DIALOG_TRANSFORM),
_page_move (4, 2),
_page_scale (4, 2),
_page_rotate (4, 2),
@@ -134,7 +133,8 @@ Transformation::Transformation()
// Apply separately
contents->pack_start(_check_apply_separately, true, true);
- _check_apply_separately.set_active(prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _check_apply_separately.set_active(prefs->getBool("/dialogs/transformation/applyseparately"));
_check_apply_separately.signal_toggled().connect(sigc::mem_fun(*this, &Transformation::onApplySeparatelyToggled));
// make sure all spinbuttons activate Apply on pressing Enter
@@ -599,7 +599,8 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
double x = _scalar_move_horizontal.getValue("px");
double y = _scalar_move_vertical.getValue("px");
- if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (!prefs->getBool("/dialogs/transformation/applyseparately")) {
// move selection as a whole
if (_check_move_relative.get_active()) {
sp_selection_move_relative(selection, x, y);
@@ -686,7 +687,8 @@ Transformation::applyPageScale(Inkscape::Selection *selection)
double scaleX = _scalar_scale_horizontal.getValue("px");
double scaleY = _scalar_scale_vertical.getValue("px");
- if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 1) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/transformation/applyseparately")) {
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
SPItem *item = SP_ITEM(l->data);
Geom::Scale scale (0,0);
@@ -741,7 +743,8 @@ Transformation::applyPageRotate(Inkscape::Selection *selection)
{
double angle = _scalar_rotate.getValue("deg");
- if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 1) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/transformation/applyseparately")) {
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
SPItem *item = SP_ITEM(l->data);
sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0));
@@ -760,7 +763,8 @@ Transformation::applyPageRotate(Inkscape::Selection *selection)
void
Transformation::applyPageSkew(Inkscape::Selection *selection)
{
- if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 1) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/transformation/applyseparately")) {
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
SPItem *item = SP_ITEM(l->data);
@@ -826,7 +830,7 @@ Transformation::applyPageTransform(Inkscape::Selection *selection)
double e = _scalar_transform_e.getValue();
double f = _scalar_transform_f.getValue();
- NR::Matrix displayed(a, b, c, d, e, f);
+ Geom::Matrix displayed(a, b, c, d, e, f);
if (_check_replace_matrix.get_active()) {
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
@@ -1046,7 +1050,8 @@ Transformation::onClear()
void
Transformation::onApplySeparatelyToggled()
{
- prefs_set_int_attribute ("dialogs.transformation", "applyseparately", _check_apply_separately.get_active()? 1 : 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/dialogs/transformation/applyseparately", _check_apply_separately.get_active());
}
@@ -1054,8 +1059,6 @@ Transformation::onApplySeparatelyToggled()
} // namespace UI
} // namespace Inkscape
-
-
/*
Local Variables:
mode:c++
diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h
index e64353f5a..9d05713ad 100644
--- a/src/ui/dialog/transformation.h
+++ b/src/ui/dialog/transformation.h
@@ -1,11 +1,10 @@
-/**
- * \brief Object Transformation dialog
- *
- * Author:
+/** @file
+ * @brief Transform dialog
+ */
+/* Author:
* Bryce W. Harrington <bryce@bryceharrington.org>
*
* Copyright (C) 2004, 2005 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index f2f51a780..2dec1e2d4 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -1,11 +1,10 @@
-/**
- * \brief Undo History dialog
- *
- * Author:
+/** @file
+ * @brief Undo History dialog - implementation
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2006 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -125,7 +124,7 @@ UndoHistory::setDesktop(SPDesktop* desktop)
}
UndoHistory::UndoHistory()
- : UI::Widget::Panel ("", "dialogs.undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
+ : UI::Widget::Panel ("", "/dialogs/undo-history", SP_VERB_DIALOG_UNDO_HISTORY),
_document (sp_desktop_document(getDesktop())),
_event_log (getDesktop() ? getDesktop()->event_log : NULL),
_columns (_event_log ? &_event_log->getColumns() : NULL),
diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h
index 070a1eb22..82e04f3c9 100644
--- a/src/ui/dialog/undo-history.h
+++ b/src/ui/dialog/undo-history.h
@@ -1,16 +1,10 @@
-/**
- * Undo History dialog
- *
- * \brief A dialog for presenting an event log of commited, undone and redone events. Allows the
- * user to undo and redo multiple events in a more convenient way than repateaded ctrl-z,
- * ctrl-shift-z.
- *
- *
- * Author:
+/** @file
+ * @brief Undo History dialog
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2006 Authors
- *
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -111,11 +105,12 @@ private:
struct NoFilter : Filter { bool operator() (const int& /*x*/) const { return true; } };
};
-
/**
- *
+ * \brief Dialog for presenting document change history
+ *
+ * This dialog allows the user to undo and redo multiple events in a more convenient way
+ * than repateaded ctrl-z, ctrl-shift-z.
*/
-
class UndoHistory : public Widget::Panel {
public:
virtual ~UndoHistory();
diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp
index f91d4a607..b18ed99d4 100644
--- a/src/ui/dialog/whiteboard-connect.cpp
+++ b/src/ui/dialog/whiteboard-connect.cpp
@@ -1,12 +1,15 @@
-/**
- * Whiteboard connection establishment dialog
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
+/** @file
+ * @brief Whiteboard connection dialog - implementation
+ */
+/* Authors:
+ * David Yip <yipdw@rose-hulman.edu>
+ * Jason Segal
+ * Jonas Collaros
+ * Stephen Montgomery
+ * Brandi Soggs
+ * Matthew Weinstock (original C/Gtk version)
*
* Copyright (c) 2004-2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -83,11 +86,11 @@ WhiteboardConnectDialogImpl::_construct()
this->_labels[3].set_mnemonic_widget(this->_port);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- this->_server.set_text(prefs->getString("whiteboard.server", "name"));
+ this->_server.set_text(prefs->getString("/whiteboard/server/name"));
/// @todo Convert port to an integer preference?
- this->_port.set_text(prefs->getString("whiteboard.server", "port"));
- this->_username.set_text(prefs->getString("whiteboard.server", "username"));
- this->_usessl.set_active(prefs->getBool("whiteboard.server", "ssl", false);
+ this->_port.set_text(prefs->getString("/whiteboard/server/port"));
+ this->_username.set_text(prefs->getString("/whiteboard/server/username"));
+ this->_usessl.set_active(prefs->getBool("/whiteboard/server/ssl", false);
this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
this->_layout.attach(this->_labels[1], 0, 1, 1, 2);
@@ -236,7 +239,7 @@ WhiteboardConnectDialogImpl::_respCallback(int resp)
this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
// Save preferences
- prefs->setString(this->_prefs_path, "server", this->_server.get_text());
+ prefs->setString(this->_prefs_path + "/server", this->_server.get_text());
break;
default:
break;
@@ -274,7 +277,7 @@ WhiteboardConnectDialogImpl::_respCallback(int resp)
this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
// Save preferences
- prefs->setString(this->_prefs_path, "server", this->_server.get_text());
+ prefs->setString(this->_prefs_path + "/server", this->_server.get_text());
break;
default:
break;
diff --git a/src/ui/dialog/whiteboard-connect.h b/src/ui/dialog/whiteboard-connect.h
index b96f1ce3b..8b34215f9 100644
--- a/src/ui/dialog/whiteboard-connect.h
+++ b/src/ui/dialog/whiteboard-connect.h
@@ -1,12 +1,15 @@
-/**
- * Whiteboard connection establishment dialog
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
+/** @file
+ * @brief Whiteboard connection dialog
+ */
+/* Authors:
+ * David Yip <yipdw@rose-hulman.edu>
+ * Jason Segal
+ * Jonas Collaros
+ * Stephen Montgomery
+ * Brandi Soggs
+ * Matthew Weinstock (original C/Gtk version)
*
* Copyright (c) 2004-2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -34,7 +37,7 @@ namespace Dialog {
class WhiteboardConnectDialog : public Dialog {
public:
- WhiteboardConnectDialog() : Dialog("dialogs.whiteboard_connect", SP_VERB_DIALOG_WHITEBOARD_CONNECT)
+ WhiteboardConnectDialog() : Dialog("/dialogs/whiteboard_connect", SP_VERB_DIALOG_WHITEBOARD_CONNECT)
{
}
diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp
index 4e9ea7abf..3315a7029 100644
--- a/src/ui/dialog/whiteboard-sharewithchat.cpp
+++ b/src/ui/dialog/whiteboard-sharewithchat.cpp
@@ -1,13 +1,15 @@
-/**
- * @file
- * @brief Whiteboard share with chatroom dialog
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
+/** @file
+ * @brief Whiteboard share with chatroom dialog - implementation
+ */
+/* Authors:
+ * David Yip <yipdw@rose-hulman.edu>
+ * Jason Segal
+ * Jonas Collaros
+ * Stephen Montgomery
+ * Brandi Soggs
+ * Matthew Weinstock (original C/Gtk version)
*
* Copyright (c) 2004-2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -82,9 +84,9 @@ WhiteboardShareWithChatroomDialogImpl::_construct()
this->_labels[3].set_mnemonic_widget(this->_handle);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- this->_roomname.set_text(prefs->getString("whiteboard.room", "name"));
- this->_confserver.set_text(prefs->getString("whiteboard.room", "server"));
- this->_handle.set_text(prefs->getString("whiteboard.server", "username"));
+ this->_roomname.set_text(prefs->getString("/whiteboard/room/name"));
+ this->_confserver.set_text(prefs->getString("/whiteboard/room/server"));
+ this->_handle.set_text(prefs->getString("/whiteboard/server/username"));
// Pack table
this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
diff --git a/src/ui/dialog/whiteboard-sharewithchat.h b/src/ui/dialog/whiteboard-sharewithchat.h
index 898f8da26..4a6c2fc89 100644
--- a/src/ui/dialog/whiteboard-sharewithchat.h
+++ b/src/ui/dialog/whiteboard-sharewithchat.h
@@ -1,12 +1,15 @@
-/**
- * Whiteboard share with chatroom dialog
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
+/** @file
+ * @brief Whiteboard share with chatroom dialog
+ */
+/* Authors:
+ * David Yip <yipdw@rose-hulman.edu>
+ * Jason Segal
+ * Jonas Collaros
+ * Stephen Montgomery
+ * Brandi Soggs
+ * Matthew Weinstock (original C/Gtk version)
*
* Copyright (c) 2004-2005 Authors
- *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -35,7 +38,7 @@ namespace Dialog {
class WhiteboardShareWithChatroomDialog : public Dialog {
public:
- WhiteboardShareWithChatroomDialog() : Dialog("dialogs.whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER)
+ WhiteboardShareWithChatroomDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER)
{
}
diff --git a/src/ui/dialog/whiteboard-sharewithuser.cpp b/src/ui/dialog/whiteboard-sharewithuser.cpp
index ebe91f0f3..bb3761f31 100644
--- a/src/ui/dialog/whiteboard-sharewithuser.cpp
+++ b/src/ui/dialog/whiteboard-sharewithuser.cpp
@@ -1,7 +1,7 @@
-/**
- * Whiteboard share with user dialog
- *
- * Authors:
+/** @file
+ * Whiteboard share with user dialog - implementation
+ */
+/* Authors:
* David Yip <yipdw@rose-hulman.edu>
* Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
*
diff --git a/src/ui/dialog/whiteboard-sharewithuser.h b/src/ui/dialog/whiteboard-sharewithuser.h
index ad0870707..24ec91be5 100644
--- a/src/ui/dialog/whiteboard-sharewithuser.h
+++ b/src/ui/dialog/whiteboard-sharewithuser.h
@@ -1,7 +1,7 @@
-/**
- * Whiteboard share with user dialog
- *
- * Authors:
+/** @file
+ * @brief Whiteboard share with user dialog
+ */
+/* Authors:
* David Yip <yipdw@rose-hulman.edu>
* Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version)
*
@@ -33,7 +33,7 @@ namespace Inkscape {
class WhiteboardShareWithUserDialog : public Dialog {
public:
- WhiteboardShareWithUserDialog() : Dialog("dialogs.whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER)
+ WhiteboardShareWithUserDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER)
{
}
diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp
index 67091fc40..5e7713044 100644
--- a/src/ui/view/edit-widget.cpp
+++ b/src/ui/view/edit-widget.cpp
@@ -46,7 +46,7 @@
#include "macros.h"
#include "path-prefix.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "file.h"
#include "application/editor.h"
#include "edit-widget.h"
@@ -1056,9 +1056,9 @@ EditWidget::initRightScrollbar()
void
EditWidget::initStickyZoom()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_viewport_table.attach(_sticky_zoom, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _sticky_zoom.set_active (prefs_get_int_attribute ("options.stickyzoom", "value", 0) != 0);
+ _sticky_zoom.set_active (prefs->getBool("/options/stickyzoom/value"));
_tooltips.set_tip (_sticky_zoom, _("Zoom drawing if window size changes"));
/// \todo icon not implemented
@@ -1437,30 +1437,32 @@ EditWidget::updateScrollbars (double scale)
void
EditWidget::toggleRulers()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (_top_ruler.is_visible())
{
_top_ruler.hide_all();
_left_ruler.hide_all();
- prefs_set_int_attribute (_desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", 0);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false);
} else {
_top_ruler.show_all();
_left_ruler.show_all();
- prefs_set_int_attribute (_desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", 1);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", true);
}
}
void
EditWidget::toggleScrollbars()
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (_bottom_scrollbar.is_visible())
{
_bottom_scrollbar.hide_all();
_right_scrollbar.hide_all();
- prefs_set_int_attribute (_desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", 0);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", false);
} else {
_bottom_scrollbar.show_all();
_right_scrollbar.show_all();
- prefs_set_int_attribute (_desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", 1);
+ prefs->setBool(_desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", true);
}
}
@@ -1662,8 +1664,8 @@ EditWidget::onWindowSizeAllocate (Gtk::Allocation &newall)
void
EditWidget::onWindowRealize()
{
- NR::Rect d(Geom::Point(0, 0),
- Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())));
+ NR::Rect d( Geom::Point(0, 0),
+ Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())) );
if (d.isEmpty(1.0)) {
return;
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp
index e61b8080e..12a0686f0 100644
--- a/src/ui/widget/dock-item.cpp
+++ b/src/ui/widget/dock-item.cpp
@@ -12,7 +12,7 @@
#include "dock-item.h"
#include "desktop.h"
#include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "ui/widget/dock.h"
#include "widgets/icon.h"
@@ -37,11 +37,11 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
_gdl_dock_item(0),
_dock_item_action_area(0)
{
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GdlDockItemBehavior gdl_dock_behavior =
- (prefs_get_int_attribute_limited ("options.dock", "cancenterdock", 1, 0, 1) == 0 ?
- GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER
- : GDL_DOCK_ITEM_BEH_NORMAL);
+ (prefs->getBool("/options/dock/cancenterdock", true) ?
+ GDL_DOCK_ITEM_BEH_NORMAL :
+ GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER);
if (!icon_name.empty()) {
Gtk::Widget *icon = sp_icon_get_icon(icon_name, Inkscape::ICON_SIZE_MENU);
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index 563ed8e98..3608c3551 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -1,7 +1,7 @@
-/**
- * \brief A desktop dock pane to dock dialogs.
- *
- * Author:
+/** @file
+ * @brief A desktop dock pane to dock dialogs.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
@@ -10,7 +10,7 @@
*/
#include "inkscape.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop.h"
#include "dock.h"
@@ -74,8 +74,9 @@ Dock::Dock(Gtk::Orientation orientation)
_scrolled_window->set_size_request(0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GdlSwitcherStyle gdl_switcher_style =
- static_cast<GdlSwitcherStyle>(prefs_get_int_attribute_limited("options.dock", "switcherstyle",
+ static_cast<GdlSwitcherStyle>(prefs->getIntLimited("/options/dock/switcherstyle",
GDL_SWITCHER_STYLE_BOTH, 0, 4));
g_object_set (GDL_DOCK_OBJECT(_gdl_dock)->master,
@@ -84,7 +85,7 @@ Dock::Dock(Gtk::Orientation orientation)
NULL);
GdlDockBarStyle gdl_dock_bar_style =
- static_cast<GdlDockBarStyle>(prefs_get_int_attribute_limited("options.dock", "dockbarstyle",
+ static_cast<GdlDockBarStyle>(prefs->getIntLimited("/options/dock/dockbarstyle",
GDL_DOCK_BAR_BOTH, 0, 3));
gdl_dock_bar_set_style(_gdl_dock_bar, gdl_dock_bar_style);
diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h
index dd501f186..c49d71268 100644
--- a/src/ui/widget/dock.h
+++ b/src/ui/widget/dock.h
@@ -1,7 +1,7 @@
-/**
- * \brief A desktop dock pane to dock dialogs, a custom wrapper around gdl-dock.
- *
- * Author:
+/** @file
+ * @brief A desktop dock pane to dock dialogs, a custom wrapper around gdl-dock.
+ */
+/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index 9333ffc35..9811cc89c 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -26,7 +26,7 @@
#include "panel.h"
#include "icon-size.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "desktop-handles.h"
#include "inkscape.h"
#include "dialogs/eek-preview.h"
@@ -94,50 +94,40 @@ void Panel::_init()
Glib::ustring tmp("<");
_anchor = Gtk::ANCHOR_CENTER;
- guint panel_size = 0;
- if (_prefs_path) {
- panel_size = prefs_get_int_attribute_limited( _prefs_path, "panel_size", 1, 0, static_cast<long long>(PREVIEW_SIZE_HUGE) );
- }
-
- guint panel_mode = 0;
- if (_prefs_path) {
- panel_mode = prefs_get_int_attribute_limited( _prefs_path, "panel_mode", 1, 0, 10 );
- }
-
- guint panel_wrap = 0;
- if (_prefs_path) {
- panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 );
- }
-
- guint panel_ratio = 100;
- if (_prefs_path) {
- panel_ratio = prefs_get_int_attribute_limited( _prefs_path, "panel_ratio", 100, 0, 500 );
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ bool panel_wrap = 0;
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ panel_wrap = prefs->getBool(_prefs_path + "/panel_wrap");
+ panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
+ panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
+ panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 100, 0, 500 );
}
_menu = new Gtk::Menu();
{
- Gtk::RadioMenuItem::Group group;
- Glib::ustring one_label(_("List"));
- Glib::ustring two_label(_("Grid"));
- Gtk::RadioMenuItem *one = manage(new Gtk::RadioMenuItem(group, one_label));
- Gtk::RadioMenuItem *two = manage(new Gtk::RadioMenuItem(group, two_label));
-
- if (panel_mode == 0) {
- one->set_active(true);
- } else if (panel_mode == 1) {
- two->set_active(true);
- }
-
- _menu->append(*one);
- _non_horizontal.push_back(one);
- _menu->append(*two);
- _non_horizontal.push_back(two);
- Gtk::MenuItem* sep = manage(new Gtk::SeparatorMenuItem());
- _menu->append(*sep);
- _non_horizontal.push_back(sep);
- one->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 0));
- two->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 1));
+ Gtk::RadioMenuItem::Group group;
+ Glib::ustring one_label(_("List"));
+ Glib::ustring two_label(_("Grid"));
+ Gtk::RadioMenuItem *one = manage(new Gtk::RadioMenuItem(group, one_label));
+ Gtk::RadioMenuItem *two = manage(new Gtk::RadioMenuItem(group, two_label));
+
+ if (panel_mode == 0) {
+ one->set_active(true);
+ } else if (panel_mode == 1) {
+ two->set_active(true);
+ }
+
+ _menu->append(*one);
+ _non_horizontal.push_back(one);
+ _menu->append(*two);
+ _non_horizontal.push_back(two);
+ Gtk::MenuItem* sep = manage(new Gtk::SeparatorMenuItem());
+ _menu->append(*sep);
+ _non_horizontal.push_back(sep);
+ one->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 0));
+ two->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_MODE, 1));
}
{
@@ -336,21 +326,14 @@ void Panel::present()
void Panel::restorePanelPrefs()
{
- guint panel_size = 0;
- if (_prefs_path) {
- panel_size = prefs_get_int_attribute_limited(_prefs_path, "panel_size", 1, 0, static_cast<long long>(PREVIEW_SIZE_HUGE));
- }
- guint panel_mode = 0;
- if (_prefs_path) {
- panel_mode = prefs_get_int_attribute_limited(_prefs_path, "panel_mode", 1, 0, 10);
- }
- guint panel_wrap = 0;
- if (_prefs_path) {
- panel_wrap = prefs_get_int_attribute_limited(_prefs_path, "panel_wrap", 0, 0, 1 );
- }
- guint panel_ratio = 100;
- if (_prefs_path) {
- panel_ratio = prefs_get_int_attribute_limited(_prefs_path, "panel_ratio", 000, 0, 500 );
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ bool panel_wrap = 0;
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ panel_wrap = prefs->getBool(_prefs_path + "/panel_wrap");
+ panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
+ panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
+ panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 000, 0, 500 );
}
_bounceCall(PANEL_SETTING_SIZE, panel_size);
_bounceCall(PANEL_SETTING_MODE, panel_mode);
@@ -375,8 +358,9 @@ void Panel::_bounceCall(int i, int j)
_menu->set_active(0);
switch (i) {
case PANEL_SETTING_SIZE:
- if (_prefs_path) {
- prefs_set_int_attribute(_prefs_path, "panel_size", j);
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/panel_size", j);
}
if (_fillable) {
ViewType curr_type = _fillable->getPreviewType();
@@ -413,8 +397,9 @@ void Panel::_bounceCall(int i, int j)
}
break;
case PANEL_SETTING_MODE:
- if (_prefs_path) {
- prefs_set_int_attribute (_prefs_path, "panel_mode", j);
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/panel_mode", j);
}
if (_fillable) {
::PreviewSize curr_size = _fillable->getPreviewSize();
@@ -436,8 +421,9 @@ void Panel::_bounceCall(int i, int j)
}
break;
case PANEL_SETTING_SHAPE:
- if (_prefs_path) {
- prefs_set_int_attribute (_prefs_path, "panel_ratio", j);
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/panel_ratio", j);
}
if ( _fillable ) {
ViewType curr_type = _fillable->getPreviewType();
@@ -446,8 +432,9 @@ void Panel::_bounceCall(int i, int j)
}
break;
case PANEL_SETTING_WRAP:
- if (_prefs_path) {
- prefs_set_int_attribute (_prefs_path, "panel_wrap", j ? 1 : 0);
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool(_prefs_path + "/panel_wrap", j);
}
if ( _fillable ) {
_fillable->setWrap(j);
@@ -468,7 +455,7 @@ void Panel::_wrapToggled(Gtk::CheckMenuItem* toggler)
gchar const *Panel::getPrefsPath() const
{
- return _prefs_path;
+ return _prefs_path.data();
}
Glib::ustring const &Panel::getLabel() const
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 1062ee58e..d42548f16 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -92,7 +92,7 @@ protected:
/** Tooltips object for all descendants to use */
Gtk::Tooltips _tooltips;
- const gchar *_prefs_path;
+ Glib::ustring const _prefs_path;
bool _menu_desired;
Gtk::AnchorType _anchor;
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index b11ca2e93..72df1baab 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -128,13 +128,12 @@ void DialogPage::set_tip(Gtk::Widget& widget, Glib::ustring const &tip)
}
void PrefCheckButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
- Glib::ustring const &attr, bool default_value)
+ bool default_value)
{
_prefs_path = prefs_path;
- _attr = attr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->set_label(label);
- this->set_active( prefs->getBool(_prefs_path, _attr, default_value) );
+ this->set_active( prefs->getBool(_prefs_path, default_value) );
}
void PrefCheckButton::on_toggled()
@@ -142,15 +141,14 @@ void PrefCheckButton::on_toggled()
if (this->is_visible()) //only take action if the user toggled it
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(_prefs_path, _attr, this->get_active());
+ prefs->setBool(_prefs_path, this->get_active());
}
}
void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
- Glib::ustring const &attr, Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member)
+ Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member)
{
_prefs_path = prefs_path;
- _attr = attr;
_value_type = VAL_STRING;
_string_value = string_value;
(void)default_value;
@@ -161,7 +159,7 @@ void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &pref
this->set_group(rbg);
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring val = prefs->getString(_prefs_path, _attr);
+ Glib::ustring val = prefs->getString(_prefs_path);
if ( !val.empty() )
this->set_active(val == _string_value);
else
@@ -169,10 +167,9 @@ void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &pref
}
void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
- Glib::ustring const &attr, int int_value, bool default_value, PrefRadioButton* group_member)
+ int int_value, bool default_value, PrefRadioButton* group_member)
{
_prefs_path = prefs_path;
- _attr = attr;
_value_type = VAL_INT;
_int_value = int_value;
this->set_label(label);
@@ -183,9 +180,9 @@ void PrefRadioButton::init(Glib::ustring const &label, Glib::ustring const &pref
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (default_value)
- this->set_active( prefs->getInt(_prefs_path, _attr, int_value) == _int_value );
+ this->set_active( prefs->getInt(_prefs_path, int_value) == _int_value );
else
- this->set_active( prefs->getInt(_prefs_path, _attr, int_value + 1) == _int_value );
+ this->set_active( prefs->getInt(_prefs_path, int_value + 1) == _int_value );
}
void PrefRadioButton::on_toggled()
@@ -196,30 +193,29 @@ void PrefRadioButton::on_toggled()
if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
{
if ( _value_type == VAL_STRING )
- prefs->setString(_prefs_path, _attr, _string_value);
+ prefs->setString(_prefs_path, _string_value);
else if ( _value_type == VAL_INT )
- prefs->setInt(_prefs_path, _attr, _int_value);
+ prefs->setInt(_prefs_path, _int_value);
}
}
-void PrefSpinButton::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+void PrefSpinButton::init(Glib::ustring const &prefs_path,
double lower, double upper, double step_increment, double page_increment,
double default_value, bool is_int, bool is_percent)
{
_prefs_path = prefs_path;
- _attr = attr;
_is_int = is_int;
_is_percent = is_percent;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double value;
if (is_int) {
if (is_percent) {
- value = 100 * prefs->getDoubleLimited(prefs_path, attr, default_value, lower/100.0, upper/100.0);
+ value = 100 * prefs->getDoubleLimited(prefs_path, default_value, lower/100.0, upper/100.0);
} else {
- value = (double) prefs->getIntLimited(prefs_path, attr, (int) default_value, (int) lower, (int) upper);
+ value = (double) prefs->getIntLimited(prefs_path, (int) default_value, (int) lower, (int) upper);
}
} else {
- value = prefs->getDoubleLimited(prefs_path, attr, default_value, lower, upper);
+ value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper);
}
this->set_range (lower, upper);
@@ -243,12 +239,12 @@ void PrefSpinButton::on_value_changed()
{
if (_is_int) {
if (_is_percent) {
- prefs->setDouble(_prefs_path, _attr, this->get_value()/100.0);
+ prefs->setDouble(_prefs_path, this->get_value()/100.0);
} else {
- prefs->setInt(_prefs_path, _attr, (int) this->get_value());
+ prefs->setInt(_prefs_path, (int) this->get_value());
}
} else {
- prefs->setDouble(_prefs_path, _attr, this->get_value());
+ prefs->setDouble(_prefs_path, this->get_value());
}
}
}
@@ -273,7 +269,7 @@ void ZoomCorrRuler::set_size(int x, int y)
// The following two functions are borrowed from 2geom's toy-framework-2; if they are useful in
// other locations, we should perhaps make them (or adapted versions of them) publicly available
static void
-draw_text(cairo_t *cr, Geom::Point loc, const char* txt, bool bottom = "false",
+draw_text(cairo_t *cr, Geom::Point loc, const char* txt, bool bottom = false,
double fontsize = ZoomCorrRuler::textsize, std::string fontdesc = "Sans") {
PangoLayout* layout = pango_cairo_create_layout (cr);
pango_layout_set_text(layout, txt, -1);
@@ -306,7 +302,7 @@ draw_number(cairo_t *cr, Geom::Point pos, double num) {
void
ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- const double zoomcorr = prefs->getDouble("options.zoomcorrection", "value", 1.0);
+ const double zoomcorr = prefs->getDouble("/options/zoomcorrection/value", 1.0);
double mark = 0;
int i = 0;
while (mark <= _drawing_width) {
@@ -347,7 +343,7 @@ ZoomCorrRuler::redraw() {
cr->line_to (_drawing_width, _height);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring abbr = prefs->getString("options.zoomcorrection", "unit");
+ Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit");
if (abbr == "cm") {
draw_marks(cr, 0.1, 10);
} else if (abbr == "ft") {
@@ -383,7 +379,7 @@ ZoomCorrRulerSlider::on_slider_value_changed()
{
freeze = true;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("options.zoomcorrection", "value", _slider.get_value() / 100.0);
+ prefs->setDouble("/options/zoomcorrection/value", _slider.get_value() / 100.0);
_sb.set_value(_slider.get_value());
_ruler.redraw();
freeze = false;
@@ -397,7 +393,7 @@ ZoomCorrRulerSlider::on_spinbutton_value_changed()
{
freeze = true;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("options.zoomcorrection", "value", _sb.get_value() / 100.0);
+ prefs->setDouble("/options/zoomcorrection/value", _sb.get_value() / 100.0);
_slider.set_value(_sb.get_value());
_ruler.redraw();
freeze = false;
@@ -412,7 +408,7 @@ ZoomCorrRulerSlider::on_unit_changed() {
return;
}
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("options.zoomcorrection", "unit", _unit.getUnitAbbr());
+ prefs->setString("/options/zoomcorrection/unit", _unit.getUnitAbbr());
double conv = _unit.getConversion(_unit.getUnitAbbr(), "px");
_ruler.set_unit_conversion(conv);
if (_ruler.is_visible()) {
@@ -425,7 +421,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
double step_increment, double page_increment, double default_value)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double value = prefs->getDoubleLimited("options.zoomcorrection", "value", default_value, lower, upper) * 100.0;
+ double value = prefs->getDoubleLimited("/options/zoomcorrection/value", default_value, lower, upper) * 100.0;
freeze = false;
@@ -449,7 +445,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
_unit.set_data("sensitive", GINT_TO_POINTER(0));
_unit.setUnitType(UNIT_TYPE_LINEAR);
_unit.set_data("sensitive", GINT_TO_POINTER(1));
- _unit.setUnit(prefs->getString("options.zoomcorrection", "unit"));
+ _unit.setUnit(prefs->getString("/options/zoomcorrection/unit"));
Gtk::Table *table = Gtk::manage(new Gtk::Table());
Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
@@ -465,14 +461,13 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
-void PrefCombo::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+void PrefCombo::init(Glib::ustring const &prefs_path,
Glib::ustring labels[], int values[], int num_items, int default_value)
{
_prefs_path = prefs_path;
- _attr = attr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int row = 0;
- int value = prefs->getInt(_prefs_path, _attr, default_value);
+ int value = prefs->getInt(_prefs_path, default_value);
for (int i = 0 ; i < num_items; ++i)
{
@@ -489,22 +484,21 @@ void PrefCombo::on_changed()
if (this->is_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(_prefs_path, _attr, _values[this->get_active_row_number()]);
+ prefs->setInt(_prefs_path, _values[this->get_active_row_number()]);
}
}
-void PrefEntryButtonHBox::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+void PrefEntryButtonHBox::init(Glib::ustring const &prefs_path,
bool visibility, Glib::ustring const &default_string)
{
_prefs_path = prefs_path;
- _attr = attr;
_default_string = default_string;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
relatedEntry = new Gtk::Entry();
relatedButton = new Gtk::Button(_("Reset"));
relatedEntry->set_invisible_char('*');
relatedEntry->set_visibility(visibility);
- relatedEntry->set_text(prefs->getString(_prefs_path, _attr));
+ relatedEntry->set_text(prefs->getString(_prefs_path));
this->pack_start(*relatedEntry);
this->pack_start(*relatedButton);
relatedButton->signal_clicked().connect(
@@ -518,7 +512,7 @@ void PrefEntryButtonHBox::onRelatedEntryChangedCallback()
if (this->is_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, _attr, relatedEntry->get_text());
+ prefs->setString(_prefs_path, relatedEntry->get_text());
}
}
@@ -527,18 +521,17 @@ void PrefEntryButtonHBox::onRelatedButtonClickedCallback()
if (this->is_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, _attr, _default_string);
+ prefs->setString(_prefs_path, _default_string);
relatedEntry->set_text(_default_string);
}
}
-void PrefFileButton::init(Glib::ustring const &prefs_path, Glib::ustring const &attr)
+void PrefFileButton::init(Glib::ustring const &prefs_path)
{
_prefs_path = prefs_path;
- _attr = attr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- select_filename(Glib::filename_from_utf8(prefs->getString(_prefs_path, _attr)));
+ select_filename(Glib::filename_from_utf8(prefs->getString(_prefs_path)));
signal_selection_changed().connect(sigc::mem_fun(*this, &PrefFileButton::onFileChanged));
}
@@ -546,18 +539,16 @@ void PrefFileButton::init(Glib::ustring const &prefs_path, Glib::ustring const &
void PrefFileButton::onFileChanged()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, _attr, Glib::filename_to_utf8(get_filename()));
+ prefs->setString(_prefs_path, Glib::filename_to_utf8(get_filename()));
}
-void PrefEntry::init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
- bool visibility)
+void PrefEntry::init(Glib::ustring const &prefs_path, bool visibility)
{
_prefs_path = prefs_path;
- _attr = attr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
this->set_invisible_char('*');
this->set_visibility(visibility);
- this->set_text(prefs->getString(_prefs_path, _attr));
+ this->set_text(prefs->getString(_prefs_path));
}
void PrefEntry::on_changed()
@@ -565,18 +556,17 @@ void PrefEntry::on_changed()
if (this->is_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, _attr, this->get_text());
+ prefs->setString(_prefs_path, this->get_text());
}
}
-void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path,
guint32 default_rgba)
{
_prefs_path = prefs_path;
- _attr = attr;
_title = label;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- this->setRgba32( prefs->getInt(_prefs_path, _attr, (int)default_rgba) );
+ this->setRgba32( prefs->getInt(_prefs_path, (int)default_rgba) );
}
void PrefColorPicker::on_changed (guint32 rgba)
@@ -584,17 +574,16 @@ void PrefColorPicker::on_changed (guint32 rgba)
if (this->is_visible()) //only take action if the user toggled it
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(_prefs_path, _attr, (int) rgba);
+ prefs->setInt(_prefs_path, (int) rgba);
}
}
-void PrefUnit::init(Glib::ustring const &prefs_path, Glib::ustring const &attr)
+void PrefUnit::init(Glib::ustring const &prefs_path)
{
_prefs_path = prefs_path;
- _attr = attr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
setUnitType(UNIT_TYPE_LINEAR);
- setUnit(prefs->getString(_prefs_path, _attr));
+ setUnit(prefs->getString(_prefs_path));
}
void PrefUnit::on_changed()
@@ -602,7 +591,7 @@ void PrefUnit::on_changed()
if (this->is_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path, _attr, getUnitAbbr());
+ prefs->setString(_prefs_path, getUnitAbbr());
}
}
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index da07db5d9..dbc319c1a 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -39,25 +39,23 @@ namespace Widget {
class PrefCheckButton : public Gtk::CheckButton
{
public:
- void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
bool default_value);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
void on_toggled();
};
class PrefRadioButton : public Gtk::RadioButton
{
public:
- void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
int int_value, bool default_value, PrefRadioButton* group_member);
- void init(Glib::ustring const &label, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member);
sigc::signal<void, bool> changed_signal;
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
Glib::ustring _string_value;
int _value_type;
enum
@@ -72,12 +70,11 @@ protected:
class PrefSpinButton : public Gtk::SpinButton
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &prefs_path,
double lower, double upper, double step_increment, double page_increment,
double default_value, bool is_int, bool is_percent);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
bool _is_int;
bool _is_percent;
void on_value_changed();
@@ -128,11 +125,10 @@ private:
class PrefCombo : public Gtk::ComboBoxText
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &prefs_path,
Glib::ustring labels[], int values[], int num_items, int default_value);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
std::vector<int> _values;
void on_changed();
};
@@ -140,22 +136,19 @@ protected:
class PrefEntry : public Gtk::Entry
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
- bool mask);
+ void init(Glib::ustring const &prefs_path, bool mask);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
void on_changed();
};
class PrefEntryButtonHBox : public Gtk::HBox
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &prefs_path,
bool mask, Glib::ustring const &default_string);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
Glib::ustring _default_string;
Gtk::Button *relatedButton;
Gtk::Entry *relatedEntry;
@@ -166,11 +159,10 @@ protected:
class PrefFileButton : public Gtk::FileChooserButton
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr);
+ void init(Glib::ustring const &prefs_path);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
void onFileChanged();
};
@@ -180,22 +172,20 @@ public:
PrefColorPicker() : ColorPicker("", "", 0, false) {};
virtual ~PrefColorPicker() {};
- void init(Glib::ustring const &abel, Glib::ustring const &prefs_path, Glib::ustring const &attr,
+ void init(Glib::ustring const &abel, Glib::ustring const &prefs_path,
guint32 default_rgba);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
virtual void on_changed (guint32 rgba);
};
class PrefUnit : public UnitMenu
{
public:
- void init(Glib::ustring const &prefs_path, Glib::ustring const &attr);
+ void init(Glib::ustring const &prefs_path);
protected:
Glib::ustring _prefs_path;
- Glib::ustring _attr;
void on_changed();
};
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 2cc6e3c62..95ddec286 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -155,6 +155,8 @@ RegisteredScalarUnit::RegisteredScalarUnit (const Glib::ustring& label, const Gl
{
init_parent(key, wr, repr_in, doc_in);
+ setProgrammatically = false;
+
initScalar (-1e6, 1e6);
setUnit (rum.getUnitMenu()->getUnitAbbr());
setDigits (2);
@@ -203,6 +205,8 @@ RegisteredScalar::RegisteredScalar ( const Glib::ustring& label, const Glib::ust
{
init_parent(key, wr, repr_in, doc_in);
+ setProgrammatically = false;
+
setRange (-1e6, 1e6);
setDigits (2);
setIncrements(0.1, 1.0);
@@ -249,6 +253,8 @@ RegisteredText::RegisteredText ( const Glib::ustring& label, const Glib::ustring
{
init_parent(key, wr, repr_in, doc_in);
+ setProgrammatically = false;
+
setText("");
_activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate));
}
@@ -597,6 +603,8 @@ RegisteredRandom::RegisteredRandom ( const Glib::ustring& label, const Glib::ust
{
init_parent(key, wr, repr_in, doc_in);
+ setProgrammatically = false;
+
setRange (-1e6, 1e6);
setDigits (2);
setIncrements(0.1, 1.0);
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index 807c21de5..47f6292e3 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -1,10 +1,11 @@
-/**
- * \brief Static style swatch (fill, stroke, opacity)
- *
- * Author:
+/** @file
+ * @brief Static style swatch (fill, stroke, opacity)
+ */
+/* Authors:
* buliabyak@gmail.com
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
- * Copyright (C) 2005 author
+ * Copyright (C) 2005-2008 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -26,10 +27,10 @@
#include "sp-radial-gradient-fns.h"
#include "sp-pattern.h"
#include "xml/repr.h"
-#include "xml/node-event-vector.h"
#include "widgets/widget-sizes.h"
#include "helper/units.h"
#include "helper/action.h"
+#include "preferences.h"
#include "inkscape.h"
enum {
@@ -37,74 +38,80 @@ enum {
SS_STROKE
};
-static void style_swatch_attr_changed( Inkscape::XML::Node *repr, gchar const *name,
- gchar const */*old_value*/, gchar const */*new_value*/,
- bool /*is_interactive*/, gpointer data)
-{
- Inkscape::UI::Widget::StyleSwatch *ss = (Inkscape::UI::Widget::StyleSwatch *) data;
-
- if (!strcmp (name, "style")) { // FIXME: watching only for the style attr, no CSS attrs
- SPCSSAttr *css = sp_repr_css_attr_inherited(repr, "style");
- ss->setStyle (css);
- }
-}
-
+namespace Inkscape {
+namespace UI {
+namespace Widget {
-static Inkscape::XML::NodeEventVector style_swatch_repr_events =
-{
- NULL, /* child_added */
- NULL, /* child_removed */
- style_swatch_attr_changed,
- NULL, /* content_changed */
- NULL /* order_changed */
+/**
+ * @brief Watches whether the tool uses the current style
+ */
+class StyleSwatch::ToolObserver : public Inkscape::Preferences::Observer {
+public:
+ ToolObserver(Glib::ustring const &path, StyleSwatch &ss) :
+ Observer(path),
+ _style_swatch(ss)
+ {}
+ virtual void notify(Inkscape::Preferences::Entry const &val);
+private:
+ StyleSwatch &_style_swatch;
};
+/**
+ * @brief Watches for changes in the observed style pref
+ */
+class StyleSwatch::StyleObserver : public Inkscape::Preferences::Observer {
+public:
+ StyleObserver(Glib::ustring const &path, StyleSwatch &ss) :
+ Observer(path),
+ _style_swatch(ss)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ this->notify(prefs->getEntry(path));
+ }
+ virtual void notify(Inkscape::Preferences::Entry const &val) {
+ SPCSSAttr *css = val.getInheritedStyle();
+ _style_swatch.setStyle(css);
+ sp_repr_css_attr_unref(css);
+ }
+private:
+ StyleSwatch &_style_swatch;
+};
-static void style_swatch_tool_attr_changed( Inkscape::XML::Node */*repr*/, gchar const *name,
- gchar const */*old_value*/, gchar const *new_value,
- bool /*is_interactive*/, gpointer data)
+void StyleSwatch::ToolObserver::notify(Inkscape::Preferences::Entry const &val)
{
- Inkscape::UI::Widget::StyleSwatch *ss = (Inkscape::UI::Widget::StyleSwatch *) data;
+ bool usecurrent = val.getBool();
- if (!strcmp (name, "usecurrent")) { // FIXME: watching only for the style attr, no CSS attrs
- if (!strcmp (new_value, "1")) {
- ss->setWatched (inkscape_get_repr(INKSCAPE, "desktop"), inkscape_get_repr(INKSCAPE, ss->_tool_path));
- } else {
- ss->setWatched (inkscape_get_repr(INKSCAPE, ss->_tool_path), NULL);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (_style_swatch._style_obs) delete _style_swatch._style_obs;
+
+ if (usecurrent) {
+ _style_swatch._style_obs = new StyleObserver("/desktop/style", _style_swatch);
+
+ // If desktop's last-set style is empty, a tool uses its own fixed style even if set to use
+ // last-set (so long as it's empty). To correctly show this, we get the tool's style
+ // if the desktop's style is empty.
+ SPCSSAttr *css = prefs->getStyle("/desktop/style");
+ if (!css->attributeList()) {
+ SPCSSAttr *css2 = prefs->getInheritedStyle(_style_swatch._tool_path + "/style");
+ _style_swatch.setStyle(css2);
+ sp_repr_css_attr_unref(css2);
}
- // UGLY HACK: we have to reconnect to the watched tool repr again, retrieving it from the stored
- // tool_path, because the actual repr keeps shifting with each change, no idea why
- ss->setWatchedTool(ss->_tool_path, false);
+ sp_repr_css_attr_unref(css);
+ } else {
+ _style_swatch._style_obs = new StyleObserver(_style_swatch._tool_path + "/style", _style_swatch);
}
+ prefs->addObserver(*_style_swatch._style_obs);
}
-static Inkscape::XML::NodeEventVector style_swatch_tool_repr_events =
-{
- NULL, /* child_added */
- NULL, /* child_removed */
- style_swatch_tool_attr_changed,
- NULL, /* content_changed */
- NULL /* order_changed */
-};
-
-namespace Inkscape {
-namespace UI {
-namespace Widget {
-
StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
:
- _tool_path(NULL),
- _desktop(0),
- _verb_t(0),
- _css (NULL),
-
- _watched(NULL),
- _watched_tool(NULL),
-
+ _desktop(NULL),
+ _verb_t(NULL),
+ _css(NULL),
+ _tool_obs(NULL),
+ _style_obs(NULL),
_table(2, 6),
-
_sw_unit(NULL),
-
_tooltips ()
{
_label[SS_FILL].set_markup(_("Fill:"));
@@ -185,72 +192,33 @@ StyleSwatch::~StyleSwatch()
delete _color_preview[i];
}
- if (_watched) {
- sp_repr_remove_listener_by_data(_watched, this);
- Inkscape::GC::release(_watched);
- _watched = NULL;
- }
-
- if (_watched_tool) {
- sp_repr_remove_listener_by_data(_watched_tool, this);
- Inkscape::GC::release(_watched_tool);
- _watched_tool = NULL;
- _tool_path = NULL;
- }
-}
-
-void
-StyleSwatch::setWatched(Inkscape::XML::Node *watched, Inkscape::XML::Node *secondary)
-{
- if (_watched) {
- sp_repr_remove_listener_by_data(_watched, this);
- Inkscape::GC::release(_watched);
- _watched = NULL;
- }
-
- if (watched) {
- _watched = watched;
- Inkscape::GC::anchor(_watched);
- sp_repr_add_listener(_watched, &style_swatch_repr_events, this);
- sp_repr_synthesize_events(_watched, &style_swatch_repr_events, this);
-
- // If desktop's last-set style is empty, a tool uses its own fixed style even if set to use
- // last-set (so long as it's empty). To correctly show this, we're passed the second repr,
- // that of the tool prefs node, from which we now setStyle if the watched repr's style is
- // empty.
- if (secondary) {
- SPCSSAttr *css = sp_repr_css_attr_inherited(watched, "style");
- if (!css->attributeList()) { // is css empty?
- SPCSSAttr *css_secondary = sp_repr_css_attr_inherited(secondary, "style");
- this->setStyle (css_secondary);
- }
- }
- }
+ if (_style_obs) delete _style_obs;
+ if (_tool_obs) delete _tool_obs;
}
void
StyleSwatch::setWatchedTool(const char *path, bool synthesize)
{
- if (_watched_tool) {
- sp_repr_remove_listener_by_data(_watched_tool, this);
- Inkscape::GC::release(_watched_tool);
- _watched_tool = NULL;
- _tool_path = NULL;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ if (_tool_obs) {
+ delete _tool_obs;
+ _tool_obs = NULL;
}
if (path) {
- _tool_path = (char *) path;
- Inkscape::XML::Node *watched_tool = inkscape_get_repr(INKSCAPE, path);
- if (watched_tool) {
- _watched_tool = watched_tool;
- Inkscape::GC::anchor(_watched_tool);
- sp_repr_add_listener(_watched_tool, &style_swatch_tool_repr_events, this);
- if (synthesize) {
- sp_repr_synthesize_events(_watched_tool, &style_swatch_tool_repr_events, this);
- }
- }
+ _tool_path = path;
+ _tool_obs = new ToolObserver(_tool_path + "/usecurrent", *this);
+ prefs->addObserver(*_tool_obs);
+ } else {
+ _tool_path = "";
+ }
+
+ // hack until there is a real synthesize events function for prefs,
+ // which shouldn't be hard to write once there is sufficient need for it
+ if (synthesize && _tool_obs) {
+ _tool_obs->notify(prefs->getEntry(_tool_path + "/usecurrent"));
}
-
}
diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h
index 5efd561f3..dfbbe13d3 100644
--- a/src/ui/widget/style-swatch.h
+++ b/src/ui/widget/style-swatch.h
@@ -1,10 +1,11 @@
-/**
- * \brief Static style swatch (fill, stroke, opacity)
- *
- * Author:
+/** @file
+ * @brief Static style swatch (fill, stroke, opacity)
+ */
+/* Authors:
* buliabyak@gmail.com
+ * Krzysztof Kosiński <tweenk.pl@gmail.com>
*
- * Copyright (C) 2005 author
+ * Copyright (C) 2005-2008 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
@@ -20,22 +21,16 @@
#include <glibmm/i18n.h>
-#include <desktop.h>
-#include <verbs.h>
-
+#include "desktop.h"
+#include "verbs.h"
#include "button.h"
+#include "preferences.h"
class SPUnit;
class SPStyle;
class SPCSSAttr;
namespace Inkscape {
-namespace XML {
-class Node;
-}
-}
-
-namespace Inkscape {
namespace UI {
namespace Widget {
@@ -50,40 +45,32 @@ public:
void setStyle(SPCSSAttr *attr);
SPCSSAttr *getStyle();
- void setWatched (Inkscape::XML::Node *watched, Inkscape::XML::Node *secondary);
void setWatchedTool (const char *path, bool synthesize);
void setClickVerb(sp_verb_t verb_t);
void setDesktop(SPDesktop *desktop);
bool on_click(GdkEventButton *event);
- char *_tool_path;
+private:
+ class ToolObserver;
+ class StyleObserver;
-protected:
SPDesktop *_desktop;
-
sp_verb_t _verb_t;
-
SPCSSAttr *_css;
-
- Inkscape::XML::Node *_watched;
- Inkscape::XML::Node *_watched_tool;
+ ToolObserver *_tool_obs;
+ StyleObserver *_style_obs;
+ Glib::ustring _tool_path;
Gtk::EventBox _swatch;
-
Gtk::Table _table;
-
Gtk::Label _label[2];
-
Gtk::EventBox _place[2];
Gtk::EventBox _opacity_place;
-
Gtk::Label _value[2];
Gtk::Label _opacity_value;
-
Gtk::Widget *_color_preview[2];
Glib::ustring __color[2];
-
Gtk::HBox _stroke;
Gtk::EventBox _stroke_width_place;
Gtk::Label _stroke_width;
@@ -91,6 +78,8 @@ protected:
SPUnit *_sw_unit;
Gtk::Tooltips _tooltips;
+
+friend class ToolObserver;
};
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 14bf8d161..c57232c74 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -130,7 +130,7 @@ vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint stat
// without Shift; see if we need to snap to another dragger
for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) {
VPDragger *d_new = (VPDragger *) di->data;
- if ((d_new != dragger) && (NR::L2 (d_new->point - p) < snap_dist)) {
+ if ((d_new != dragger) && (Geom::L2 (d_new->point - p) < snap_dist)) {
if (have_VPs_of_same_perspective (dragger, d_new)) {
// this would result in degenerate boxes, which we disallow for the time being
continue;
@@ -457,7 +457,7 @@ VPDragger::updateZOrders ()
void
VPDragger::printVPs() {
- g_print ("VPDragger at position (%f, %f):\n", point[NR::X], point[NR::Y]);
+ g_print ("VPDragger at position (%f, %f):\n", point[Geom::X], point[Geom::Y]);
for (std::list<VanishingPoint>::iterator i = this->vps.begin(); i != this->vps.end(); ++i) {
g_print (" VP %s\n", (*i).axisString());
}
@@ -725,7 +725,7 @@ VPDrag::addDragger (VanishingPoint &vp)
for (GList *i = this->draggers; i != NULL; i = i->next) {
VPDragger *dragger = (VPDragger *) i->data;
- if (NR::L2 (dragger->point - p) < MERGE_DIST) {
+ if (Geom::L2 (dragger->point - p) < MERGE_DIST) {
// distance is small, merge this draggable into dragger, no need to create new dragger
dragger->addVP (vp);
return;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 55a465fbb..37961ab15 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -71,7 +71,7 @@
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/inkscape-preferences.h"
#include "interface.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "splivarot.h"
#include "sp-namedview.h"
#include "sp-flowtext.h"
@@ -1314,7 +1314,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
}
// If the rotation center of the selection is visible, choose it as reference point
// for horizontal and vertical flips. Otherwise, take the center of the bounding box.
- NR::Point center;
+ Geom::Point center;
if (tools_isactive(dt, TOOLS_SELECT) && sel->center() && SP_SELECT_CONTEXT(ec)->_seltrans->centerIsVisible())
center = *sel->center();
else
@@ -1431,6 +1431,7 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
}
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
switch (verb) {
case SP_VERB_CONTEXT_SELECT:
tools_switch(dt, TOOLS_SELECT);
@@ -1491,80 +1492,80 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
break;
case SP_VERB_CONTEXT_SELECT_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SELECTOR);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SELECTOR);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_NODE_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_NODE);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_NODE);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_TWEAK_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_TWEAK);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_TWEAK);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_RECT_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_RECT);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_RECT);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_3DBOX_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_3DBOX);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_3DBOX);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_ARC_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_STAR_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_STAR);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_STAR);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_SPIRAL_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_PENCIL_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PENCIL);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_PENCIL);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_PEN_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PEN);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_PEN);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_CALLIGRAPHY);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_CALLIGRAPHY);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_TEXT_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_TEXT);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_TEXT);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_GRADIENT_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_GRADIENT);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_GRADIENT);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_ZOOM_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_ZOOM);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_ZOOM);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_DROPPER_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_DROPPER);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_DROPPER);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_CONNECTOR_PREFS:
- prefs_set_int_attribute ("dialogs.preferences", "page", PREFS_PAGE_TOOLS_CONNECTOR);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_CONNECTOR);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_PAINTBUCKET_PREFS:
- prefs_set_int_attribute ("dialogs.preferences", "page", PREFS_PAGE_TOOLS_PAINTBUCKET);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_PAINTBUCKET);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_ERASER_PREFS:
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_ERASER);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_ERASER);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
case SP_VERB_CONTEXT_LPETOOL_PREFS:
g_print ("TODO: Create preferences page for LPETool\n");
- prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_LPETOOL);
+ prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_LPETOOL);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
@@ -1601,9 +1602,9 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
Inkscape::XML::Node *repr = SP_OBJECT_REPR(dt->namedview);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble zoom_inc =
- prefs_get_double_attribute_limited( "options.zoomincrement",
- "value", 1.414213562, 1.01, 10 );
+ prefs->getDoubleLimited( "/options/zoomincrement/value", 1.414213562, 1.01, 10 );
switch (GPOINTER_TO_INT(data)) {
case SP_VERB_ZOOM_IN:
@@ -1644,21 +1645,21 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
}
case SP_VERB_ZOOM_1_1:
{
- double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
+ double zcorr = prefs->getDouble("/options/zoomcorrection/value", 1.0);
Geom::Rect const d = dt->get_display_area();
dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 1.0 * zcorr );
break;
}
case SP_VERB_ZOOM_1_2:
{
- double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
+ double zcorr = prefs->getDouble("/options/zoomcorrection/value", 1.0);
Geom::Rect const d = dt->get_display_area();
dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 0.5 * zcorr );
break;
}
case SP_VERB_ZOOM_2_1:
{
- double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
+ double zcorr = prefs->getDouble("/options/zoomcorrection/value", 1.0);
Geom::Rect const d = dt->get_display_area();
dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 2.0 * zcorr );
break;
diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp
index 57f9259e2..284a8a596 100644
--- a/src/widgets/dash-selector.cpp
+++ b/src/widgets/dash-selector.cpp
@@ -1,9 +1,9 @@
#define __SP_DASH_SELECTOR_NEW_C__
-/*
- * Optionmenu for selecting dash patterns
- *
- * Author:
+/** @file
+ * @brief Option menu for selecting dash patterns - implementation
+ */
+/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <maximilian.albert@gmail.com>
@@ -28,6 +28,7 @@
#include "style.h"
#include "dialogs/dialog-events.h"
+#include "preferences.h"
#include <gtkmm/optionmenu.h>
#include <gtkmm/adjustment.h>
@@ -36,6 +37,8 @@
#include "dash-selector.h"
+gchar const *const SPDashSelector::_prefs_path = "/palette/dashes";
+
static double dash_0[] = {-1.0};
static double dash_1_1[] = {1.0, 1.0, -1.0};
static double dash_2_1[] = {2.0, 1.0, -1.0};
@@ -49,9 +52,9 @@ static double **dashes = NULL;
static void sp_dash_selector_menu_item_image_realize(Gtk::Image *px, double *pattern);
-SPDashSelector::SPDashSelector(Inkscape::XML::Node *drepr) {
+SPDashSelector::SPDashSelector() {
// TODO: find something more sensible here!!
- init_dashes(drepr);
+ init_dashes();
Gtk::Tooltips *tt = new Gtk::Tooltips();
@@ -89,39 +92,33 @@ SPDashSelector::~SPDashSelector() {
}
void
-SPDashSelector::init_dashes(Inkscape::XML::Node *drepr) {
+SPDashSelector::init_dashes() {
if (!dashes) {
- int ndashes = 0;
- if (drepr) {
- for (Inkscape::XML::Node *dr = drepr->firstChild(); dr; dr = dr->next()) {
- if (!strcmp (dr->name(), "dash"))
- ndashes += 1;
- }
- }
-
- if (ndashes > 0) {
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ std::vector<Glib::ustring> dash_prefs = prefs->getAllDirs(_prefs_path);
+
+ if (!dash_prefs.empty()) {
int pos = 0;
SPStyle *style = sp_style_new (NULL);
- dashes = g_new (double *, ndashes + 1);
- for (Inkscape::XML::Node *dr = drepr->firstChild(); dr; dr = dr->next()) {
- if (!strcmp (dr->name(), "dash")) {
- sp_style_read_from_repr (style, dr);
- if (style->stroke_dash.n_dash > 0) {
- dashes[pos] = g_new (double, style->stroke_dash.n_dash + 1);
- double *d = dashes[pos];
- int i = 0;
- for (; i < style->stroke_dash.n_dash; i++) {
- d[i] = style->stroke_dash.dash[i];
- }
- d[i] = -1;
- } else {
- dashes[pos] = dash_0;
+ dashes = g_new (double *, dash_prefs.size() + 1);
+
+ for (std::vector<Glib::ustring>::iterator i = dash_prefs.begin(); i != dash_prefs.end(); ++i) {
+ sp_style_read_from_prefs(style, *i);
+
+ if (style->stroke_dash.n_dash > 0) {
+ dashes[pos] = g_new (double, style->stroke_dash.n_dash + 1);
+ double *d = dashes[pos];
+ int i = 0;
+ for (; i < style->stroke_dash.n_dash; i++) {
+ d[i] = style->stroke_dash.dash[i];
}
- pos += 1;
+ d[i] = -1;
+ } else {
+ dashes[pos] = dash_0;
}
+ pos += 1;
}
- sp_style_unref (style);
- dashes[pos] = NULL;
} else {
dashes = builtin_dashes;
}
diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h
index 97e0b7379..25417285a 100644
--- a/src/widgets/dash-selector.h
+++ b/src/widgets/dash-selector.h
@@ -1,10 +1,10 @@
#ifndef __SP_DASH_SELECTOR_NEW_H__
#define __SP_DASH_SELECTOR_NEW_H__
-/*
- * Optionmenu for selecting dash patterns
- *
- * Author:
+/** @file
+ * @brief Option menu for selecting dash patterns
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Maximilian Albert <maximilian.albert> (gtkmm-ification)
*
@@ -13,8 +13,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "xml/repr.h"
-
+#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <sigc++/signal.h>
@@ -28,7 +27,7 @@ class Adjustment;
// TODO: should we rather derive this from OptionMenu and add the spinbutton somehow else?
class SPDashSelector : public Gtk::HBox {
public:
- SPDashSelector(Inkscape::XML::Node *drepr);
+ SPDashSelector();
~SPDashSelector();
void set_dash(int ndash, double *dash, double offset);
@@ -37,13 +36,15 @@ public:
sigc::signal<void> changed_signal;
private:
- static void init_dashes(Inkscape::XML::Node *drepr);
+ static void init_dashes();
void dash_activate(Gtk::MenuItem *mi);
void offset_value_changed();
Gtk::MenuItem *menu_item_new(double *pattern);
Gtk::OptionMenu *dash;
Gtk::Adjustment *offset;
+
+ static gchar const *const _prefs_path;
};
#endif
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index e4190b930..3c78eb0bb 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -2,8 +2,8 @@
/** \file
* Desktop widget implementation
- *
- * Authors:
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* MenTaLguY <mental@rydia.net>
* bulia byak <buliabyak@users.sf.net>
@@ -57,7 +57,6 @@
#include "ege-select-one-action.h"
#include "ege-color-prof-tracker.h"
#include "color-profile-fns.h"
-#include "xml/node-observer.h"
#include "box3d-context.h"
#include "sp-image.h"
@@ -114,48 +113,68 @@ static void sp_dtw_zoom_selection (GtkMenuItem *item, gpointer data);
SPViewWidgetClass *dtw_parent_class;
-using Inkscape::XML::Node;
-
-class PrefWatcher : public Inkscape::XML::NodeObserver {
+class CMSPrefWatcher {
public:
- PrefWatcher();
- virtual ~PrefWatcher();
-
-
- virtual void notifyChildAdded( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
- virtual void notifyChildRemoved( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
- virtual void notifyChildOrderChanged( Node &/*node*/, Node &/*child*/,
- Node */*old_prev*/, Node */*new_prev*/ ) {}
- virtual void notifyContentChanged( Node &/*node*/,
- Inkscape::Util::ptr_shared<char> /*old_content*/,
- Inkscape::Util::ptr_shared<char> /*new_content*/ ) {}
- virtual void notifyAttributeChanged( Node &node, GQuark name,
- Inkscape::Util::ptr_shared<char> old_value,
- Inkscape::Util::ptr_shared<char> new_value );
- void add( SPDesktopWidget* dtw );
- void remove( SPDesktopWidget* dtw );
+ CMSPrefWatcher() :
+ _dpw(*this),
+ _spw(*this),
+ _tracker(ege_color_prof_tracker_new(0))
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ g_signal_connect( G_OBJECT(_tracker), "modified", G_CALLBACK(hook), this );
+ prefs->addObserver(_dpw);
+ prefs->addObserver(_spw);
+ }
+ virtual ~CMSPrefWatcher() {}
+
+ //virtual void notify(PrefValue &);
+ void add( SPDesktopWidget* dtw ) {
+ _widget_list.push_back(dtw);
+ }
+ void remove( SPDesktopWidget* dtw ) {
+ _widget_list.remove(dtw);
+ }
private:
- static void hook(EgeColorProfTracker *tracker, gint a, gint b, PrefWatcher *watcher);
+ static void hook(EgeColorProfTracker *tracker, gint a, gint b, CMSPrefWatcher *watcher);
+
+ class DisplayProfileWatcher : public Inkscape::Preferences::Observer {
+ public:
+ DisplayProfileWatcher(CMSPrefWatcher &pw) : Observer("/options/displayprofile"), _pw(pw) {}
+ virtual void notify(Inkscape::Preferences::Entry const &val) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _pw._setCmsSensitive(!prefs->getString("/options/displayprofile/uri").empty());
+ _pw._refreshAll();
+ }
+ private:
+ CMSPrefWatcher &_pw;
+ };
+
+ DisplayProfileWatcher _dpw;
+
+ class SoftProofWatcher : public Inkscape::Preferences::Observer {
+ public:
+ SoftProofWatcher(CMSPrefWatcher &pw) : Observer("/options/softproof"), _pw(pw) {}
+ virtual void notify(Inkscape::Preferences::Entry const &) {
+ _pw._refreshAll();
+ }
+ private:
+ CMSPrefWatcher &_pw;
+ };
+
+ SoftProofWatcher _spw;
+
+ void _refreshAll();
+ void _setCmsSensitive(bool value);
- std::list<SPDesktopWidget*> dtws;
+ std::list<SPDesktopWidget*> _widget_list;
EgeColorProfTracker *_tracker;
+
+ friend class DisplayProfileWatcher;
+ friend class SoftproofWatcher;
};
-PrefWatcher::PrefWatcher() :
- NodeObserver(),
- dtws(),
- _tracker(0)
-{
- _tracker = ege_color_prof_tracker_new(0);
- g_signal_connect( G_OBJECT(_tracker), "modified", G_CALLBACK(hook), this );
-}
-
-PrefWatcher::~PrefWatcher()
-{
-}
-
-void PrefWatcher::hook(EgeColorProfTracker */*tracker*/, gint screen, gint monitor, PrefWatcher */*watcher*/)
+void CMSPrefWatcher::hook(EgeColorProfTracker */*tracker*/, gint screen, gint monitor, CMSPrefWatcher */*watcher*/)
{
#if ENABLE_LCMS
unsigned char* buf = 0;
@@ -166,56 +185,32 @@ void PrefWatcher::hook(EgeColorProfTracker */*tracker*/, gint screen, gint monit
#endif // ENABLE_LCMS
}
-void PrefWatcher::add( SPDesktopWidget* dtw )
-{
- dtws.push_back(dtw);
-}
-
-void PrefWatcher::remove( SPDesktopWidget* dtw )
+/// @todo Use conditional compilation in saner places. The whole PrefWatcher
+/// object is unnecessary if ENABLE_LCMS is not defined.
+void CMSPrefWatcher::_refreshAll()
{
- dtws.remove(dtw);
+#if ENABLE_LCMS
+ for ( std::list<SPDesktopWidget*>::iterator it = _widget_list.begin(); it != _widget_list.end(); ++it ) {
+ (*it)->requestCanvasUpdate();
+ }
+#endif // ENABLE_LCMS
}
-void PrefWatcher::notifyAttributeChanged( Node &node, GQuark name,
- Inkscape::Util::ptr_shared<char> /*old_value*/,
- Inkscape::Util::ptr_shared<char> /*new_value*/ )
+void CMSPrefWatcher::_setCmsSensitive(bool enabled)
{
#if ENABLE_LCMS
- (void)name;
- if ( strcmp("group", node.name()) == 0 ) {
- gchar const* id = node.attribute("id");
- bool refresh = false;
- if ( !id ) {
- // bad
- } else if (strcmp("displayprofile", id) == 0) {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Glib::ustring current = prefs->getString("options.displayprofile", "uri");
- bool enabled = !current.empty();
-
- for ( std::list<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it ) {
- SPDesktopWidget* dtw = *it;
- if ( GTK_WIDGET_SENSITIVE( dtw->cms_adjust ) != enabled ) {
- cms_adjust_set_sensitive( dtw, enabled );
- }
- }
- refresh = true;
- } else if (strcmp("softproof", id) == 0) {
- refresh = true;
- }
-
- if ( refresh ) {
- for ( std::list<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it ) {
- (*it)->requestCanvasUpdate();
- }
+ for ( std::list<SPDesktopWidget*>::iterator it = _widget_list.begin(); it != _widget_list.end(); ++it ) {
+ SPDesktopWidget *dtw = *it;
+ if ( GTK_WIDGET_SENSITIVE( dtw->cms_adjust ) != enabled ) {
+ cms_adjust_set_sensitive( dtw, enabled );
}
}
#else
- (void)node;
- (void)name;
+ (void) enabled;
#endif // ENABLE_LCMS
}
-static PrefWatcher* watcher = 0;
+static CMSPrefWatcher* watcher = NULL;
void
SPDesktopWidget::setMessage (Inkscape::MessageType type, const gchar *message)
@@ -317,7 +312,7 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
{
using Inkscape::UI::Dialogs::SwatchesPanel;
- SwatchesPanel* swatches = new SwatchesPanel("embedded.swatches");
+ SwatchesPanel* swatches = new SwatchesPanel("/embedded/swatches");
swatches->setOrientation( Gtk::ANCHOR_SOUTH );
dtw->panels = GTK_WIDGET(swatches->gobj());
gtk_box_pack_end( GTK_BOX( dtw->vbox ), dtw->panels, FALSE, TRUE, 0 );
@@ -378,7 +373,7 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
"sticky_zoom",
_("Zoom drawing if window size changes"),
dtw->tt);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("options.stickyzoom", "value"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value"));
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0);
dtw->vadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj));
@@ -402,11 +397,11 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
dtw->tt );
#if ENABLE_LCMS
{
- Glib::ustring current = prefs->getString("options.displayprofile", "uri");
+ Glib::ustring current = prefs->getString("/options/displayprofile/uri");
bool enabled = current.length() > 0;
cms_adjust_set_sensitive( dtw, enabled );
if ( enabled ) {
- bool active = prefs->getBool("options.displayprofile", "enable");
+ bool active = prefs->getBool("/options/displayprofile/enable");
if ( active ) {
sp_button_toggle_set_down( SP_BUTTON(dtw->cms_adjust), TRUE );
}
@@ -418,10 +413,8 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
#endif // ENABLE_LCMS
gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0);
{
- Inkscape::Preferences* prefs = Inkscape::Preferences::get();
if (!watcher) {
- watcher = new PrefWatcher();
- prefs->addPrefsObserver( watcher );
+ watcher = new CMSPrefWatcher();
}
watcher->add(dtw);
}
@@ -429,20 +422,20 @@ sp_desktop_widget_init (SPDesktopWidget *dtw)
/* Canvas */
dtw->canvas = SP_CANVAS (sp_canvas_new_aa ());
#if ENABLE_LCMS
- dtw->canvas->enable_cms_display_adj = prefs->getBool("options.displayprofile", "enable");
+ dtw->canvas->enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable");
#endif // ENABLE_LCMS
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dtw->canvas), GTK_CAN_FOCUS);
style = gtk_style_copy (GTK_WIDGET (dtw->canvas)->style);
style->bg[GTK_STATE_NORMAL] = style->white;
gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style);
- if ( prefs->getBool("options.useextinput", "value", true) )
+ if ( prefs->getBool("/options/useextinput/value", true) )
gtk_widget_set_extension_events(GTK_WIDGET (dtw->canvas) , GDK_EXTENSION_EVENTS_ALL); //set extension events for tablets, unless disabled in preferences
g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw);
gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);
/* Dock */
bool create_dock =
- prefs->getIntLimited("options.dialogtype", "value", Inkscape::UI::Dialog::FLOATING, 0, 1) ==
+ prefs->getIntLimited("/options/dialogtype/value", Inkscape::UI::Dialog::FLOATING, 0, 1) ==
Inkscape::UI::Dialog::DOCK;
if (create_dock) {
@@ -782,7 +775,7 @@ void cms_adjust_toggled( GtkWidget */*button*/, gpointer data )
dtw->canvas->enable_cms_display_adj = down;
dtw->requestCanvasUpdate();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("options.displayprofile", "enable", down);
+ prefs->setBool("/options/displayprofile/enable", down);
}
#endif // ENABLE_LCMS
}
@@ -948,18 +941,18 @@ SPDesktopWidget::shutdown()
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool maxed = desktop->is_maximized();
bool full = desktop->is_fullscreen();
- prefs->setBool("desktop.geometry", "fullscreen", full);
- prefs->setBool("desktop.geometry", "maximized", maxed);
+ prefs->setBool("/desktop/geometry/fullscreen", full);
+ prefs->setBool("/desktop/geometry/maximized", maxed);
gint w, h, x, y;
desktop->getWindowGeometry(x, y, w, h);
// Don't save geom for maximized windows. It
// just tells you the current maximized size, which is not
// as useful as whatever value it had previously.
if (!maxed && !full) {
- prefs->setInt("desktop.geometry", "width", w);
- prefs->setInt("desktop.geometry", "height", h);
- prefs->setInt("desktop.geometry", "x", x);
- prefs->setInt("desktop.geometry", "y", y);
+ prefs->setInt("/desktop/geometry/width", w);
+ prefs->setInt("/desktop/geometry/height", h);
+ prefs->setInt("/desktop/geometry/x", x);
+ prefs->setInt("/desktop/geometry/y", y);
}
}
@@ -1148,10 +1141,10 @@ sp_desktop_widget_maximize(SPDesktopWidget *dtw)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint w, h, x, y;
dtw->getWindowGeometry(x, y, w, h);
- prefs->setInt("desktop.geometry", "width", w);
- prefs->setInt("desktop.geometry", "height", h);
- prefs->setInt("desktop.geometry", "x", x);
- prefs->setInt("desktop.geometry", "y", y);
+ prefs->setInt("/desktop/geometry/width", w);
+ prefs->setInt("/desktop/geometry/height", h);
+ prefs->setInt("/desktop/geometry/x", x);
+ prefs->setInt("/desktop/geometry/y", y);
}
gtk_window_maximize(topw);
}
@@ -1176,10 +1169,10 @@ sp_desktop_widget_fullscreen(SPDesktopWidget *dtw)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint w, h, x, y;
dtw->getWindowGeometry(x, y, w, h);
- prefs->setInt("desktop.geometry", "width", w);
- prefs->setInt("desktop.geometry", "height", h);
- prefs->setInt("desktop.geometry", "x", x);
- prefs->setInt("desktop.geometry", "y", y);
+ prefs->setInt("/desktop/geometry/width", w);
+ prefs->setInt("/desktop/geometry/height", h);
+ prefs->setInt("/desktop/geometry/x", x);
+ prefs->setInt("/desktop/geometry/y", y);
}
gtk_window_fullscreen(topw);
// widget layout is triggered by the resulting window_state_event
@@ -1194,72 +1187,56 @@ sp_desktop_widget_fullscreen(SPDesktopWidget *dtw)
void
sp_desktop_widget_layout (SPDesktopWidget *dtw)
{
- gchar * pref_path = NULL;
- gchar const * pref_root = NULL;
-
- if (dtw->desktop->is_focusMode()) {
- pref_root = "focus.";
- } else if (dtw->desktop->is_fullscreen()) {
- pref_root = "fullscreen.";
- } else {
- pref_root = "window.";
- }
-
- pref_path = g_strconcat(pref_root, "menu", NULL);
-
+ Glib::ustring pref_root;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (dtw->desktop->is_focusMode()) {
+ pref_root = "/focus/";
+ } else if (dtw->desktop->is_fullscreen()) {
+ pref_root = "/fullscreen/";
+ } else {
+ pref_root = "/window/";
+ }
+
+ if (!prefs->getBool(pref_root + "menu/state", true)) {
gtk_widget_hide_all (dtw->menubar);
} else {
gtk_widget_show_all (dtw->menubar);
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "commands", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "commands/state", true)) {
gtk_widget_hide_all (dtw->commands_toolbox);
} else {
gtk_widget_show_all (dtw->commands_toolbox);
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "toppanel", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "toppanel/state", true)) {
gtk_widget_hide_all (dtw->aux_toolbox);
} else {
// we cannot just show_all because that will show all tools' panels;
// this is a function from toolbox.cpp that shows only the current tool's panel
show_aux_toolbox (dtw->aux_toolbox);
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "toolbox", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "toolbox/state", true)) {
gtk_widget_hide_all (dtw->tool_toolbox);
} else {
gtk_widget_show_all (dtw->tool_toolbox);
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "statusbar", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "statusbar/state", true)) {
gtk_widget_hide_all (dtw->statusbar);
} else {
gtk_widget_show_all (dtw->statusbar);
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "panels", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "panels/state", true)) {
gtk_widget_hide_all( dtw->panels );
} else {
gtk_widget_show_all( dtw->panels );
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "scrollbars", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "scrollbars/state", true)) {
gtk_widget_hide_all (dtw->hscrollbar);
gtk_widget_hide_all (dtw->vscrollbar_box);
gtk_widget_hide_all( dtw->cms_adjust );
@@ -1268,19 +1245,14 @@ sp_desktop_widget_layout (SPDesktopWidget *dtw)
gtk_widget_show_all (dtw->vscrollbar_box);
gtk_widget_show_all( dtw->cms_adjust );
}
- g_free(pref_path);
- pref_path = g_strconcat(pref_root, "rulers", NULL);
- if (!prefs->getBool(pref_path, "state", true)) {
+ if (!prefs->getBool(pref_root + "rulers/state", true)) {
gtk_widget_hide_all (dtw->hruler);
gtk_widget_hide_all (dtw->vruler);
} else {
gtk_widget_show_all (dtw->hruler);
gtk_widget_show_all (dtw->vruler);
}
- g_free(pref_path);
-
- return;
}
void
@@ -1468,7 +1440,7 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWid
bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs->getBool("options.bitmapautoreload", "value", true)) {
+ if (prefs->getBool("/options/bitmapautoreload/value", true)) {
GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image");
for (GSList const *p = imageList; p; p = p->next) {
SPImage* image = SP_IMAGE(p->data);
@@ -1646,11 +1618,11 @@ sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw)
if (GTK_WIDGET_VISIBLE (dtw->hruler)) {
gtk_widget_hide_all (dtw->hruler);
gtk_widget_hide_all (dtw->vruler);
- prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", false);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false);
} else {
gtk_widget_show_all (dtw->hruler);
gtk_widget_show_all (dtw->vruler);
- prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.rulers" : "window.rulers", "state", true);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", true);
}
}
@@ -1662,12 +1634,12 @@ sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw)
gtk_widget_hide_all (dtw->hscrollbar);
gtk_widget_hide_all (dtw->vscrollbar_box);
gtk_widget_hide_all( dtw->cms_adjust );
- prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", false);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", false);
} else {
gtk_widget_show_all (dtw->hscrollbar);
gtk_widget_show_all (dtw->vscrollbar_box);
gtk_widget_show_all( dtw->cms_adjust );
- prefs->setBool(dtw->desktop->is_fullscreen() ? "fullscreen.scrollbars" : "window.scrollbars", "state", true);
+ prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/scrollbars/state" : "/window/scrollbars/state", true);
}
}
@@ -1690,10 +1662,10 @@ sp_spw_toggle_menubar (SPDesktopWidget *dtw, bool is_fullscreen)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (GTK_WIDGET_VISIBLE (dtw->menubar)) {
gtk_widget_hide_all (dtw->menubar);
- prefs->setBool(is_fullscreen ? "fullscreen.menu" : "window.menu", "state", false);
+ prefs->setBool(is_fullscreen ? "/fullscreen/menu/state" : "/window/menu/state", false);
} else {
gtk_widget_show_all (dtw->menubar);
- prefs->setBool(is_fullscreen ? "fullscreen.menu" : "window.menu", "state", true);
+ prefs->setBool(is_fullscreen ? "/fullscreen/menu/state" : "/window/menu/state", true);
}
}
*/
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index afb20cbd5..319ef4be1 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -26,7 +26,7 @@
#include "widgets/gradient-image.h"
#include "style.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "document-private.h"
#include "desktop.h"
#include "desktop-handles.h"
@@ -47,25 +47,27 @@
//########################
static void gr_toggle_type (GtkWidget *button, gpointer data) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkWidget *linear = (GtkWidget *) g_object_get_data (G_OBJECT(data), "linear");
GtkWidget *radial = (GtkWidget *) g_object_get_data (G_OBJECT(data), "radial");
if (button == linear && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (linear))) {
- prefs_set_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR);
+ prefs->setInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
if (radial) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radial), FALSE);
} else if (button == radial && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radial))) {
- prefs_set_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_RADIAL);
+ prefs->setInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_RADIAL);
if (linear) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linear), FALSE);
}
}
static void gr_toggle_fillstroke (GtkWidget *button, gpointer data) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkWidget *fill = (GtkWidget *) g_object_get_data (G_OBJECT(data), "fill");
GtkWidget *stroke = (GtkWidget *) g_object_get_data (G_OBJECT(data), "stroke");
if (button == fill && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fill))) {
- prefs_set_int_attribute ("tools.gradient", "newfillorstroke", 1);
+ prefs->setBool("/tools/gradient/newfillorstroke", true);
if (stroke) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stroke), FALSE);
} else if (button == stroke && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stroke))) {
- prefs_set_int_attribute ("tools.gradient", "newfillorstroke", 0);
+ prefs->setBool("/tools/gradient/newfillorstroke", false);
if (fill) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fill), FALSE);
}
}
@@ -113,8 +115,9 @@ gradient.
void
gr_apply_gradient (Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr)
{
- SPGradientType new_type = (SPGradientType) prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR);
- guint new_fill = prefs_get_int_attribute ("tools.gradient", "newfillorstroke", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
+ guint new_fill = prefs->getBool("/tools/gradient/newfillorstroke", true);
// GRADIENTFIXME: make this work for multiple selected draggers.
@@ -512,6 +515,7 @@ gr_change_widget (SPDesktop *desktop)
GtkWidget *
sp_gradient_toolbox_new(SPDesktop *desktop)
{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkWidget *tbl = gtk_toolbar_new();
gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
@@ -537,7 +541,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop)
g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl);
g_object_set_data(G_OBJECT(tbl), "linear", button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_LINEAR);
+ prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_LINEAR);
gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
}
@@ -551,7 +555,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop)
g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_type), tbl);
g_object_set_data(G_OBJECT(tbl), "radial", button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_RADIAL);
+ prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_RADIAL);
gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
}
@@ -579,7 +583,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop)
g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl);
g_object_set_data(G_OBJECT(tbl), "fill", button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- prefs_get_int_attribute ("tools.gradient", "newfillorstroke", 1) == 1);
+ prefs->getBool("/tools/gradient/newfillorstroke", true));
gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
}
@@ -593,7 +597,7 @@ sp_gradient_toolbox_new(SPDesktop *desktop)
g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (gr_toggle_fillstroke), tbl);
g_object_set_data(G_OBJECT(tbl), "stroke", button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- prefs_get_int_attribute ("tools.gradient", "newfillorstroke", 1) == 0);
+ !prefs->getBool("/tools/gradient/newfillorstroke", true));
gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0);
}
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 881f34628..5f4d06172 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -36,7 +36,7 @@
#include "xml/repr.h"
#include "../dialogs/dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "svg/css-ostringstream.h"
#include "sp-stop.h"
@@ -65,7 +65,7 @@ static guint signals[LAST_SIGNAL] = {0};
static GtkWidget *dlg = NULL;
static win_data wd;
static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs
-static gchar const *prefs_path = "dialogs.gradienteditor";
+static Glib::ustring const prefs_path = "/dialogs/gradienteditor/";
GtkType
sp_gradient_vector_selector_get_type (void)
@@ -892,67 +892,68 @@ sp_gradient_vector_widget_new (SPGradient *gradient, SPStop *select_stop)
GtkWidget *
sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop)
{
- GtkWidget *wid;
-
- if (dlg == NULL) {
-
- dlg = sp_window_new (_("Gradient editor"), TRUE);
- if (x == -1000 || y == -1000) {
- x = prefs_get_int_attribute (prefs_path, "x", 0);
- y = prefs_get_int_attribute (prefs_path, "y", 0);
- }
- if (w ==0 || h == 0) {
- w = prefs_get_int_attribute (prefs_path, "w", 0);
- h = prefs_get_int_attribute (prefs_path, "h", 0);
- }
-
- if (x<0) x=0;
- if (y<0) y=0;
-
- if (x != 0 || y != 0)
- gtk_window_move ((GtkWindow *) dlg, x, y);
- else
- gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
- if (w && h) gtk_window_resize ((GtkWindow *) dlg, w, h);
- sp_transientize (dlg);
- wd.win = dlg;
- wd.stop = 0;
- g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
- gtk_signal_connect (GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
- gtk_signal_connect (GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_gradient_vector_dialog_destroy), dlg);
- gtk_signal_connect (GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect (G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg );
- g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg );
-
- gtk_container_set_border_width (GTK_CONTAINER (dlg), PAD);
-
- wid = (GtkWidget*)sp_gradient_vector_widget_new (gradient, stop);
- g_object_set_data (G_OBJECT (dlg), "gradient-vector-widget", wid);
- /* Connect signals */
- gtk_widget_show (wid);
- gtk_container_add (GTK_CONTAINER (dlg), wid);
- } else {
- // FIXME: temp fix for 0.38
- // Simply load_gradient into the editor does not work for multi-stop gradients,
- // as the stop list and other widgets are in a wrong state and crash readily.
- // Instead we just delete the window (by sending the delete signal)
- // and call sp_gradient_vector_editor_new again, so it creates the window anew.
-
- GdkEventAny event;
- GtkWidget *widget = (GtkWidget *) dlg;
- event.type = GDK_DELETE;
- event.window = widget->window;
- event.send_event = TRUE;
- g_object_ref (G_OBJECT (event.window));
- gtk_main_do_event ((GdkEvent*)&event);
- g_object_unref (G_OBJECT (event.window));
-
- g_assert (dlg == NULL);
- sp_gradient_vector_editor_new (gradient, stop);
- }
-
- return dlg;
+ GtkWidget *wid;
+
+ if (dlg == NULL) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ dlg = sp_window_new (_("Gradient editor"), TRUE);
+ if (x == -1000 || y == -1000) {
+ x = prefs->getInt(prefs_path + "x", -1000);
+ y = prefs->getInt(prefs_path + "y", -1000);
+ }
+ if (w ==0 || h == 0) {
+ w = prefs->getInt(prefs_path + "w", 0);
+ h = prefs->getInt(prefs_path + "h", 0);
+ }
+
+ if (x<0) x=0;
+ if (y<0) y=0;
+
+ if (x != 0 || y != 0)
+ gtk_window_move ((GtkWindow *) dlg, x, y);
+ else
+ gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
+ if (w && h) gtk_window_resize ((GtkWindow *) dlg, w, h);
+ sp_transientize (dlg);
+ wd.win = dlg;
+ wd.stop = 0;
+ g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
+ gtk_signal_connect (GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_gradient_vector_dialog_destroy), dlg);
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg);
+ g_signal_connect (G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg);
+ g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg );
+ g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg );
+
+ gtk_container_set_border_width (GTK_CONTAINER (dlg), PAD);
+
+ wid = (GtkWidget*)sp_gradient_vector_widget_new (gradient, stop);
+ g_object_set_data (G_OBJECT (dlg), "gradient-vector-widget", wid);
+ /* Connect signals */
+ gtk_widget_show (wid);
+ gtk_container_add (GTK_CONTAINER (dlg), wid);
+ } else {
+ // FIXME: temp fix for 0.38
+ // Simply load_gradient into the editor does not work for multi-stop gradients,
+ // as the stop list and other widgets are in a wrong state and crash readily.
+ // Instead we just delete the window (by sending the delete signal)
+ // and call sp_gradient_vector_editor_new again, so it creates the window anew.
+
+ GdkEventAny event;
+ GtkWidget *widget = (GtkWidget *) dlg;
+ event.type = GDK_DELETE;
+ event.window = widget->window;
+ event.send_event = TRUE;
+ g_object_ref (G_OBJECT (event.window));
+ gtk_main_do_event ((GdkEvent*)&event);
+ g_object_unref (G_OBJECT (event.window));
+
+ g_assert (dlg == NULL);
+ sp_gradient_vector_editor_new (gradient, stop);
+ }
+
+ return dlg;
}
static void
@@ -1051,18 +1052,19 @@ sp_gradient_vector_dialog_destroy (GtkObject *object, gpointer data)
static gboolean
sp_gradient_vector_dialog_delete (GtkWidget *widget, GdkEvent *event, GtkWidget *dialog)
{
- gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
- gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
+ gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
+ gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
if (x<0) x=0;
if (y<0) y=0;
- prefs_set_int_attribute (prefs_path, "x", x);
- prefs_set_int_attribute (prefs_path, "y", y);
- prefs_set_int_attribute (prefs_path, "w", w);
- prefs_set_int_attribute (prefs_path, "h", h);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + "x", x);
+ prefs->setInt(prefs_path + "y", y);
+ prefs->setInt(prefs_path + "w", w);
+ prefs->setInt(prefs_path + "h", h);
- return FALSE; // which means, go ahead and destroy it
+ return FALSE; // which means, go ahead and destroy it
}
/* Widget destroy handler */
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 401d76474..4c0439da7 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -27,7 +27,7 @@
#include <gtkmm/image.h>
#include "path-prefix.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "inkscape.h"
#include "document.h"
#include "sp-item.h"
@@ -280,7 +280,8 @@ static void setupLegacyNaming() {
static GtkWidget *
sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name )
{
- static gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpGtk", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ static bool dump = prefs->getBool( "/debug/icons/dumpGtk");
GtkWidget *widget = 0;
gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
@@ -336,7 +337,7 @@ sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name )
// Add a hook to render if set visible before prerender is done.
g_signal_connect( G_OBJECT(widget), "map", G_CALLBACK(imageMapNamedCB), GINT_TO_POINTER(0) );
- if ( prefs_get_int_attribute_limited( "options.iconrender", "named_nodelay", 0, 0, 1 ) ) {
+ if ( prefs->getBool("/options/iconrender/named_nodelay") ) {
int psize = sp_icon_get_phys_size(lsize);
prerender_icon(name, mappedSize, psize);
} else {
@@ -408,7 +409,8 @@ static void injectCustomSize()
// TODO - still need to handle the case of theme changes and resize, especially as we can't re-register a string.
if ( !sizeMapDone )
{
- gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpDefault", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool dump = prefs->getBool( "/debug/icons/dumpDefault");
gint width = 0;
gint height = 0;
if ( gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height ) ) {
@@ -493,7 +495,8 @@ int sp_icon_get_phys_size(int size)
if ( !init ) {
sizeDirty = false;
- gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpDefault", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool dump = prefs->getBool("/debug/icons/dumpDefault");
if ( dump ) {
g_message( "Default icon sizes:" );
@@ -650,7 +653,8 @@ extern "C" guchar *
sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
gchar const *name, unsigned psize )
{
- gint const dump = prefs_get_int_attribute_limited( "debug.icons", "dumpSvg", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool const dump = prefs->getBool("/debug/icons/dumpSvg");
guchar *px = NULL;
if (doc) {
@@ -763,7 +767,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
NR_ARENA_ITEM_RENDER_NO_CACHE );
nr_pixblock_release(&B);
- gint useOverlay = prefs_get_int_attribute_limited( "debug.icons", "overlaySvg", 0, 0, 1 );
+ bool useOverlay = prefs->getBool("/debug/icons/overlaySvg");
if ( useOverlay ) {
sp_icon_overlay_pixels( px, psize, psize, 4 * psize, 0x00, 0x00, 0xff );
}
@@ -890,7 +894,8 @@ static void populate_placeholder_icon(gchar const* name, GtkIconSize size)
}
static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, unsigned psize) {
- static gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpGtk", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ static bool dump = prefs->getBool("/debug/icons/dumpGtk");
GtkStockItem stock;
gboolean stockFound = gtk_stock_lookup( name, &stock );
if ( !stockFound ) {
@@ -924,7 +929,8 @@ static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, un
// returns true if icon needed preloading, false if nothing was done
bool prerender_icon(gchar const *name, GtkIconSize lsize, unsigned psize)
{
- static gint dump = prefs_get_int_attribute_limited( "debug.icons", "dumpGtk", 0, 0, 1 );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ static bool dump = prefs->getBool("/debug/icons/dumpGtk");
Glib::ustring key = icon_cache_key(name, lsize, psize);
GdkPixbuf *pb = get_cached_pixbuf(key);
if (pb) {
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 5f43f7925..af1883916 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -25,7 +25,7 @@
#include "widgets/icon.h"
#include "widgets/sp-widget.h"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "selection-chemistry.h"
#include "document.h"
#include "inkscape.h"
@@ -39,7 +39,6 @@
#include "helper/units.h"
#include "inkscape.h"
#include "verbs.h"
-#include "prefs-utils.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "sp-item-transform.h"
@@ -62,10 +61,11 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
using Geom::X;
using Geom::Y;
if ( sel && !sel->isEmpty() ) {
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
+ int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
boost::optional<Geom::Rect> const bbox(sel->bounds(bbox_type));
@@ -155,7 +155,8 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
SPDocument *document = sp_desktop_document(desktop);
sp_document_ensure_up_to_date (document);
- int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int prefs_bbox = prefs->getInt("/tools/bounding_box");
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
boost::optional<Geom::Rect> bbox = selection->bounds(bbox_type);
@@ -236,9 +237,9 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
gdouble strokewidth = stroke_average_width (selection->itemList());
- int transform_stroke = prefs_get_int_attribute ("options.transform", "stroke", 1);
+ int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0;
- NR::Matrix scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1);
+ Geom::Matrix scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1);
sp_selection_apply_affine(selection, scaler);
sp_document_maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT,
@@ -292,9 +293,11 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
// toggle button callbacks and updaters
-static void toggle_stroke( GtkToggleAction* act, gpointer data ) {
- gboolean active = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute( "options.transform", "stroke", active ? 1 : 0 );
+static void toggle_stroke( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/options/transform/stroke", active);
SPDesktop *desktop = (SPDesktop *)data;
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>scaled</b> when objects are scaled."));
@@ -303,9 +306,11 @@ static void toggle_stroke( GtkToggleAction* act, gpointer data ) {
}
}
-static void toggle_corners( GtkToggleAction* act, gpointer data) {
- gboolean active = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute( "options.transform", "rectcorners", active ? 1 : 0 );
+static void toggle_corners( GtkToggleAction* act, gpointer data)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/options/transform/rectcorners", active);
SPDesktop *desktop = (SPDesktop *)data;
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>scaled</b> when rectangles are scaled."));
@@ -314,9 +319,11 @@ static void toggle_corners( GtkToggleAction* act, gpointer data) {
}
}
-static void toggle_gradient( GtkToggleAction *act, gpointer data ) {
- gboolean active = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute( "options.transform", "gradient", active ? 1 : 0 );
+static void toggle_gradient( GtkToggleAction *act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/options/transform/gradient", active);
SPDesktop *desktop = (SPDesktop *)data;
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
@@ -325,9 +332,11 @@ static void toggle_gradient( GtkToggleAction *act, gpointer data ) {
}
}
-static void toggle_pattern( GtkToggleAction* act, gpointer data ) {
- gboolean active = gtk_toggle_action_get_active( act );
- prefs_set_int_attribute( "options.transform", "pattern", active ? 1 : 0 );
+static void toggle_pattern( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setInt("/options/transform/pattern", active);
SPDesktop *desktop = (SPDesktop *)data;
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
@@ -378,7 +387,8 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi
void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::UI::View::View *view = desktop;
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAction* act = 0;
@@ -532,7 +542,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("When scaling objects, scale the stroke width by the same proportion"),
"transform_stroke",
Inkscape::ICON_SIZE_DECORATION );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs_get_int_attribute("options.transform", "stroke", 1) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/stroke", true) );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_stroke), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
@@ -543,7 +553,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("When scaling rectangles, scale the radii of rounded corners"),
"transform_corners",
Inkscape::ICON_SIZE_DECORATION );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs_get_int_attribute("options.transform", "rectcorners", 1) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/rectcorners", true) );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_corners), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
@@ -554,7 +564,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Move gradients (in fill or stroke) along with the objects"),
"transform_gradient",
Inkscape::ICON_SIZE_DECORATION );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs_get_int_attribute("options.transform", "gradient", 1) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/gradient", true) );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_gradient), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
@@ -565,7 +575,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Move patterns (in fill or stroke) along with the objects"),
"transform_pattern",
Inkscape::ICON_SIZE_DECORATION );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs_get_int_attribute("options.transform", "pattern", 1) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/pattern", true) );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_pattern), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp
index 43a2a3cbe..b18290923 100644
--- a/src/widgets/sp-color-icc-selector.cpp
+++ b/src/widgets/sp-color-icc-selector.cpp
@@ -24,7 +24,7 @@
#include "color-profile.h"
//#define DEBUG_LCMS
#ifdef DEBUG_LCMS
-#include "prefs-utils.h"
+#include "preferences.h"
#include <gtk/gtkmessagedialog.h>
#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
@@ -34,10 +34,11 @@
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
- gint dump = prefs_get_int_attribute_limited("options.scislac", #key, 0, 0, 1);\
- gint dumpD = prefs_get_int_attribute_limited("options.scislac", #key"D", 0, 0, 1);\
- gint dumpD2 = prefs_get_int_attribute_limited("options.scislac", #key"D2", 0, 0, 1);\
- dumpD &= ( (update_in_progress == 0) || dumpD2 );\
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
+ bool dump = prefs->getBool("/options/scislac/" #key);\
+ bool dumpD = prefs->getBool("/options/scislac/" #key "D");\
+ bool dumpD2 = prefs->getBool("/options/scislac/" #key "D2");\
+ dumpD &&= ( (update_in_progress == 0) || dumpD2 );\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp
index 376cd8ee5..9766a9498 100644
--- a/src/widgets/sp-color-notebook.cpp
+++ b/src/widgets/sp-color-notebook.cpp
@@ -26,7 +26,7 @@
#include <glibmm/i18n.h>
#include "../dialogs/dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "sp-color-notebook.h"
#include "spw-utilities.h"
#include "sp-color-scales.h"
@@ -97,19 +97,19 @@ sp_color_notebook_class_init (SPColorNotebookClass *klass)
static void
sp_color_notebook_switch_page(GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- SPColorNotebook *colorbook)
+ GtkNotebookPage *page,
+ guint page_num,
+ SPColorNotebook *colorbook)
{
- if ( colorbook )
- {
+ if ( colorbook )
+ {
ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
nb->switchPage( notebook, page, page_num );
- // remember the page we seitched to
- prefs_set_int_attribute ("colorselector", "page", page_num);
-
- }
+ // remember the page we seitched to
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/colorselector/page", page_num);
+ }
}
void ColorNotebook::switchPage(GtkNotebook*,
@@ -274,7 +274,8 @@ void ColorNotebook::init()
XPAD, YPAD);
// restore the last active page
- gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs_get_int_attribute ("colorselector", "page", 0));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs->getInt("/colorselector/page", 0));
{
gboolean found = FALSE;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index b70684692..b945765db 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -1,28 +1,25 @@
-/** \file
- * Controls bars for some of Inkscape's tools
- * (for some tools, they are in their own files)
+/** @file
+ * @brief Controls bars for some of Inkscape's tools (for some tools,
+ * they are in their own files)
+ */
+/* Authors:
+ * MenTaLguY <mental@rydia.net>
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * bulia byak <buliabyak@users.sf.net>
+ * Frank Felfe <innerspace@iname.com>
+ * John Cliff <simarilius@yahoo.com>
+ * David Turner <novalis@gnu.org>
+ * Josh Andler <scislac@scislac.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Maximilian Albert <maximilian.albert@gmail.com>
+ *
+ * Copyright (C) 2004 David Turner
+ * Copyright (C) 2003 MenTaLguY
+ * Copyright (C) 1999-2008 authors
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
*/
-
-/*
-*
-* Authors:
-* MenTaLguY <mental@rydia.net>
-* Lauris Kaplinski <lauris@kaplinski.com>
-* bulia byak <buliabyak@users.sf.net>
-* Frank Felfe <innerspace@iname.com>
-* John Cliff <simarilius@yahoo.com>
-* David Turner <novalis@gnu.org>
-* Josh Andler <scislac@scislac.com>
-* Jon A. Cruz <jon@joncruz.org>
-* Maximilian Albert <maximilian.albert@gmail.com>
-*
-* Copyright (C) 2004 David Turner
-* Copyright (C) 2003 MenTaLguY
-* Copyright (C) 1999-2008 authors
-* Copyright (C) 2001-2002 Ximian, Inc.
-*
-* Released under GNU GPL, read the file 'COPYING' for more information
-*/
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -140,14 +137,14 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* ma
namespace { GtkWidget *sp_text_toolbox_new (SPDesktop *desktop); }
-Inkscape::IconSize prefToSize( gchar const *path, gchar const *attr, int base ) {
+Inkscape::IconSize prefToSize( Glib::ustring const &path, int base ) {
static Inkscape::IconSize sizeChoices[] = {
Inkscape::ICON_SIZE_LARGE_TOOLBAR,
Inkscape::ICON_SIZE_SMALL_TOOLBAR,
Inkscape::ICON_SIZE_MENU
};
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int index = prefs->getIntLimited( path, attr, base, 0, G_N_ELEMENTS(sizeChoices) );
+ int index = prefs->getIntLimited( path, base, 0, G_N_ELEMENTS(sizeChoices) );
return sizeChoices[index];
}
@@ -194,29 +191,29 @@ static struct {
{ "SPNodeContext", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
- SP_VERB_CONTEXT_TWEAK_PREFS, "tools.tweak", N_("Color/opacity used for color tweaking")},
+ SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")},
{ "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
- SP_VERB_CONTEXT_STAR_PREFS, "tools.shapes.star", N_("Style of new stars")},
+ SP_VERB_CONTEXT_STAR_PREFS, "/tools/shapes/star", N_("Style of new stars")},
{ "SPRectContext", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar",
- SP_VERB_CONTEXT_RECT_PREFS, "tools.shapes.rect", N_("Style of new rectangles")},
+ SP_VERB_CONTEXT_RECT_PREFS, "/tools/shapes/rect", N_("Style of new rectangles")},
{ "Box3DContext", "3dbox_toolbox", 0, box3d_toolbox_prep, "3DBoxToolbar",
- SP_VERB_CONTEXT_3DBOX_PREFS, "tools.shapes.3dbox", N_("Style of new 3D boxes")},
+ SP_VERB_CONTEXT_3DBOX_PREFS, "/tools/shapes/3dbox", N_("Style of new 3D boxes")},
{ "SPArcContext", "arc_toolbox", 0, sp_arc_toolbox_prep, "ArcToolbar",
- SP_VERB_CONTEXT_ARC_PREFS, "tools.shapes.arc", N_("Style of new ellipses")},
+ SP_VERB_CONTEXT_ARC_PREFS, "/tools/shapes/arc", N_("Style of new ellipses")},
{ "SPSpiralContext", "spiral_toolbox", 0, sp_spiral_toolbox_prep, "SpiralToolbar",
- SP_VERB_CONTEXT_SPIRAL_PREFS, "tools.shapes.spiral", N_("Style of new spirals")},
+ SP_VERB_CONTEXT_SPIRAL_PREFS, "/tools/shapes/spiral", N_("Style of new spirals")},
{ "SPPencilContext", "pencil_toolbox", 0, sp_pencil_toolbox_prep, "PencilToolbar",
- SP_VERB_CONTEXT_PENCIL_PREFS, "tools.freehand.pencil", N_("Style of new paths created by Pencil")},
+ SP_VERB_CONTEXT_PENCIL_PREFS, "/tools/freehand/pencil", N_("Style of new paths created by Pencil")},
{ "SPPenContext", "pen_toolbox", 0, sp_pen_toolbox_prep, "PenToolbar",
- SP_VERB_CONTEXT_PEN_PREFS, "tools.freehand.pen", N_("Style of new paths created by Pen")},
+ SP_VERB_CONTEXT_PEN_PREFS, "/tools/freehand/pen", N_("Style of new paths created by Pen")},
{ "SPDynaDrawContext", "calligraphy_toolbox", 0, sp_calligraphy_toolbox_prep,"CalligraphyToolbar",
- SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "tools.calligraphic", N_("Style of new calligraphic strokes")},
+ SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "/tools/calligraphic", N_("Style of new calligraphic strokes")},
{ "SPEraserContext", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar",
- SP_VERB_CONTEXT_ERASER_PREFS, "tools.eraser", _("TBD")},
+ SP_VERB_CONTEXT_ERASER_PREFS, "/tools/eraser", _("TBD")},
{ "SPLPEToolContext", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
- SP_VERB_CONTEXT_LPETOOL_PREFS, "tools.lpetool", _("TBD")},
+ SP_VERB_CONTEXT_LPETOOL_PREFS, "/tools/lpetool", _("TBD")},
{ "SPTextContext", "text_toolbox", sp_text_toolbox_new, 0, 0,
SP_VERB_INVALID, 0, 0},
{ "SPDropperContext", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
@@ -226,7 +223,7 @@ static struct {
{ "SPConnectorContext", "connector_toolbox", 0, sp_connector_toolbox_prep, "ConnectorToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPFloodContext", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar",
- SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "tools.paintbucket", N_("Style of Paint Bucket fill objects")},
+ SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")},
{ NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL }
};
@@ -276,6 +273,7 @@ static gchar const * ui_descr =
" <toolitem action='NodeCuspAction' />"
" <toolitem action='NodeSmoothAction' />"
" <toolitem action='NodeSymmetricAction' />"
+ " <toolitem action='NodeAutoAction' />"
" <separator />"
" <toolitem action='NodeLineAction' />"
" <toolitem action='NodeCurveAction' />"
@@ -561,7 +559,7 @@ Gtk::Widget* VerbAction::create_menu_item_vfunc()
Gtk::Widget* VerbAction::create_tool_item_vfunc()
{
// Gtk::Widget* widg = Gtk::Action::create_tool_item_vfunc();
- Inkscape::IconSize toolboxSize = prefToSize("toolbox.tools", "small");
+ Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
GtkWidget* toolbox = 0;
GtkWidget *button = sp_toolbox_button_new_from_verb_with_doubleclick( toolbox, toolboxSize,
SP_BUTTON_TYPE_TOGGLE,
@@ -768,7 +766,7 @@ Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* desktop )
SP_VERB_ZOOM_SELECTION,
};
- Inkscape::IconSize toolboxSize = prefToSize("toolbox", "small");
+ Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
static std::map<SPDesktop*, Glib::RefPtr<Gtk::ActionGroup> > groups;
Glib::RefPtr<Gtk::ActionGroup> mainActions;
@@ -913,7 +911,7 @@ sp_commands_toolbox_new()
static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
gchar const *label, gchar const *shortLabel, gchar const *tooltip,
- gchar const *path, gchar const *data, gdouble def,
+ Glib::ustring const &path, gdouble def,
GtkWidget *focusTarget,
GtkWidget *us,
GObject *dataKludge,
@@ -924,7 +922,7 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
gdouble climb = 0.1, guint digits = 3, double factor = 1.0 )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, data, def) * factor,
+ GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, def) * factor,
lower, upper, step, page, page ) );
if (us) {
sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us), adj );
@@ -950,7 +948,9 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
}
if ( dataKludge ) {
- g_object_set_data( dataKludge, data, adj );
+ // Rather lame, but it's the only place where we need to get the entry name
+ // but we don't have an Entry
+ g_object_set_data( dataKludge, prefs->getEntry(path).getEntryName().data(), adj );
}
// Using a cast just to make sure we pass in the right kind of function pointer
@@ -1060,10 +1060,17 @@ sp_node_path_edit_symmetrical(void)
if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_SYMM);
}
+void
+sp_node_path_edit_auto(void)
+{
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_AUTO);
+}
+
static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs->setBool("tools.nodes", "show_handles", show);
+ prefs->setBool("/tools/nodes/show_handles", show);
ShapeEditor *shape_editor = get_current_shape_editor();
if (shape_editor) shape_editor->show_handles(show);
}
@@ -1071,7 +1078,7 @@ static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
static void toggle_show_helperpath (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs->setBool("tools.nodes", "show_helperpath", show);
+ prefs->setBool("/tools/nodes/show_helperpath", show);
ShapeEditor *shape_editor = get_current_shape_editor();
if (shape_editor) shape_editor->show_helperpath(show);
}
@@ -1164,7 +1171,7 @@ sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_
SPUnit const *unit = tracker->getActiveUnit();
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs->setDouble("tools.nodes", value_name, sp_units_get_pixels(adj->value, *unit));
+ prefs->setDouble(Glib::ustring("/tools/nodes/") + value_name, sp_units_get_pixels(adj->value, *unit));
}
// quit if run by the attr_changed listener
@@ -1258,7 +1265,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
g_object_set_data( holder, "tracker", tracker );
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
InkAction* inky = ink_action_new( "NodeInsertAction",
@@ -1355,6 +1362,16 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
}
{
+ InkAction* inky = ink_action_new( "NodeAutoAction",
+ _("Node Auto"),
+ _("Make selected nodes auto-smooth"),
+ "node_auto",
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_auto), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
+ }
+
+ {
InkAction* inky = ink_action_new( "NodeLineAction",
_("Node Line"),
_("Make selected segments lines"),
@@ -1382,7 +1399,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_handles), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.nodes", "show_handles", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_handles", true) );
}
{
@@ -1393,7 +1410,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_helperpath), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.nodes", "show_helperpath", false) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_helperpath", false) );
}
{
@@ -1436,7 +1453,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500};
eact = create_adjustment_action( "NodeXAction",
_("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"),
- "tools.nodes", "Xcoord", 0,
+ "/tools/nodes/Xcoord", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-nodes",
-1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -1454,7 +1471,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500};
eact = create_adjustment_action( "NodeYAction",
_("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"),
- "tools.nodes", "Ycoord", 0,
+ "/tools/nodes/Ycoord", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
-1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -1608,10 +1625,10 @@ setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/ToolToolbar" );
- if ( prefs->getIntLimited("toolbox", "icononly", 1, 0, 1) ) {
+ if ( prefs->getBool("/toolbox/icononly", true) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- Inkscape::IconSize toolboxSize = prefToSize("toolbox.tools", "small");
+ Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_VERTICAL);
@@ -1625,7 +1642,7 @@ setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
}
gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
-// Inkscape::IconSize toolboxSize = prefToSize("toolbox.tools", "small");
+// Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
}
@@ -1703,9 +1720,8 @@ setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
g_free( tmp );
tmp = 0;
- Inkscape::IconSize toolboxSize = prefToSize("toolbox", "small");
- /// @todo convert to getBool
- if ( prefs->getIntLimited( "toolbox", "icononly", 1, 0, 1 ) ) {
+ Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
+ if ( prefs->getBool( "/toolbox/icononly", true) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
@@ -1803,11 +1819,11 @@ setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/CommandsToolbar" );
- if ( prefs->getBool("toolbox", "icononly", true) ) {
+ if ( prefs->getBool("/toolbox/icononly", true) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- Inkscape::IconSize toolboxSize = prefToSize("toolbox", "small");
+ Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_HORIZONTAL);
@@ -1870,7 +1886,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
// do not remember prefs if this call is initiated by an undo change, because undoing object
// creation sets bogus values to its attributes before it is deleted
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.shapes.star", "magnitude", (gint)adj->value);
+ prefs->setInt("/tools/shapes/star/magnitude", (gint)adj->value);
}
// quit if run by the attr_changed listener
@@ -1908,7 +1924,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.star", "proportion", adj->value);
+ prefs->setDouble("/tools/shapes/star/proportion", adj->value);
}
// quit if run by the attr_changed listener
@@ -1952,7 +1968,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool( "tools.shapes.star", "isflatsided", flat);
+ prefs->setBool( "/tools/shapes/star/isflatsided", flat);
}
// quit if run by the attr_changed listener
@@ -1995,7 +2011,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.star", "rounded", (gdouble) adj->value);
+ prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value);
}
// quit if run by the attr_changed listener
@@ -2030,7 +2046,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.star", "randomized", (gdouble) adj->value);
+ prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value);
}
// quit if run by the attr_changed listener
@@ -2077,7 +2093,7 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n
GtkAdjustment *adj = 0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool isFlatSided = prefs->getBool("tools.shapes.star", "isflatsided", true);
+ bool isFlatSided = prefs->getBool("/tools/shapes/star/isflatsided", true);
if (!strcmp(name, "inkscape:randomized")) {
adj = GTK_ADJUSTMENT( gtk_object_get_data(GTK_OBJECT(tbl), "randomized") );
@@ -2223,7 +2239,7 @@ sp_toolbox_add_label(GtkWidget *tbl, gchar const *title, bool wide)
static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "StarStateAction", _("<b>New:</b>"), "", 0 );
@@ -2235,7 +2251,7 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
EgeAdjustmentAction* eact = 0;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool isFlatSided = prefs->getBool("tools.shapes.star", "isflatsided", true);
+ bool isFlatSided = prefs->getBool("/tools/shapes/star/isflatsided", true);
/* Flatsided checkbox */
{
@@ -2277,7 +2293,7 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {3, 4, 5, 6, 7, 8, 10, 12, 20};
eact = create_adjustment_action( "MagnitudeAction",
_("Corners"), _("Corners:"), _("Number of corners of a polygon or star"),
- "tools.shapes.star", "magnitude", 3,
+ "/tools/shapes/star/magnitude", 3,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
3, 1024, 1, 5,
labels, values, G_N_ELEMENTS(labels),
@@ -2296,7 +2312,7 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
// TRANSLATORS: Tip radius of a star is the distance from the center to the farthest handle.
// Base radius is the same for the closest handle.
_("Base radius to tip radius ratio"),
- "tools.shapes.star", "proportion", 0.5,
+ "/tools/shapes/star/proportion", 0.5,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.01, 1.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
@@ -2317,7 +2333,7 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {-1, -0.2, -0.03, 0, 0.05, 0.1, 0.2, 0.3, 0.5, 1, 10};
eact = create_adjustment_action( "RoundednessAction",
_("Rounded"), _("Rounded:"), _("How much rounded are the corners (0 for sharp)"),
- "tools.shapes.star", "rounded", 0.0,
+ "/tools/shapes/star/rounded", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
-10.0, 10.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
@@ -2332,7 +2348,7 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {0, 0.01, 0.1, 0.5, 10};
eact = create_adjustment_action( "RandomizationAction",
_("Randomized"), _("Randomized:"), _("Scatter randomly the corners and angles"),
- "tools.shapes.star", "randomized", 0.0,
+ "/tools/shapes/star/randomized", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
-10.0, 10.0, 0.001, 0.01,
labels, values, G_N_ELEMENTS(labels),
@@ -2392,7 +2408,7 @@ sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.rect", value_name, sp_units_get_pixels(adj->value, *unit));
+ prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name, sp_units_get_pixels(adj->value, *unit));
}
// quit if run by the attr_changed listener
@@ -2592,7 +2608,7 @@ sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "RectStateAction", _("<b>New:</b>"), "", 0 );
@@ -2614,7 +2630,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500};
eact = create_adjustment_action( "RectWidthAction",
_("Width"), _("W:"), _("Width of rectangle"),
- "tools.shapes.rect", "width", 0,
+ "/tools/shapes/rect/width", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-rect",
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -2631,7 +2647,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500};
eact = create_adjustment_action( "RectHeightAction",
_("Height"), _("H:"), _("Height of rectangle"),
- "tools.shapes.rect", "height", 0,
+ "/tools/shapes/rect/height", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -2648,7 +2664,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {0.5, 1, 2, 3, 5, 10, 20, 50, 100};
eact = create_adjustment_action( "RadiusXAction",
_("Horizontal radius"), _("Rx:"), _("Horizontal radius of rounded corners"),
- "tools.shapes.rect", "rx", 0,
+ "/tools/shapes/rect/rx", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -2663,7 +2679,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gdouble values[] = {0.5, 1, 2, 3, 5, 10, 20, 50, 100};
eact = create_adjustment_action( "RadiusYAction",
_("Vertical radius"), _("Ry:"), _("Vertical radius of rounded corners"),
- "tools.shapes.rect", "ry", 0,
+ "/tools/shapes/rect/ry", 0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
@@ -2777,16 +2793,14 @@ static void box3d_persp_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar c
{
GtkWidget *tbl = GTK_WIDGET(data);
- // quit if run by the attr_changed listener
- // note: it used to work without the differently called freeze_ attributes (here and in
- // box3d_angle_value_changed()) but I now it doesn't so I'm leaving them in for now
- if (g_object_get_data(G_OBJECT(tbl), "freeze_angle")) {
+ // quit if run by the attr_changed or selection changed listener
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
return;
}
// set freeze so that it can be caught in box3d_angle_z_value_changed() (to avoid calling
// sp_document_maybe_done() when the document is undo insensitive)
- g_object_set_data(G_OBJECT(tbl), "freeze_attr", GINT_TO_POINTER(TRUE));
+ g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
// TODO: Only update the appropriate part of the toolbar
// if (!strcmp(name, "inkscape:vp_z")) {
@@ -2796,7 +2810,7 @@ static void box3d_persp_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar c
Persp3D *persp = persp3d_get_from_repr(repr);
persp3d_update_box_reprs(persp);
- g_object_set_data(G_OBJECT(tbl), "freeze_attr", GINT_TO_POINTER(FALSE));
+ g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
}
static Inkscape::XML::NodeEventVector box3d_persp_tb_repr_events =
@@ -2838,9 +2852,11 @@ box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
inkscape_active_document()->current_persp3d = persp3d_get_from_repr(persp_repr);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("tools.shapes.3dbox", "persp", persp_repr->attribute("id"));
+ prefs->setString("/tools/shapes/3dbox/persp", persp_repr->attribute("id"));
+ g_object_set_data(tbl, "freeze", GINT_TO_POINTER(TRUE));
box3d_resync_toolbar(persp_repr, tbl);
+ g_object_set_data(tbl, "freeze", GINT_TO_POINTER(FALSE));
}
}
@@ -2850,15 +2866,13 @@ box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis ax
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
SPDocument *document = sp_desktop_document(desktop);
- // quit if run by the attr_changed listener
- // note: it used to work without the differently called freeze_ attributes (here and in
- // box3d_persp_tb_event_attr_changed()) but I now it doesn't so I'm leaving them in for now
- if (g_object_get_data( dataKludge, "freeze_attr" )) {
+ // quit if run by the attr_changed or selection changed listener
+ if (g_object_get_data( dataKludge, "freeze" )) {
return;
}
// in turn, prevent listener from responding
- g_object_set_data(dataKludge, "freeze_angle", GINT_TO_POINTER(TRUE));
+ g_object_set_data(dataKludge, "freeze", GINT_TO_POINTER(TRUE));
//Persp3D *persp = document->current_persp3d;
std::list<Persp3D *> sel_persps = sp_desktop_selection(desktop)->perspList();
@@ -2874,7 +2888,7 @@ box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis ax
// TODO: use the correct axis here, too
sp_document_maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
- g_object_set_data( dataKludge, "freeze_angle", GINT_TO_POINTER(FALSE) );
+ g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -2945,7 +2959,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
_("Angle in X direction"), _("Angle X:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in X direction"),
- "tools.shapes.3dbox", "box3d_angle_x", 30,
+ "/tools/shapes/3dbox/box3d_angle_x", 30,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-box3d",
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -2973,8 +2987,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_x_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_x_state_changed), box3d_angle_x );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_x), !prefs->getBool("tools.shapes.3dbox", "vp_x_state", true) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_x_state", true) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_x), !prefs->getBool("/tools/shapes/3dbox/vp_x_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_x_state", true) );
}
/* Angle Y */
@@ -2985,7 +2999,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
_("Angle in Y direction"), _("Angle Y:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Y direction"),
- "tools.shapes.3dbox", "box3d_angle_y", 30,
+ "/tools/shapes/3dbox/box3d_angle_y", 30,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3012,8 +3026,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_y_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_y_state_changed), box3d_angle_y );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_y), !prefs->getBool("tools.shapes.3dbox", "vp_y_state", true) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_y_state", true) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_y), !prefs->getBool("/tools/shapes/3dbox/vp_y_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_y_state", true) );
}
/* Angle Z */
@@ -3024,7 +3038,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
_("Angle in Z direction"), _("Angle Z:"),
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Z direction"),
- "tools.shapes.3dbox", "box3d_angle_z", 30,
+ "/tools/shapes/3dbox/box3d_angle_z", 30,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3051,8 +3065,8 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_z_state_action", act );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(box3d_vp_z_state_changed), box3d_angle_z );
- gtk_action_set_sensitive( GTK_ACTION(box3d_angle_z), !prefs->getBool("tools.shapes.3dbox", "vp_z_state", true) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.shapes.3dbox", "vp_z_state", true) );
+ gtk_action_set_sensitive( GTK_ACTION(box3d_angle_z), !prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) );
}
sigc::connection *connection = new sigc::connection(
@@ -3067,13 +3081,13 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
//########################
static void
-sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name)
+sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name)
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.spiral", value_name, adj->value);
+ prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value);
}
// quit if run by the attr_changed listener
@@ -3084,7 +3098,7 @@ sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_nam
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL);
+ gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL);
bool modmade = false;
for (GSList const *items = sp_desktop_selection(desktop)->itemList();
@@ -3233,7 +3247,7 @@ sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl
static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "SpiralStateAction", _("<b>New:</b>"), "", 0 );
@@ -3248,7 +3262,7 @@ static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
gdouble values[] = {0.01, 0.5, 1, 2, 3, 5, 10, 20, 50, 100};
eact = create_adjustment_action( "SpiralRevolutionAction",
_("Number of turns"), _("Turns:"), _("Number of revolutions"),
- "tools.shapes.spiral", "revolution", 3.0,
+ "/tools/shapes/spiral/revolution", 3.0,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-spiral",
0.01, 1024.0, 0.1, 1.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3262,7 +3276,7 @@ static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
gdouble values[] = {0, 0.1, 0.5, 1, 1.5, 5, 20};
eact = create_adjustment_action( "SpiralExpansionAction",
_("Divergence"), _("Divergence:"), _("How much denser/sparser are outer revolutions; 1 = uniform"),
- "tools.shapes.spiral", "expansion", 1.0,
+ "/tools/shapes/spiral/expansion", 1.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 1000.0, 0.01, 1.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3276,7 +3290,7 @@ static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
gdouble values[] = {0, 0.5, 0.9};
eact = create_adjustment_action( "SpiralT0Action",
_("Inner radius"), _("Inner radius:"), _("Radius of the innermost revolution (relative to the spiral size)"),
- "tools.shapes.spiral", "t0", 0.0,
+ "/tools/shapes/spiral/t0", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 0.999, 0.01, 1.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3308,13 +3322,13 @@ static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
//########################
/* This is used in generic functions below to share large portions of code between pen and pencil tool */
-static char const *
+static Glib::ustring const
freehand_tool_name(GObject *dataKludge)
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data(dataKludge, "desktop");
return ( tools_isactive(desktop, TOOLS_FREEHAND_PEN)
- ? "tools.freehand.pen"
- : "tools.freehand.pencil" );
+ ? "/tools/freehand/pen"
+ : "/tools/freehand/pencil" );
}
static void freehand_mode_changed(EgeSelectOneAction* act, GObject* tbl)
@@ -3322,7 +3336,7 @@ static void freehand_mode_changed(EgeSelectOneAction* act, GObject* tbl)
gint mode = ege_select_one_action_get_active(act);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(freehand_tool_name(tbl), "freehand-mode", mode);
+ prefs->setInt(freehand_tool_name(tbl) + "/freehand-mode", mode);
SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop");
@@ -3339,8 +3353,8 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
/* Freehand mode toggle buttons */
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- guint freehandMode = prefs->getInt(( tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen" ), "freehand-mode", 0);
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ guint freehandMode = prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/freehand-mode" : "/tools/freehand/pen/freehand-mode" ), 0);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
@@ -3398,7 +3412,7 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) {
gint shape = ege_select_one_action_get_active( act );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(freehand_tool_name(dataKludge), "shape", shape);
+ prefs->setInt(freehand_tool_name(dataKludge) + "/shape", shape);
}
/**
@@ -3439,7 +3453,7 @@ freehand_add_advanced_shape_options(GtkActionGroup* mainActions, GObject* holder
_("Shape:"), ("Shape"), NULL, GTK_TREE_MODEL(model));
g_object_set( act1, "short_label", _("Shape:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
- ege_select_one_action_set_active( act1, prefs->getInt(( tool_is_pencil ? "tools.freehand.pencil" : "tools.freehand.pen" ), "shape", 0) );
+ ege_select_one_action_set_active( act1, prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/shape" : "/tools/freehand/pen/shape" ), 0) );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(freehand_change_shape), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act1) );
g_object_set_data( holder, "shape_action", act1 );
@@ -3473,7 +3487,6 @@ sp_pencil_tb_defaults(GtkWidget */*widget*/, GtkObject *obj)
static void
sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
{
-
// quit if run by the attr_changed listener
if (g_object_get_data( tbl, "freeze" )) {
return;
@@ -3481,45 +3494,36 @@ sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
// in turn, prevent listener from responding
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- prefs->setDouble("tools.freehand.pencil", "tolerance", adj->value);
+ prefs->setDouble("/tools/freehand/pencil/tolerance", adj->value);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-
}
-
-
-static void
-sp_pencil_tb_tolerance_value_changed_external(Inkscape::XML::Node */*repr*/,
- const gchar */*key*/,
- const gchar */*oldval*/,
- const gchar */*newval*/,
- bool /*is_interactive*/,
- void * data)
-{
- GObject* tbl = G_OBJECT(data);
- if (g_object_get_data( tbl, "freeze" )) {
- return;
+class PencilToleranceObserver : public Inkscape::Preferences::Observer {
+public:
+ PencilToleranceObserver(Glib::ustring const &path, GObject *x) : Observer(path), _obj(x)
+ {
+ g_object_set_data(_obj, "prefobserver", this);
}
+ virtual ~PencilToleranceObserver() {
+ if (g_object_get_data(_obj, "prefobserver") == this) {
+ g_object_set_data(_obj, "prefobserver", NULL);
+ }
+ }
+ virtual void notify(Inkscape::Preferences::Entry const &val) {
+ GObject* tbl = _obj;
+ if (g_object_get_data( tbl, "freeze" )) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
-
- GtkAdjustment * adj = (GtkAdjustment*)g_object_get_data(tbl,
- "tolerance");
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double v = prefs->getDouble("tools.freehand.pencil", "tolerance", adj->value);
- gtk_adjustment_set_value(adj, v);
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-
-}
+ GtkAdjustment * adj = (GtkAdjustment*)g_object_get_data(tbl, "tolerance");
-static Inkscape::XML::NodeEventVector pencil_node_events =
-{
- NULL,
- NULL,
- sp_pencil_tb_tolerance_value_changed_external,
- NULL,
- NULL,
+ double v = val.getDouble(adj->value);
+ gtk_adjustment_set_value(adj, v);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ }
+private:
+ GObject *_obj;
};
@@ -3536,7 +3540,7 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
eact = create_adjustment_action( "PencilToleranceAction",
_("Smoothing:"), _("Smoothing: "),
_("How much smoothing (simplifying) is applied to the line"),
- "tools.freehand.pencil", "tolerance",
+ "/tools/freehand/pencil/tolerance",
3.0,
GTK_WIDGET(desktop->canvas), NULL,
holder, TRUE, "altx-pencil",
@@ -3547,11 +3551,8 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE,
- "tools.freehand.pencil");
- repr->addListener(&pencil_node_events, G_OBJECT(holder));
- g_object_set_data(G_OBJECT(holder), "repr", repr);
-
+ PencilToleranceObserver *obs =
+ new PencilToleranceObserver("/tools/freehand/pencil/tolerance", G_OBJECT(holder));
}
/* advanced shape options */
@@ -3580,26 +3581,26 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
static void sp_tweak_width_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.tweak", "width", adj->value * 0.01 );
+ prefs->setDouble( "/tools/tweak/width", adj->value * 0.01 );
}
static void sp_tweak_force_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.tweak", "force", adj->value * 0.01 );
+ prefs->setDouble( "/tools/tweak/force", adj->value * 0.01 );
}
static void sp_tweak_pressure_state_changed( GtkToggleAction *act, gpointer /*data*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.tweak", "usepressure", gtk_toggle_action_get_active(act));
+ prefs->setBool("/tools/tweak/usepressure", gtk_toggle_action_get_active(act));
}
static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
int mode = ege_select_one_action_get_active( act );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.tweak", "mode", mode);
+ prefs->setInt("/tools/tweak/mode", mode);
GtkAction *doh = GTK_ACTION(g_object_get_data( tbl, "tweak_doh"));
GtkAction *dos = GTK_ACTION(g_object_get_data( tbl, "tweak_dos"));
@@ -3627,29 +3628,29 @@ static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
static void sp_tweak_fidelity_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.tweak", "fidelity", adj->value * 0.01 );
+ prefs->setDouble( "/tools/tweak/fidelity", adj->value * 0.01 );
}
static void tweak_toggle_doh (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.tweak", "doh", gtk_toggle_action_get_active(act));
+ prefs->setBool("/tools/tweak/doh", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_dos (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.tweak", "dos", gtk_toggle_action_get_active(act));
+ prefs->setBool("/tools/tweak/dos", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_dol (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.tweak", "dol", gtk_toggle_action_get_active(act));
+ prefs->setBool("/tools/tweak/dol", gtk_toggle_action_get_active(act));
}
static void tweak_toggle_doo (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.tweak", "doo", gtk_toggle_action_get_active(act));
+ prefs->setBool("/tools/tweak/doo", gtk_toggle_action_get_active(act));
}
static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
@@ -3658,7 +3659,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "TweakWidthAction",
_("Width"), _("Width:"), _("The width of the tweak area (relative to the visible canvas area)"),
- "tools.tweak", "width", 15,
+ "/tools/tweak/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-tweak",
1, 100, 1.0, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3675,7 +3676,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "TweakForceAction",
_("Force"), _("Force:"), _("The force of the tweak action"),
- "tools.tweak", "force", 20,
+ "/tools/tweak/force", 20,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-force",
1, 100, 1.0, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3794,14 +3795,14 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
ege_select_one_action_set_icon_size( act, secondarySize );
ege_select_one_action_set_tooltip_column( act, 1 );
- gint mode = prefs->getInt("tools.tweak", "mode", 0);
+ gint mode = prefs->getInt("/tools/tweak/mode", 0);
ege_select_one_action_set_active( act, mode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_tweak_mode_changed), holder );
g_object_set_data( G_OBJECT(holder), "tweak_tool_mode", act);
}
- guint mode = prefs->getInt("tools.tweak", "mode", 0);
+ guint mode = prefs->getInt("/tools/tweak/mode", 0);
{
EgeOutputAction* act = ege_output_action_new( "TweakChannelsLabel", _("Channels:"), "", 0 );
@@ -3822,7 +3823,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("H"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doh), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "doh", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doh", true) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_doh", act);
@@ -3837,7 +3838,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("S"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dos), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "dos", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dos", true) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_dos", act );
@@ -3852,7 +3853,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("L"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dol), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "dol", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dol", true) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_dol", act );
@@ -3867,7 +3868,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
g_object_set( act, "short_label", _("O"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doo), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.tweak", "doo", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doo", true) );
if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER)
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
g_object_set_data( holder, "tweak_doo", act );
@@ -3879,7 +3880,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
EgeAdjustmentAction *eact = create_adjustment_action( "TweakFidelityAction",
_("Fidelity"), _("Fidelity:"),
_("Low fidelity simplifies paths; high fidelity preserves path features but may generate a lot of new nodes"),
- "tools.tweak", "fidelity", 50,
+ "/tools/tweak/fidelity", 50,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-fidelity",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -3901,7 +3902,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.tweak", "usepressure", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/usepressure", true) );
}
}
@@ -3918,29 +3919,26 @@ static void update_presets_list (GObject *tbl)
EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
if (!sel) {
- ege_select_one_action_set_active(sel, 0);
+ // WTF!? This will cause a segfault if ever reached
+ //ege_select_one_action_set_active(sel, 0);
return;
}
- int total_prefs = prefs->childCount("tools.calligraphic.preset");
-
- for (int i = 0; i < total_prefs; ++i) {
- Glib::ustring preset_path = prefs->getNthChild("tools.calligraphic.preset", i);
- /// @todo Remove the use of _getNode()
- Inkscape::XML::Node *preset_repr = prefs->_getNode(preset_path);
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ int ege_index = 1;
+ for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) {
bool match = true;
+
+ std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(*i);
+ for (std::vector<Inkscape::Preferences::Entry>::iterator j = preset.begin(); j != preset.end(); ++j) {
+ Glib::ustring entry_name = j->getEntryName();
+ if (entry_name == "id" || entry_name == "name") continue;
- for ( Inkscape::Util::List<Inkscape::XML::AttributeRecord const> iter = preset_repr->attributeList();
- iter;
- ++iter ) {
- const gchar *attr_name = g_quark_to_string(iter->key);
- if (!strcmp(attr_name, "id") || !strcmp(attr_name, "name"))
- continue;
- void *widget = g_object_get_data(tbl, attr_name);
+ void *widget = g_object_get_data(tbl, entry_name.data());
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
- double v = prefs->getDouble(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
+ double v = j->getDouble();
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
//std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n";
if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) {
@@ -3948,7 +3946,7 @@ static void update_presets_list (GObject *tbl)
break;
}
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
- bool v = prefs->getBool(preset_path, attr_name);
+ bool v = j->getBool();
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
//std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n";
if ( static_cast<bool>(gtk_toggle_action_get_active(toggle)) != v ) {
@@ -3957,13 +3955,13 @@ static void update_presets_list (GObject *tbl)
}
}
}
- }
-
- if (match) {
+ }
+
+ if (match) {
// newly added item is at the same index as the
// save command, so we need to change twice for it to take effect
ege_select_one_action_set_active(sel, 0);
- ege_select_one_action_set_active(sel, i + 1); // one-based index
+ ege_select_one_action_set_active(sel, ege_index); // one-based index
return;
}
}
@@ -3975,70 +3973,70 @@ static void update_presets_list (GObject *tbl)
static void sp_ddc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "mass", adj->value * 0.01 );
+ prefs->setDouble( "/tools/calligraphic/mass", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_wiggle_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "wiggle", adj->value * 0.01 );
+ prefs->setDouble( "/tools/calligraphic/wiggle", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_angle_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "angle", adj->value );
+ prefs->setDouble( "/tools/calligraphic/angle", adj->value );
update_presets_list(tbl);
}
static void sp_ddc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "width", adj->value * 0.01 );
+ prefs->setDouble( "/tools/calligraphic/width", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.calligraphic", "thinning", adj->value * 0.01 );
+ prefs->setDouble("/tools/calligraphic/thinning", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_flatness_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "flatness", adj->value * 0.01);
+ prefs->setDouble( "/tools/calligraphic/flatness", adj->value * 0.01);
update_presets_list(tbl);
}
static void sp_ddc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "tremor", adj->value * 0.01 );
+ prefs->setDouble( "/tools/calligraphic/tremor", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_ddc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.calligraphic", "cap_rounding", adj->value );
+ prefs->setDouble( "/tools/calligraphic/cap_rounding", adj->value );
update_presets_list(tbl);
}
static void sp_ddc_pressure_state_changed( GtkToggleAction *act, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.calligraphic", "usepressure", gtk_toggle_action_get_active( act ));
+ prefs->setBool("/tools/calligraphic/usepressure", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
}
static void sp_ddc_trace_background_changed( GtkToggleAction *act, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.calligraphic", "tracebackground", gtk_toggle_action_get_active( act ));
+ prefs->setBool("/tools/calligraphic/tracebackground", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
}
@@ -4046,7 +4044,7 @@ static void sp_ddc_tilt_state_changed( GtkToggleAction *act, GObject* tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAction * calligraphy_angle = static_cast<GtkAction *> (g_object_get_data(tbl,"angle_action"));
- prefs->setBool("tools.calligraphic", "usetilt", gtk_toggle_action_get_active( act ));
+ prefs->setBool("/tools/calligraphic/usetilt", gtk_toggle_action_get_active( act ));
update_presets_list(tbl);
if (calligraphy_angle )
gtk_action_set_sensitive( calligraphy_angle, !gtk_toggle_action_get_active( act ) );
@@ -4081,18 +4079,17 @@ static void sp_dcc_build_presets_list(GObject *tbl)
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter, 0, _("No preset"), 1, 0, -1 );
}
-
- /// @todo Use public Preferences API instead of node manipulation
+
+ // iterate over all presets to populate the list
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::XML::Node *repr = prefs->_getNode("tools.calligraphic.preset", true);
- Inkscape::XML::Node *child_repr = repr->firstChild();
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
int ii=1;
- while (child_repr) {
- GtkTreeIter iter;
- char *preset_name = (char *) child_repr->attribute("name");
+
+ for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i) {
+ GtkTreeIter iter;
+ Glib::ustring preset_name = prefs->getString(*i + "/name");
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, preset_name, 1, ii++, -1 );
- child_repr = child_repr->next();
+ gtk_list_store_set( model, &iter, 0, preset_name.data(), 1, ii++, -1 );
}
{
@@ -4131,29 +4128,28 @@ static void sp_dcc_save_profile (GtkWidget */*widget*/, GObject *tbl)
}
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE));
-
+
+ // If there's a preset with the given name, find it and set save_path appropriately
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ int total_presets = presets.size();
int new_index = -1;
- Glib::ustring pref_path;
- int total_prefs = prefs->childCount("tools.calligraphic.preset");
-
- for (int i = 0; i < total_prefs; ++i) {
- Glib::ustring path = prefs->getNthChild("tools.calligraphic.preset", i);
- Glib::ustring name = prefs->getString(path, "name");
- if (!name.empty() && ( profile_name == name )) {
- // we already have preset with this name, replace its values
- new_index = i;
- pref_path = path;
+ Glib::ustring save_path; // profile pref path without a trailing slash
+
+ int temp_index = 0;
+ for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) {
+ Glib::ustring name = prefs->getString(*i + "/name");
+ if (!name.empty() && profile_name == name) {
+ new_index = temp_index;
+ save_path = *i;
break;
- }
+ }
}
if (new_index == -1) {
// no preset with this name, create
- /// @todo This is wrong, the name should be encoded in the key
- /// to allow deletion of presets
- new_index = total_prefs + 1;
- gchar *profile_id = g_strdup_printf(".dcc%d", new_index);
- pref_path = Glib::ustring("tools.calligraphic.preset") + profile_id;
+ new_index = total_presets + 1;
+ gchar *profile_id = g_strdup_printf("/dcc%d", new_index);
+ save_path = Glib::ustring("/tools/calligraphic/preset") + profile_id;
g_free(profile_id);
}
@@ -4163,22 +4159,20 @@ static void sp_dcc_save_profile (GtkWidget */*widget*/, GObject *tbl)
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
- double v = gtk_adjustment_get_value(adj);
- prefs->setDouble(pref_path, widget_name, v);
+ prefs->setDouble(save_path + "/" + widget_name, gtk_adjustment_get_value(adj));
//std::cout << "wrote adj " << widget_name << ": " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
- bool v = gtk_toggle_action_get_active(toggle);
- prefs->setBool(pref_path, widget_name, v);
+ prefs->setBool(save_path + "/" + widget_name, gtk_toggle_action_get_active(toggle));
//std::cout << "wrote tog " << widget_name << ": " << v << "\n";
} else {
- g_warning("Unknown widget type for preset: %s\n", widget_name);
+ g_warning("Unknown widget type for preset: %s\n", widget_name);
}
} else {
g_warning("Bad key when writing preset: %s\n", widget_name);
}
}
- prefs->setString(pref_path, "name", profile_name);
+ prefs->setString(save_path + "/name", profile_name);
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
sp_dcc_build_presets_list (tbl);
@@ -4190,6 +4184,11 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint preset_index = ege_select_one_action_get_active( act );
+ // This is necessary because EgeSelectOneAction spams us with GObject "changed" signal calls
+ // even when the preset is not changed. It would be good to replace it with something more
+ // modern. Index 0 means "No preset", so we don't do anything.
+ if (preset_index == 0) return;
+
gint save_presets_index = GPOINTER_TO_INT(g_object_get_data(tbl, "save_presets_index"));
if (preset_index == save_presets_index) {
@@ -4202,44 +4201,37 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl) {
return;
// preset_index is one-based so we subtract 1
- Glib::ustring preset_path = prefs->getNthChild("tools.calligraphic.preset", preset_index - 1);
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ Glib::ustring preset_path = presets.at(preset_index - 1);
if (!preset_path.empty()) {
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it
-
- /// @todo Remove the use of _getNode() in this fragment, modify
- /// the public interface of Preferences if necessary
- Inkscape::XML::Node *preset_repr = prefs->_getNode(preset_path);
+
+ std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(preset_path);
// Shouldn't this be std::map?
- for ( Inkscape::Util::List<Inkscape::XML::AttributeRecord const> iter = preset_repr->attributeList();
- iter;
- ++iter ) {
- const gchar *attr_name = g_quark_to_string(iter->key);
- if (!strcmp(attr_name, "id") || !strcmp(attr_name, "name"))
- continue;
- void *widget = g_object_get_data(tbl, attr_name);
+ for (std::vector<Inkscape::Preferences::Entry>::iterator i = preset.begin(); i != preset.end(); ++i) {
+ Glib::ustring entry_name = i->getEntryName();
+ if (entry_name == "id" || entry_name == "name") continue;
+ void *widget = g_object_get_data(tbl, entry_name.data());
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
- double v = prefs->getDouble(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
- gtk_adjustment_set_value(adj, v);
+ gtk_adjustment_set_value(adj, i->getDouble());
//std::cout << "set adj " << attr_name << " to " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
- int v = prefs->getInt(preset_path, attr_name, 0); // fixme: no min/max checks here, add?
GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
- gtk_toggle_action_set_active(toggle, v);
+ gtk_toggle_action_set_active(toggle, i->getBool());
//std::cout << "set toggle " << attr_name << " to " << v << "\n";
} else {
- g_warning("Unknown widget type for preset: %s\n", attr_name);
+ g_warning("Unknown widget type for preset: %s\n", entry_name.data());
}
} else {
- g_warning("Bad key found in a preset record: %s\n", attr_name);
+ g_warning("Bad key found in a preset record: %s\n", entry_name.data());
}
}
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
}
-
}
@@ -4258,7 +4250,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction *eact = create_adjustment_action( "CalligraphyWidthAction",
_("Pen Width"), _("Width:"),
_("The width of the calligraphic pen (relative to the visible canvas area)"),
- "tools.calligraphic", "width", 15,
+ "/tools/calligraphic/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-calligraphy",
1, 100, 1.0, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4275,7 +4267,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "ThinningAction",
_("Stroke Thinning"), _("Thinning:"),
_("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"),
- "tools.calligraphic", "thinning", 10,
+ "/tools/calligraphic/thinning", 10,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
-100, 100, 1, 0.1,
labels, values, G_N_ELEMENTS(labels),
@@ -4291,7 +4283,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "AngleAction",
_("Pen Angle"), _("Angle:"),
_("The angle of the pen's nib (in degrees; 0 = horizontal; has no effect if fixation = 0)"),
- "tools.calligraphic", "angle", 30,
+ "/tools/calligraphic/angle", 30,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "calligraphy-angle",
-90.0, 90.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4309,7 +4301,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "FixationAction",
_("Fixation"), _("Fixation:"),
_("Angle behavior (0 = nib always perpendicular to stroke direction, 100 = fixed angle)"),
- "tools.calligraphic", "flatness", 90,
+ "/tools/calligraphic/flatness", 90,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4326,7 +4318,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "CapRoundingAction",
_("Cap rounding"), _("Caps:"),
_("Increase to make caps at the ends of strokes protrude more (0 = no caps, 1 = round caps)"),
- "tools.calligraphic", "cap_rounding", 0.0,
+ "/tools/calligraphic/cap_rounding", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 5.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
@@ -4342,7 +4334,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "TremorAction",
_("Stroke Tremor"), _("Tremor:"),
_("Increase to make strokes rugged and trembling"),
- "tools.calligraphic", "tremor", 0.0,
+ "/tools/calligraphic/tremor", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 100, 1, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4360,7 +4352,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "WiggleAction",
_("Pen Wiggle"), _("Wiggle:"),
_("Increase to make the pen waver and wiggle"),
- "tools.calligraphic", "wiggle", 0.0,
+ "/tools/calligraphic/wiggle", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 100, 1, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4377,7 +4369,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeAdjustmentAction* eact = create_adjustment_action( "MassAction",
_("Pen Mass"), _("Mass:"),
_("Increase to make the pen drag behind, as if slowed by inertia"),
- "tools.calligraphic", "mass", 2.0,
+ "/tools/calligraphic/mass", 2.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 100, 1, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -4397,7 +4389,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_trace_background_changed), holder);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "tracebackground", false) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/calligraphic/tracebackground", false) );
g_object_set_data( holder, "tracebackground", act );
}
@@ -4410,7 +4402,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_pressure_state_changed), holder);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "usepressure", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/calligraphic/usepressure", true) );
g_object_set_data( holder, "usepressure", act );
}
@@ -4423,8 +4415,8 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_tilt_state_changed), holder );
- gtk_action_set_sensitive( GTK_ACTION(calligraphy_angle), !prefs->getBool("tools.calligraphic", "usetilt", true) );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("tools.calligraphic", "usetilt", true) );
+ gtk_action_set_sensitive( GTK_ACTION(calligraphy_angle), !prefs->getBool("/tools/calligraphic/usetilt", true) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/calligraphic/usetilt", true) );
g_object_set_data( holder, "usetilt", act );
}
@@ -4473,7 +4465,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.shapes.arc", value_name, (adj->value * M_PI)/ 180);
+ prefs->setDouble(Glib::ustring("/tools/shapes/arc") + value_name, (adj->value * M_PI)/ 180);
}
// quit if run by the attr_changed listener
@@ -4542,7 +4534,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.shapes.arc", "open", ege_select_one_action_get_active(act) != 0);
+ prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
}
// quit if run by the attr_changed listener
@@ -4696,7 +4688,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
@@ -4711,7 +4703,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
eact = create_adjustment_action( "ArcStartAction",
_("Start"), _("Start:"),
_("The angle (in degrees) from the horizontal to the arc's start point"),
- "tools.shapes.arc", "start", 0.0,
+ "/tools/shapes/arc/start", 0.0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-arc",
-360.0, 360.0, 1.0, 10.0,
0, 0, 0,
@@ -4724,7 +4716,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
eact = create_adjustment_action( "ArcEndAction",
_("End"), _("End:"),
_("The angle (in degrees) from the horizontal to the arc's end point"),
- "tools.shapes.arc", "end", 0.0,
+ "/tools/shapes/arc/end", 0.0,
GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
0, 0, 0,
@@ -4762,7 +4754,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
ege_select_one_action_set_icon_size( act, secondarySize );
ege_select_one_action_set_tooltip_column( act, 1 );
- bool isClosed = !prefs->getBool("tools.shapes.arc", "open", false);
+ bool isClosed = !prefs->getBool("/tools/shapes/arc/open", false);
ege_select_one_action_set_active( act, isClosed ? 0 : 1 );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_arctb_open_state_changed), holder );
}
@@ -4807,7 +4799,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
static void toggle_dropper_pick_alpha( GtkToggleAction* act, gpointer tbl ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt( "tools.dropper", "pick", gtk_toggle_action_get_active( act ) );
+ prefs->setInt( "/tools/dropper/pick", gtk_toggle_action_get_active( act ) );
GtkAction* set_action = GTK_ACTION( g_object_get_data(G_OBJECT(tbl), "set_action") );
if ( set_action ) {
if ( gtk_toggle_action_get_active( act ) ) {
@@ -4822,7 +4814,7 @@ static void toggle_dropper_pick_alpha( GtkToggleAction* act, gpointer tbl ) {
static void toggle_dropper_set_alpha( GtkToggleAction* act, gpointer tbl ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt( "tools.dropper", "setalpha", gtk_toggle_action_get_active( act ) ? 1 : 0 );
+ prefs->setBool( "/tools/dropper/setalpha", gtk_toggle_action_get_active( act ) );
spinbutton_defocus(GTK_OBJECT(tbl));
}
@@ -4837,7 +4829,7 @@ static void toggle_dropper_set_alpha( GtkToggleAction* act, gpointer tbl ) {
static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint pickAlpha = prefs->getInt( "tools.dropper", "pick", 1 );
+ gint pickAlpha = prefs->getInt( "/tools/dropper/pick", 1 );
{
EgeOutputAction* act = ege_output_action_new( "DropperOpacityAction", _("Opacity:"), "", 0 );
@@ -4867,7 +4859,7 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main
g_object_set( act, "short_label", _("Assign"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "set_action", act );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.dropper", "setalpha", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/dropper/setalpha", true) );
// make sure it's disabled if we're not picking alpha
gtk_action_set_sensitive( GTK_ACTION(act), pickAlpha );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_dropper_set_alpha), holder );
@@ -4913,7 +4905,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt( "tools.lpetool", "mode", mode );
+ prefs->setInt( "/tools/lpetool/mode", mode );
}
g_object_set_data(tbl, "freeze", GINT_TO_POINTER(FALSE));
@@ -4971,7 +4963,7 @@ lpetool_toggle_show_bbox (GtkToggleAction *act, gpointer data) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs->setInt("tools.lpetool", "show_bbox", show ? 1 : 0);
+ prefs->setBool("/tools/lpetool/show_bbox", show);
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
@@ -4990,7 +4982,7 @@ lpetool_toggle_show_measuring_info (GtkToggleAction *act, GObject *tbl) {
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs->setInt("tools.lpetool", "show_measuring_info", show ? 1 : 0);
+ prefs->setBool("/tools/lpetool/show_measuring_info", show);
lpetool_show_measuring_info(lc, show);
gtk_action_set_sensitive(GTK_ACTION(unitact), show);
}
@@ -5000,7 +4992,7 @@ static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl) {
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
SPUnit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.lpetool", "unitid", unit->unit_id);
+ prefs->setInt("/tools/lpetool/unitid", unit->unit_id);
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) {
@@ -5026,10 +5018,10 @@ lpetool_toggle_set_bbox (GtkToggleAction *act, gpointer data) {
// TODO: should we provide a way to store points in prefs?
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.lpetool", "bbox_upperleftx", A[Geom::X]);
- prefs->setDouble("tools.lpetool", "bbox_upperlefty", A[Geom::Y]);
- prefs->setDouble("tools.lpetool", "bbox_lowerrightx", B[Geom::X]);
- prefs->setDouble("tools.lpetool", "bbox_lowerrighty", B[Geom::Y]);
+ prefs->setDouble("/tools/lpetool/bbox_upperleftx", A[Geom::X]);
+ prefs->setDouble("/tools/lpetool/bbox_upperlefty", A[Geom::Y]);
+ prefs->setDouble("/tools/lpetool/bbox_lowerrightx", B[Geom::X]);
+ prefs->setDouble("/tools/lpetool/bbox_lowerrighty", B[Geom::Y]);
lpetool_context_reset_limiting_bbox(SP_LPETOOL_CONTEXT(desktop->event_context));
}
@@ -5103,7 +5095,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
SPUnit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.lpetool", "unitid", unit->unit_id);
+ prefs->setInt("/tools/lpetool/unitid", unit->unit_id);
/** Automatically create a list of LPEs that get added to the toolbar **/
{
@@ -5141,7 +5133,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_tooltip_column( act, 1 );
- gint lpeToolMode = prefs->getInt("tools.lpetool", "mode", 0);
+ gint lpeToolMode = prefs->getInt("/tools/lpetool/mode", 0);
ege_select_one_action_set_active( act, lpeToolMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_lpetool_mode_changed), holder );
}
@@ -5155,7 +5147,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_bbox), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.lpetool", "show_bbox", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/lpetool/show_bbox", true ) );
}
/* Set limiting bounding box to bbox of current selection */
@@ -5196,7 +5188,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_measuring_info), holder );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getInt( "tools.lpetool", "show_measuring_info", 1 ) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/lpetool/show_measuring_info", true ) );
}
// add the units menu
@@ -5205,7 +5197,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
gtk_action_group_add_action( mainActions, act );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), (GObject*)holder );
g_object_set_data(holder, "lpetool_units_action", act);
- gtk_action_set_sensitive(act, prefs->getInt("tools.lpetool", "show_measuring_info", 1));
+ gtk_action_set_sensitive(act, prefs->getBool("/tools/lpetool/show_measuring_info", true));
}
/* Open LPE dialog (to adapt parameters numerically) */
@@ -5241,17 +5233,17 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "tools.eraser", "width", adj->value * 0.01 );
+ prefs->setDouble( "/tools/eraser/width", adj->value * 0.01 );
update_presets_list(tbl);
}
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- gint eraserMode = (ege_select_one_action_get_active( act ) != 0) ? 1 : 0;
+ bool eraserMode = ege_select_one_action_get_active( act ) != 0;
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt( "tools.eraser", "mode", eraserMode );
+ prefs->setBool( "/tools/eraser/mode", eraserMode );
}
// only take action if run by the attr_changed listener
@@ -5277,7 +5269,7 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction",
_("Pen Width"), _("Width:"),
_("The width of the eraser pen (relative to the visible canvas area)"),
- "tools.eraser", "width", 15,
+ "/tools/eraser/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser",
1, 100, 1.0, 0.0,
labels, values, G_N_ELEMENTS(labels),
@@ -5317,7 +5309,7 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
/// @todo Convert to boolean?
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = (prefs->getInt("tools.eraser", "mode", 0) != 0) ? 1 : 0;
+ gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
ege_select_one_action_set_active( act, eraserMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder );
}
@@ -5385,20 +5377,15 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
// there are no texts in selection, read from prefs
-
- Inkscape::XML::Node *repr = inkscape_get_repr (INKSCAPE, "tools.text");
- if (repr) {
- sp_style_read_from_repr (query, repr);
- if (g_object_get_data(tbl, "text_style_from_prefs")) {
- // do not reset the toolbar style from prefs if we already did it last time
- sp_style_unref(query);
- return;
- }
- g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
- } else {
+
+ sp_style_read_from_prefs(query, "/tools/text");
+
+ if (g_object_get_data(tbl, "text_style_from_prefs")) {
+ // do not reset the toolbar style from prefs if we already did it last time
sp_style_unref(query);
return;
}
+ g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
} else {
g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(FALSE));
}
@@ -5635,7 +5622,8 @@ sp_text_toolbox_family_changed (GtkTreeSelection *selection,
// If querying returned nothing, set the default style of the tool (for new texts)
if (result_fontspec == QUERY_STYLE_NOTHING)
{
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/text/style", css);
sp_text_edit_dialog_default_set_insensitive (); //FIXME: Replace trough a verb
}
else
@@ -5727,7 +5715,8 @@ sp_text_toolbox_anchoring_toggled (GtkRadioButton *button,
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_numbers == QUERY_STYLE_NOTHING)
{
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/text/style", css);
}
sp_style_unref(query);
@@ -5805,7 +5794,8 @@ sp_text_toolbox_style_toggled (GtkToggleButton *button,
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_fontspec == QUERY_STYLE_NOTHING)
{
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/text/style", css);
}
sp_style_unref(query);
@@ -5854,7 +5844,8 @@ sp_text_toolbox_orientation_toggled (GtkRadioButton *button,
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_numbers == QUERY_STYLE_NOTHING)
{
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/text/style", css);
}
sp_desktop_set_style (desktop, css, true, true);
@@ -5954,7 +5945,8 @@ sp_text_toolbox_size_changed (GtkComboBox *cbox,
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_numbers == QUERY_STYLE_NOTHING)
{
- sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setStyle("/tools/text/style", css);
}
sp_style_unref(query);
@@ -6117,7 +6109,7 @@ GtkWidget*
sp_text_toolbox_new (SPDesktop *desktop)
{
GtkToolbar *tbl = GTK_TOOLBAR(gtk_toolbar_new());
- GtkIconSize secondarySize = static_cast<GtkIconSize>(prefToSize("toolbox", "secondary", 1));
+ GtkIconSize secondarySize = static_cast<GtkIconSize>(prefToSize("/toolbox/secondary", 1));
gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop);
@@ -6437,12 +6429,12 @@ static void sp_connector_graph_layout(void)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// hack for clones, see comment in align-and-distribute.cpp
- int saved_compensation = prefs->getInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
- prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
+ 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(SP_ACTIVE_DESKTOP)->itemList());
- prefs->setInt("options.clonecompensation", "value", saved_compensation);
+ prefs->setInt("/options/clonecompensation/value", saved_compensation);
sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
}
@@ -6450,14 +6442,14 @@ static void sp_connector_graph_layout(void)
static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.connector", "directedlayout",
+ prefs->setBool("/tools/connector/directedlayout",
gtk_toggle_action_get_active( act ));
}
static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("tools.connector", "avoidoverlaplayout",
+ prefs->setBool("/tools/connector/avoidoverlaplayout",
gtk_toggle_action_get_active( act ));
}
@@ -6465,7 +6457,7 @@ static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject
static void connector_length_changed(GtkAdjustment *adj, GObject* tbl)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.connector", "length", adj->value);
+ prefs->setDouble("/tools/connector/length", adj->value);
spinbutton_defocus(GTK_OBJECT(tbl));
}
@@ -6503,7 +6495,7 @@ static Inkscape::XML::NodeEventVector connector_tb_repr_events = {
static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
+ Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
{
InkAction* inky = ink_action_new( "ConnectorAvoidAction",
@@ -6531,7 +6523,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
eact = create_adjustment_action( "ConnectorSpacingAction",
_("Connector Spacing"), _("Spacing:"),
_("The amount of space left around objects by auto-routing connectors"),
- "tools.connector", "spacing", defaultConnSpacing,
+ "/tools/connector/spacing", defaultConnSpacing,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-spacing",
0, 100, 1.0, 10.0,
0, 0, 0,
@@ -6553,7 +6545,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
eact = create_adjustment_action( "ConnectorLengthAction",
_("Connector Length"), _("Length:"),
_("Ideal length for connectors when layout is applied"),
- "tools.connector", "length", 100,
+ "/tools/connector/length", 100,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-length",
10, 1000, 10.0, 100.0,
0, 0, 0,
@@ -6570,7 +6562,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- bool tbuttonstate = prefs->getBool("tools.connector", "directedlayout");
+ bool tbuttonstate = prefs->getBool("/tools/connector/directedlayout");
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder );
@@ -6585,7 +6577,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- bool tbuttonstate = prefs->getBool("tools.connector", "avoidoverlaplayout");
+ bool tbuttonstate = prefs->getBool("/tools/connector/avoidoverlaplayout");
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), (tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_nooverlaps_graph_layout_toggled), holder );
@@ -6620,13 +6612,13 @@ static void paintbucket_channels_changed(EgeSelectOneAction* act, GObject* /*tbl
static void paintbucket_threshold_changed(GtkAdjustment *adj, GObject */*tbl*/)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.paintbucket", "threshold", (gint)adj->value);
+ prefs->setInt("/tools/paintbucket/threshold", (gint)adj->value);
}
static void paintbucket_autogap_changed(EgeSelectOneAction* act, GObject */*tbl*/)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("tools.paintbucket", "autogap", ege_select_one_action_get_active( act ));
+ prefs->setBool("/tools/paintbucket/autogap", ege_select_one_action_get_active( act ));
}
static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl)
@@ -6635,8 +6627,8 @@ static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl)
SPUnit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("tools.paintbucket", "offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
- prefs->setString("tools.paintbucket", "offsetunits", sp_unit_get_abbreviation(unit));
+ prefs->setDouble("/tools/paintbucket/offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
+ prefs->setString("/tools/paintbucket/offsetunits", sp_unit_get_abbreviation(unit));
}
static void paintbucket_defaults (GtkWidget *, GObject *tbl)
@@ -6686,7 +6678,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeSelectOneAction* act1 = ege_select_one_action_new( "ChannelsAction", _("Fill by"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act1, "short_label", _("Fill by:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
- ege_select_one_action_set_active( act1, prefs->getInt("tools.paintbucket", "channels", 0) );
+ ege_select_one_action_set_active( act1, prefs->getInt("/tools/paintbucket/channels", 0) );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(paintbucket_channels_changed), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act1) );
g_object_set_data( holder, "channels_action", act1 );
@@ -6698,7 +6690,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
"ThresholdAction",
_("Fill Threshold"), _("Threshold:"),
_("The maximum allowed difference between the clicked pixel and the neighboring pixels to be counted in the fill"),
- "tools.paintbucket", "threshold", 5, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE,
+ "/tools/paintbucket/threshold", 5, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE,
"inkscape:paintbucket-threshold", 0, 100.0, 1.0, 0.0,
0, 0, 0,
paintbucket_threshold_changed, 1, 0 );
@@ -6709,7 +6701,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
// Create the units menu.
UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- Glib::ustring stored_unit = prefs->getString("tools.paintbucket", "offsetunits");
+ Glib::ustring stored_unit = prefs->getString("/tools/paintbucket/offsetunits");
if (!stored_unit.empty())
tracker->setActiveUnit(sp_unit_get_by_abbreviation(stored_unit.data()));
g_object_set_data( holder, "tracker", tracker );
@@ -6724,7 +6716,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
"OffsetAction",
_("Grow/shrink by"), _("Grow/shrink by:"),
_("The amount to grow (positive) or shrink (negative) the created fill path"),
- "tools.paintbucket", "offset", 0, GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE,
+ "/tools/paintbucket/offset", 0, GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE,
"inkscape:paintbucket-offset", -1e6, 1e6, 0.1, 0.5,
0, 0, 0,
paintbucket_offset_changed, 1, 2);
@@ -6751,7 +6743,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
EgeSelectOneAction* act2 = ege_select_one_action_new( "AutoGapAction", _("Close gaps"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act2, "short_label", _("Close gaps:"), NULL );
ege_select_one_action_set_appearance( act2, "compact" );
- ege_select_one_action_set_active( act2, prefs->getInt("tools.paintbucket", "autogap", 0) );
+ ege_select_one_action_set_active( act2, prefs->getBool("/tools/paintbucket/autogap") );
g_signal_connect( G_OBJECT(act2), "changed", G_CALLBACK(paintbucket_autogap_changed), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act2) );
g_object_set_data( holder, "autogap_action", act2 );
@@ -6780,7 +6772,3 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
-
-
-
-
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index 27bf6d052..a4d6f21a5 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -42,7 +42,7 @@ void aux_toolbox_space(GtkWidget *tb, gint space);
// utility
void sp_toolbox_add_label(GtkWidget *tbl, gchar const *title, bool wide = true);
-Inkscape::IconSize prefToSize( gchar const *path, gchar const *attr, int base = 0 );
+Inkscape::IconSize prefToSize(Glib::ustring const &path, int base = 0 );
#endif /* !SEEN_TOOLBOX_H */
diff --git a/src/xml/node-observer.h b/src/xml/node-observer.h
index 6052e48b6..8f317e2d0 100644
--- a/src/xml/node-observer.h
+++ b/src/xml/node-observer.h
@@ -29,7 +29,7 @@ namespace XML {
/**
* @brief Interface for XML node observers
*
- * This pure abstract class defines an interface for objects that can receive
+ * This class defines an interface for objects that can receive
* XML node state change notifications. The observer has to be registered using
* the Node::addObserver() method to be notified of changes of this node only,
* or using Node::addSubtreeObserver() to also receive notifications about its
@@ -40,6 +40,11 @@ namespace XML {
* The method will be called again due to the XML modification performed in it. If you
* don't take special precautions to ignore the second call, it will result in infinite
* recursion.
+ *
+ * The virtual methods of this class do nothing by default, so you don't need to provide
+ * stubs for things you don't use. A good idea is to make the observer register itself
+ * on construction and unregister itself on destruction. This will ensure there are
+ * no dangling references.
*/
class NodeObserver {
public:
@@ -56,7 +61,7 @@ public:
* @param child The newly added child node
* @param prev The node after which the new child was inserted into the sibling order, or NULL
*/
- virtual void notifyChildAdded(Node &node, Node &child, Node *prev)=0;
+ virtual void notifyChildAdded(Node &node, Node &child, Node *prev) {}
/**
* @brief Child removal callback
@@ -68,7 +73,7 @@ public:
* @param child The removed child node
* @param prev The node that was before the removed node in sibling order, or NULL
*/
- virtual void notifyChildRemoved(Node &node, Node &child, Node *prev)=0;
+ virtual void notifyChildRemoved(Node &node, Node &child, Node *prev) {}
/**
* @brief Child order change callback
@@ -84,7 +89,7 @@ public:
* @param new_prev The node that is before @c child after the order change
*/
virtual void notifyChildOrderChanged(Node &node, Node &child,
- Node *old_prev, Node *new_prev)=0;
+ Node *old_prev, Node *new_prev) {}
/**
* @brief Content change callback
@@ -98,7 +103,7 @@ public:
*/
virtual void notifyContentChanged(Node &node,
Util::ptr_shared<char> old_content,
- Util::ptr_shared<char> new_content)=0;
+ Util::ptr_shared<char> new_content) {}
/**
* @brief Attribute change callback
@@ -112,7 +117,7 @@ public:
*/
virtual void notifyAttributeChanged(Node &node, GQuark name,
Util::ptr_shared<char> old_value,
- Util::ptr_shared<char> new_value)=0;
+ Util::ptr_shared<char> new_value) {}
};
} // namespace XML
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 2a5125375..371af729f 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -29,7 +29,7 @@
#include "io/stringstream.h"
#include "io/gzipstream.h"
-#include "prefs-utils.h"
+#include "preferences.h"
using Inkscape::IO::Writer;
using Inkscape::Util::List;
@@ -511,8 +511,9 @@ void
sp_repr_save_writer(Document *doc, Inkscape::IO::Writer *out,
gchar const *default_ns)
{
- int inlineattrs = prefs_get_int_attribute("options.svgoutput", "inlineattrs", 0);
- int indent = prefs_get_int_attribute("options.svgoutput", "indent", 2);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool inlineattrs = prefs->getBool("/options/svgoutput/inlineattrs");
+ int indent = prefs->getInt("/options/svgoutput/indent", 2);
/* fixme: do this The Right Way */
out->writeString( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" );
diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp
index 1d14d20cd..b00845077 100644
--- a/src/zoom-context.cpp
+++ b/src/zoom-context.cpp
@@ -21,7 +21,7 @@
#include "desktop.h"
#include "pixmaps/cursor-zoom.xpm"
#include "pixmaps/cursor-zoom-out.xpm"
-#include "prefs-utils.h"
+#include "preferences.h"
#include "zoom-context.h"
@@ -91,10 +91,11 @@ sp_zoom_context_finish (SPEventContext *ec)
static void sp_zoom_context_setup(SPEventContext *ec)
{
- if (prefs_get_int_attribute("tools.zoom", "selcue", 0) != 0) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/zoom/selcue")) {
ec->enableSelectionCue();
}
- if (prefs_get_int_attribute("tools.zoom", "gradientdrag", 0) != 0) {
+ if (prefs->getBool("/tools/zoom/gradientdrag")) {
ec->enableGrDrag();
}
@@ -117,16 +118,17 @@ static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *
static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent *event)
{
SPDesktop *desktop = event_context->desktop;
- tolerance = prefs_get_int_attribute_limited ("options.dragtolerance", "value", 0, 0, 100);
- double const zoom_inc = prefs_get_double_attribute_limited("options.zoomincrement", "value", M_SQRT2, 1.01, 10);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
{
- NR::Point const button_w(event->button.x, event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_w(event->button.x, event->button.y);
+ Geom::Point const button_dt(desktop->w2d(button_w));
if (event->button.button == 1 && !event_context->space_panning) {
// save drag origin
xp = (gint) event->button.x;
@@ -162,8 +164,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
// motion notify coordinates as given (no snapping back to origin)
within_tolerance = false;
- NR::Point const motion_w(event->motion.x, event->motion.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ Geom::Point const motion_w(event->motion.x, event->motion.y);
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
Inkscape::Rubberband::get(desktop)->move(motion_dt);
gobble_motion_events(GDK_BUTTON1_MASK);
}
@@ -171,8 +173,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_BUTTON_RELEASE:
{
- NR::Point const button_w(event->button.x, event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_w(event->button.x, event->button.y);
+ Geom::Point const button_dt(desktop->w2d(button_w));
if ( event->button.button == 1 && !event_context->space_panning) {
boost::optional<Geom::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
if (b && !within_tolerance) {