summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
committerMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
commite7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch)
tree9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/ui
parentupdated to latest trunk (diff)
parent[Bug #1695016] Xaml export misses some radialGradients. (diff)
downloadinkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz
inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt17
-rw-r--r--src/ui/Makefile_insert31
-rw-r--r--src/ui/cache/Makefile_insert6
-rw-r--r--src/ui/clipboard.cpp321
-rw-r--r--src/ui/clipboard.h10
-rw-r--r--src/ui/control-manager.cpp9
-rw-r--r--src/ui/dialog-events.cpp5
-rw-r--r--src/ui/dialog-events.h1
-rw-r--r--src/ui/dialog/Makefile_insert133
-rw-r--r--src/ui/dialog/aboutbox.cpp71
-rw-r--r--src/ui/dialog/align-and-distribute.cpp75
-rw-r--r--src/ui/dialog/align-and-distribute.h38
-rw-r--r--src/ui/dialog/calligraphic-profile-rename.cpp34
-rw-r--r--src/ui/dialog/calligraphic-profile-rename.h9
-rw-r--r--src/ui/dialog/clonetiler.cpp1256
-rw-r--r--src/ui/dialog/clonetiler.h132
-rw-r--r--src/ui/dialog/color-item.cpp10
-rw-r--r--src/ui/dialog/cssdialog.cpp146
-rw-r--r--src/ui/dialog/cssdialog.h93
-rw-r--r--src/ui/dialog/debug.cpp10
-rw-r--r--src/ui/dialog/desktop-tracker.cpp1
-rw-r--r--src/ui/dialog/dialog-manager.cpp14
-rw-r--r--src/ui/dialog/dialog-manager.h10
-rw-r--r--src/ui/dialog/dialog.cpp6
-rw-r--r--src/ui/dialog/dock-behavior.cpp9
-rw-r--r--src/ui/dialog/document-metadata.cpp34
-rw-r--r--src/ui/dialog/document-metadata.h12
-rw-r--r--src/ui/dialog/document-properties.cpp164
-rw-r--r--src/ui/dialog/document-properties.h6
-rw-r--r--src/ui/dialog/export.cpp218
-rw-r--r--src/ui/dialog/export.h58
-rw-r--r--src/ui/dialog/extension-editor.cpp4
-rw-r--r--src/ui/dialog/filedialog.cpp9
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp101
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp168
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp23
-rw-r--r--src/ui/dialog/fill-and-stroke.h4
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp331
-rw-r--r--src/ui/dialog/filter-effects-dialog.h20
-rw-r--r--src/ui/dialog/find.cpp23
-rw-r--r--src/ui/dialog/find.h6
-rw-r--r--src/ui/dialog/floating-behavior.cpp13
-rw-r--r--src/ui/dialog/font-substitution.cpp15
-rw-r--r--src/ui/dialog/glyphs.cpp91
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp351
-rw-r--r--src/ui/dialog/grid-arrange-tab.h5
-rw-r--r--src/ui/dialog/guides.cpp72
-rw-r--r--src/ui/dialog/guides.h12
-rw-r--r--src/ui/dialog/icon-preview.cpp12
-rw-r--r--src/ui/dialog/icon-preview.h6
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp65
-rw-r--r--src/ui/dialog/inkscape-preferences.h10
-rw-r--r--src/ui/dialog/input.cpp140
-rw-r--r--src/ui/dialog/knot-properties.cpp23
-rw-r--r--src/ui/dialog/knot-properties.h11
-rw-r--r--src/ui/dialog/layer-properties.cpp50
-rw-r--r--src/ui/dialog/layer-properties.h10
-rw-r--r--src/ui/dialog/layers.cpp14
-rw-r--r--src/ui/dialog/layers.h6
-rw-r--r--src/ui/dialog/livepatheffect-add.cpp27
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp102
-rw-r--r--src/ui/dialog/livepatheffect-editor.h16
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp144
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h50
-rw-r--r--src/ui/dialog/lpe-powerstroke-properties.cpp39
-rw-r--r--src/ui/dialog/lpe-powerstroke-properties.h2
-rw-r--r--src/ui/dialog/memory.cpp5
-rw-r--r--src/ui/dialog/messages.cpp2
-rw-r--r--src/ui/dialog/new-from-template.cpp11
-rw-r--r--src/ui/dialog/object-attributes.cpp3
-rw-r--r--src/ui/dialog/object-properties.cpp97
-rw-r--r--src/ui/dialog/object-properties.h4
-rw-r--r--src/ui/dialog/objects.cpp249
-rw-r--r--src/ui/dialog/objects.h15
-rw-r--r--src/ui/dialog/ocaldialogs.cpp185
-rw-r--r--src/ui/dialog/ocaldialogs.h41
-rw-r--r--src/ui/dialog/panel-dialog.h6
-rw-r--r--src/ui/dialog/pixelartdialog.cpp15
-rw-r--r--src/ui/dialog/polar-arrange-tab.cpp39
-rw-r--r--src/ui/dialog/polar-arrange-tab.h11
-rw-r--r--src/ui/dialog/print.cpp3
-rw-r--r--src/ui/dialog/prototype.cpp171
-rw-r--r--src/ui/dialog/prototype.h80
-rw-r--r--src/ui/dialog/spellcheck.cpp21
-rw-r--r--src/ui/dialog/spellcheck.h15
-rw-r--r--src/ui/dialog/styledialog.cpp1395
-rw-r--r--src/ui/dialog/styledialog.h175
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp293
-rw-r--r--src/ui/dialog/svg-fonts-dialog.h247
-rw-r--r--src/ui/dialog/swatches.cpp17
-rw-r--r--src/ui/dialog/symbols.cpp173
-rw-r--r--src/ui/dialog/tags.cpp72
-rw-r--r--src/ui/dialog/tags.h6
-rw-r--r--src/ui/dialog/template-load-tab.cpp14
-rw-r--r--src/ui/dialog/template-widget.cpp7
-rw-r--r--src/ui/dialog/text-edit.cpp72
-rw-r--r--src/ui/dialog/text-edit.h12
-rw-r--r--src/ui/dialog/tile.h5
-rw-r--r--src/ui/dialog/tracedialog.cpp10
-rw-r--r--src/ui/dialog/transformation.cpp155
-rw-r--r--src/ui/dialog/transformation.h4
-rw-r--r--src/ui/dialog/undo-history.cpp49
-rw-r--r--src/ui/dialog/undo-history.h18
-rw-r--r--src/ui/dialog/xml-tree.cpp27
-rw-r--r--src/ui/dialog/xml-tree.h11
-rw-r--r--src/ui/event-debug.h132
-rw-r--r--src/ui/interface.cpp77
-rw-r--r--src/ui/object-edit.cpp118
-rw-r--r--src/ui/previewholder.cpp146
-rw-r--r--src/ui/previewholder.h9
-rw-r--r--src/ui/selected-color.cpp2
-rw-r--r--src/ui/shape-editor.cpp5
-rw-r--r--src/ui/tool-factory.cpp2
-rw-r--r--src/ui/tool/Makefile_insert30
-rw-r--r--src/ui/tool/control-point-selection.cpp1
-rw-r--r--src/ui/tool/control-point.cpp2
-rw-r--r--src/ui/tool/curve-drag-point.cpp3
-rw-r--r--src/ui/tool/manipulator.cpp4
-rw-r--r--src/ui/tool/modifier-tracker.cpp1
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp2
-rw-r--r--src/ui/tool/multi-path-manipulator.h15
-rw-r--r--src/ui/tool/node.cpp15
-rw-r--r--src/ui/tool/node.h5
-rw-r--r--src/ui/tool/path-manipulator.cpp32
-rw-r--r--src/ui/tool/selector.cpp1
-rw-r--r--src/ui/tool/transform-handle-set.cpp9
-rw-r--r--src/ui/tools-switch.cpp6
-rw-r--r--src/ui/tools/Makefile_insert34
-rw-r--r--src/ui/tools/arc-tool.cpp3
-rw-r--r--src/ui/tools/box3d-tool.cpp15
-rw-r--r--src/ui/tools/calligraphic-tool.cpp24
-rw-r--r--src/ui/tools/connector-tool.cpp23
-rw-r--r--src/ui/tools/dropper-tool.cpp13
-rw-r--r--src/ui/tools/dynamic-base.cpp6
-rw-r--r--src/ui/tools/eraser-tool.cpp179
-rw-r--r--src/ui/tools/eraser-tool.h4
-rw-r--r--src/ui/tools/flood-tool.cpp81
-rw-r--r--src/ui/tools/freehand-base.cpp161
-rw-r--r--src/ui/tools/freehand-base.h6
-rw-r--r--src/ui/tools/gradient-tool.cpp46
-rw-r--r--src/ui/tools/lpe-tool.cpp9
-rw-r--r--src/ui/tools/measure-tool.cpp135
-rw-r--r--src/ui/tools/measure-tool.h9
-rw-r--r--src/ui/tools/mesh-tool.cpp499
-rw-r--r--src/ui/tools/mesh-tool.h28
-rw-r--r--src/ui/tools/node-tool.cpp65
-rw-r--r--src/ui/tools/node-tool.h9
-rw-r--r--src/ui/tools/pen-tool.cpp84
-rw-r--r--src/ui/tools/pencil-tool.cpp13
-rw-r--r--src/ui/tools/rect-tool.cpp7
-rw-r--r--src/ui/tools/select-tool.cpp319
-rw-r--r--src/ui/tools/select-tool.h3
-rw-r--r--src/ui/tools/spiral-tool.cpp5
-rw-r--r--src/ui/tools/spray-tool.cpp72
-rw-r--r--src/ui/tools/spray-tool.h9
-rw-r--r--src/ui/tools/star-tool.cpp5
-rw-r--r--src/ui/tools/text-tool.cpp62
-rw-r--r--src/ui/tools/text-tool.h1
-rw-r--r--src/ui/tools/tool-base.cpp183
-rw-r--r--src/ui/tools/tool-base.h1
-rw-r--r--src/ui/tools/tweak-tool.cpp219
-rw-r--r--src/ui/tools/zoom-tool.cpp21
-rw-r--r--src/ui/uxmanager.cpp35
-rw-r--r--src/ui/uxmanager.h1
-rw-r--r--src/ui/view/Makefile_insert9
-rw-r--r--src/ui/view/edit-widget-interface.h3
-rw-r--r--src/ui/widget/Makefile_insert110
-rw-r--r--src/ui/widget/addtoicon.cpp37
-rw-r--r--src/ui/widget/addtoicon.h14
-rw-r--r--src/ui/widget/anchor-selector.cpp11
-rw-r--r--src/ui/widget/anchor-selector.h12
-rw-r--r--src/ui/widget/clipmaskicon.cpp59
-rw-r--r--src/ui/widget/clipmaskicon.h17
-rw-r--r--src/ui/widget/color-icc-selector.cpp30
-rw-r--r--src/ui/widget/color-icc-selector.h8
-rw-r--r--src/ui/widget/color-notebook.cpp34
-rw-r--r--src/ui/widget/color-notebook.h9
-rw-r--r--src/ui/widget/color-picker.cpp5
-rw-r--r--src/ui/widget/color-preview.cpp26
-rw-r--r--src/ui/widget/color-preview.h6
-rw-r--r--src/ui/widget/color-scales.cpp33
-rw-r--r--src/ui/widget/color-scales.h8
-rw-r--r--src/ui/widget/color-slider.cpp125
-rw-r--r--src/ui/widget/color-slider.h18
-rw-r--r--src/ui/widget/color-wheel-selector.cpp54
-rw-r--r--src/ui/widget/color-wheel-selector.h12
-rw-r--r--src/ui/widget/combo-enums.h9
-rw-r--r--src/ui/widget/dock-item.cpp20
-rw-r--r--src/ui/widget/dock-item.h4
-rw-r--r--src/ui/widget/dock.cpp14
-rw-r--r--src/ui/widget/entity-entry.cpp3
-rw-r--r--src/ui/widget/entry.cpp2
-rw-r--r--src/ui/widget/filter-effect-chooser.cpp8
-rw-r--r--src/ui/widget/font-button.cpp61
-rw-r--r--src/ui/widget/font-button.h62
-rw-r--r--src/ui/widget/font-variants.cpp69
-rw-r--r--src/ui/widget/font-variants.h3
-rw-r--r--src/ui/widget/frame.cpp32
-rw-r--r--src/ui/widget/frame.h3
-rw-r--r--src/ui/widget/gimpcolorwheel.c1604
-rw-r--r--src/ui/widget/gimpcolorwheel.h95
-rw-r--r--src/ui/widget/gimpspinscale.c1225
-rw-r--r--src/ui/widget/gimpspinscale.h82
-rw-r--r--src/ui/widget/highlight-picker.cpp36
-rw-r--r--src/ui/widget/highlight-picker.h14
-rw-r--r--src/ui/widget/imageicon.cpp7
-rw-r--r--src/ui/widget/imagetoggler.cpp33
-rw-r--r--src/ui/widget/imagetoggler.h14
-rw-r--r--src/ui/widget/insertordericon.cpp32
-rw-r--r--src/ui/widget/insertordericon.h13
-rw-r--r--src/ui/widget/layer-selector.cpp24
-rw-r--r--src/ui/widget/layertypeicon.cpp36
-rw-r--r--src/ui/widget/layertypeicon.h14
-rw-r--r--src/ui/widget/licensor.cpp12
-rw-r--r--src/ui/widget/notebook-page.cpp12
-rw-r--r--src/ui/widget/notebook-page.h13
-rw-r--r--src/ui/widget/object-composite-settings.cpp9
-rw-r--r--src/ui/widget/page-sizer.cpp64
-rw-r--r--src/ui/widget/page-sizer.h26
-rw-r--r--src/ui/widget/panel.cpp32
-rw-r--r--src/ui/widget/panel.h24
-rw-r--r--src/ui/widget/point.cpp9
-rw-r--r--src/ui/widget/point.h4
-rw-r--r--src/ui/widget/preferences-widget.cpp94
-rw-r--r--src/ui/widget/preferences-widget.h25
-rw-r--r--src/ui/widget/random.cpp6
-rw-r--r--src/ui/widget/random.h4
-rw-r--r--src/ui/widget/registered-enums.h6
-rw-r--r--src/ui/widget/registered-widget.cpp78
-rw-r--r--src/ui/widget/registered-widget.h25
-rw-r--r--src/ui/widget/rendering-options.cpp2
-rw-r--r--src/ui/widget/rotateable.cpp4
-rw-r--r--src/ui/widget/scalar.cpp16
-rw-r--r--src/ui/widget/scalar.h6
-rw-r--r--src/ui/widget/selected-style.cpp125
-rw-r--r--src/ui/widget/selected-style.h18
-rw-r--r--src/ui/widget/spin-scale.cpp31
-rw-r--r--src/ui/widget/spin-scale.h25
-rw-r--r--src/ui/widget/spin-slider.cpp61
-rw-r--r--src/ui/widget/spin-slider.h18
-rw-r--r--src/ui/widget/spinbutton.cpp2
-rw-r--r--src/ui/widget/spinbutton.h4
-rw-r--r--src/ui/widget/style-subject.cpp11
-rw-r--r--src/ui/widget/style-swatch.cpp29
-rw-r--r--src/ui/widget/style-swatch.h8
-rw-r--r--src/ui/widget/text.cpp6
-rw-r--r--src/ui/widget/text.h4
-rw-r--r--src/ui/widget/tolerance-slider.cpp12
-rw-r--r--src/ui/widget/tolerance-slider.h10
249 files changed, 6366 insertions, 10283 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 587974b90..389e8902a 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -57,6 +57,7 @@ set(ui_SRC
dialog/calligraphic-profile-rename.cpp
dialog/clonetiler.cpp
dialog/color-item.cpp
+ dialog/cssdialog.cpp
dialog/debug.cpp
dialog/desktop-tracker.cpp
dialog/dialog-manager.cpp
@@ -98,7 +99,9 @@ set(ui_SRC
dialog/polar-arrange-tab.cpp
dialog/print-colors-preview-dialog.cpp
dialog/print.cpp
+ dialog/prototype.cpp
dialog/spellcheck.cpp
+ dialog/styledialog.cpp
dialog/svg-fonts-dialog.cpp
dialog/swatches.cpp
dialog/symbols.cpp
@@ -128,10 +131,9 @@ set(ui_SRC
widget/entity-entry.cpp
widget/entry.cpp
widget/filter-effect-chooser.cpp
+ widget/font-button.cpp
widget/font-variants.cpp
widget/frame.cpp
- widget/gimpcolorwheel.c
- widget/gimpspinscale.c
widget/highlight-picker.cpp
widget/imageicon.cpp
widget/imagetoggler.cpp
@@ -175,6 +177,7 @@ set(ui_SRC
control-types.h
dialog-events.h
draw-anchor.h
+ event-debug.h
icon-names.h
interface.h
object-edit.h
@@ -196,6 +199,7 @@ set(ui_SRC
dialog/calligraphic-profile-rename.h
dialog/clonetiler.h
dialog/color-item.h
+ dialog/cssdialog.h
dialog/debug.h
dialog/desktop-tracker.h
dialog/dialog-manager.h
@@ -239,7 +243,9 @@ set(ui_SRC
dialog/polar-arrange-tab.h
dialog/print-colors-preview-dialog.h
dialog/print.h
+ dialog/prototype.h
dialog/spellcheck.h
+ dialog/styledialog.h
dialog/svg-fonts-dialog.h
dialog/swatches.h
dialog/symbols.h
@@ -248,6 +254,7 @@ set(ui_SRC
dialog/template-widget.h
dialog/text-edit.h
dialog/tile.h
+ dialog/tracedialog.h
dialog/transformation.h
dialog/undo-history.h
dialog/xml-tree.h
@@ -275,14 +282,15 @@ set(ui_SRC
tools/dropper-tool.h
tools/dynamic-base.h
tools/eraser-tool.h
+ tools/flood-tool.h
tools/freehand-base.h
tools/gradient-tool.h
tools/lpe-tool.h
tools/measure-tool.h
tools/mesh-tool.h
tools/node-tool.h
- tools/pencil-tool.h
tools/pen-tool.h
+ tools/pencil-tool.h
tools/rect-tool.h
tools/select-tool.h
tools/spiral-tool.h
@@ -312,10 +320,9 @@ set(ui_SRC
widget/entity-entry.h
widget/entry.h
widget/filter-effect-chooser.h
+ widget/font-button.h
widget/font-variants.h
widget/frame.h
- widget/gimpspinscale.h
- widget/gimpcolorwheel.h
widget/highlight-picker.h
widget/insertordericon.h
widget/imageicon.h
diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert
deleted file mode 100644
index bbfdb532c..000000000
--- a/src/ui/Makefile_insert
+++ /dev/null
@@ -1,31 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/clipboard.cpp \
- ui/clipboard.h \
- ui/control-manager.cpp \
- ui/control-manager.h \
- ui/control-types.h \
- ui/dialog-events.cpp \
- ui/dialog-events.h \
- ui/draw-anchor.cpp \
- ui/draw-anchor.h \
- ui/icon-names.h \
- ui/interface.cpp \
- ui/interface.h \
- ui/object-edit.cpp \
- ui/object-edit.h \
- ui/previewable.h \
- ui/previewfillable.h \
- ui/previewholder.cpp \
- ui/previewholder.h \
- ui/selected-color.h \
- ui/selected-color.cpp \
- ui/shape-editor.cpp \
- ui/shape-editor.h \
- ui/tool-factory.cpp \
- ui/tool-factory.h \
- ui/tools-switch.cpp \
- ui/tools-switch.h \
- ui/uxmanager.cpp \
- ui/uxmanager.h
diff --git a/src/ui/cache/Makefile_insert b/src/ui/cache/Makefile_insert
deleted file mode 100644
index c648777f8..000000000
--- a/src/ui/cache/Makefile_insert
+++ /dev/null
@@ -1,6 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/cache/svg_preview_cache.h \
- ui/cache/svg_preview_cache.cpp
-
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index d581dbf7e..3cc8ac098 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -27,9 +27,6 @@
// TODO: reduce header bloat if possible
#include "file.h" // for file_import, used in _pasteImage
-#include <list>
-#include <algorithm>
-#include <glibmm/ustring.h>
#include <glibmm/i18n.h>
#include <glib/gstdio.h> // for g_file_set_contents etc., used in _onGet and paste
#include "inkgc/gc-core.h"
@@ -41,7 +38,6 @@
#include "desktop-style.h" // for sp_desktop_set_style, used in _pasteStyle
#include "document.h"
#include "document-private.h"
-#include "selection.h"
#include "message-stack.h"
#include "context-fns.h"
#include "ui/tools/dropper-tool.h" // used in copy()
@@ -50,17 +46,13 @@
#include "extension/input.h"
#include "extension/output.h"
#include "selection-chemistry.h"
-#include <2geom/rect.h>
#include <2geom/transforms.h>
#include "box3d.h"
#include "gradient-drag.h"
#include "sp-marker.h"
-#include "sp-item.h"
#include "sp-item-transform.h" // for sp_item_scale_rel, used in _pasteSize
#include "sp-path.h"
#include "sp-pattern.h"
-#include "sp-shape.h"
-#include "sp-gradient.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
@@ -68,8 +60,7 @@
#include "sp-mask.h"
#include "sp-textpath.h"
#include "sp-rect.h"
-#include "sp-use.h"
-#include "sp-symbol.h"
+#include "sp-object.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
@@ -83,9 +74,9 @@
#include "helper/png-write.h"
#include "svg/svg-color.h"
#include "sp-namedview.h"
-#include "snap.h"
#include "persp3d.h"
-#include "preferences.h"
+#include "object-set.h"
+#include "extension/find_extension_by_mime.h"
/// Made up mimetype to represent Gdk::Pixbuf clipboard contents.
#define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf"
@@ -105,13 +96,13 @@ namespace UI {
*/
class ClipboardManagerImpl : public ClipboardManager {
public:
- virtual void copy(SPDesktop *desktop);
+ virtual void copy(ObjectSet *set);
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *);
virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol);
virtual bool paste(SPDesktop *desktop, bool in_place);
- virtual bool pasteStyle(SPDesktop *desktop);
- virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y);
- virtual bool pastePathEffect(SPDesktop *desktop);
+ virtual bool pasteStyle(ObjectSet *set);
+ virtual bool pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y);
+ virtual bool pastePathEffect(ObjectSet *set);
virtual Glib::ustring getPathParameter(SPDesktop* desktop);
virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop);
virtual const gchar *getFirstObjectID();
@@ -120,7 +111,7 @@ public:
~ClipboardManagerImpl();
private:
- void _copySelection(Inkscape::Selection *);
+ void _copySelection(ObjectSet *);
void _copyUsedDefs(SPItem *);
void _copyGradient(SPGradient *);
void _copyPattern(SPPattern *);
@@ -153,6 +144,11 @@ private:
Inkscape::XML::Node *_clipnode; ///< The node that holds extra information
Inkscape::XML::Document *_doc; ///< Reference to the clipboard's Inkscape::XML::Document
std::set<SPItem*> cloned_elements;
+ std::vector<SPCSSAttr*> te_selected_style;
+ std::vector<unsigned> te_selected_style_positions;
+ int nr_blocks = 0;
+ unsigned copied_style_length = 0;
+
// we need a way to copy plain text AND remember its style;
// the standard _clipnode is only available in an SVG tree, hence this special storage
@@ -195,76 +191,77 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {}
/**
* Copy selection contents to the clipboard.
*/
-void ClipboardManagerImpl::copy(SPDesktop *desktop)
+void ClipboardManagerImpl::copy(ObjectSet *set)
{
- if ( desktop == NULL ) {
- return;
- }
- Inkscape::Selection *selection = desktop->getSelection();
+ if ( set->desktop() ) {
+ SPDesktop *desktop = set->desktop();
+
+ // Special case for when the gradient dragger is active - copies gradient color
+ if (desktop->event_context->get_drag()) {
+ GrDrag *drag = desktop->event_context->get_drag();
+ if (drag->hasSelection()) {
+ guint32 col = drag->getColor();
+
+ // set the color as clipboard content (text in RRGGBBAA format)
+ _setClipboardColor(col);
+
+ // create a style with this color on fill and opacity in master opacity, so it can be
+ // pasted on other stops or objects
+ if (_text_style) {
+ sp_repr_css_attr_unref(_text_style);
+ _text_style = NULL;
+ }
+ _text_style = sp_repr_css_attr_new();
+ // print and set properties
+ gchar color_str[16];
+ g_snprintf(color_str, 16, "#%06x", col >> 8);
+ sp_repr_css_set_property(_text_style, "fill", color_str);
+ float opacity = SP_RGBA32_A_F(col);
+ if (opacity > 1.0) {
+ opacity = 1.0; // safeguard
+ }
+ Inkscape::CSSOStringStream opcss;
+ opcss << opacity;
+ sp_repr_css_set_property(_text_style, "opacity", opcss.str().data());
- // Special case for when the gradient dragger is active - copies gradient color
- if (desktop->event_context->get_drag()) {
- GrDrag *drag = desktop->event_context->get_drag();
- if (drag->hasSelection()) {
- guint32 col = drag->getColor();
+ _discardInternalClipboard();
+ return;
+ }
+ }
- // set the color as clipboard content (text in RRGGBBAA format)
- _setClipboardColor(col);
+ // Special case for when the color picker ("dropper") is active - copies color under cursor
+ if (tools_isactive(desktop, TOOLS_DROPPER)) {
+ //_setClipboardColor(sp_dropper_context_get_color(desktop->event_context));
+ _setClipboardColor(SP_DROPPER_CONTEXT(desktop->event_context)->get_color());
+ _discardInternalClipboard();
+ return;
+ }
- // create a style with this color on fill and opacity in master opacity, so it can be
- // pasted on other stops or objects
+ // Special case for when the text tool is active - if some text is selected, copy plain text,
+ // not the object that holds it; also copy the style at cursor into
+ if (tools_isactive(desktop, TOOLS_TEXT)) {
+ _discardInternalClipboard();
+ Glib::ustring selected_text = Inkscape::UI::Tools::sp_text_get_selected_text(desktop->event_context);
+ _clipboard->set_text(selected_text);
if (_text_style) {
sp_repr_css_attr_unref(_text_style);
_text_style = NULL;
}
- _text_style = sp_repr_css_attr_new();
- // print and set properties
- gchar color_str[16];
- g_snprintf(color_str, 16, "#%06x", col >> 8);
- sp_repr_css_set_property(_text_style, "fill", color_str);
- float opacity = SP_RGBA32_A_F(col);
- if (opacity > 1.0) {
- opacity = 1.0; // safeguard
- }
- Inkscape::CSSOStringStream opcss;
- opcss << opacity;
- sp_repr_css_set_property(_text_style, "opacity", opcss.str().data());
-
- _discardInternalClipboard();
+ te_selected_style.clear();
+ te_selected_style_positions.clear();
+ te_selected_style = Inkscape::UI::Tools::sp_text_get_selected_style(desktop->event_context, &copied_style_length, &nr_blocks, &te_selected_style_positions);
+ _text_style = Inkscape::UI::Tools::sp_text_get_style_at_cursor(desktop->event_context);
return;
}
}
-
- // Special case for when the color picker ("dropper") is active - copies color under cursor
- if (tools_isactive(desktop, TOOLS_DROPPER)) {
- //_setClipboardColor(sp_dropper_context_get_color(desktop->event_context));
- _setClipboardColor(SP_DROPPER_CONTEXT(desktop->event_context)->get_color());
- _discardInternalClipboard();
- return;
- }
-
- // Special case for when the text tool is active - if some text is selected, copy plain text,
- // not the object that holds it; also copy the style at cursor into
- if (tools_isactive(desktop, TOOLS_TEXT)) {
- _discardInternalClipboard();
- Glib::ustring selected_text = Inkscape::UI::Tools::sp_text_get_selected_text(desktop->event_context);
- _clipboard->set_text(selected_text);
- if (_text_style) {
- sp_repr_css_attr_unref(_text_style);
- _text_style = NULL;
- }
- _text_style = Inkscape::UI::Tools::sp_text_get_style_at_cursor(desktop->event_context);
- return;
- }
-
- if (selection->isEmpty()) { // check whether something is selected
- _userWarn(desktop, _("Nothing was copied."));
+ if (set->isEmpty()) { // check whether something is selected
+ _userWarn(set->desktop(), _("Nothing was copied."));
return;
}
_discardInternalClipboard();
_createInternalClipboard(); // construct a new clipboard document
- _copySelection(selection); // copy all items in the selection to the internal clipboard
+ _copySelection(set); // copy all items in the selection to the internal clipboard
fit_canvas_to_drawing(_clipboardSPDoc);
_setClipboardTargets();
@@ -438,16 +435,15 @@ const gchar *ClipboardManagerImpl::getFirstObjectID()
/**
* Implements the Paste Style action.
*/
-bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
+bool ClipboardManagerImpl::pasteStyle(ObjectSet *set)
{
- if (desktop == NULL) {
+ if (set->desktop() == NULL) {
return false;
}
// check whether something is selected
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste style to."));
+ if (set->isEmpty()) {
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste style to."));
return false;
}
@@ -455,10 +451,10 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
if ( tempdoc == NULL ) {
// no document, but we can try _text_style
if (_text_style) {
- sp_desktop_set_style(desktop, _text_style);
+ sp_desktop_set_style(set, set->desktop(), _text_style);
return true;
} else {
- _userWarn(desktop, _("No style on the clipboard."));
+ _userWarn(set->desktop(), _("No style on the clipboard."));
return false;
}
}
@@ -469,13 +465,13 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
bool pasted = false;
if (clipnode) {
- desktop->doc()->importDefs(tempdoc);
+ set->document()->importDefs(tempdoc);
SPCSSAttr *style = sp_repr_css_attr(clipnode, "style");
- sp_desktop_set_style(desktop, style);
+ sp_desktop_set_style(set, set->desktop(), style);
pasted = true;
}
else {
- _userWarn(desktop, _("No style on the clipboard."));
+ _userWarn(set->desktop(), _("No style on the clipboard."));
}
tempdoc->doUnref();
@@ -489,29 +485,31 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
* @param apply_x Whether to scale the width of objects / selection
* @param apply_y Whether to scale the height of objects / selection
*/
-bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y)
+bool ClipboardManagerImpl::pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y)
{
if (!apply_x && !apply_y) {
return false; // pointless parameters
}
- if ( desktop == NULL ) {
+/* if ( desktop == NULL ) {
return false;
}
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste size to."));
+ Inkscape::Selection *selection = desktop->getSelection();*/
+ if (set->isEmpty()) {
+ if(set->desktop())
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste size to."));
return false;
}
// FIXME: actually, this should accept arbitrary documents
SPDocument *tempdoc = _retrieveClipboard("image/x-inkscape-svg");
if ( tempdoc == NULL ) {
- _userWarn(desktop, _("No size on the clipboard."));
+ if(set->desktop())
+ _userWarn(set->desktop(), _("No size on the clipboard."));
return false;
}
- // retrieve size ifomration from the clipboard
+ // retrieve size information from the clipboard
Inkscape::XML::Node *root = tempdoc->getReprRoot();
Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1);
bool pasted = false;
@@ -522,13 +520,13 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
- std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ auto itemlist= set->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (item) {
Geom::OptRect obj_size = item->desktopVisualBounds();
if ( obj_size ) {
- sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y));
+ sp_item_scale_rel(item, _getScale(set->desktop(), min, max, *obj_size, apply_x, apply_y));
}
} else {
g_assert_not_reached();
@@ -537,10 +535,10 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
}
// resize the selection as a whole
else {
- Geom::OptRect sel_size = selection->visualBounds();
+ Geom::OptRect sel_size = set->visualBounds();
if ( sel_size ) {
- sp_selection_scale_relative(selection, sel_size->midpoint(),
- _getScale(desktop, min, max, *sel_size, apply_x, apply_y));
+ set->setScaleRelative(sel_size->midpoint(),
+ _getScale(set->desktop(), min, max, *sel_size, apply_x, apply_y));
}
}
pasted = true;
@@ -553,18 +551,18 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
/**
* Applies a path effect from the clipboard to the selected path.
*/
-bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
+bool ClipboardManagerImpl::pastePathEffect(ObjectSet *set)
{
/** @todo FIXME: pastePathEffect crashes when moving the path with the applied effect,
segfaulting in fork_private_if_necessary(). */
- if ( desktop == NULL ) {
+ if ( set->desktop() == NULL ) {
return false;
}
- Inkscape::Selection *selection = desktop->getSelection();
- if (!selection || selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste live path effect to."));
+ //Inkscape::Selection *selection = desktop->getSelection();
+ if (!set || set->isEmpty()) {
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste live path effect to."));
return false;
}
@@ -575,11 +573,11 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
if ( clipnode ) {
gchar const *effectstack = clipnode->attribute("inkscape:path-effect");
if ( effectstack ) {
- desktop->doc()->importDefs(tempdoc);
+ set->document()->importDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
- sp_selected_to_lpeitems(desktop);
- std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ set->toLPEItems();
+ auto itemlist= set->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
_applyPathEffect(item, effectstack);
}
@@ -590,7 +588,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
}
// no_effect:
- _userWarn(desktop, _("No effect on the clipboard."));
+ _userWarn(set->desktop(), _("No effect on the clipboard."));
return false;
}
@@ -654,16 +652,15 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
return svgd;
}
-
/**
* Iterate over a list of items and copy them to the clipboard.
*/
-void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
+void ClipboardManagerImpl::_copySelection(ObjectSet *selection)
{
// copy the defs used by all items
- std::vector<SPItem*> itemlist=selection->itemList();
+ auto itemlist= selection->items();
cloned_elements.clear();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (item) {
_copyUsedDefs(item);
@@ -674,7 +671,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
// copy the representation of the items
std::vector<SPObject*> sorted_items;
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i)
+ for(auto i=itemlist.begin();i!=itemlist.end();++i)
sorted_items.push_back(*i);
sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position_bool);
@@ -700,7 +697,6 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
else
obj_copy = _copyNode(obj, _doc, _clipnode);
-
// copy complete inherited style
SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style");
sp_repr_css_set(obj_copy, css, "style");
@@ -712,7 +708,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
// (we're dealing with unattached representations, so we write to their attributes
// instead of using sp_item_set_transform)
SPUse *use=dynamic_cast<SPUse *>(item);
- if( use && selection->includes(use->get_original()) ){//we are copying something whose parent is also copied (!)
+ if( use && use->get_original() && use->get_original()->parent ){//we are copying something whose parent is also copied (!)
transform = ((SPItem*)(use->get_original()->parent))->i2doc_affine().inverse() * transform;
}
gchar *transform_str = sp_svg_transform_write(transform );
@@ -732,7 +728,6 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
sp_repr_css_set(_clipnode, style, "style");
sp_repr_css_attr_unref(style);
}
-
// copy path effect from the first path
if (object) {
gchar const *effect =object->getRepr()->attribute("inkscape:path-effect");
@@ -796,20 +791,6 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
- // For lpe items, copy lpe stack if applicable
- SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
- if (lpeitem) {
- if (lpeitem->hasPathEffect()) {
- for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
- {
- LivePathEffectObject *lpeobj = (*it)->lpeobject;
- if (lpeobj) {
- _copyNode(lpeobj->getRepr(), _doc, _defs);
- }
- }
- }
- }
-
// For 3D boxes, copy perspectives
{
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
@@ -839,8 +820,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
SPObject *mask = item->mask_ref->getObject();
_copyNode(mask->getRepr(), _doc, _defs);
// recurse into the mask for its gradients etc.
- for (SPObject *o = mask->children ; o != NULL ; o = o->next) {
- SPItem *childItem = dynamic_cast<SPItem *>(o);
+ for(auto& o: mask->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&o);
if (childItem) {
_copyUsedDefs(childItem);
}
@@ -856,9 +837,22 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
+ // For lpe items, copy lpe stack if applicable
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (lpeitem) {
+ if (lpeitem->hasPathEffect()) {
+ for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it){
+ LivePathEffectObject *lpeobj = (*it)->lpeobject;
+ if (lpeobj) {
+ _copyNode(lpeobj->getRepr(), _doc, _defs);
+ }
+ }
+ }
+ }
+
// recurse
- for (SPObject *o = item->children ; o != NULL ; o = o->next) {
- SPItem *childItem = dynamic_cast<SPItem *>(o);
+ for(auto& o: item->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&o);
if (childItem) {
_copyUsedDefs(childItem);
}
@@ -894,8 +888,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
_copyNode(pattern->getRepr(), _doc, _defs);
// items in the pattern may also use gradients and other patterns, so recurse
- for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: pattern->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
_copyUsedDefs(childItem);
}
@@ -960,15 +954,7 @@ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc)
return false;
}
- // TODO unify with interface.cpp's sp_ui_drag_data_received()
- // AARGH stupid
- Inkscape::Extension::DB::InputList o;
- Inkscape::Extension::db.get_input_list(o);
- Inkscape::Extension::DB::InputList::const_iterator i = o.begin();
- while (i != o.end() && strcmp( (*i)->get_mimetype(), "image/png" ) != 0) {
- ++i;
- }
- Inkscape::Extension::Extension *png = *i;
+ Inkscape::Extension::Extension *png = Inkscape::Extension::find_by_mime("image/png");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring attr_saved = prefs->getString("/dialogs/import/link");
bool ask_saved = prefs->getBool("/dialogs/import/ask");
@@ -998,7 +984,42 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop)
// if the text editing tool is active, paste the text into the active text object
if (tools_isactive(desktop, TOOLS_TEXT)) {
- return Inkscape::UI::Tools::sp_text_paste_inline(desktop->event_context);
+ if(Inkscape::UI::Tools::sp_text_paste_inline(desktop->event_context) == false)
+ return false;
+ //apply the saved style to pasted text
+ Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
+ Glib::ustring const clip_text = refClipboard->wait_for_text();
+ Glib::ustring text(clip_text);
+ if(text.length() == copied_style_length)
+ {
+ Inkscape::UI::Tools::TextTool *tc = SP_TEXT_CONTEXT(desktop->event_context);
+ Inkscape::Text::Layout const *layout = te_get_layout(tc->text);
+ Inkscape::Text::Layout::iterator it_next;
+ Inkscape::Text::Layout::iterator it = tc->text_sel_end;
+
+ SPCSSAttr *css = take_style_from_item(tc->text);
+ for (int i = 0; i < nr_blocks; ++i)
+ {
+ gchar const *w = sp_repr_css_property(css, "font-size", "40px");
+ if (w)
+ sp_repr_css_set_property(te_selected_style[i], "font-size", w);
+ }
+
+ for (int i = 0; i < text.length(); ++i)
+ it.prevCharacter();
+ it_next = layout->charIndexToIterator(layout->iteratorToCharIndex(it));
+
+ for (int i = 0; i < nr_blocks; ++i)
+ {
+ for (int j = te_selected_style_positions[i]; j < te_selected_style_positions[i+1]; ++j)
+ it_next.nextCharacter();
+ sp_te_apply_style(tc->text, it, it_next, te_selected_style[i]);
+ te_update_layout_now_recursive(tc->text);
+ for (int j = te_selected_style_positions[i]; j < te_selected_style_positions[i+1]; ++j)
+ it.nextCharacter();
+ }
+ }
+ return true;
}
// try to parse the text as a color and, if successful, apply it as the current style
@@ -1282,7 +1303,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons
}
// If the "lock aspect ratio" button is pressed and we paste only a single coordinate,
// resize the second one by the same ratio too
- if (desktop->isToolboxButtonActive("lock")) {
+ if (desktop && desktop->isToolboxButtonActive("lock")) {
if (apply_x && !apply_y) {
scale_y = scale_x;
}
@@ -1300,11 +1321,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons
*/
Glib::ustring ClipboardManagerImpl::_getBestTarget()
{
-#if WITH_GTKMM_3_0
- std::vector<Glib::ustring> targets = _clipboard->wait_for_targets();
-#else
- std::list<Glib::ustring> targets = _clipboard->wait_for_targets();
-#endif
+ auto targets = _clipboard->wait_for_targets();
// clipboard target debugging snippet
/*
@@ -1363,12 +1380,7 @@ void ClipboardManagerImpl::_setClipboardTargets()
{
Inkscape::Extension::DB::OutputList outlist;
Inkscape::Extension::db.get_output_list(outlist);
-
-#if WITH_GTKMM_3_0
std::vector<Gtk::TargetEntry> target_list;
-#else
- std::list<Gtk::TargetEntry> target_list;
-#endif
bool plaintextSet = false;
for (Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin() ; out != outlist.end() ; ++out) {
@@ -1453,7 +1465,8 @@ void ClipboardManagerImpl::_setClipboardColor(guint32 color)
*/
void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg)
{
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg);
+ if(desktop)
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg);
}
/* #######################################
diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h
index 9f3b6cbdb..32a49867c 100644
--- a/src/ui/clipboard.h
+++ b/src/ui/clipboard.h
@@ -24,7 +24,7 @@
// forward declarations
class SPDesktop;
namespace Inkscape {
-class Selection;
+class ObjectSet;
namespace XML { class Node; }
namespace LivePathEffect { class PathParam; }
@@ -42,13 +42,13 @@ namespace UI {
class ClipboardManager {
public:
- virtual void copy(SPDesktop *desktop) = 0;
+ virtual void copy(ObjectSet *set) = 0;
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0;
virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol = true) = 0;
virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0;
- virtual bool pasteStyle(SPDesktop *desktop) = 0;
- virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0;
- virtual bool pastePathEffect(SPDesktop *desktop) = 0;
+ virtual bool pasteStyle(ObjectSet *set) = 0;
+ virtual bool pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y) = 0;
+ virtual bool pastePathEffect(ObjectSet *set) = 0;
virtual Glib::ustring getPathParameter(SPDesktop* desktop) = 0;
virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop) = 0;
virtual const gchar *getFirstObjectID() = 0;
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp
index a2c977533..d0285e467 100644
--- a/src/ui/control-manager.cpp
+++ b/src/ui/control-manager.cpp
@@ -17,7 +17,6 @@
#include <glib-object.h>
#include "display/sodipodi-ctrl.h" // for SP_TYPE_CTRL
-#include "display/sp-canvas-item.h"
#include "display/sp-ctrlline.h"
#include "display/sp-ctrlcurve.h"
#include "preferences.h"
@@ -149,7 +148,7 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) :
_ctrlToShape[CTRL_TYPE_NODE_AUTO] = SP_CTRL_SHAPE_CIRCLE;
_ctrlToShape[CTRL_TYPE_NODE_SYMETRICAL] = SP_CTRL_SHAPE_SQUARE;
- _ctrlToShape[CTRL_TYPE_ADJ_HANDLE] = SP_CTRL_SHAPE_CIRCLE;
+ _ctrlToShape[CTRL_TYPE_ADJ_HANDLE] =SP_CTRL_SHAPE_CIRCLE;
_ctrlToShape[CTRL_TYPE_INVISIPOINT] = SP_CTRL_SHAPE_SQUARE;
// -------
@@ -223,10 +222,10 @@ SPCanvasItem *ControlManagerImpl::createControl(SPCanvasGroup *parent, ControlTy
{
case CTRL_TYPE_ADJ_HANDLE:
item = sp_canvas_item_new(parent, SP_TYPE_CTRL,
- "shape", SP_CTRL_SHAPE_CIRCLE,
+ "shape",SP_CTRL_SHAPE_CIRCLE,
"size", targetSize,
- "filled", 0,
- "fill_color", 0xff00007f,
+ "filled", 1,
+ "fill_color", 0xffffff7f,
"stroked", 1,
"stroke_color", 0x0000ff7f,
NULL);
diff --git a/src/ui/dialog-events.cpp b/src/ui/dialog-events.cpp
index 8856631c0..d7d56fa50 100644
--- a/src/ui/dialog-events.cpp
+++ b/src/ui/dialog-events.cpp
@@ -12,17 +12,14 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <gtkmm/entry.h>
#include <gtkmm/window.h>
-#include <gdk/gdkkeysyms.h>
#include "macros.h"
-#include <gtk/gtk.h>
#include "desktop.h"
#include "inkscape.h"
-#include "preferences.h"
#include "ui/tools/tool-base.h"
#include "ui/dialog-events.h"
diff --git a/src/ui/dialog-events.h b/src/ui/dialog-events.h
index b4a5d7c35..547cfb95d 100644
--- a/src/ui/dialog-events.h
+++ b/src/ui/dialog-events.h
@@ -12,6 +12,7 @@
#ifndef SEEN_DIALOG_EVENTS_H
#define SEEN_DIALOG_EVENTS_H
+#include <gtk/gtk.h>
/*
* event callback can only accept one argument, but we need two,
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert
deleted file mode 100644
index 71628973e..000000000
--- a/src/ui/dialog/Makefile_insert
+++ /dev/null
@@ -1,133 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/dialog/aboutbox.cpp \
- ui/dialog/aboutbox.h \
- ui/dialog/align-and-distribute.cpp \
- ui/dialog/align-and-distribute.h \
- ui/dialog/arrange-tab.h \
- ui/dialog/behavior.h \
- ui/dialog/calligraphic-profile-rename.h \
- ui/dialog/calligraphic-profile-rename.cpp \
- ui/dialog/clonetiler.cpp \
- ui/dialog/clonetiler.h \
- ui/dialog/color-item.cpp \
- ui/dialog/color-item.h \
- ui/dialog/debug.cpp \
- ui/dialog/debug.h \
- ui/dialog/desktop-tracker.cpp \
- ui/dialog/desktop-tracker.h \
- ui/dialog/dialog.cpp \
- ui/dialog/dialog.h \
- ui/dialog/dialog-manager.cpp \
- ui/dialog/dialog-manager.h \
- ui/dialog/dock-behavior.cpp \
- ui/dialog/dock-behavior.h \
- ui/dialog/document-metadata.cpp \
- ui/dialog/document-metadata.h \
- ui/dialog/document-properties.cpp \
- ui/dialog/document-properties.h \
- ui/dialog/export.cpp \
- ui/dialog/export.h \
- ui/dialog/extension-editor.cpp \
- ui/dialog/extension-editor.h \
- ui/dialog/extensions.cpp \
- ui/dialog/extensions.h \
- ui/dialog/filedialog.cpp \
- ui/dialog/filedialog.h \
- ui/dialog/filedialogimpl-gtkmm.cpp \
- ui/dialog/filedialogimpl-gtkmm.h \
- ui/dialog/filedialogimpl-win32.cpp \
- ui/dialog/filedialogimpl-win32.h \
- ui/dialog/fill-and-stroke.cpp \
- ui/dialog/fill-and-stroke.h \
- ui/dialog/filter-effects-dialog.cpp \
- ui/dialog/filter-effects-dialog.h \
- ui/dialog/find.cpp \
- ui/dialog/find.h \
- ui/dialog/font-substitution.cpp \
- ui/dialog/font-substitution.h \
- ui/dialog/floating-behavior.cpp \
- ui/dialog/floating-behavior.h \
- ui/dialog/glyphs.cpp \
- ui/dialog/glyphs.h \
- ui/dialog/grid-arrange-tab.h \
- ui/dialog/grid-arrange-tab.cpp \
- ui/dialog/guides.cpp \
- ui/dialog/guides.h \
- ui/dialog/icon-preview.cpp \
- ui/dialog/icon-preview.h \
- ui/dialog/inkscape-preferences.cpp \
- ui/dialog/inkscape-preferences.h \
- ui/dialog/input.cpp \
- ui/dialog/input.h \
- ui/dialog/knot-properties.cpp \
- ui/dialog/knot-properties.h \
- ui/dialog/layer-properties.cpp \
- ui/dialog/layer-properties.h \
- ui/dialog/layers.cpp \
- ui/dialog/layers.h \
- ui/dialog/livepatheffect-add.cpp \
- ui/dialog/livepatheffect-add.h \
- ui/dialog/livepatheffect-editor.cpp \
- ui/dialog/livepatheffect-editor.h \
- ui/dialog/memory.cpp \
- ui/dialog/memory.h \
- ui/dialog/messages.cpp \
- ui/dialog/messages.h \
- ui/dialog/new-from-template.cpp \
- ui/dialog/new-from-template.h \
- ui/dialog/ocaldialogs.cpp \
- ui/dialog/ocaldialogs.h \
- ui/dialog/object-attributes.cpp \
- ui/dialog/object-attributes.h \
- ui/dialog/object-properties.cpp \
- ui/dialog/object-properties.h \
- ui/dialog/panel-dialog.h \
- ui/dialog/polar-arrange-tab.cpp \
- ui/dialog/polar-arrange-tab.h \
- ui/dialog/print.cpp \
- ui/dialog/print.h \
- ui/dialog/print-colors-preview-dialog.cpp \
- ui/dialog/print-colors-preview-dialog.h \
- ui/dialog/spellcheck.cpp \
- ui/dialog/spellcheck.h \
- ui/dialog/svg-fonts-dialog.cpp \
- ui/dialog/svg-fonts-dialog.h \
- ui/dialog/swatches.cpp \
- ui/dialog/swatches.h \
- ui/dialog/symbols.cpp \
- ui/dialog/symbols.h \
- ui/dialog/template-load-tab.cpp \
- ui/dialog/template-load-tab.h \
- ui/dialog/template-widget.cpp \
- ui/dialog/template-widget.h \
- ui/dialog/tags.cpp \
- ui/dialog/tags.h \
- ui/dialog/text-edit.cpp \
- ui/dialog/text-edit.h \
- ui/dialog/tile.cpp \
- ui/dialog/tile.h \
- ui/dialog/pixelartdialog.cpp \
- ui/dialog/pixelartdialog.h \
- ui/dialog/transformation.cpp \
- ui/dialog/transformation.h \
- ui/dialog/undo-history.cpp \
- ui/dialog/undo-history.h \
- ui/dialog/xml-tree.cpp \
- ui/dialog/xml-tree.h \
- ui/dialog/lpe-powerstroke-properties.cpp \
- ui/dialog/lpe-powerstroke-properties.h \
- ui/dialog/objects.cpp \
- ui/dialog/objects.h \
- ui/dialog/lpe-fillet-chamfer-properties.cpp \
- ui/dialog/lpe-fillet-chamfer-properties.h \
- $(inkboard_dialogs)
-
-if HAVE_POTRACE
-
-ink_common_sources += \
- ui/dialog/tracedialog.cpp \
- ui/dialog/tracedialog.h
-
-endif
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 1a87a9718..805bfb562 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -27,7 +27,6 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/aspectframe.h>
#include <gtkmm/textview.h>
-#include <gtkmm/stock.h>
#include "path-prefix.h"
#include "document.h"
@@ -39,8 +38,6 @@
#include "inkscape-version.h"
-
-
namespace Inkscape {
namespace UI {
namespace Dialog {
@@ -98,15 +95,11 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
tabs->append_page(*manage(
make_scrolled_text(license_text)), _("_License"), true);
-#if WITH_GTKMM_3_0
get_content_area()->pack_end(*manage(tabs), true, true);
-#else
- get_vbox()->pack_end(*manage(tabs), true, true);
-#endif
tabs->show_all();
- add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
+ add_button(_("_Close"), Gtk::RESPONSE_CLOSE);
set_default_response(Gtk::RESPONSE_CLOSE);
Gtk::Label *label=new Gtk::Label();
@@ -122,7 +115,7 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
Gtk::Label *link = new Gtk::Label();
const gchar *website_link =
- "<a href=\"https://www.inkscape.org\"> https://www.inkscape.org</a>";
+ "<a href=\"https://www.inkscape.org\">https://www.inkscape.org</a>";
link->set_markup(website_link);
link->set_alignment(Gtk::ALIGN_END);
@@ -130,23 +123,16 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
link->set_selectable(true);
link->show();
-#if WITH_GTKMM_3_0
get_content_area()->pack_start(*manage(label), false, false);
get_content_area()->pack_start(*manage(link), false, false);
-#else
- get_vbox()->pack_start(*manage(label), false, false);
- get_vbox()->pack_start(*manage(link), false, false);
-#endif
- Gtk::Requisition requisition;
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_get_preferred_size(reinterpret_cast<GtkWidget*>(gobj()), &requisition, NULL);
-#else
- gtk_widget_size_request (reinterpret_cast<GtkWidget*>(gobj()), &requisition);
-#endif
+ Gtk::Requisition minimum_size;
+ Gtk::Requisition natural_size;
+ get_preferred_size(minimum_size, natural_size);
+
// allow window to shrink
set_size_request(0, 0);
- set_default_size(requisition.width, requisition.height);
+ set_default_size(minimum_size.width, minimum_size.height);
}
@@ -166,16 +152,16 @@ Gtk::Widget *build_splash_widget() {
the `screens' directory. Thus the translation of "about.svg" should be
the filename of its translated version, e.g. about.zh.svg for Chinese.
- N.B. about.svg changes once per release. (We should probably rename
- the original to about-0.40.svg etc. as soon as we have a translation.
- If we do so, then add an item to release-checklist saying that the
- string here should be changed.) */
+ Please don't translate the filename unless the translated picture exists. */
// FIXME? INKSCAPE_SCREENSDIR and "about.svg" are in UTF-8, not the
// native filename encoding... and the filename passed to sp_document_new
// should be in UTF-*8..
char *about=g_build_filename(INKSCAPE_SCREENSDIR, _("about.svg"), NULL);
+ if (!g_file_test (about, G_FILE_TEST_EXISTS)) {
+ about=g_build_filename(INKSCAPE_SCREENSDIR, "about.svg", NULL);
+ }
SPDocument *doc=SPDocument::createNewDoc (about, TRUE);
g_free(about);
g_return_val_if_fail(doc != NULL, NULL);
@@ -267,6 +253,7 @@ void AboutBox::initStrings() {
"Joshua L. Blocher\n"
"Hanno Böck\n"
"Tomasz Boczkowski\n"
+"Adrian Boguszewski\n"
"Henrik Bohre\n"
"Boldewyn\n"
"Daniel Borgmann\n"
@@ -276,6 +263,7 @@ void AboutBox::initStrings() {
"Christopher Brown\n"
"Marcus Brubaker\n"
"Luca Bruno\n"
+"Brynn (brynn@inkscapecommunity.com)\n"
"Nicu Buculei\n"
"Bulia Byak\n"
"Pierre Caclin\n"
@@ -300,10 +288,12 @@ void AboutBox::initStrings() {
"Nicolas Dufour\n"
"Tim Dwyer\n"
"Maxim V. Dziumanenko\n"
+"Moritz Eberl\n"
"Johan Engelen\n"
"Miklos Erdelyi\n"
"Ulf Erikson\n"
"Noé Falzon\n"
+"Sebastian Faubel\n"
"Frank Felfe\n"
"Andrew Fitzsimon\n"
"Edward Flick\n"
@@ -335,6 +325,7 @@ void AboutBox::initStrings() {
"Jean-Olivier Irisson\n"
"Bob Jamison\n"
"Ted Janeczko\n"
+"Marc Jeanmougin\n"
"jEsuSdA\n"
"Fernando Lucchesi Bastos Jurema\n"
"Lauris Kaplinski\n"
@@ -400,6 +391,7 @@ void AboutBox::initStrings() {
"Shivaken\n"
"Michael Sloan\n"
"John Smith\n"
+"Sandra Snan\n"
"Boštjan Špetič\n"
"Aaron Spike\n"
"Kaushik Sridharan\n"
@@ -424,7 +416,8 @@ void AboutBox::initStrings() {
"Gellule Xg\n"
"Daniel Yacob\n"
"Masatake Yamato\n"
-"David Yip";
+"David Yip"
+;
//##############################
//# T R A N S L A T O R S
@@ -467,7 +460,8 @@ void AboutBox::initStrings() {
"Adib Taraben <theadib@gmail.com>, 2004-2014.\n"
"Alan Monfort <alan.monfort@free.fr>, 2009-2010.\n"
"Alastair McKinstry <mckinstry@computer.org>, 2000.\n"
-"Aleksandar Urošević <urke@users.sourceforge.net>, 2004-2006.\n"
+"Aleksandar Marković <alleksandar.markovic@gmail.com>, 2015.\n"
+"Aleksandar Urošević <urke@users.sourceforge.net>, 2004-2009.\n"
"Alessio Frusciante <algol@firenze.linux.it>, 2002, 2003.\n"
"Alexander Shopov <ash@contact.bg>, 2006.\n"
"Alexandre Prokoudine <alexandre.prokoudine@gmail.com>, 2005, 2010-2014.\n"
@@ -499,18 +493,19 @@ void AboutBox::initStrings() {
"Cédric Gemy <radar.map35@free.fr>, 2006.\n"
"Daniel Díaz <yosoy@danieldiaz.org>, 2004.\n"
"Didier Conchaudron <conchaudron@free.fr>, 2003.\n"
-"Dimitris Spingos <dmtrs32@gmail.com>, 2011-2013.\n"
+"Dimitris Spingos (Δημήτρης Σπίγγος) <dmtrs32@gmail.com>, 2011-2015.\n"
"Dorji Tashi <dorjee_doss@hotmail.com>, 2006.\n"
"Duarte Loreto <happyguy_pt@hotmail.com> 2002, 2003 (Maintainer).\n"
"Elias Norberg <elno0959 at student.su.se>, 2009.\n"
"Equipe de Tradução Inkscape Brasil <www.inkscapebrasil.org>, 2007.\n"
"Fatih Demir <kabalak@gtranslator.org>, 2000.\n"
-"Firas Hanife <FirasHanife@gmail.com>, 2014-2015.\n"
+"Firas Hanife <FirasHanife@gmail.com>, 2014-2016.\n"
"Foppe Benedictus <foppe.benedictus@gmail.com>, 2007-2009.\n"
"Francesc Dorca <f.dorca@filnet.es>, 2003. Traducció sodipodi.\n"
"Francisco Javier F. Serrador <serrador@arrakis.es>, 2003.\n"
"Francisco Xosé Vázquez Grandal <fxvazquez@arrakis.es>, 2001.\n"
"Frederic Rodrigo <f.rodrigo free.fr>, 2004-2005.\n"
+"Ganesh Murmu <g_murmu_in@yahoo.com>, 2014.\n"
"Ge'ez Frontier Foundation <locales@geez.org>, 2002.\n"
"George Boukeas <boukeas@gmail.com>, 2011.\n"
"Heiko Wöhrle <mail@heikowoehrle.de>, 2014.\n"
@@ -528,6 +523,7 @@ void AboutBox::initStrings() {
"Jeroen van der Vegt <jvdvegt@gmail.com>, 2003, 2005, 2008.\n"
"Jin-Hwan Jeong <yongdoria@gmail.com>, 2009.\n"
"Jonathan Ernst <jernst@users.sourceforge.net>, 2006.\n"
+"Jordi Mas i Hernàndez <jmas@softcatala.org>, 2015.\n"
"Jose Antonio Salgueiro Aquino <developer@telefonica.net>, 2003.\n"
"Josef Vybiral <josef.vybiral@gmail.com>, 2005-2006.\n"
"Juarez Rudsatz <juarez@correio.com>, 2004.\n"
@@ -542,13 +538,16 @@ void AboutBox::initStrings() {
"Kingsley Turner <kingsley@maddogsbreakfast.com.au>, 2006.\n"
"Kitae <bluetux@gmail.com>, 2006.\n"
"Kjartan Maraas <kmaraas@gnome.org>, 2000-2002.\n"
-"Kris De Gussem <Kris.DeGussem@gmail.com>, 2008-2014.\n"
+"Kris De Gussem <Kris.DeGussem@gmail.com>, 2008-2015.\n"
"Lauris Kaplinski <lauris@ariman.ee>, 2000.\n"
"Leandro Regueiro <leandro.regueiro@gmail.com>, 2006-2008, 2010.\n"
"Liu Xiaoqin <liuxqsmile@gmail.com>, 2008.\n"
+"Louni Kandulna <kandulna.louni@gmail.com>, 2014.\n"
"Luca Bruno <luca.br@uno.it>, 2005.\n"
"Lucas Vieites Fariña<lucas@codexion.com>, 2003-2013.\n"
"Mahesh subedi <submanesh@hotmail.com>, 2006.\n"
+"Marcin Floryan <marcin.floryan+inkscape (at) gmail.com>, 2016.\n"
+"Maren Hachmann <marenhachmann@yahoo.com>, 2015-2016.\n"
"Martin Srebotnjak, <miles@filmsi.net>, 2005, 2010.\n"
"Masatake YAMATO <jet@gyve.org>, 2002.\n"
"Masato Hashimoto <cabezon.hashimoto@gmail.com>, 2009-2014.\n"
@@ -561,8 +560,10 @@ void AboutBox::initStrings() {
"Mufit Eribol <meribol@ere.com.tr>, 2000.\n"
"Muhammad Bashir Al-Noimi <mhdbnoimi@gmail.com>, 2008.\n"
"Myckel Habets <myckel@sdf.lonestar.org>, 2008.\n"
+"Nasreen <nasreen_saifee@hotmail.com>, 2013.\n"
"Nguyen Dinh Trung <nguyendinhtrung141@gmail.com>, 2007, 2008.\n"
-"Nicolas Dufour <nicoduf@yahoo.fr>, 2008-2014.\n"
+"Nicolas Dufour <nicoduf@yahoo.fr>, 2008-2016.\n"
+"Paresh prabhu <goa.paresh@Gmail.com>, 2013.\n"
"Pawan Chitrakar <pchitrakar@gmail.com>, 2006.\n"
"Przemysław Loesch <p_loesch@poczta.onet.pl>, 2005.\n"
"Quico Llach <quico@softcatala.org>, 2000. Traducció sodipodi.\n"
@@ -570,6 +571,8 @@ void AboutBox::initStrings() {
"Riku Leino <tsoots@gmail.com>, 2006-2011.\n"
"Rune Rønde Laursen <runerl@skjoldhoej.dk>, 2006.\n"
"Ruud Steltenpool <svg@steltenpower.com>, 2006.\n"
+"Sangeeta <sk@gma.co>, 2011.\n"
+"Savitha <savithasprasad@yahoo.co.in>, 2013.\n"
"Serdar Soytetir <sendirom@gmail.com>, 2005.\n"
"shivaken <shivaken@owls-nest.net>, 2004.\n"
"Shyam Krishna Bal <shyamkrishna_bal@yahoo.com>, 2006.\n"
@@ -577,8 +580,11 @@ void AboutBox::initStrings() {
"Spyros Blanas <cid_e@users.sourceforge.net>, 2006, 2011.\n"
"Stefan Graubner <pflaumenmus92@gmx.net>, 2005.\n"
"Supranee Thirawatthanasuk <supranee@opentle.org>, 2006.\n"
+"Sushma Joshi <shshma_joshi8266@vsnl.net>, 2011.\n"
+"Sveinn í Felli <sv1@fellsnet.is>, 2014-2015.\n"
+"Sylvain Chiron <chironsylvain@orange.fr>, 2016.\n"
"Takeshi Aihana <aihana@muc.biglobe.ne.jp>, 2000, 2001.\n"
-"Tim Sheridan <tghs@tghs.net>, 2007-2014.\n"
+"Tim Sheridan <tghs@tghs.net>, 2007-2016.\n"
"Theppitak Karoonboonyanan <thep@linux.thai.net>, 2006.\n"
"Thiago Pimentel <thiago.merces@gmail.com>, 2006.\n"
"Toshifumi Sato <sato@centrosystem.com>, 2005.\n"
@@ -592,6 +598,7 @@ void AboutBox::initStrings() {
"Vital Khilko <dojlid@mova.org>, 2003.\n"
"Vitaly Lipatov <lav@altlinux.ru>, 2002, 2004.\n"
"vonHalenbach <vonHalenbach@users.sourceforge.net>, 2005.\n"
+"vrundeshw <vrundeshw@cdac.in>, 2012.\n"
"Waluyo Adi Siswanto <was.uthm@gmail.com>, 2011.\n"
"Wang Li <charlesw1234@163.com>, 2002.\n"
"Wei-Lun Chao <william.chao@ossii.com.tw>, 2006.\n"
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 8f87932b8..1c88fc849 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -18,7 +18,7 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "align-and-distribute.h"
@@ -27,13 +27,10 @@
#include "unclump.h"
#include "document.h"
-#include "enums.h"
#include "graphlayout.h"
#include "inkscape.h"
-#include "macros.h"
#include "preferences.h"
#include "removeoverlap.h"
-#include "selection.h"
#include "sp-flowtext.h"
#include "sp-item-transform.h"
#include "sp-text.h"
@@ -61,11 +58,7 @@ namespace Dialog {
Action::Action(const Glib::ustring &id,
const Glib::ustring &tiptext,
guint row, guint column,
-#if WITH_GTKMM_3_0
- Gtk::Grid &parent,
-#else
- Gtk::Table &parent,
-#endif
+ Gtk::Grid &parent,
AlignAndDistribute &dialog):
_dialog(dialog),
_id(id),
@@ -81,11 +74,7 @@ Action::Action(const Glib::ustring &id,
pButton->signal_clicked()
.connect(sigc::mem_fun(*this, &Action::on_button_click));
pButton->set_tooltip_text(tiptext);
-#if WITH_GTKMM_3_0
parent.attach(*pButton, column, row, 1, 1);
-#else
- parent.attach(*pButton, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL);
-#endif
}
@@ -133,22 +122,22 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups");
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
const Coeffs &a = _allCoeffs[index];
SPItem *focus = NULL;
Geom::OptRect b = Geom::OptRect();
Selection::CompareSize horiz = (a.mx0 != 0.0) || (a.mx1 != 0.0)
- ? Selection::HORIZONTAL : Selection::VERTICAL;
+ ? Selection::VERTICAL : Selection::HORIZONTAL;
switch (AlignTarget(prefs->getInt("/dialogs/align/align-to", 6)))
{
case LAST:
- focus = SP_ITEM(*selected.begin());
+ focus = SP_ITEM(*--(selected.end()));
break;
case FIRST:
- focus = SP_ITEM(*--(selected.end()));
+ focus = SP_ITEM(*selected.begin());
break;
case BIGGEST:
focus = selection->largestItem(horiz);
@@ -293,7 +282,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -447,11 +436,7 @@ public:
Action(id, tiptext, row, column + 4,
dialog.removeOverlap_table(), dialog)
{
-#if WITH_GTKMM_3_0
dialog.removeOverlap_table().set_column_spacing(3);
-#else
- dialog.removeOverlap_table().set_col_spacings(3);
-#endif
removeOverlapXGap.set_digits(1);
removeOverlapXGap.set_size_request(60, -1);
@@ -473,17 +458,10 @@ public:
removeOverlapYGapLabel.set_text_with_mnemonic(C_("Gap", "_V:"));
removeOverlapYGapLabel.set_mnemonic_widget(removeOverlapYGap);
-#if WITH_GTKMM_3_0
dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, row, 1, 1);
dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, row, 1, 1);
dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, row, 1, 1);
dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, row, 1, 1);
-#else
- dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, column+3, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, column+4, row, row+1, Gtk::FILL, Gtk::FILL);
-#endif
}
private :
@@ -499,7 +477,9 @@ private :
// xGap and yGap are the minimum space required between bounding rectangles.
double const xGap = removeOverlapXGap.get_value();
double const yGap = removeOverlapYGap.get_value();
- removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap);
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ removeoverlap(vec, xGap, yGap);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -530,8 +510,9 @@ private :
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- graphlayout(_dialog.getDesktop()->getSelection()->itemList());
-
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ graphlayout(vec);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -590,7 +571,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -633,7 +614,7 @@ private :
}
};
-// instantiae the private static member
+// instantiate the private static member
boost::optional<Geom::Point> ActionExchangePositions::center;
class ActionUnclump : public Action {
@@ -656,7 +637,8 @@ private :
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);
- std::vector<SPItem*> x(_dialog.getDesktop()->getSelection()->itemList());
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem*> x(tmp.begin(), tmp.end());
unclump (x);
// restore compensation setting
@@ -687,7 +669,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -762,11 +744,7 @@ public :
guint row,
guint column,
AlignAndDistribute &dialog,
-#if WITH_GTKMM_3_0
Gtk::Grid &table,
-#else
- Gtk::Table &table,
-#endif
Geom::Dim2 orientation, bool distribute):
Action(id, tiptext, row, column,
table, dialog),
@@ -785,7 +763,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
//Check 2 or more selected objects
if (selected.size() < 2) return;
@@ -939,26 +917,18 @@ AlignAndDistribute::AlignAndDistribute()
_rearrangeFrame(_("Rearrange")),
_removeOverlapFrame(_("Remove overlaps")),
_nodesFrame(_("Nodes")),
-#if WITH_GTKMM_3_0
_alignTable(),
_distributeTable(),
_rearrangeTable(),
_removeOverlapTable(),
_nodesTable(),
-#else
- _alignTable(2, 6, true),
- _distributeTable(2, 6, true),
- _rearrangeTable(1, 5, false),
- _removeOverlapTable(1, 5, false),
- _nodesTable(1, 4, true),
-#endif
_anchorLabel(_("Relative to: ")),
_anchorLabelNode(_("Relative to: ")),
_selgrpLabel(_("_Treat selection as group: "), 1)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- //Instanciate the align buttons
+ //Instantiate the align buttons
addAlignButton(INKSCAPE_ICON("align-horizontal-right-to-anchor"),
_("Align right edges of objects to the left edge of the anchor"),
0, 0);
@@ -1316,13 +1286,8 @@ void AlignAndDistribute::addRandomizeButton(const Glib::ustring &id, const Glib:
);
}
-#if WITH_GTKMM_3_0
void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext,
guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute)
-#else
-void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext,
- guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute)
-#endif
{
_actionList.push_back(
new ActionBaseline(
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index f8cc61af2..acb3d02ed 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -22,15 +22,11 @@
#include <gtkmm/frame.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/label.h>
-#include "2geom/rect.h"
-#include "ui/dialog/desktop-tracker.h"
-
-#if WITH_GTKMM_3_0
#include <gtkmm/checkbutton.h>
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
+
+#include "2geom/rect.h"
+#include "ui/dialog/desktop-tracker.h"
class SPItem;
@@ -51,19 +47,11 @@ public:
static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); }
-#if WITH_GTKMM_3_0
Gtk::Grid &align_table(){return _alignTable;}
Gtk::Grid &distribute_table(){return _distributeTable;}
Gtk::Grid &rearrange_table(){return _rearrangeTable;}
Gtk::Grid &removeOverlap_table(){return _removeOverlapTable;}
Gtk::Grid &nodes_table(){return _nodesTable;}
-#else
- Gtk::Table &align_table(){return _alignTable;}
- Gtk::Table &distribute_table(){return _distributeTable;}
- Gtk::Table &rearrange_table(){return _rearrangeTable;}
- Gtk::Table &removeOverlap_table(){return _removeOverlapTable;}
- Gtk::Table &nodes_table(){return _nodesTable;}
-#endif
void setMode(bool nodeEdit);
@@ -100,22 +88,13 @@ protected:
guint row, guint col);
void addRandomizeButton(const Glib::ustring &id, const Glib::ustring tiptext,
guint row, guint col);
-#if WITH_GTKMM_3_0
void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext,
guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute);
-#else
- void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext,
- guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute);
-#endif
void setTargetDesktop(SPDesktop *desktop);
std::list<Action *> _actionList;
UI::Widget::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame;
-#if WITH_GTKMM_3_0
Gtk::Grid _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable;
-#else
- Gtk::Table _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable;
-#endif
Gtk::HBox _anchorBox;
Gtk::HBox _selgrpBox;
Gtk::VBox _alignBox;
@@ -163,11 +142,7 @@ public :
Action(const Glib::ustring &id,
const Glib::ustring &tiptext,
guint row, guint column,
- #if WITH_GTKMM_3_0
- Gtk::Grid &parent,
- #else
- Gtk::Table &parent,
- #endif
+ Gtk::Grid &parent,
AlignAndDistribute &dialog);
virtual ~Action(){}
@@ -178,12 +153,7 @@ private :
virtual void on_button_click(){}
Glib::ustring _id;
-
-#if WITH_GTKMM_3_0
Gtk::Grid &_parent;
-#else
- Gtk::Table &_parent;
-#endif
};
diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp
index 9ae22db2d..36570e769 100644
--- a/src/ui/dialog/calligraphic-profile-rename.cpp
+++ b/src/ui/dialog/calligraphic-profile-rename.cpp
@@ -15,13 +15,7 @@
#include "calligraphic-profile-rename.h"
#include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include "desktop.h"
@@ -30,54 +24,38 @@ namespace UI {
namespace Dialog {
CalligraphicProfileRename::CalligraphicProfileRename() :
-#if WITH_GTKMM_3_0
_layout_table(Gtk::manage(new Gtk::Grid())),
-#else
- _layout_table(Gtk::manage(new Gtk::Table(1, 2))),
-#endif
_applied(false)
{
set_title(_("Edit profile"));
-#if WITH_GTKMM_3_0
- Gtk::Box *mainVBox = get_content_area();
+ auto mainVBox = get_content_area();
_layout_table->set_column_spacing(4);
_layout_table->set_row_spacing(4);
-#else
- Gtk::Box *mainVBox = get_vbox();
- _layout_table->set_spacings(4);
-#endif
_profile_name_entry.set_activates_default(true);
_profile_name_label.set_label(_("Profile name:"));
_profile_name_label.set_alignment(1.0, 0.5);
-#if WITH_GTKMM_3_0
_layout_table->attach(_profile_name_label, 0, 0, 1, 1);
_profile_name_entry.set_hexpand();
_layout_table->attach(_profile_name_entry, 1, 0, 1, 1);
-#else
- _layout_table->attach(_profile_name_label,
- 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
- _layout_table->attach(_profile_name_entry,
- 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
-#endif
mainVBox->pack_start(*_layout_table, false, false, 4);
// Buttons
- _close_button.set_use_stock(true);
- _close_button.set_label(Gtk::Stock::CANCEL.id);
+ _close_button.set_use_underline();
+ _close_button.set_label(_("_Cancel"));
_close_button.set_can_default();
_delete_button.set_use_underline(true);
- _delete_button.set_label(_("Delete"));
+ _delete_button.set_label(_("_Delete"));
_delete_button.set_can_default();
_delete_button.set_visible(false);
_apply_button.set_use_underline(true);
- _apply_button.set_label(_("Save"));
+ _apply_button.set_label(_("_Save"));
_apply_button.set_can_default();
_close_button.signal_clicked()
diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h
index 4ef71900b..b7a97a1e7 100644
--- a/src/ui/dialog/calligraphic-profile-rename.h
+++ b/src/ui/dialog/calligraphic-profile-rename.h
@@ -20,11 +20,7 @@
#include <gtkmm/label.h>
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
class SPDesktop;
@@ -59,12 +55,7 @@ protected:
Gtk::Label _profile_name_label;
Gtk::Entry _profile_name_entry;
-
-#if WITH_GTKMM_3_0
Gtk::Grid* _layout_table;
-#else
- Gtk::Table* _layout_table;
-#endif
Gtk::Button _close_button;
Gtk::Button _delete_button;
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index b727c87ee..3cdcf594a 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -15,39 +15,34 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include "clonetiler.h"
-#include <climits>
-
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
+
#include <gtkmm/adjustment.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/combobox.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/radiobutton.h>
#include "desktop.h"
#include "display/cairo-utils.h"
#include "display/drawing.h"
#include "display/drawing-context.h"
-#include "display/drawing-item.h"
#include "document.h"
#include "document-undo.h"
#include "filter-chemistry.h"
#include "ui/widget/unit-menu.h"
-#include "util/units.h"
#include "helper/window.h"
#include "inkscape.h"
#include "ui/interface.h"
-#include "macros.h"
#include "message-stack.h"
-#include "preferences.h"
-#include "selection.h"
-#include "sp-filter.h"
#include "sp-namedview.h"
-#include "sp-use.h"
-#include "style.h"
#include "svg/svg-color.h"
#include "svg/svg.h"
#include "ui/icon-names.h"
@@ -55,8 +50,6 @@
#include "unclump.h"
#include "verbs.h"
#include "widgets/icon.h"
-#include "xml/repr.h"
-#include "sp-root.h"
using Inkscape::DocumentUndo;
using Inkscape::Util::unit_table;
@@ -75,10 +68,8 @@ static unsigned trace_visionkey;
static gdouble trace_zoom;
static SPDocument *trace_doc = NULL;
-
CloneTiler::CloneTiler () :
UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER),
- dlg(NULL),
desktop(NULL),
deskTrack(),
table_row_labels(NULL)
@@ -87,16 +78,10 @@ CloneTiler::CloneTiler () :
contents->set_spacing(0);
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- dlg = GTK_WIDGET(gobj());
+ auto prefs = Inkscape::Preferences::get();
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
+ auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE);
-#else
- GtkWidget *mainbox = gtk_vbox_new(FALSE, 4);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6);
contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0);
@@ -107,7 +92,7 @@ CloneTiler::CloneTiler () :
// Symmetry
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry"));
+ GtkWidget *vb = new_tab (nb, _("_Symmetry"));
/* TRANSLATORS: For the following 17 symmetry groups, see
* http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples);
@@ -116,7 +101,7 @@ CloneTiler::CloneTiler () :
*/
struct SymGroups {
gint group;
- gchar const *label;
+ Glib::ustring label;
} const sym_groups[] = {
// TRANSLATORS: "translation" means "shift" / "displacement" here.
{TILE_P1, _("<b>P1</b>: simple translation")},
@@ -142,42 +127,36 @@ CloneTiler::CloneTiler () :
gint current = prefs->getInt(prefs_path + "symmetrygroup", 0);
- // Create a list structure containing all the data to be displayed in
- // the symmetry group combo box.
- GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
- GtkTreeIter iter;
-
- for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
- SymGroups const &sg = sym_groups[j];
+ // Add a new combo box widget with the list of symmetry groups to the vbox
+ auto combo = Gtk::manage(new Gtk::ComboBoxText());
+ combo->set_tooltip_text(_("Select one of the 17 symmetry groups for the tiling"));
- // Add the description of the symgroup to a new row
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, 0, sg.label, -1);
- }
+ // Hack to add markup support
+ auto cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo->gobj()));
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo->gobj()),
+ GTK_CELL_RENDERER(cell_list->data),
+ "markup", 0, NULL);
- // Add a new combo box widget with the list of symmetry groups to the vbox
- GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
- gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling"));
- gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN);
+ for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
+ SymGroups const &sg = sym_groups[j];
- // Specify the rendering of data from the list in a combo box cell
- GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
- gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "markup", 0, NULL);
+ // Add the description of the symgroup to a new row
+ combo->append(sg.label);
+ }
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current);
+ gtk_box_pack_start (GTK_BOX (vb), GTK_WIDGET(combo->gobj()), FALSE, FALSE, SB_MARGIN);
- g_signal_connect(G_OBJECT(combo), "changed",
- G_CALLBACK(clonetiler_symgroup_changed), NULL);
+ combo->set_active(current);
+ combo->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::symgroup_changed), combo));
}
table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
// Shift
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));
+ GtkWidget *vb = new_tab (nb, _("S_hift"));
- GtkWidget *table = clonetiler_table_x_y_rand (3);
+ GtkWidget *table = table_x_y_rand (3);
gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
// X
@@ -187,29 +166,29 @@ CloneTiler::CloneTiler () :
// xgettext:no-c-format
gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 2, 1);
+ table_attach (table, l, 1, 2, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
-10000, 10000, "%");
- clonetiler_table_attach (table, l, 0, 2, 2);
+ table_attach (table, l, 0, 2, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
-10000, 10000, "%");
- clonetiler_table_attach (table, l, 0, 2, 3);
+ table_attach (table, l, 0, 2, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand",
+ auto l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand",
0, 1000, "%");
- clonetiler_table_attach (table, l, 0, 2, 4);
+ table_attach (table, l, 0, 2, 4);
}
// Y
@@ -219,30 +198,30 @@ CloneTiler::CloneTiler () :
// xgettext:no-c-format
gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 3, 1);
+ table_attach (table, l, 1, 3, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Vertical shift per row (in % of tile height)"), "shifty_per_j",
-10000, 10000, "%");
- clonetiler_table_attach (table, l, 0, 3, 2);
+ table_attach (table, l, 0, 3, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Vertical shift per column (in % of tile height)"), "shifty_per_i",
-10000, 10000, "%");
- clonetiler_table_attach (table, l, 0, 3, 3);
+ table_attach (table, l, 0, 3, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
_("Randomize the vertical shift by this percentage"), "shifty_rand",
0, 1000, "%");
- clonetiler_table_attach (table, l, 0, 3, 4);
+ table_attach (table, l, 0, 3, 4);
}
// Exponent
@@ -250,21 +229,21 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 4, 1);
+ table_attach (table, l, 1, 4, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
_("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp",
0, 10, "", true);
- clonetiler_table_attach (table, l, 0, 4, 2);
+ table_attach (table, l, 0, 4, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
_("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp",
0, 10, "", true);
- clonetiler_table_attach (table, l, 0, 4, 3);
+ table_attach (table, l, 0, 4, 3);
}
{ // alternates
@@ -272,17 +251,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Alternate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 5, 1);
+ table_attach (table, l, 1, 5, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate");
- clonetiler_table_attach (table, l, 0, 5, 2);
+ auto l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate");
+ table_attach (table, l, 0, 5, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate");
- clonetiler_table_attach (table, l, 0, 5, 3);
+ auto l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate");
+ table_attach (table, l, 0, 5, 3);
}
{ // Cumulate
@@ -290,17 +269,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Cumulate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 6, 1);
+ table_attach (table, l, 1, 6, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate");
- clonetiler_table_attach (table, l, 0, 6, 2);
+ auto l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate");
+ table_attach (table, l, 0, 6, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate");
- clonetiler_table_attach (table, l, 0, 6, 3);
+ auto l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate");
+ table_attach (table, l, 0, 6, 3);
}
{ // Exclude tile width and height in shift
@@ -308,17 +287,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Cumulate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 7, 1);
+ table_attach (table, l, 1, 7, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh");
- clonetiler_table_attach (table, l, 0, 7, 2);
+ auto l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh");
+ table_attach (table, l, 0, 7, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew");
- clonetiler_table_attach (table, l, 0, 7, 3);
+ auto l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew");
+ table_attach (table, l, 0, 7, 3);
}
}
@@ -326,9 +305,9 @@ CloneTiler::CloneTiler () :
// Scale
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));
+ GtkWidget *vb = new_tab (nb, _("Sc_ale"));
- GtkWidget *table = clonetiler_table_x_y_rand (2);
+ GtkWidget *table = table_x_y_rand (2);
gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
// X
@@ -336,29 +315,29 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 2, 1);
+ table_attach (table, l, 1, 2, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Horizontal scale per row (in % of tile width)"), "scalex_per_j",
-100, 1000, "%");
- clonetiler_table_attach (table, l, 0, 2, 2);
+ table_attach (table, l, 0, 2, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Horizontal scale per column (in % of tile width)"), "scalex_per_i",
-100, 1000, "%");
- clonetiler_table_attach (table, l, 0, 2, 3);
+ table_attach (table, l, 0, 2, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand",
+ auto l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand",
0, 1000, "%");
- clonetiler_table_attach (table, l, 0, 2, 4);
+ table_attach (table, l, 0, 2, 4);
}
// Y
@@ -366,29 +345,29 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 3, 1);
+ table_attach (table, l, 1, 3, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Vertical scale per row (in % of tile height)"), "scaley_per_j",
-100, 1000, "%");
- clonetiler_table_attach (table, l, 0, 3, 2);
+ table_attach (table, l, 0, 3, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Vertical scale per column (in % of tile height)"), "scaley_per_i",
-100, 1000, "%");
- clonetiler_table_attach (table, l, 0, 3, 3);
+ table_attach (table, l, 0, 3, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand",
+ auto l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand",
0, 1000, "%");
- clonetiler_table_attach (table, l, 0, 3, 4);
+ table_attach (table, l, 0, 3, 4);
}
// Exponent
@@ -396,19 +375,19 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 4, 1);
+ table_attach (table, l, 1, 4, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",
+ auto l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",
0, 10, "", true);
- clonetiler_table_attach (table, l, 0, 4, 2);
+ table_attach (table, l, 0, 4, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
+ auto l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
0, 10, "", true);
- clonetiler_table_attach (table, l, 0, 4, 3);
+ table_attach (table, l, 0, 4, 3);
}
// Logarithmic (as in logarithmic spiral)
@@ -416,19 +395,19 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 5, 1);
+ table_attach (table, l, 1, 5, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",
+ auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",
0, 10, "", false);
- clonetiler_table_attach (table, l, 0, 5, 2);
+ table_attach (table, l, 0, 5, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log",
+ auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log",
0, 10, "", false);
- clonetiler_table_attach (table, l, 0, 5, 3);
+ table_attach (table, l, 0, 5, 3);
}
{ // alternates
@@ -436,17 +415,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Alternate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 6, 1);
+ table_attach (table, l, 1, 6, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate");
- clonetiler_table_attach (table, l, 0, 6, 2);
+ auto l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate");
+ table_attach (table, l, 0, 6, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate");
- clonetiler_table_attach (table, l, 0, 6, 3);
+ auto l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate");
+ table_attach (table, l, 0, 6, 3);
}
{ // Cumulate
@@ -454,17 +433,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Cumulate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 7, 1);
+ table_attach (table, l, 1, 7, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate");
- clonetiler_table_attach (table, l, 0, 7, 2);
+ auto l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate");
+ table_attach (table, l, 0, 7, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate");
- clonetiler_table_attach (table, l, 0, 7, 3);
+ auto l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate");
+ table_attach (table, l, 0, 7, 3);
}
}
@@ -472,9 +451,9 @@ CloneTiler::CloneTiler () :
// Rotation
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));
+ GtkWidget *vb = new_tab (nb, _("_Rotation"));
- GtkWidget *table = clonetiler_table_x_y_rand (1);
+ GtkWidget *table = table_x_y_rand (1);
gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
// Angle
@@ -482,29 +461,29 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 2, 1);
+ table_attach (table, l, 1, 2, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Rotate tiles by this angle for each row"), "rotate_per_j",
-180, 180, "&#176;");
- clonetiler_table_attach (table, l, 0, 2, 2);
+ table_attach (table, l, 0, 2, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (
+ auto l = spinbox (
// xgettext:no-c-format
_("Rotate tiles by this angle for each column"), "rotate_per_i",
-180, 180, "&#176;");
- clonetiler_table_attach (table, l, 0, 2, 3);
+ table_attach (table, l, 0, 2, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand",
+ auto l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 4);
+ table_attach (table, l, 0, 2, 4);
}
{ // alternates
@@ -512,17 +491,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Alternate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 3, 1);
+ table_attach (table, l, 1, 3, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej");
- clonetiler_table_attach (table, l, 0, 3, 2);
+ auto l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej");
+ table_attach (table, l, 0, 3, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei");
- clonetiler_table_attach (table, l, 0, 3, 3);
+ auto l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei");
+ table_attach (table, l, 0, 3, 3);
}
{ // Cumulate
@@ -530,17 +509,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Cumulate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 4, 1);
+ table_attach (table, l, 1, 4, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej");
- clonetiler_table_attach (table, l, 0, 4, 2);
+ auto l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej");
+ table_attach (table, l, 0, 4, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei");
- clonetiler_table_attach (table, l, 0, 4, 3);
+ auto l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei");
+ table_attach (table, l, 0, 4, 3);
}
}
@@ -548,9 +527,9 @@ CloneTiler::CloneTiler () :
// Blur and opacity
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity"));
+ GtkWidget *vb = new_tab (nb, _("_Blur & opacity"));
- GtkWidget *table = clonetiler_table_x_y_rand (1);
+ GtkWidget *table = table_x_y_rand (1);
gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
@@ -559,25 +538,25 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Blur:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 2, 1);
+ table_attach (table, l, 1, 2, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j",
+ auto l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 2);
+ table_attach (table, l, 0, 2, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i",
+ auto l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 3);
+ table_attach (table, l, 0, 2, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand",
+ auto l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 4);
+ table_attach (table, l, 0, 2, 4);
}
{ // alternates
@@ -585,17 +564,17 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Alternate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 3, 1);
+ table_attach (table, l, 1, 3, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej");
- clonetiler_table_attach (table, l, 0, 3, 2);
+ auto l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej");
+ table_attach (table, l, 0, 3, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei");
- clonetiler_table_attach (table, l, 0, 3, 3);
+ auto l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei");
+ table_attach (table, l, 0, 3, 3);
}
@@ -605,25 +584,25 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>Opacity:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 4, 1);
+ table_attach (table, l, 1, 4, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j",
+ auto l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 2);
+ table_attach (table, l, 0, 4, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i",
+ auto l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 3);
+ table_attach (table, l, 0, 4, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand",
+ auto l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 4);
+ table_attach (table, l, 0, 4, 4);
}
{ // alternates
@@ -631,39 +610,35 @@ CloneTiler::CloneTiler () :
// TRANSLATORS: "Alternate" is a verb here
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 5, 1);
+ table_attach (table, l, 1, 5, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej");
- clonetiler_table_attach (table, l, 0, 5, 2);
+ auto l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej");
+ table_attach (table, l, 0, 5, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei");
- clonetiler_table_attach (table, l, 0, 5, 3);
+ auto l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei");
+ table_attach (table, l, 0, 5, 3);
}
}
// Color
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor"));
+ GtkWidget *vb = new_tab (nb, _("Co_lor"));
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new (FALSE, 0);
-#endif
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);
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 or on spray tool in copy mode)")), rgba, false);
- color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
+ color_changed_connection = color_picker->connectChanged(sigc::mem_fun(*this, &CloneTiler::on_picker_color_changed));
gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
@@ -671,7 +646,7 @@ CloneTiler::CloneTiler () :
}
- GtkWidget *table = clonetiler_table_x_y_rand (3);
+ GtkWidget *table = table_x_y_rand (3);
gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
// Hue
@@ -679,25 +654,25 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 2, 1);
+ table_attach (table, l, 1, 2, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j",
+ auto l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 2);
+ table_attach (table, l, 0, 2, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i",
+ auto l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 3);
+ table_attach (table, l, 0, 2, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand",
+ auto l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 2, 4);
+ table_attach (table, l, 0, 2, 4);
}
@@ -706,25 +681,25 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 3, 1);
+ table_attach (table, l, 1, 3, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j",
+ auto l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 3, 2);
+ table_attach (table, l, 0, 3, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i",
+ auto l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 3, 3);
+ table_attach (table, l, 0, 3, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand",
+ auto l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 3, 4);
+ table_attach (table, l, 0, 3, 4);
}
// Lightness
@@ -732,25 +707,25 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 4, 1);
+ table_attach (table, l, 1, 4, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j",
+ auto l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 2);
+ table_attach (table, l, 0, 4, 2);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i",
+ auto l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i",
-100, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 3);
+ table_attach (table, l, 0, 4, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand",
+ auto l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand",
0, 100, "%");
- clonetiler_table_attach (table, l, 0, 4, 4);
+ table_attach (table, l, 0, 4, 4);
}
@@ -758,135 +733,109 @@ CloneTiler::CloneTiler () :
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
gtk_size_group_add_widget(table_row_labels, l);
- clonetiler_table_attach (table, l, 1, 5, 1);
+ table_attach (table, l, 1, 5, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej");
- clonetiler_table_attach (table, l, 0, 5, 2);
+ auto l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej");
+ table_attach (table, l, 0, 5, 2);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei");
- clonetiler_table_attach (table, l, 0, 5, 3);
+ auto l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei");
+ table_attach (table, l, 0, 5, 3);
}
}
// Trace
{
- GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));
+ GtkWidget *vb = new_tab (nb, _("_Trace"));
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
- b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items"));
- g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
+ _b = Gtk::manage(new Gtk::CheckButton(_("Trace the drawing under the clones/sprayed items")));
+ _b->set_data("uncheckable", GINT_TO_POINTER(TRUE));
bool old = prefs->getBool(prefs_path + "dotrace");
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
- gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it"));
- gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
-
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)dlg);
+ _b->set_active(old);
+ _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it"));
+ gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0);
+ _b->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled));
}
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE);
-#else
- GtkWidget *vvb = gtk_vbox_new (FALSE, 0);
-#endif
gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb);
-
+ _dotrace = vvb;
{
GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:"));
gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *table = gtk_grid_new();
+ auto table = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(table), 4);
gtk_grid_set_column_spacing(GTK_GRID(table), 6);
-#else
- GtkWidget *table = gtk_table_new (3, 3, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-#endif
gtk_container_add(GTK_CONTAINER(frame), table);
-
- GtkWidget* radio;
+ Gtk::RadioButtonGroup rb_group;
{
- radio = gtk_radio_button_new_with_label (NULL, _("Color"));
- gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity"));
- clonetiler_table_attach (table, radio, 0.0, 1, 1);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Color")));
+ radio->set_tooltip_text(_("Pick the visible color and opacity"));
+ table_attach(table, radio, 0.0, 1, 1);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_COLOR));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
- gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity"));
- clonetiler_table_attach (table, radio, 0.0, 2, 1);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Opacity")));
+ radio->set_tooltip_text(_("Pick the total accumulated opacity"));
+ table_attach (table, radio, 0.0, 2, 1);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_OPACITY));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R"));
- gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color"));
- clonetiler_table_attach (table, radio, 0.0, 1, 2);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("R")));
+ radio->set_tooltip_text(_("Pick the Red component of the color"));
+ table_attach (table, radio, 0.0, 1, 2);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_R));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_R);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G"));
- gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color"));
- clonetiler_table_attach (table, radio, 0.0, 2, 2);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("G")));
+ radio->set_tooltip_text(_("Pick the Green component of the color"));
+ table_attach (table, radio, 0.0, 2, 2);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_G));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_G);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B"));
- gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color"));
- clonetiler_table_attach (table, radio, 0.0, 3, 2);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("B")));
+ radio->set_tooltip_text(_("Pick the Blue component of the color"));
+ table_attach (table, radio, 0.0, 3, 2);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_B));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_B);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H"));
- gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color"));
- clonetiler_table_attach (table, radio, 0.0, 1, 3);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color hue", "H")));
+ radio->set_tooltip_text(_("Pick the hue of the color"));
+ table_attach (table, radio, 0.0, 1, 3);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_H));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_H);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S"));
- gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color"));
- clonetiler_table_attach (table, radio, 0.0, 2, 3);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color saturation", "S")));
+ radio->set_tooltip_text(_("Pick the saturation of the color"));
+ table_attach (table, radio, 0.0, 2, 3);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_S));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_S);
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L"));
- gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color"));
- clonetiler_table_attach (table, radio, 0.0, 3, 3);
- g_signal_connect (G_OBJECT (radio), "toggled",
- G_CALLBACK (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);
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color lightness", "L")));
+ radio->set_tooltip_text(_("Pick the lightness of the color"));
+ table_attach (table, radio, 0.0, 3, 3);
+ radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_L));
+ radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_L);
}
}
@@ -895,48 +844,42 @@ CloneTiler::CloneTiler () :
GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:"));
gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *table = gtk_grid_new();
+ auto table = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(table), 4);
gtk_grid_set_column_spacing(GTK_GRID(table), 6);
-#else
- GtkWidget *table = gtk_table_new (4, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-#endif
gtk_container_add(GTK_CONTAINER(frame), table);
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:"));
- clonetiler_table_attach (table, l, 1.0, 1, 1);
+ table_attach (table, l, 1.0, 1, 1);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
+ auto l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
-10, 10, "");
- clonetiler_table_attach (table, l, 0.0, 1, 2);
+ table_attach (table, l, 0.0, 1, 2);
}
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("Randomize:"));
- clonetiler_table_attach (table, l, 1.0, 1, 3);
+ table_attach (table, l, 1.0, 1, 3);
}
{
- GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked",
+ auto l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked",
0, 100, "%");
- clonetiler_table_attach (table, l, 0.0, 1, 4);
+ table_attach (table, l, 0.0, 1, 4);
}
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("Invert:"));
- clonetiler_table_attach (table, l, 1.0, 2, 1);
+ table_attach (table, l, 1.0, 2, 1);
}
{
- GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked");
- clonetiler_table_attach (table, l, 0.0, 2, 2);
+ auto l = checkbox (_("Invert the picked value"), "invert_picked");
+ table_attach (table, l, 0.0, 2, 2);
}
}
@@ -944,55 +887,45 @@ CloneTiler::CloneTiler () :
GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':"));
gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *table = gtk_grid_new();
+ auto table = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(table), 4);
gtk_grid_set_column_spacing(GTK_GRID(table), 6);
-#else
- GtkWidget *table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-#endif
gtk_container_add(GTK_CONTAINER(frame), table);
{
- GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
+ auto b = Gtk::manage(new Gtk::CheckButton(_("Presence")));
bool old = prefs->getBool(prefs_path + "pick_to_presence", true);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
- gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point"));
- clonetiler_table_attach (table, b, 0.0, 1, 1);
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence");
+ b->set_active(old);
+ b->set_tooltip_text(_("Each clone is created with the probability determined by the picked value in that point"));
+ table_attach (table, b, 0.0, 1, 1);
+ b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_presence"));
}
{
- GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
+ auto b = Gtk::manage(new Gtk::CheckButton(_("Size")));
bool old = prefs->getBool(prefs_path + "pick_to_size");
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
- gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point"));
- clonetiler_table_attach (table, b, 0.0, 2, 1);
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size");
+ b->set_active(old);
+ b->set_tooltip_text(_("Each clone's size is determined by the picked value in that point"));
+ table_attach (table, b, 0.0, 2, 1);
+ b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_size"));
}
{
- GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
+ auto b = Gtk::manage(new Gtk::CheckButton(_("Color")));
bool old = prefs->getBool(prefs_path + "pick_to_color", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
- gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"));
- clonetiler_table_attach (table, b, 0.0, 1, 2);
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color");
+ b->set_active(old);
+ b->set_tooltip_text(_("Each clone is painted by the picked color (the original must have unset fill or stroke)"));
+ table_attach (table, b, 0.0, 1, 2);
+ b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_color"));
}
{
- GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
+ auto b = Gtk::manage(new Gtk::CheckButton(_("Opacity")));
bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
- gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point"));
- clonetiler_table_attach (table, b, 0.0, 2, 2);
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity");
+ b->set_active(old);
+ b->set_tooltip_text(_("Each clone's opacity is determined by the picked value in that point"));
+ table_attach (table, b, 0.0, 2, 2);
+ b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_opacity"));
}
}
gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace"));
@@ -1000,309 +933,220 @@ CloneTiler::CloneTiler () :
}
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
- GtkWidget *l = gtk_label_new(_(""));
+ GtkWidget *l = gtk_label_new("");
gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:"));
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
}
// Rows/columns, width/height
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *table = gtk_grid_new();
+ auto table = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(table), 4);
gtk_grid_set_column_spacing(GTK_GRID(table), 6);
-#else
- GtkWidget *table = gtk_table_new (2, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 4);
- gtk_table_set_col_spacings (GTK_TABLE (table), 6);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0);
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
- g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb);
+ _rowscols = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN));
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment>a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0);
-#else
- Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0);
-#endif
+ auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0);
int value = prefs->getInt(prefs_path + "jmax", 2);
a->set_value (value);
-#if WITH_GTKMM_3_0
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0);
-#else
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0);
-#endif
+ auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0);
sb->set_tooltip_text (_("How many rows in the tiling"));
sb->set_width_chars (7);
- gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0);
+ _rowscols->pack_start(*sb, true, true, 0);
- // TODO: C++ification
- g_signal_connect(G_OBJECT(a->gobj()), "value_changed",
- G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax");
+ a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "jmax"));
}
{
- GtkWidget *l = gtk_label_new ("");
- gtk_label_set_markup (GTK_LABEL(l), "&#215;");
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_halign(l, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
-#endif
- gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
+ auto l = Gtk::manage(new Gtk::Label(""));
+ l->set_markup("&#215;");
+ l->set_halign(Gtk::ALIGN_END);
+ _rowscols->pack_start(*l, true, true, 0);
}
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0);
-#else
- Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0);
-#endif
+ auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0);
int value = prefs->getInt(prefs_path + "imax", 2);
a->set_value (value);
-#if WITH_GTKMM_3_0
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0);
-#else
- Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0);
-#endif
+ auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0);
sb->set_tooltip_text (_("How many columns in the tiling"));
sb->set_width_chars (7);
- gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0);
+ _rowscols->pack_start(*sb, true, true, 0);
- // TODO: C++ification
- g_signal_connect(G_OBJECT(a->gobj()), "value_changed",
- G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax");
+ a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "imax"));
}
- clonetiler_table_attach (table, hb, 0.0, 1, 2);
+ table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2);
}
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
- g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb);
+ _widthheight = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN));
// unitmenu
unit_menu = new Inkscape::UI::Widget::UnitMenu();
unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR);
unit_menu->setUnit(SP_ACTIVE_DESKTOP->getNamedView()->display_units->abbr);
- unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed));
+ unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::unit_changed));
{
// Width spinbutton
-#if WITH_GTKMM_3_0
fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0);
-#else
- fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0);
-#endif
double value = prefs->getDouble(prefs_path + "fillwidth", 50.0);
Inkscape::Util::Unit const *unit = unit_menu->getUnit();
gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit);
fill_width->set_value (units);
-#if WITH_GTKMM_3_0
- Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2);
-#else
- Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2);
-#endif
+ auto e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2);
e->set_tooltip_text (_("Width of the rectangle to be filled"));
e->set_width_chars (7);
e->set_digits (4);
- gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0);
- // TODO: C++ification
- g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed",
- G_CALLBACK(clonetiler_fill_width_changed), unit_menu);
+ _widthheight->pack_start(*e, true, true, 0);
+ fill_width->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_width_changed));
}
{
- GtkWidget *l = gtk_label_new ("");
- gtk_label_set_markup (GTK_LABEL(l), "&#215;");
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_halign(l, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
-#endif
- gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
+ auto l = Gtk::manage(new Gtk::Label(""));
+ l->set_markup("&#215;");
+ l->set_halign(Gtk::ALIGN_END);
+ _widthheight->pack_start(*l, true, true, 0);
}
{
// Height spinbutton
-#if WITH_GTKMM_3_0
fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0);
-#else
- fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0);
-#endif
double value = prefs->getDouble(prefs_path + "fillheight", 50.0);
Inkscape::Util::Unit const *unit = unit_menu->getUnit();
gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit);
fill_height->set_value (units);
-#if WITH_GTKMM_3_0
- Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2);
-#else
- Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2);
-#endif
+ auto e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2);
e->set_tooltip_text (_("Height of the rectangle to be filled"));
e->set_width_chars (7);
e->set_digits (4);
- gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0);
- // TODO: C++ification
- g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed",
- G_CALLBACK(clonetiler_fill_height_changed), unit_menu);
+ _widthheight->pack_start(*e, true, true, 0);
+ fill_height->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_height_changed));
}
- gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0);
- clonetiler_table_attach (table, hb, 0.0, 2, 2);
+ _widthheight->pack_start(*unit_menu, true, true, 0);
+ table_attach (table, GTK_WIDGET(_widthheight->gobj()), 0.0, 2, 2);
}
// Switch
- GtkWidget* radio;
+ Gtk::RadioButtonGroup rb_group;
{
- radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: "));
- gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns"));
- clonetiler_table_attach (table, radio, 0.0, 1, 1);
- g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg);
- }
- if (!prefs->getBool(prefs_path + "fillrect")) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Rows, columns: ")));
+ radio->set_tooltip_text(_("Create the specified number of rows and columns"));
+ table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 1, 1);
+ radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_create));
+
+ if (!prefs->getBool(prefs_path + "fillrect")) {
+ radio->set_active(true);
+ }
}
{
- radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
- gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling"));
- clonetiler_table_attach (table, radio, 0.0, 2, 1);
- g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg);
- }
- if (prefs->getBool(prefs_path + "fillrect")) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
+ auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Width, height: ")));
+ radio->set_tooltip_text(_("Fill the specified width and height with the tiling"));
+ table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 2, 1);
+ radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_fill));
+
+ if (prefs->getBool(prefs_path + "fillrect")) {
+ radio->set_active(true);
+ }
}
}
// Use saved pos
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
- 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);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox);
- gtk_widget_set_tooltip_text (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"));
- gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
-
- g_signal_connect(G_OBJECT(b), "toggled",
- G_CALLBACK(clonetiler_keep_bbox_toggled), NULL);
+ auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN));
+ gtk_box_pack_start (GTK_BOX (mainbox), GTK_WIDGET(hb->gobj()), FALSE, FALSE, 0);
+
+ _cb_keep_bbox = Gtk::manage(new Gtk::CheckButton(_("Use saved size and position of the tile")));
+ auto keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
+ _cb_keep_bbox->set_active(keepbbox);
+ _cb_keep_bbox->set_tooltip_text(_("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"));
+ hb->pack_start(*_cb_keep_bbox, false, false, 0);
+ _cb_keep_bbox->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::keep_bbox_toggled));
}
// Statusbar
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
GtkWidget *l = gtk_label_new("");
- g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l);
+ _status = l;
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
}
// Buttons
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
{
- GtkWidget *b = gtk_button_new ();
- GtkWidget *l = gtk_label_new ("");
- gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> "));
- gtk_container_add (GTK_CONTAINER(b), l);
- gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection"));
- g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), dlg);
- gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0);
+ auto b = Gtk::manage(new Gtk::Button());
+ auto l = Gtk::manage(new Gtk::Label(""));
+ l->set_markup_with_mnemonic(_(" <b>_Create</b> "));
+ b->add(*l);
+ b->set_tooltip_text(_("Create and tile the clones of the selection"));
+ b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::apply));
+ gtk_box_pack_end (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0);
}
{ // buttons which are enabled only when there are tiled clones
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(sb), FALSE);
-#else
- GtkWidget *sb = gtk_hbox_new(FALSE, 0);
-#endif
gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb);
+ _buttons_on_tiles = sb;
{
// TRANSLATORS: if a group of objects are "clumped" together, then they
// are unevenly spread in the given amount of space - as shown in the
// diagrams on the left in the following screenshot:
// http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png
// So unclumping is the process of spreading a number of objects out more evenly.
- GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump "));
- gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly"));
- g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL);
- gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
+ auto b = Gtk::manage(new Gtk::Button(_(" _Unclump "), true));
+ b->set_tooltip_text(_("Spread out clones to reduce clumping; can be applied repeatedly"));
+ b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::unclump));
+ gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0);
}
{
- GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move "));
- gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)"));
- g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), gpointer(dlg));
- gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
+ auto b = Gtk::manage(new Gtk::Button(_(" Re_move "), true));
+ b->set_tooltip_text(_("Remove existing tiled clones of the selected object (siblings only)"));
+ b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::on_remove_button_clicked));
+ gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0);
}
// connect to global selection changed signal (so we can change desktops) and
// external_change (so we're not fooled by undo)
- selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg));
- externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg));
-
- g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this);
+ selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::mem_fun(*this, &CloneTiler::change_selection));
+ externChangedConn = INKSCAPE.signal_external_change.connect(sigc::mem_fun(*this, &CloneTiler::external_change));
// update now
- clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg);
+ change_selection(SP_ACTIVE_DESKTOP->getSelection());
}
{
- GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset "));
+ auto b = Gtk::manage(new Gtk::Button(_(" R_eset "), true));
// TRANSLATORS: "change" is a noun here
- gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"));
- g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), dlg);
- gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
+ b->set_tooltip_text(_("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"));
+ b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::reset));
+ gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0);
}
}
@@ -1319,8 +1163,9 @@ CloneTiler::CloneTiler () :
CloneTiler::~CloneTiler (void)
{
//subselChangedConn.disconnect();
- //selectChangedConn.disconnect();
//selectModifiedConn.disconnect();
+ selectChangedConn.disconnect();
+ externChangedConn.disconnect();
desktopChangeConn.disconnect();
deskTrack.disconnect();
color_changed_connection.disconnect();
@@ -1335,17 +1180,7 @@ void CloneTiler::setDesktop(SPDesktop *desktop)
void CloneTiler::setTargetDesktop(SPDesktop *desktop)
{
if (this->desktop != desktop) {
- if (this->desktop) {
- //selectModifiedConn.disconnect();
- //subselChangedConn.disconnect();
- //selectChangedConn.disconnect();
- }
this->desktop = desktop;
- if (desktop && desktop->selection) {
- //selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
- //subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
- //selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
- }
}
}
@@ -1365,50 +1200,38 @@ void CloneTiler::on_picker_color_changed(guint rgba)
is_updating = false;
}
-void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg)
+void CloneTiler::change_selection(Inkscape::Selection *selection)
{
- GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles"));
- GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status"));
-
if (selection->isEmpty()) {
- gtk_widget_set_sensitive (buttons, FALSE);
- gtk_label_set_markup (GTK_LABEL(status), _("<small>Nothing selected.</small>"));
+ gtk_widget_set_sensitive (_buttons_on_tiles, FALSE);
+ gtk_label_set_markup (GTK_LABEL(_status), _("<small>Nothing selected.</small>"));
return;
}
- if (selection->itemList().size() > 1) {
- gtk_widget_set_sensitive (buttons, FALSE);
- gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
+ if (boost::distance(selection->items()) > 1) {
+ gtk_widget_set_sensitive (_buttons_on_tiles, FALSE);
+ gtk_label_set_markup (GTK_LABEL(_status), _("<small>More than one object selected.</small>"));
return;
}
- guint n = clonetiler_number_of_clones(selection->singleItem());
+ guint n = number_of_clones(selection->singleItem());
if (n > 0) {
- gtk_widget_set_sensitive (buttons, TRUE);
+ gtk_widget_set_sensitive (_buttons_on_tiles, TRUE);
gchar *sta = g_strdup_printf (_("<small>Object has <b>%d</b> tiled clones.</small>"), n);
- gtk_label_set_markup (GTK_LABEL(status), sta);
+ gtk_label_set_markup (GTK_LABEL(_status), sta);
g_free (sta);
} else {
- gtk_widget_set_sensitive (buttons, FALSE);
- gtk_label_set_markup (GTK_LABEL(status), _("<small>Object has no tiled clones.</small>"));
+ gtk_widget_set_sensitive (_buttons_on_tiles, FALSE);
+ gtk_label_set_markup (GTK_LABEL(_status), _("<small>Object has no tiled clones.</small>"));
}
}
-void CloneTiler::clonetiler_external_change(GtkWidget *dlg)
-{
- clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg);
-}
-
-void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source)
+void CloneTiler::external_change()
{
- g_return_if_fail(source != NULL);
-
- CloneTiler* dlg = reinterpret_cast<CloneTiler*>(source);
- dlg->selectChangedConn.disconnect();
- dlg->externChangedConn.disconnect();
+ change_selection(SP_ACTIVE_DESKTOP->getSelection());
}
-Geom::Affine CloneTiler::clonetiler_get_transform(
+Geom::Affine CloneTiler::get_transform(
// symmetry group
int type,
@@ -2010,7 +1833,7 @@ Geom::Affine CloneTiler::clonetiler_get_transform(
return Geom::identity();
}
-bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj)
+bool CloneTiler::is_a_clone_of(SPObject *tile, SPObject *obj)
{
bool result = false;
char *id_href = NULL;
@@ -2037,21 +1860,21 @@ bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj)
return result;
}
-void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from)
+void CloneTiler::trace_hide_tiled_clones_recursively(SPObject *from)
{
if (!trace_drawing)
return;
- for (SPObject *o = from->firstChild(); o != NULL; o = o->next) {
- SPItem *item = dynamic_cast<SPItem *>(o);
- if (item && clonetiler_is_a_clone_of(o, NULL)) {
+ for (auto& o: from->children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
+ if (item && is_a_clone_of(&o, NULL)) {
item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too!
}
- clonetiler_trace_hide_tiled_clones_recursively (o);
+ trace_hide_tiled_clones_recursively (&o);
}
}
-void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original)
+void CloneTiler::trace_setup(SPDocument *doc, gdouble zoom, SPItem *original)
{
trace_drawing = new Inkscape::Drawing();
/* Create ArenaItem and set transform */
@@ -2061,7 +1884,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o
// hide the (current) original and any tiled clones, we only want to pick the background
original->invoke_hide(trace_visionkey);
- clonetiler_trace_hide_tiled_clones_recursively(trace_doc->getRoot());
+ trace_hide_tiled_clones_recursively(trace_doc->getRoot());
trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
trace_doc->ensureUpToDate();
@@ -2069,7 +1892,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o
trace_zoom = zoom;
}
-guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box)
+guint32 CloneTiler::trace_pick(Geom::Rect box)
{
if (!trace_drawing) {
return 0;
@@ -2093,7 +1916,7 @@ guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box)
return SP_RGBA32_F_COMPOSE (R, G, B, A);
}
-void CloneTiler::clonetiler_trace_finish()
+void CloneTiler::trace_finish()
{
if (trace_doc) {
trace_doc->getRoot()->invoke_hide(trace_visionkey);
@@ -2103,48 +1926,48 @@ void CloneTiler::clonetiler_trace_finish()
}
}
-void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
+void CloneTiler::unclump()
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ auto desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL) {
return;
}
- Inkscape::Selection *selection = desktop->getSelection();
+ auto selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || selection->itemList().size() > 1) {
+ if (selection->isEmpty() || boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
return;
}
- SPObject *obj = selection->singleItem();
- SPObject *parent = obj->parent;
+ auto obj = selection->singleItem();
+ auto parent = obj->parent;
std::vector<SPItem*> to_unclump; // not including the original
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_unclump.push_back((SPItem*)child);
+ for (auto& child: parent->children) {
+ if (is_a_clone_of (&child, obj)) {
+ to_unclump.push_back((SPItem*)&child);
}
}
desktop->getDocument()->ensureUpToDate();
reverse(to_unclump.begin(),to_unclump.end());
- unclump (to_unclump);
+ ::unclump (to_unclump);
DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
_("Unclump tiled clones"));
}
-guint CloneTiler::clonetiler_number_of_clones(SPObject *obj)
+guint CloneTiler::number_of_clones(SPObject *obj)
{
SPObject *parent = obj->parent;
guint n = 0;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
+ for (auto& child: parent->children) {
+ if (is_a_clone_of (&child, obj)) {
n ++;
}
}
@@ -2152,7 +1975,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj)
return n;
}
-void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo/* = true*/)
+void CloneTiler::remove(bool do_undo/* = true*/)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL) {
@@ -2162,7 +1985,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || selection->itemList().size() > 1) {
+ if (selection->isEmpty() || boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
@@ -2172,9 +1995,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
// remove old tiling
GSList *to_delete = NULL;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_delete = g_slist_prepend (to_delete, child);
+ for (auto& child: parent->children) {
+ if (is_a_clone_of (&child, obj)) {
+ to_delete = g_slist_prepend (to_delete, &child);
}
}
for (GSList *i = to_delete; i; i = i->next) {
@@ -2184,7 +2007,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
}
g_slist_free (to_delete);
- clonetiler_change_selection (selection, dlg);
+ change_selection (selection);
if (do_undo) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER,
@@ -2224,7 +2047,7 @@ double CloneTiler::randomize01(double val, double rand)
}
-void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
+void CloneTiler::apply()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL) {
@@ -2240,7 +2063,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
}
// Check if more than one object is selected.
- if (selection->itemList().size() > 1) {
+ if (boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
return;
}
@@ -2249,9 +2072,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
desktop->setWaitingCursor();
// set statusbar text
- GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status"));
- gtk_label_set_markup (GTK_LABEL(status), _("<small>Creating tiled clones...</small>"));
- gtk_widget_queue_draw(GTK_WIDGET(status));
+ gtk_label_set_markup (GTK_LABEL(_status), _("<small>Creating tiled clones...</small>"));
+ gtk_widget_queue_draw(GTK_WIDGET(_status));
gdk_window_process_all_updates();
SPObject *obj = selection->singleItem();
@@ -2264,7 +2086,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
SPObject *parent = obj->parent;
- clonetiler_remove (NULL, dlg, false);
+ remove(false);
Geom::Scale scale = desktop->getDocument()->getDocumentScale().inverse();
double scale_units = scale[Geom::X]; // Use just x direction....
@@ -2353,7 +2175,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
SPItem *item = dynamic_cast<SPItem *>(obj);
if (dotrace) {
- clonetiler_trace_setup (desktop->getDocument(), 1.0, item);
+ trace_setup(desktop->getDocument(), 1.0, item);
}
Geom::Point center;
@@ -2425,7 +2247,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
// Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
// Get transform from symmetry, shift, scale, rotation
- Geom::Affine orig_t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h,
+ Geom::Affine orig_t = get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h,
shiftx_per_i, shifty_per_i,
shiftx_per_j, shifty_per_j,
shiftx_rand, shifty_rand,
@@ -2499,7 +2321,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
if (dotrace) {
Geom::Rect bbox_t = transform_rect (bbox_original, t*Geom::Scale(1.0/scale_units));
- guint32 rgba = clonetiler_trace_pick (bbox_t);
+ guint32 rgba = trace_pick (bbox_t);
float r = SP_RGBA32_R_F(rgba);
float g = SP_RGBA32_G_F(rgba);
float b = SP_RGBA32_B_F(rgba);
@@ -2659,10 +2481,10 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
}
if (dotrace) {
- clonetiler_trace_finish ();
+ trace_finish ();
}
- clonetiler_change_selection (selection, dlg);
+ change_selection(selection);
desktop->clearWaitingCursor();
@@ -2670,111 +2492,84 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
_("Create tiled clones"));
}
-GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label)
+GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label)
{
GtkWidget *l = gtk_label_new_with_mnemonic (label);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN);
+ auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN);
gtk_box_set_homogeneous(GTK_BOX(vb), FALSE);
-#else
- GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN);
gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l);
return vb;
}
-void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data)
+void CloneTiler::checkbox_toggled(Gtk::ToggleButton *tb,
+ const Glib::ustring &attr)
{
- const gchar *attr = (const gchar *) data;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb));
+ auto prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path + attr, tb->get_active());
}
-GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr)
+Gtk::Widget * CloneTiler::checkbox(const char *tip,
+ const Glib::ustring &attr)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
-#endif
+ auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN));
+ auto b = Gtk::manage(new Gtk::CheckButton());
+ b->set_tooltip_text(tip);
- GtkWidget *b = gtk_check_button_new ();
- gtk_widget_set_tooltip_text (b, tip);
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool value = prefs->getBool(prefs_path + attr);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
+ auto const prefs = Inkscape::Preferences::get();
+ auto const value = prefs->getBool(prefs_path + attr);
+ b->set_active(value);
- gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
- g_signal_connect ( G_OBJECT (b), "clicked",
- G_CALLBACK (clonetiler_checkbox_toggled), (gpointer) attr);
+ hb->pack_end(*b, false, true);
+ b->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::checkbox_toggled), b, attr));
- g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
+ b->set_data("uncheckable", GINT_TO_POINTER(true));
return hb;
}
-void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data)
+void CloneTiler::value_changed(Glib::RefPtr<Gtk::Adjustment> &adj,
+ Glib::ustring const &pref)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- const gchar *pref = (const gchar *) data;
- prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj));
+ auto prefs = Inkscape::Preferences::get();
+ prefs->setDouble(prefs_path + pref, adj->get_value());
}
-GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/)
+Gtk::Widget * CloneTiler::spinbox(const char *tip,
+ const Glib::ustring &attr,
+ double lower,
+ double upper,
+ const gchar *suffix,
+ bool exponent/* = false*/)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new(FALSE, 0);
-#endif
+ auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0));
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> a;
- if (exponent) {
- a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0);
- } else {
- a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0);
- }
-#else
- Gtk::Adjustment *a;
- if (exponent) {
- a = new Gtk::Adjustment (1.0, lower, upper, 0.01, 0.05, 0);
- } else {
- a = new Gtk::Adjustment (0.0, lower, upper, 0.1, 0.5, 0);
- }
-#endif
+ // Parameters for adjustment
+ auto const initial_value = (exponent ? 1.0 : 0.0);
+ auto const step_increment = (exponent ? 0.01 : 0.1);
+ auto const page_increment = (exponent ? 0.05 : 0.4);
- Inkscape::UI::Widget::SpinButton *sb;
-#if WITH_GTKMM_3_0
- if (exponent) {
- sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2);
- } else {
- sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1);
- }
-#else
- if (exponent) {
- sb = new Inkscape::UI::Widget::SpinButton (*a, 0.01, 2);
- } else {
- sb = new Inkscape::UI::Widget::SpinButton (*a, 0.1, 1);
- }
-#endif
+ auto a = Gtk::Adjustment::create(initial_value,
+ lower,
+ upper,
+ step_increment,
+ page_increment);
+
+ auto const climb_rate = (exponent ? 0.01 : 0.1);
+ auto const digits = (exponent ? 2 : 1);
+
+ auto sb = new Inkscape::UI::Widget::SpinButton(a, climb_rate, digits);
sb->set_tooltip_text (tip);
sb->set_width_chars (5);
sb->set_digits(3);
- gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), FALSE, FALSE, SB_MARGIN);
+ hb->pack_start(*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);
+ auto prefs = Inkscape::Preferences::get();
+ auto value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper);
a->set_value (value);
- // TODO: C++ification
- g_signal_connect(G_OBJECT(a->gobj()), "value_changed",
- G_CALLBACK(clonetiler_value_changed), (gpointer) attr);
+ a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::value_changed), a, attr));
if (exponent) {
sb->set_data ("oneable", GINT_TO_POINTER(TRUE));
@@ -2784,49 +2579,43 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do
}
{
- GtkWidget *l = gtk_label_new ("");
- gtk_label_set_markup (GTK_LABEL(l), suffix);
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_halign(l, GTK_ALIGN_END);
- gtk_widget_set_valign(l, GTK_ALIGN_START);
-#else
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0);
-#endif
- gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
+ auto l = Gtk::manage(new Gtk::Label(""));
+ l->set_markup(suffix);
+ l->set_halign(Gtk::ALIGN_END);
+ l->set_valign(Gtk::ALIGN_START);
+ hb->pack_start(*l);
}
return hb;
}
-void CloneTiler::clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/)
+void CloneTiler::symgroup_changed(Gtk::ComboBox *cb)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint group_new = gtk_combo_box_get_active (cb);
+ auto prefs = Inkscape::Preferences::get();
+ auto group_new = cb->get_active_row_number();
prefs->setInt(prefs_path + "symmetrygroup", group_new);
}
-void CloneTiler::clonetiler_xy_changed(GtkAdjustment *adj, gpointer data)
+void CloneTiler::xy_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- const gchar *pref = (const gchar *) data;
- prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5));
+ auto prefs = Inkscape::Preferences::get();
+ prefs->setInt(prefs_path + pref, (int) floor(adj->get_value() + 0.5));
}
-void CloneTiler::clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/)
+void CloneTiler::keep_bbox_toggled()
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb));
+ auto prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active());
}
-void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data)
+void CloneTiler::pick_to(Gtk::ToggleButton *tb, Glib::ustring const &pref)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- const gchar *pref = (const gchar *) data;
- prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb));
+ auto prefs = Inkscape::Preferences::get();
+ prefs->setBool(prefs_path + pref, tb->get_active());
}
-void CloneTiler::clonetiler_reset_recursive(GtkWidget *w)
+void CloneTiler::reset_recursive(GtkWidget *w)
{
if (w && G_IS_OBJECT(w)) {
{
@@ -2854,51 +2643,40 @@ void CloneTiler::clonetiler_reset_recursive(GtkWidget *w)
if (GTK_IS_CONTAINER(w)) {
GList *ch = gtk_container_get_children (GTK_CONTAINER(w));
for (GList *i = ch; i != NULL; i = i->next) {
- clonetiler_reset_recursive (GTK_WIDGET(i->data));
+ reset_recursive (GTK_WIDGET(i->data));
}
g_list_free (ch);
}
}
-void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg)
+void CloneTiler::reset()
{
- clonetiler_reset_recursive (dlg);
+ reset_recursive(GTK_WIDGET(this->gobj()));
}
-void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col)
+void CloneTiler::table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col)
+{
+ table_attach(table, GTK_WIDGET(widget->gobj()), align, row, col);
+}
+
+void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col)
{
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(widget, GTK_ALIGN_FILL);
gtk_widget_set_valign(widget, GTK_ALIGN_START);
gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1);
-#else
- GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
- gtk_container_add(GTK_CONTAINER(a), widget);
- gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 );
-#endif
}
-GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values)
+GtkWidget * CloneTiler::table_x_y_rand(int values)
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *table = gtk_grid_new();
+ auto table = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(table), 6);
gtk_grid_set_column_spacing(GTK_GRID(table), 8);
-#else
- GtkWidget *table = gtk_table_new (values + 2, 5, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 8);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new (FALSE, 0);
-#endif
GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows"));
gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
@@ -2907,16 +2685,12 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values)
gtk_label_set_markup (GTK_LABEL(l), _("<small>Per row:</small>"));
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
- clonetiler_table_attach (table, hb, 0, 1, 2);
+ table_attach (table, hb, 0, 1, 2);
}
{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
-#else
- GtkWidget *hb = gtk_hbox_new (FALSE, 0);
-#endif
GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns"));
gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
@@ -2925,83 +2699,72 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values)
gtk_label_set_markup (GTK_LABEL(l), _("<small>Per column:</small>"));
gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
- clonetiler_table_attach (table, hb, 0, 1, 3);
+ table_attach (table, hb, 0, 1, 3);
}
{
GtkWidget *l = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL(l), _("<small>Randomize:</small>"));
- clonetiler_table_attach (table, l, 0, 1, 4);
+ table_attach (table, l, 0, 1, 4);
}
return table;
}
-void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data)
+void CloneTiler::pick_switched(PickType v)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- guint v = GPOINTER_TO_INT (data);
+ auto prefs = Inkscape::Preferences::get();
prefs->setInt(prefs_path + "pick", v);
}
-
-void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg)
+void CloneTiler::switch_to_create()
{
- GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols"));
- GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight"));
-
- if (rowscols) {
- gtk_widget_set_sensitive (rowscols, TRUE);
+ if (_rowscols) {
+ _rowscols->set_sensitive(true);
}
- if (widthheight) {
- gtk_widget_set_sensitive (widthheight, FALSE);
+ if (_widthheight) {
+ _widthheight->set_sensitive(false);
}
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ auto prefs = Inkscape::Preferences::get();
prefs->setBool(prefs_path + "fillrect", false);
}
-void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg)
+void CloneTiler::switch_to_fill()
{
- GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols"));
- GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight"));
-
- if (rowscols) {
- gtk_widget_set_sensitive (rowscols, FALSE);
+ if (_rowscols) {
+ _rowscols->set_sensitive(false);
}
- if (widthheight) {
- gtk_widget_set_sensitive (widthheight, TRUE);
+ if (_widthheight) {
+ _widthheight->set_sensitive(true);
}
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ auto prefs = Inkscape::Preferences::get();
prefs->setBool(prefs_path + "fillrect", true);
}
-
-
-
-void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u)
+void CloneTiler::fill_width_changed()
{
- gdouble const raw_dist = gtk_adjustment_get_value (adj);
- Inkscape::Util::Unit const *unit = u->getUnit();
- gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px");
+ auto const raw_dist = fill_width->get_value();
+ auto const unit = unit_menu->getUnit();
+ auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px");
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ auto prefs = Inkscape::Preferences::get();
prefs->setDouble(prefs_path + "fillwidth", pixels);
}
-void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u)
+void CloneTiler::fill_height_changed()
{
- gdouble const raw_dist = gtk_adjustment_get_value (adj);
- Inkscape::Util::Unit const *unit = u->getUnit();
- gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px");
+ auto const raw_dist = fill_height->get_value();
+ auto const unit = unit_menu->getUnit();
+ auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px");
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ auto prefs = Inkscape::Preferences::get();
prefs->setDouble(prefs_path + "fillheight", pixels);
}
-void CloneTiler::clonetiler_unit_changed()
+void CloneTiler::unit_changed()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth");
@@ -3015,22 +2778,21 @@ void CloneTiler::clonetiler_unit_changed()
gtk_adjustment_set_value(fill_height->gobj(), height_value);
}
-void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg)
+void CloneTiler::do_pick_toggled()
{
- GtkWidget *vvb = GTK_WIDGET(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));
+ auto prefs = Inkscape::Preferences::get();
+ auto active = _b->get_active();
+ prefs->setBool(prefs_path + "dotrace", active);
- if (vvb) {
- gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
+ if (_dotrace) {
+ gtk_widget_set_sensitive (_dotrace, active);
}
}
void CloneTiler::show_page_trace()
{
gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6);
- gtk_toggle_button_set_active ((GtkToggleButton *) b, false);
+ _b->set_active(false);
}
diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h
index a8f1df0a0..db3049ef1 100644
--- a/src/ui/dialog/clonetiler.h
+++ b/src/ui/dialog/clonetiler.h
@@ -16,6 +16,12 @@
#include "ui/widget/color-picker.h"
#include "sp-root.h"
+namespace Gtk {
+ class CheckButton;
+ class ComboBox;
+ class ToggleButton;
+}
+
namespace Inkscape {
namespace UI {
@@ -33,45 +39,66 @@ public:
static CloneTiler &getInstance() { return *new CloneTiler(); }
void show_page_trace();
protected:
-
- GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label);
- GtkWidget * clonetiler_table_x_y_rand(int values);
- GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false);
- GtkWidget * clonetiler_checkbox(const char *tip, const char *attr);
- void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col);
-
- static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/);
- static void clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo = true);
- static void on_picker_color_changed(guint rgba);
- static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from);
- static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data);
- static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data);
- static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg);
- static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data);
- static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data);
- static void clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u);
- static void clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u);
- void clonetiler_unit_changed();
- static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg);
- static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg);
- static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/);
- static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg);
- static void clonetiler_unclump(GtkWidget */*widget*/, void *);
- static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg);
- static void clonetiler_external_change(GtkWidget *dlg);
- static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source);
- static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg);
- static guint clonetiler_number_of_clones(SPObject *obj);
- static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original);
- static guint32 clonetiler_trace_pick(Geom::Rect box);
- static void clonetiler_trace_finish();
- static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj);
- static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m);
- static double randomize01(double val, double rand);
- static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data);
- static void clonetiler_reset_recursive(GtkWidget *w);
-
- static Geom::Affine clonetiler_get_transform( // symmetry group
+ enum PickType {
+ PICK_COLOR,
+ PICK_OPACITY,
+ PICK_R,
+ PICK_G,
+ PICK_B,
+ PICK_H,
+ PICK_S,
+ PICK_L
+ };
+
+ GtkWidget * new_tab(GtkWidget *nb, const gchar *label);
+ GtkWidget * table_x_y_rand(int values);
+ Gtk::Widget * spinbox(const char *tip,
+ const Glib::ustring &attr,
+ double lower,
+ double upper,
+ const gchar *suffix,
+ bool exponent = false);
+ Gtk::Widget * checkbox(const char *tip,
+ const Glib::ustring &attr);
+ void table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col);
+ void table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col);
+
+ void symgroup_changed(Gtk::ComboBox *cb);
+ void on_picker_color_changed(guint rgba);
+ void trace_hide_tiled_clones_recursively(SPObject *from);
+ guint number_of_clones(SPObject *obj);
+ void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original);
+ guint32 trace_pick(Geom::Rect box);
+ void trace_finish();
+ bool is_a_clone_of(SPObject *tile, SPObject *obj);
+ Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m);
+ double randomize01(double val, double rand);
+
+ void apply();
+ void change_selection(Inkscape::Selection *selection);
+ void checkbox_toggled(Gtk::ToggleButton *tb,
+ Glib::ustring const &attr);
+ void do_pick_toggled();
+ void external_change();
+ void fill_width_changed();
+ void fill_height_changed();
+ void keep_bbox_toggled();
+ void on_remove_button_clicked() {remove();}
+ void pick_switched(PickType);
+ void pick_to(Gtk::ToggleButton *tb,
+ Glib::ustring const &pref);
+ void remove(bool do_undo = true);
+ void reset();
+ void reset_recursive(GtkWidget *w);
+ void switch_to_create();
+ void switch_to_fill();
+ void unclump();
+ void unit_changed();
+ void value_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref);
+ void xy_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref);
+
+ Geom::Affine get_transform(
+ // symmetry group
int type,
// row, column
@@ -112,22 +139,17 @@ private:
CloneTiler(CloneTiler const &d);
CloneTiler& operator=(CloneTiler const &d);
- GtkWidget *dlg;
+ Gtk::CheckButton *_b;
+ Gtk::CheckButton *_cb_keep_bbox;
GtkWidget *nb;
- GtkWidget *b;
SPDesktop *desktop;
DesktopTracker deskTrack;
Inkscape::UI::Widget::ColorPicker *color_picker;
GtkSizeGroup* table_row_labels;
Inkscape::UI::Widget::UnitMenu *unit_menu;
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> fill_width;
Glib::RefPtr<Gtk::Adjustment> fill_height;
-#else
- Gtk::Adjustment *fill_width;
- Gtk::Adjustment *fill_height;
-#endif
sigc::connection desktopChangeConn;
sigc::connection selectChangedConn;
@@ -147,21 +169,17 @@ private:
*/
void setTargetDesktop(SPDesktop *desktop);
+ // Variables that used to be set using GObject
+ GtkWidget *_buttons_on_tiles;
+ GtkWidget *_dotrace;
+ GtkWidget *_status;
+ Gtk::Box *_rowscols;
+ Gtk::Box *_widthheight;
+
};
enum {
- PICK_COLOR,
- PICK_OPACITY,
- PICK_R,
- PICK_G,
- PICK_B,
- PICK_H,
- PICK_S,
- PICK_L
-};
-
-enum {
TILE_P1,
TILE_P2,
TILE_PM,
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
index 34cdb92e3..df4ab6485 100644
--- a/src/ui/dialog/color-item.cpp
+++ b/src/ui/dialog/color-item.cpp
@@ -12,15 +12,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <errno.h>
#include <gtkmm/label.h>
#include <glibmm/i18n.h>
-#include <cairo.h>
-#include <gtk/gtk.h>
#include "color-item.h"
@@ -34,16 +32,10 @@
#include "io/resource.h"
#include "io/sys.h"
#include "message-context.h"
-#include "sp-gradient.h"
-#include "sp-item.h"
#include "svg/svg-color.h"
-#include "xml/node.h"
-#include "xml/repr.h"
#include "verbs.h"
#include "widgets/gradient-vector.h"
-#include "color.h" // for SP_RGBA32_U_COMPOSE
-
namespace Inkscape {
namespace UI {
diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp
new file mode 100644
index 000000000..85c804b75
--- /dev/null
+++ b/src/ui/dialog/cssdialog.cpp
@@ -0,0 +1,146 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ * Tavmjong Bah
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ * Copyright (C) Tavmjong Bah 2017 <tavmjong@free.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "cssdialog.h"
+#include "ui/widget/addtoicon.h"
+#include "widgets/icon.h"
+#include "verbs.h"
+#include "sp-object.h"
+#include "selection.h"
+#include "xml/attribute-record.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * Constructor
+ * A treeview whose each row corresponds to a CSS property of selector selected.
+ * New CSS property can be added by clicking '+' at bottom of the CSS pane. '-'
+ * in front of the CSS property row can be clicked to delete the CSS property.
+ * Besides clicking on an already selected property row makes the property editable
+ * and clicking 'Enter' updates the property with changes reflected in the
+ * drawing.
+ */
+CssDialog::CssDialog():
+ UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS),
+ _desktop(0)
+{
+ set_size_request(20, 15);
+ _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
+ _treeView.set_headers_visible(true);
+ _scrolledWindow.add(_treeView);
+ _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+
+ _store = Gtk::ListStore::create(_cssColumns);
+ _treeView.set_model(_store);
+
+ Inkscape::UI::Widget::AddToIcon * addRenderer = manage(new Inkscape::UI::Widget::AddToIcon());
+ addRenderer->property_active() = false;
+
+ int addCol = _treeView.append_column("", *addRenderer) - 1;
+ Gtk::TreeViewColumn *col = _treeView.get_column(addCol);
+ if (col) {
+ col->add_attribute(addRenderer->property_active(), _cssColumns._colUnsetProp);
+ }
+
+ _propRenderer = Gtk::manage(new Gtk::CellRendererText());
+ _propRenderer->property_editable() = true;
+ int nameColNum = _treeView.append_column("CSS Property", *_propRenderer) - 1;
+ _propCol = _treeView.get_column(nameColNum);
+ if (_propCol) {
+ _propCol->add_attribute(_propRenderer->property_text(), _cssColumns._propertyLabel);
+ }
+
+ _sheetRenderer = Gtk::manage(new Gtk::CellRendererText());
+ _sheetRenderer->property_editable() = true;
+ int sheetColNum = _treeView.append_column("Style Sheet", *_sheetRenderer) - 1;
+ _sheetCol = _treeView.get_column(sheetColNum);
+ if (_sheetCol) {
+ _sheetCol->add_attribute(_sheetRenderer->property_text(), _cssColumns._styleSheetVal);
+ }
+
+ _attrRenderer = Gtk::manage(new Gtk::CellRendererText());
+ _attrRenderer->property_editable() = false;
+ int attrColNum = _treeView.append_column("Style Attribute", *_attrRenderer) - 1;
+ _attrCol = _treeView.get_column(attrColNum);
+ if (_attrCol) {
+ _attrCol->add_attribute(_attrRenderer->property_text(), _cssColumns._styleAttrVal);
+ }
+
+ _styleButton(_buttonAddProperty, "list-add", "Add a new property");
+
+ _mainBox.pack_end(_buttonBox, Gtk::PACK_SHRINK);
+ _buttonBox.pack_start(_buttonAddProperty, Gtk::PACK_SHRINK);
+
+ _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET);
+
+ setDesktop(getDesktop());
+
+ _buttonAddProperty.signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty));
+}
+
+
+/**
+ * @brief CssDialog::~CssDialog
+ * Class destructor
+ */
+CssDialog::~CssDialog()
+{
+ setDesktop(NULL);
+}
+
+
+/**
+ * @brief CssDialog::setDesktop
+ * @param desktop
+ * This function sets the 'desktop' for the CSS pane.
+ */
+void CssDialog::setDesktop(SPDesktop* desktop)
+{
+ _desktop = desktop;
+}
+
+
+/**
+ * @brief CssDialog::_styleButton
+ * @param btn
+ * @param iconName
+ * @param tooltip
+ * This function sets the style of '+'button at the bottom of dialog.
+ */
+void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName,
+ char const* tooltip)
+{
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show(child);
+ btn.add(*manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
+ btn.set_tooltip_text(tooltip);
+}
+
+
+/**
+ * @brief CssDialog::_addProperty
+ * This function is a slot to signal_clicked for '+' button at the bottom of CSS
+ * panel. A new row is added, double clicking which text for new property can be
+ * added.
+ */
+void CssDialog::_addProperty()
+{
+ _propRow = *(_store->append());
+}
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
diff --git a/src/ui/dialog/cssdialog.h b/src/ui/dialog/cssdialog.h
new file mode 100644
index 000000000..31eb67e3f
--- /dev/null
+++ b/src/ui/dialog/cssdialog.h
@@ -0,0 +1,93 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ * Tavmjong Bah
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ * Copyright (C) Tavmjong Bah 2017 <tavmjong@free.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef CSSDIALOG_H
+#define CSSDIALOG_H
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/dialog.h>
+#include <ui/widget/panel.h>
+
+#include "desktop.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * @brief The CssDialog class
+ * This dialog allows to add, delete and modify CSS properties for selectors
+ * created in Style Dialog. Double clicking any selector in Style dialog, a list
+ * of CSS properties will show up in this dialog (if any exist), else new properties
+ * can be added and each new property forms a new row in this pane.
+ */
+class CssDialog : public UI::Widget::Panel
+{
+public:
+ CssDialog();
+ ~CssDialog();
+
+ static CssDialog &getInstance() { return *new CssDialog(); }
+
+ // Data structure
+ class CssColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ CssColumns() {
+ add(_colUnsetProp);
+ add(_propertyLabel);
+ add(_styleSheetVal);
+ add(_styleAttrVal);
+ }
+ Gtk::TreeModelColumn<bool> _colUnsetProp;
+ Gtk::TreeModelColumn<Glib::ustring> _propertyLabel;
+ Gtk::TreeModelColumn<Glib::ustring> _styleSheetVal;
+ Gtk::TreeModelColumn<Glib::ustring> _styleAttrVal;
+ };
+ CssColumns _cssColumns;
+
+ // TreeView
+ Gtk::TreeView _treeView;
+ Glib::RefPtr<Gtk::ListStore> _store;
+ Gtk::TreeModel::Row _propRow;
+ Gtk::CellRendererText *_propRenderer;
+ Gtk::CellRendererText *_sheetRenderer;
+ Gtk::CellRendererText *_attrRenderer;
+ Gtk::TreeViewColumn *_propCol;
+ Gtk::TreeViewColumn *_sheetCol;
+ Gtk::TreeViewColumn *_attrCol;
+
+ // Widgets
+ Gtk::VBox _mainBox;
+ Gtk::ScrolledWindow _scrolledWindow;
+ Gtk::HBox _buttonBox;
+ Gtk::Button _buttonAddProperty;
+
+ // Variables - Inkscape
+ SPDesktop* _desktop;
+
+ // Helper functions
+ void setDesktop(SPDesktop* desktop);
+ void _styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip);
+
+ // Signal handlers
+ void _addProperty();
+};
+
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+#endif // CSSDIALOG_H
diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp
index d127261c0..d062bf863 100644
--- a/src/ui/dialog/debug.cpp
+++ b/src/ui/dialog/debug.cpp
@@ -10,13 +10,12 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include <gtkmm/box.h>
#include <gtkmm/dialog.h>
#include <gtkmm/textview.h>
-#include <gtkmm/button.h>
#include <gtkmm/menubar.h>
#include <gtkmm/scrolledwindow.h>
#include <glibmm/i18n.h>
@@ -68,12 +67,7 @@ DebugDialogImpl::DebugDialogImpl()
{
set_title(_("Messages"));
set_size_request(300, 400);
-
-#if WITH_GTKMM_3_0
- Gtk::Box *mainVBox = get_content_area();
-#else
- Gtk::Box *mainVBox = get_vbox();
-#endif
+ auto mainVBox = get_content_area();
//## Add a menu for clear()
Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true));
diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp
index 0659de67b..c18711a55 100644
--- a/src/ui/dialog/desktop-tracker.cpp
+++ b/src/ui/dialog/desktop-tracker.cpp
@@ -6,7 +6,6 @@
*/
#include "widgets/desktop-widget.h"
-#include <glib-object.h>
#include "desktop-tracker.h"
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 49853277c..01cd9dd0f 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -14,11 +14,12 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "ui/dialog/dialog-manager.h"
+#include "ui/dialog/prototype.h"
#include "ui/dialog/align-and-distribute.h"
#include "ui/dialog/document-metadata.h"
#include "ui/dialog/document-properties.h"
@@ -45,11 +46,8 @@
#include "ui/dialog/panel-dialog.h"
#include "ui/dialog/layers.h"
#include "ui/dialog/icon-preview.h"
-#include "ui/dialog/floating-behavior.h"
-#include "ui/dialog/dock-behavior.h"
//#include "ui/dialog/print-colors-preview-dialog.h"
#include "util/ege-appear-time-tracker.h"
-#include "preferences.h"
#include "ui/dialog/object-attributes.h"
#include "ui/dialog/object-properties.h"
#include "ui/dialog/text-edit.h"
@@ -60,6 +58,8 @@
#include "ui/dialog/svg-fonts-dialog.h"
#include "ui/dialog/objects.h"
#include "ui/dialog/tags.h"
+#include "ui/dialog/styledialog.h"
+#include "ui/dialog/cssdialog.h"
namespace Inkscape {
namespace UI {
@@ -106,6 +106,7 @@ DialogManager::DialogManager() {
registerFactory("InkscapePreferences", &create<InkscapePreferences, FloatingBehavior>);
if (dialogs_type == FLOATING) {
+ registerFactory("Prototype", &create<Prototype, FloatingBehavior>);
registerFactory("AlignAndDistribute", &create<AlignAndDistribute, FloatingBehavior>);
registerFactory("DocumentMetadata", &create<DocumentMetadata, FloatingBehavior>);
registerFactory("DocumentProperties", &create<DocumentProperties, FloatingBehavior>);
@@ -128,6 +129,8 @@ DialogManager::DialogManager() {
registerFactory("Swatches", &create<SwatchesPanel, FloatingBehavior>);
registerFactory("TileDialog", &create<ArrangeDialog, FloatingBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, FloatingBehavior>);
+ registerFactory("StyleDialog", &create<StyleDialog, FloatingBehavior>);
+ registerFactory("CssDialog", &create<CssDialog, FloatingBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, FloatingBehavior>);
@@ -145,6 +148,7 @@ DialogManager::DialogManager() {
} else {
+ registerFactory("Prototype", &create<Prototype, DockBehavior>);
registerFactory("AlignAndDistribute", &create<AlignAndDistribute, DockBehavior>);
registerFactory("DocumentMetadata", &create<DocumentMetadata, DockBehavior>);
registerFactory("DocumentProperties", &create<DocumentProperties, DockBehavior>);
@@ -167,6 +171,8 @@ DialogManager::DialogManager() {
registerFactory("Swatches", &create<SwatchesPanel, DockBehavior>);
registerFactory("TileDialog", &create<ArrangeDialog, DockBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, DockBehavior>);
+ registerFactory("StyleDialog", &create<StyleDialog, DockBehavior>);
+ registerFactory("CssDialog", &create<CssDialog, DockBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, DockBehavior>);
diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h
index 15573f760..36e9a12be 100644
--- a/src/ui/dialog/dialog-manager.h
+++ b/src/ui/dialog/dialog-manager.h
@@ -30,11 +30,11 @@ public:
static DialogManager &getInstance();
- sigc::signal<void> show_dialogs;
- sigc::signal<void> show_f12;
- sigc::signal<void> hide_dialogs;
- sigc::signal<void> hide_f12;
- sigc::signal<void> transientize;
+ // sigc::signal<void> show_dialogs;
+ // sigc::signal<void> show_f12;
+ // sigc::signal<void> hide_dialogs;
+ // sigc::signal<void> hide_f12;
+ // sigc::signal<void> transientize;
/* generic dialog management start */
typedef std::map<GQuark, DialogFactory> FactoryMap;
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index 27d88bae7..27a6e55d9 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -14,12 +14,11 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "dialog-manager.h"
#include <gtkmm/dialog.h>
-#include <gtkmm/stock.h>
#include <gdk/gdkkeysyms.h>
#include "inkscape.h"
@@ -27,13 +26,10 @@
#include "desktop.h"
#include "shortcuts.h"
-#include "preferences.h"
#include "ui/interface.h"
#include "verbs.h"
#include "ui/tool/event-utils.h"
-#include <gtk/gtk.h>
-
#define MIN_ONSCREEN_DISTANCE 50
diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp
index 50a6db208..02955b9a8 100644
--- a/src/ui/dialog/dock-behavior.cpp
+++ b/src/ui/dialog/dock-behavior.cpp
@@ -12,7 +12,7 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "dock-behavior.h"
@@ -23,15 +23,8 @@
#include "ui/widget/dock.h"
#include "verbs.h"
#include "dialog.h"
-#include "preferences.h"
#include "ui/dialog-events.h"
-#include <gtkmm/invisible.h>
-#include <gtkmm/label.h>
-#include <gtkmm/stock.h>
-
-#include <gtk/gtk.h>
-
namespace Inkscape {
namespace UI {
namespace Dialog {
diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp
index da1facc08..dc1958434 100644
--- a/src/ui/dialog/document-metadata.cpp
+++ b/src/ui/dialog/document-metadata.cpp
@@ -15,13 +15,12 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "document-metadata.h"
#include "desktop.h"
-#include "inkscape.h"
#include "rdf.h"
#include "sp-namedview.h"
#include "ui/widget/entity-entry.h"
@@ -61,12 +60,7 @@ DocumentMetadata::getInstance()
DocumentMetadata::DocumentMetadata()
-#if WITH_GTKMM_3_0
: UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA)
-#else
- : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA),
- _page_metadata1(1, 1), _page_metadata2(1, 1)
-#endif
{
hide();
_getContents()->set_spacing (4);
@@ -75,15 +69,10 @@ DocumentMetadata::DocumentMetadata()
_page_metadata1.set_border_width(2);
_page_metadata2.set_border_width(2);
-#if WITH_GTKMM_3_0
_page_metadata1.set_column_spacing(2);
_page_metadata2.set_column_spacing(2);
_page_metadata1.set_row_spacing(2);
_page_metadata2.set_row_spacing(2);
-#else
- _page_metadata1.set_spacings(2);
- _page_metadata2.set_spacings(2);
-#endif
_notebook.append_page(_page_metadata1, _("Metadata"));
_notebook.append_page(_page_metadata2, _("License"));
@@ -126,12 +115,8 @@ DocumentMetadata::build_metadata()
label->set_markup (_("<b>Dublin Core Entities</b>"));
label->set_alignment (0.0);
-#if WITH_GTKMM_3_0
label->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1.attach(*label, 0, 0, 3, 1);
-#else
- _page_metadata1.attach(*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
/* add generic metadata entry areas */
struct rdf_work_entity_t * entity;
@@ -143,7 +128,6 @@ DocumentMetadata::build_metadata()
Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
-#if WITH_GTKMM_3_0
space->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1.attach(*space, 0, row, 1, 1);
@@ -153,11 +137,6 @@ DocumentMetadata::build_metadata()
w->_packable->set_hexpand();
w->_packable->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1.attach(*w->_packable, 2, row, 1, 1);
-#else
- _page_metadata1.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata1.attach(w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata1.attach(*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
-#endif
}
}
@@ -167,31 +146,20 @@ DocumentMetadata::build_metadata()
Gtk::Label *llabel = Gtk::manage (new Gtk::Label);
llabel->set_markup (_("<b>License</b>"));
llabel->set_alignment (0.0);
-
-#if WITH_GTKMM_3_0
llabel->set_valign(Gtk::ALIGN_CENTER);
_page_metadata2.attach(*llabel, 0, row, 3, 1);
-#else
- _page_metadata2.attach(*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
/* add license selector pull-down and URI */
++row;
_licensor.init (_wr);
Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
-
-#if WITH_GTKMM_3_0
space->set_valign(Gtk::ALIGN_CENTER);
_page_metadata2.attach(*space, 0, row, 1, 1);
_licensor.set_hexpand();
_licensor.set_valign(Gtk::ALIGN_CENTER);
_page_metadata2.attach(_licensor, 1, row, 2, 1);
-#else
- _page_metadata2.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata2.attach(_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
}
/**
diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h
index cde5d92fd..2c56e9317 100644
--- a/src/ui/dialog/document-metadata.h
+++ b/src/ui/dialog/document-metadata.h
@@ -21,12 +21,7 @@
#include <stddef.h>
#include "ui/widget/panel.h"
#include <gtkmm/notebook.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include "inkscape.h"
#include "ui/widget/licensor.h"
@@ -62,13 +57,8 @@ protected:
Gtk::Notebook _notebook;
-#if WITH_GTKMM_3_0
Gtk::Grid _page_metadata1;
Gtk::Grid _page_metadata2;
-#else
- Gtk::Table _page_metadata1;
- Gtk::Table _page_metadata2;
-#endif
//---------------------------------------------------------------
RDElist _rdflist;
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 589973162..8593223c1 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -25,27 +25,17 @@
#include "ui/widget/notebook-page.h"
#include "document-properties.h"
#include "display/canvas-grid.h"
-#include "document.h"
-#include "desktop.h"
-#include "inkscape.h"
#include "io/sys.h"
-#include "preferences.h"
#include "ui/shape-editor.h"
-#include "sp-namedview.h"
#include "sp-root.h"
#include "sp-script.h"
#include "style.h"
-#include "svg/stringstream.h"
#include "ui/tools-switch.h"
-#include "ui/widget/color-picker.h"
-#include "ui/widget/scalar-unit.h"
#include "ui/dialog/filedialog.h"
#include "verbs.h"
#include "widgets/icon.h"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
-#include <algorithm> // std::min
#include "rdf.h"
#include "ui/widget/entity-entry.h"
@@ -54,11 +44,6 @@
#include "color-profile.h"
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-#include <gtkmm/imagemenuitem.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/table.h>
-
-#include <2geom/transforms.h>
#include "ui/icon-names.h"
using std::pair;
@@ -223,25 +208,16 @@ DocumentProperties::~DocumentProperties()
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
* (non-0, non-0) means two widgets in columns 2 and 3.
*/
-#if WITH_GTKMM_3_0
inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0)
-#else
-inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0)
-#endif
{
for (unsigned i = 0, r = start; i < n; i += 2) {
if (arr[i] && arr[i+1]) {
-#if WITH_GTKMM_3_0
arr[i]->set_hexpand();
arr[i+1]->set_hexpand();
arr[i]->set_valign(Gtk::ALIGN_CENTER);
arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
table.attach(*arr[i], 1, r, 1, 1);
table.attach(*arr[i+1], 2, r, 1, 1);
-#else
- table.attach(*arr[i], 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- table.attach(*arr[i+1], 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
-#endif
} else {
if (arr[i+1]) {
Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0;
@@ -252,7 +228,6 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con
if (docum_prop_flag) {
// this sets the padding for subordinate widgets on the "Page" page
if( i==(n-8) || i==(n-10) ) {
-#if WITH_GTKMM_3_0
arr[i+1]->set_hexpand();
arr[i+1]->set_margin_left(20);
arr[i+1]->set_margin_right(20);
@@ -263,11 +238,7 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con
arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
table.attach(*arr[i+1], 1, r, 2, 1);
-#else
- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0);
-#endif
} else {
-#if WITH_GTKMM_3_0
arr[i+1]->set_hexpand();
if (yoptions & Gtk::EXPAND)
@@ -276,12 +247,8 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con
arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
table.attach(*arr[i+1], 1, r, 2, 1);
-#else
- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
-#endif
}
} else {
-#if WITH_GTKMM_3_0
arr[i+1]->set_hexpand();
if (yoptions & Gtk::EXPAND)
@@ -290,32 +257,21 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con
arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
table.attach(*arr[i+1], 1, r, 2, 1);
-#else
- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
-#endif
}
} else if (arr[i]) {
Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
label.set_alignment (0.0);
-#if WITH_GTKMM_3_0
label.set_hexpand();
label.set_valign(Gtk::ALIGN_CENTER);
table.attach(label, 0, r, 3, 1);
-#else
- table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
-#endif
} else {
Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
-#if WITH_GTKMM_3_0
space->set_halign(Gtk::ALIGN_CENTER);
space->set_valign(Gtk::ALIGN_CENTER);
table.attach(*space, 0, r, 1, 1);
-#else
- table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
-#endif
}
}
++r;
@@ -599,7 +555,7 @@ void DocumentProperties::linked_profiles_list_button_release(GdkEventButton* eve
void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_EmbProfContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -609,7 +565,7 @@ void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<v
void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_ExternalScriptsContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -618,7 +574,7 @@ void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::s
void DocumentProperties::embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ Gtk::MenuItem* mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_EmbeddedScriptsContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -685,52 +641,35 @@ void DocumentProperties::build_cms()
label_link->set_alignment(0.0);
-#if WITH_GTKMM_3_0
label_link->set_hexpand();
label_link->set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(*label_link, 0, row, 3, 1);
-#else
- _page_cms->table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_LinkedProfilesListScroller.set_hexpand();
_LinkedProfilesListScroller.set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(_LinkedProfilesListScroller, 0, row, 3, 1);
-#else
- _page_cms->table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox());
spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
-#if WITH_GTKMM_3_0
spacer->set_hexpand();
spacer->set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(*spacer, 0, row, 3, 1);
-#else
- _page_cms->table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
label_avail->set_alignment(0.0);
-#if WITH_GTKMM_3_0
label_avail->set_hexpand();
label_avail->set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(*label_avail, 0, row, 3, 1);
-#else
- _page_cms->table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_AvailableProfilesList.set_hexpand();
_AvailableProfilesList.set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(_AvailableProfilesList, 0, row, 1, 1);
@@ -744,11 +683,6 @@ void DocumentProperties::build_cms()
_unlink_btn.set_halign(Gtk::ALIGN_CENTER);
_unlink_btn.set_valign(Gtk::ALIGN_CENTER);
_page_cms->table().attach(_unlink_btn, 2, row, 1, 1);
-#else
- _page_cms->table().attach(_AvailableProfilesList, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
- _page_cms->table().attach(_link_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0);
- _page_cms->table().attach(_unlink_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0);
-#endif
// Set up the Avialable Profiles combo box
_AvailableProfilesListStore = Gtk::ListStore::create(_AvailableProfilesListColumns);
@@ -815,41 +749,27 @@ void DocumentProperties::build_scripting()
gint row = 0;
label_external->set_alignment(0.0);
-
-#if WITH_GTKMM_3_0
label_external->set_hexpand();
label_external->set_valign(Gtk::ALIGN_CENTER);
_page_external_scripts->table().attach(*label_external, 0, row, 3, 1);
-#else
- _page_external_scripts->table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_ExternalScriptsListScroller.set_hexpand();
_ExternalScriptsListScroller.set_valign(Gtk::ALIGN_CENTER);
_page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, row, 3, 1);
-#else
- _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox());
spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
-#if WITH_GTKMM_3_0
spacer_external->set_hexpand();
spacer_external->set_valign(Gtk::ALIGN_CENTER);
_page_external_scripts->table().attach(*spacer_external, 0, row, 3, 1);
-#else
- _page_external_scripts->table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_script_entry.set_hexpand();
_script_entry.set_valign(Gtk::ALIGN_CENTER);
_page_external_scripts->table().attach(_script_entry, 0, row, 1, 1);
@@ -863,11 +783,6 @@ void DocumentProperties::build_scripting()
_external_remove_btn.set_halign(Gtk::ALIGN_CENTER);
_external_remove_btn.set_valign(Gtk::ALIGN_CENTER);
_page_external_scripts->table().attach(_external_remove_btn, 2, row, 1, 1);
-#else
- _page_external_scripts->table().attach(_script_entry, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
- _page_external_scripts->table().attach(_external_add_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0);
- _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0);
-#endif
//# Set up the External Scripts box
_ExternalScriptsListStore = Gtk::ListStore::create(_ExternalScriptsListColumns);
@@ -888,12 +803,6 @@ void DocumentProperties::build_scripting()
_embed_remove_btn.set_tooltip_text(_("Remove"));
docprops_style_button(_embed_remove_btn, INKSCAPE_ICON("list-remove"));
-#if !WITH_GTKMM_3_0
- // TODO: This has been removed from Gtkmm 3.0. Check that
- // everything still looks OK!
- _embed_button_box.set_child_min_width( 16 );
- _embed_button_box.set_spacing( 4 );
-#endif
_embed_button_box.set_layout (Gtk::BUTTONBOX_START);
_embed_button_box.add(_embed_new_btn);
_embed_button_box.add(_embed_remove_btn);
@@ -902,47 +811,29 @@ void DocumentProperties::build_scripting()
row = 0;
label_embedded->set_alignment(0.0);
-
-#if WITH_GTKMM_3_0
label_embedded->set_hexpand();
label_embedded->set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(*label_embedded, 0, row, 3, 1);
-#else
- _page_embedded_scripts->table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_EmbeddedScriptsListScroller.set_hexpand();
_EmbeddedScriptsListScroller.set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, row, 3, 1);
-#else
- _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_embed_button_box.set_hexpand();
_embed_button_box.set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(_embed_button_box, 0, row, 1, 1);
-#else
- _page_embedded_scripts->table().attach(_embed_button_box, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox());
spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
-
-#if WITH_GTKMM_3_0
spacer_embedded->set_hexpand();
spacer_embedded->set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(*spacer_embedded, 0, row, 3, 1);
-#else
- _page_embedded_scripts->table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
@@ -958,24 +849,15 @@ void DocumentProperties::build_scripting()
label_embedded_content->set_markup (_("<b>Content:</b>"));
label_embedded_content->set_alignment(0.0);
-
-#if WITH_GTKMM_3_0
label_embedded_content->set_hexpand();
label_embedded_content->set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(*label_embedded_content, 0, row, 3, 1);
-#else
- _page_embedded_scripts->table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
row++;
-#if WITH_GTKMM_3_0
_EmbeddedContentScroller.set_hexpand();
_EmbeddedContentScroller.set_valign(Gtk::ALIGN_CENTER);
_page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, row, 3, 1);
-#else
- _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
-#endif
_EmbeddedContentScroller.add(_EmbeddedContent);
_EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN);
@@ -1037,12 +919,8 @@ void DocumentProperties::build_metadata()
label->set_markup (_("<b>Dublin Core Entities</b>"));
label->set_alignment (0.0);
-#if WITH_GTKMM_3_0
label->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1->table().attach (*label, 0,0,3,1);
-#else
- _page_metadata1->table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
/* add generic metadata entry areas */
struct rdf_work_entity_t * entity;
@@ -1053,8 +931,6 @@ void DocumentProperties::build_metadata()
_rdflist.push_back (w);
Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
-
-#if WITH_GTKMM_3_0
space->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1->table().attach(*space, 0, row, 1, 1);
@@ -1064,11 +940,6 @@ void DocumentProperties::build_metadata()
w->_packable->set_hexpand();
w->_packable->set_valign(Gtk::ALIGN_CENTER);
_page_metadata1->table().attach(*w->_packable, 2, row, 1, 1);
-#else
- _page_metadata1->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata1->table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata1->table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
-#endif
}
}
@@ -1077,11 +948,7 @@ void DocumentProperties::build_metadata()
Gtk::Button *button_load = Gtk::manage (new Gtk::Button(_("Use _default"),1));
button_load->set_tooltip_text(_("Use the previously saved default metadata here"));
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *box_buttons = Gtk::manage (new Gtk::ButtonBox);
-#else
- Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox);
-#endif
+ auto box_buttons = Gtk::manage (new Gtk::ButtonBox);
box_buttons->set_layout(Gtk::BUTTONBOX_END);
box_buttons->set_spacing(4);
@@ -1099,12 +966,8 @@ void DocumentProperties::build_metadata()
llabel->set_markup (_("<b>License</b>"));
llabel->set_alignment (0.0);
-#if WITH_GTKMM_3_0
llabel->set_valign(Gtk::ALIGN_CENTER);
_page_metadata2->table().attach(*llabel, 0, row, 3, 1);
-#else
- _page_metadata2->table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
/* add license selector pull-down and URI */
++row;
@@ -1112,17 +975,12 @@ void DocumentProperties::build_metadata()
Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
-#if WITH_GTKMM_3_0
space->set_valign(Gtk::ALIGN_CENTER);
_page_metadata2->table().attach(*space, 0, row, 1, 1);
_licensor.set_hexpand();
_licensor.set_valign(Gtk::ALIGN_CENTER);
_page_metadata2->table().attach(_licensor, 1, row, 3, 1);
-#else
- _page_metadata2->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
- _page_metadata2->table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0);
-#endif
}
void DocumentProperties::addExternalScript(){
@@ -1315,12 +1173,7 @@ void DocumentProperties::changeEmbeddedScript(){
for (std::vector<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) {
SPObject* obj = *it;
if (id == obj->getId()){
-
- int count=0;
- for ( SPObject *child = obj->children ; child; child = child->next )
- {
- count++;
- }
+ int count = (int) obj->children.size();
if (count>1)
g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count);
@@ -1364,8 +1217,11 @@ void DocumentProperties::editEmbeddedScript(){
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node *repr = obj->getRepr();
if (repr){
- SPObject *child;
- while (NULL != (child = obj->firstChild())) child->deleteObject();
+ auto tmp = obj->children | boost::adaptors::transformed([](SPObject& o) { return &o; });
+ std::vector<SPObject*> vec(tmp.begin(), tmp.end());
+ for (auto &child: vec) {
+ child->deleteObject();
+ }
obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str()));
//TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text());
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index 7f91d9ea0..8d1c6b38a 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -173,11 +173,7 @@ protected:
Gtk::Button _external_remove_btn;
Gtk::Button _embed_new_btn;
Gtk::Button _embed_remove_btn;
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox _embed_button_box;
-#else
- Gtk::HButtonBox _embed_button_box;
-#endif
+ Gtk::ButtonBox _embed_button_box;
class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord
{
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 2fb5f9e3b..1bb952de4 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -24,18 +24,8 @@
#include <gtkmm/buttonbox.h>
#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
-#include <gtkmm/image.h>
-#include <gtkmm/label.h>
+#include <gtkmm/grid.h>
#include <gtkmm/spinbutton.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/stockid.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-#include <gtkmm/togglebutton.h>
-#include <gtkmm/widget.h>
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized
@@ -45,16 +35,12 @@
#include <glibmm/miscutils.h>
#include "ui/widget/unit-menu.h"
-#include "util/units.h"
#include "helper/window.h"
#include "inkscape.h"
#include "document.h"
#include "document-undo.h"
-#include "sp-item.h"
-#include "selection.h"
#include "file.h"
-#include "macros.h"
#include "sp-namedview.h"
#include "selection-chemistry.h"
@@ -71,12 +57,7 @@
#include "helper/png-write.h"
-#if WITH_EXT_GDL
#include <gdl/gdl-dock-item.h>
-#else
-#include "libgdl/gdl-dock-item.h"
-#endif
-
// required to set status message after export
#include "desktop.h"
@@ -89,17 +70,12 @@
#include <glibmm/fileutils.h>
#endif
-#include <gtk/gtk.h>
-
#define SP_EXPORT_MIN_SIZE 1.0
#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px")
#define EXPORT_COORD_PRECISION 3
-#include "../../document.h"
-#include "../../document-undo.h"
-#include "verbs.h"
#include "export.h"
using Inkscape::Util::unit_table;
@@ -165,15 +141,22 @@ Export::Export (void) :
units_label(_("Units:")),
filename_box(false, 5),
browse_label(_("_Export As..."), 1),
- browse_image(Gtk::StockID(Gtk::Stock::INDEX), Gtk::ICON_SIZE_BUTTON),
+ browse_image(),
batch_box(false, 5),
batch_export(_("B_atch export all selected objects"), _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")),
+ interlacing(_("Use interlacing"),_("Enables ADAM7 interlacing for PNG output. This results in slightly heavier images, but big images will look better sooner when loading the file")),
+ bitdepth_label(_("Bit depth")),
+ bitdepth_cb(),
+ zlib_label(_("Compression")),
+ zlib_compression(),
+ pHYs_label(_("pHYs dpi")),
+ pHYs_sb(pHYs_adj, 1.0, 2),
+ antialiasing_label(_("Antialiasing")),
+ antialiasing_cb(),
hide_box(false, 5),
- hide_export(_("Hide a_ll except selected"), _("In the exported image, hide all objects except those that are selected")),
+ hide_export(_("Hide all except selected"), _("In the exported image, hide all objects except those that are selected")),
closeWhenDone(_("Close when complete"), _("Once the export completes, close this dialog")),
button_box(false, 3),
- export_label(_("_Export"), 1),
- export_image(Gtk::StockID(Gtk::Stock::APPLY), Gtk::ICON_SIZE_BUTTON),
_prog(),
prog_dlg(NULL),
interrupted(false),
@@ -218,15 +201,9 @@ Export::Export (void) :
selectiontype_buttons[i]->signal_clicked().connect(sigc::mem_fun(*this, &Export::onAreaToggled));
}
-#if WITH_GTKMM_3_0
- Gtk::Grid* t = new Gtk::Grid();
+ auto t = new Gtk::Grid();
t->set_row_spacing(4);
t->set_column_spacing(4);
-#else
- Gtk::Table* t = new Gtk::Table(3, 4, false);
- t->set_row_spacings (4);
- t->set_col_spacings (4);
-#endif
x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1,
@@ -268,15 +245,9 @@ Export::Export (void) :
bm_label->set_use_markup(true);
size_box.pack_start(*bm_label, false, false, 0);
-#if WITH_GTKMM_3_0
- Gtk::Grid *t = new Gtk::Grid();
+ auto t = new Gtk::Grid();
t->set_row_spacing(4);
t->set_column_spacing(4);
-#else
- Gtk::Table *t = new Gtk::Table(2, 5, false);
- t->set_row_spacings (4);
- t->set_col_spacings (4);
-#endif
size_box.pack_start(*t);
@@ -318,6 +289,7 @@ Export::Export (void) :
filename_box.pack_start (filename_entry, true, true, 0);
Gtk::HBox* browser_im_label = new Gtk::HBox(false, 3);
+ browse_image.set_from_icon_name("folder", Gtk::ICON_SIZE_BUTTON);
browser_im_label->pack_start(browse_image);
browser_im_label->pack_start(browse_label);
browse_button.add(*browser_im_label);
@@ -346,16 +318,47 @@ Export::Export (void) :
/* Export Button row */
button_box.set_border_width(3);
- Gtk::HBox* export_image_label = new Gtk::HBox(false, 3);
- export_image_label->pack_start(export_image);
- export_image_label->pack_start(export_label);
-
- export_button.add(*export_image_label);
+ export_button.set_label(_("_Export"));
+ export_button.set_use_underline();
export_button.set_tooltip_text (_("Export the bitmap file with these settings"));
button_box.pack_start(closeWhenDone, true, true, 0 );
button_box.pack_end(export_button, false, false, 0);
+ /*Advanced*/
+ Gtk::Label *label_advanced = Gtk::manage(new Gtk::Label(_("Advanced"),1));
+ expander.set_label_widget(*label_advanced);
+ const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"};
+ for(int i=0; i<11; ++i)
+ bitdepth_cb.append(modes_list[i]);
+ bitdepth_cb.set_active_text("RGBA_8");
+ bitdepth_cb.set_hexpand();
+ const char* const zlist[]={"Z_NO_COMPRESSION","Z_BEST_SPEED","2","3","4","5","Z_DEFAULT_COMPRESSION","7","8","Z_BEST_COMPRESSION"};
+ for(int i=0; i<10; ++i)
+ zlib_compression.append(zlist[i]);
+ zlib_compression.set_active_text("Z_DEFAULT_COMPRESSION");
+ pHYs_adj = Gtk::Adjustment::create(0, 0, 100000, 0.1, 1.0, 0);
+ pHYs_sb.set_adjustment(pHYs_adj);
+ pHYs_sb.set_width_chars(7);
+ pHYs_sb.set_tooltip_text( _("Will force-set the physical dpi for the png file. Set this to 72 if you're planning to work on your png with Photoshop") );
+ zlib_compression.set_hexpand();
+ const char* const antialising_list[] = {"CAIRO_ANTIALIAS_NONE","CAIRO_ANTIALIAS_FAST","CAIRO_ANTIALIAS_GOOD (default)","CAIRO_ANTIALIAS_BEST"};
+ for(int i=0; i<4; ++i)
+ antialiasing_cb.append(antialising_list[i]);
+ antialiasing_cb.set_active_text(antialising_list[2]);
+ auto table = new Gtk::Grid();
+ gtk_container_add(GTK_CONTAINER(expander.gobj()), (GtkWidget*)(table->gobj()));
+ table->attach(interlacing,0,0,1,1);
+ table->attach(bitdepth_label,0,1,1,1);
+ table->attach(bitdepth_cb,1,1,1,1);
+ table->attach(zlib_label,0,2,1,1);
+ table->attach(zlib_compression,1,2,1,1);
+ table->attach(pHYs_label,0,3,1,1);
+ table->attach(pHYs_sb,1,3,1,1);
+ table->attach(antialiasing_label,0,4,1,1);
+ table->attach(antialiasing_cb,1,4,1,1);
+ table->show();
+
/* Main dialog */
Gtk::Box *contents = _getContents();
contents->set_spacing(0);
@@ -364,6 +367,7 @@ Export::Export (void) :
contents->pack_start(hide_box);
contents->pack_end(button_box, false, 0);
contents->pack_end(_prog, Gtk::PACK_EXPAND_WIDGET);
+ contents->pack_end(expander, FALSE, FALSE,0);
/* Signal handlers */
filename_entry.signal_changed().connect( sigc::mem_fun(*this, &Export::onFilenameModified) );
@@ -484,27 +488,14 @@ void Export::set_default_filename () {
}
}
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
float step, float page,
Gtk::Grid *t, int x, int y,
const Glib::ustring& ll, const Glib::ustring& lr,
int digits, unsigned int sensitive,
void (Export::*cb)() )
-#else
-Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
- float step, float page,
- Gtk::Table *t, int x, int y,
- const Glib::ustring& ll, const Glib::ustring& lr,
- int digits, unsigned int sensitive,
- void (Export::*cb)() )
-#endif
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = Gtk::Adjustment::create(val, min, max, step, page, 0);
-#else
- Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 );
-#endif
+ auto adj = Gtk::Adjustment::create(val, min, max, step, page, 0);
int pos = 0;
Gtk::Label *l = NULL;
@@ -512,28 +503,17 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl
if (!ll.empty()) {
l = new Gtk::Label(ll,true);
l->set_alignment (1.0, 0.5);
-
-#if WITH_GTKMM_3_0
l->set_hexpand();
l->set_vexpand();
t->attach(*l, x + pos, y, 1, 1);
-#else
- t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
-#endif
-
l->set_sensitive(sensitive);
pos++;
}
-#if WITH_GTKMM_3_0
- Gtk::SpinButton *sb = new Gtk::SpinButton(adj, 1.0, digits);
+ auto sb = new Gtk::SpinButton(adj, 1.0, digits);
sb->set_hexpand();
sb->set_vexpand();
t->attach(*sb, x + pos, y, 1, 1);
-#else
- Gtk::SpinButton *sb = new Gtk::SpinButton(*adj, 1.0, digits);
- t->attach (*sb, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
-#endif
sb->set_width_chars(7);
sb->set_sensitive (sensitive);
@@ -546,15 +526,9 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl
if (!lr.empty()) {
l = new Gtk::Label(lr,true);
l->set_alignment (0.0, 0.5);
-
-#if WITH_GTKMM_3_0
l->set_hexpand();
l->set_vexpand();
t->attach(*l, x + pos, y, 1, 1);
-#else
- t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
-#endif
-
l->set_sensitive (sensitive);
pos++;
l->set_mnemonic_widget (*sb);
@@ -608,7 +582,7 @@ void Export::onBatchClicked ()
void Export::updateCheckbuttons ()
{
- gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size();
+ gint num = (gint) boost::distance(SP_ACTIVE_DESKTOP->getSelection()->items());
if (num >= 2) {
batch_export.set_sensitive(true);
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
@@ -814,14 +788,14 @@ void Export::onAreaToggled ()
case SELECTION_SELECTION:
if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
- sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi);
+ SP_ACTIVE_DESKTOP->getSelection()->getExportHints(filename, &xdpi, &ydpi);
/* If we still don't have a filename -- let's build
one that's nice */
if (filename.empty()) {
const gchar * id = "object";
- const std::vector<XML::Node*> reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList();
- for(std::vector<XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) {
+ auto reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes();
+ for(auto i=reprlst.begin(); reprlst.end() != i; ++i) {
Inkscape::XML::Node * repr = *i;
if (repr->attribute("id")) {
id = repr->attribute("id");
@@ -932,14 +906,10 @@ Gtk::Dialog * Export::create_progress_dialog (Glib::ustring progress_text) {
Gtk::ProgressBar *prg = new Gtk::ProgressBar ();
prg->set_text(progress_text);
dlg->set_data ("progress", prg);
-#if GTK_CHECK_VERSION(3,0,0)
- Gtk::Box* CA = dlg->get_content_area();
-#else
- Gtk::Box* CA = dlg->get_vbox();
-#endif
+ auto CA = dlg->get_content_area();
CA->pack_start(*prg, FALSE, FALSE, 4);
- Gtk::Button* btn = dlg->add_button (Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
+ Gtk::Button* btn = dlg->add_button (_("_Cancel"),Gtk::RESPONSE_CANCEL );
btn->signal_clicked().connect( sigc::mem_fun(*this, &Export::onProgressCancel) );
dlg->signal_delete_event().connect( sigc::mem_fun(*this, &Export::onProgressDelete) );
@@ -1012,10 +982,23 @@ void Export::onExport ()
bool exportSuccessful = false;
bool hide = hide_export.get_active ();
+
+ // Advanced parameters
+ bool do_interlace = (interlacing.get_active());
+ float pHYs = 0;
+ int zlib = zlib_compression.get_active_row_number() ;
+ const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"};
+ int colortypes[] = {0,0,0,0,0,2,2,4,4,6,6}; //keep in sync with modes_list in Export constructor. values are from libpng doc.
+ int bitdepths[] = {1,2,4,8,16,8,16,8,16,8,16};
+ int color_type = colortypes[bitdepth_cb.get_active_row_number()] ;
+ int bit_depth = bitdepths[bitdepth_cb.get_active_row_number()] ;
+ int antialiasing = antialiasing_cb.get_active_row_number();
+
+
if (batch_export.get_active ()) {
// Batch export of selected objects
- gint num = (desktop->getSelection()->itemList()).size();
+ gint num = (gint) boost::distance(desktop->getSelection()->items());
gint n = 0;
if (num < 1) {
@@ -1029,8 +1012,8 @@ void Export::onExport ()
gint export_count = 0;
- std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){
+ auto itemlist= desktop->getSelection()->items();
+ for(auto i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){
SPItem *item = *i;
prog_dlg->set_data("current", GINT_TO_POINTER(n));
@@ -1056,6 +1039,7 @@ void Export::onExport ()
if (dpi == 0.0) {
dpi = getValue(xdpi_adj);
}
+ pHYs = (pHYs_adj->get_value() > 0.01) ? pHYs_adj->get_value() : dpi;
Geom::OptRect area = item->desktopVisualBounds();
if (area) {
@@ -1070,12 +1054,14 @@ void Export::onExport ()
MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE,
_("Exporting file <b>%s</b>..."), safeFile), desktop);
std::vector<SPItem*> x;
+ std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end());
if (!sp_export_png_file (doc, path.c_str(),
- *area, width, height, dpi, dpi,
+ *area, width, height, pHYs, pHYs,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
TRUE, // overwrite without asking
- hide ? (desktop->getSelection()->itemList()) : x
+ hide ? selected : x,
+ do_interlace, color_type, bit_depth, zlib, antialiasing
)) {
gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
@@ -1117,6 +1103,7 @@ void Export::onExport ()
float const y1 = getValuePx(y1_adj);
float const xdpi = getValue(xdpi_adj);
float const ydpi = getValue(ydpi_adj);
+ pHYs = (pHYs_adj->get_value() > 0.01) ? pHYs_adj->get_value() : xdpi;
unsigned long int const width = int(getValue(bmwidth_adj) + 0.5);
unsigned long int const height = int(getValue(bmheight_adj) + 0.5);
@@ -1160,13 +1147,15 @@ void Export::onExport ()
/* Do export */
std::vector<SPItem*> x;
+ std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end());
ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(),
- Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
+ Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, pHYs, pHYs, //previously xdpi, ydpi.
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
FALSE,
- hide ? (desktop->getSelection()->itemList()) : x
- );
+ hide ? selected : x,
+ do_interlace, color_type, bit_depth, zlib, antialiasing
+ );
if (status == EXPORT_ERROR) {
gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
@@ -1231,15 +1220,14 @@ void Export::onExport ()
break;
}
case SELECTION_SELECTION: {
- std::vector<XML::Node*> reprlst;
SPDocument * doc = SP_ACTIVE_DOCUMENT;
bool modified = false;
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false);
- reprlst = desktop->getSelection()->reprList();
+ auto reprlst = desktop->getSelection()->xmlNodes();
- for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) {
+ for(auto i=reprlst.begin(); reprlst.end() != i; ++i) {
Inkscape::XML::Node * repr = *i;
const gchar * temp_string;
Glib::ustring dir = Glib::path_get_dirname(filename.c_str());
@@ -1357,11 +1345,7 @@ void Export::onBrowse ()
Glib::RefPtr<const Gdk::Window> parentWindow = desktop->getToplevel()->get_window();
g_assert(parentWindow->gobj() != NULL);
-#if WITH_GTKMM_3_0
opf.hwndOwner = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj());
-#else
- opf.hwndOwner = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj());
-#endif
opf.lpstrFilter = filter_string;
opf.lpstrCustomFilter = 0;
opf.nMaxCustFilter = 0L;
@@ -1521,11 +1505,7 @@ void Export::detectSize() {
} /* sp_export_detect_size */
/// Called when area x0 value is changed
-#if WITH_GTKMM_3_0
void Export::areaXChange(Glib::RefPtr<Gtk::Adjustment>& adj)
-#else
-void Export::areaXChange (Gtk::Adjustment *adj)
-#endif
{
float x0, x1, xdpi, width;
@@ -1564,11 +1544,7 @@ void Export::areaXChange (Gtk::Adjustment *adj)
} // end of sp_export_area_x_value_changed()
/// Called when area y0 value is changed.
-#if WITH_GTKMM_3_0
void Export::areaYChange(Glib::RefPtr<Gtk::Adjustment>& adj)
-#else
-void Export::areaYChange (Gtk::Adjustment *adj)
-#endif
{
float y0, y1, ydpi, height;
@@ -1875,11 +1851,7 @@ void Export::setArea( double x0, double y0, double x1, double y1 )
* @param adj The adjustment widget
* @param val What value to set it to.
*/
-#if WITH_GTKMM_3_0
void Export::setValue(Glib::RefPtr<Gtk::Adjustment>& adj, double val )
-#else
-void Export::setValue( Gtk::Adjustment *adj, double val )
-#endif
{
if (adj) {
adj->set_value(val);
@@ -1897,11 +1869,7 @@ void Export::setValue( Gtk::Adjustment *adj, double val )
* @param adj The adjustment widget
* @param val What the value should be in points.
*/
-#if WITH_GTKMM_3_0
void Export::setValuePx(Glib::RefPtr<Gtk::Adjustment>& adj, double val)
-#else
-void Export::setValuePx( Gtk::Adjustment *adj, double val)
-#endif
{
Unit const *unit = unit_selector.getUnit();
@@ -1920,11 +1888,7 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val)
*
* @return The value in the specified adjustment.
*/
-#if WITH_GTKMM_3_0
float Export::getValue(Glib::RefPtr<Gtk::Adjustment>& adj)
-#else
-float Export::getValue( Gtk::Adjustment *adj )
-#endif
{
if (!adj) {
g_message("sp_export_value_get : adj is NULL");
@@ -1946,11 +1910,7 @@ float Export::getValue( Gtk::Adjustment *adj )
*
* @return The value in the adjustment in points.
*/
-#if WITH_GTKMM_3_0
float Export::getValuePx(Glib::RefPtr<Gtk::Adjustment>& adj)
-#else
-float Export::getValuePx( Gtk::Adjustment *adj )
-#endif
{
float value = getValue( adj);
Unit const *unit = unit_selector.getUnit();
diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h
index 23af0109b..1f8e87dbc 100644
--- a/src/ui/dialog/export.h
+++ b/src/ui/dialog/export.h
@@ -13,6 +13,9 @@
#define SP_EXPORT_H
#include <gtkmm/progressbar.h>
+#include <gtkmm/expander.h>
+#include <gtkmm/grid.h>
+#include <gtkmm/comboboxtext.h>
#include "ui/dialog/desktop-tracker.h"
#include "ui/widget/panel.h"
@@ -79,17 +82,10 @@ private:
/*
* Getter/setter style functions for the spinbuttons
*/
-#if WITH_GTKMM_3_0
void setValue(Glib::RefPtr<Gtk::Adjustment>& adj, double val);
void setValuePx(Glib::RefPtr<Gtk::Adjustment>& adj, double val);
float getValue(Glib::RefPtr<Gtk::Adjustment>& adj);
float getValuePx(Glib::RefPtr<Gtk::Adjustment>& adj);
-#else
- void setValue (Gtk::Adjustment *adj, double val);
- void setValuePx (Gtk::Adjustment *adj, double val);
- float getValue (Gtk::Adjustment *adj);
- float getValuePx (Gtk::Adjustment *adj);
-#endif
/**
* Helper function to create, style and pack spinbuttons for the export dialog.
@@ -112,21 +108,12 @@ private:
*
* No unit_selector is stored in the created spinbutton, relies on external unit management
*/
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> createSpinbutton( gchar const *key, float val, float min, float max,
float step, float page,
Gtk::Grid *t, int x, int y,
const Glib::ustring& ll, const Glib::ustring& lr,
int digits, unsigned int sensitive,
void (Export::*cb)() );
-#else
- Gtk::Adjustment * createSpinbutton( gchar const *key, float val, float min, float max,
- float step, float page,
- Gtk::Table *t, int x, int y,
- const Glib::ustring& ll, const Glib::ustring& lr,
- int digits, unsigned int sensitive,
- void (Export::*cb)() );
-#endif
/**
* One of the area select radio buttons was pressed
@@ -152,11 +139,7 @@ private:
void onAreaX1Change() {
areaXChange(x1_adj);
} ;
-#if WITH_GTKMM_3_0
void areaXChange(Glib::RefPtr<Gtk::Adjustment>& adj);
-#else
- void areaXChange ( Gtk::Adjustment *adj);
-#endif
/**
* Area Y value changed callback
@@ -167,11 +150,7 @@ private:
void onAreaY1Change() {
areaYChange(y1_adj);
} ;
-#if WITH_GTKMM_3_0
void areaYChange(Glib::RefPtr<Gtk::Adjustment>& adj);
-#else
- void areaYChange ( Gtk::Adjustment *adj);
-#endif
/**
* Unit changed callback
@@ -298,7 +277,6 @@ private:
Gtk::VBox area_box;
Gtk::VBox singleexport_box;
-#if WITH_GTKMM_3_0
/* Custom size widgets */
Glib::RefPtr<Gtk::Adjustment> x0_adj;
Glib::RefPtr<Gtk::Adjustment> x1_adj;
@@ -312,21 +290,6 @@ private:
Glib::RefPtr<Gtk::Adjustment> bmheight_adj;
Glib::RefPtr<Gtk::Adjustment> xdpi_adj;
Glib::RefPtr<Gtk::Adjustment> ydpi_adj;
-#else
- /* Custom size widgets */
- Gtk::Adjustment *x0_adj;
- Gtk::Adjustment *x1_adj;
- Gtk::Adjustment *y0_adj;
- Gtk::Adjustment *y1_adj;
- Gtk::Adjustment *width_adj;
- Gtk::Adjustment *height_adj;
-
- /* Bitmap size widgets */
- Gtk::Adjustment *bmwidth_adj;
- Gtk::Adjustment *bmheight_adj;
- Gtk::Adjustment *xdpi_adj;
- Gtk::Adjustment *ydpi_adj;
-#endif
Gtk::VBox size_box;
Gtk::Label* bm_label;
@@ -354,11 +317,22 @@ private:
Inkscape::UI::Widget::CheckButton closeWhenDone;
+ /* Advanced */
+ Gtk::Expander expander;
+ Inkscape::UI::Widget::CheckButton interlacing;
+ Gtk::Label bitdepth_label;
+ Gtk::ComboBoxText bitdepth_cb;
+ Gtk::Label zlib_label;
+ Gtk::ComboBoxText zlib_compression;
+ Gtk::Label pHYs_label;
+ Glib::RefPtr<Gtk::Adjustment> pHYs_adj;
+ Gtk::SpinButton pHYs_sb;
+ Gtk::Label antialiasing_label;
+ Gtk::ComboBoxText antialiasing_cb;
+
/* Export Button widgets */
Gtk::HBox button_box;
Gtk::Button export_button;
- Gtk::Label export_label;
- Gtk::Image export_image;
Gtk::ProgressBar _prog;
diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp
index 9bdddc0e0..84840f22d 100644
--- a/src/ui/dialog/extension-editor.cpp
+++ b/src/ui/dialog/extension-editor.cpp
@@ -12,14 +12,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "extension-editor.h"
#include <glibmm/i18n.h>
#include <gtkmm/frame.h>
-#include <gtkmm/scrolledwindow.h>
#include <gtkmm/alignment.h>
#include <gtkmm/notebook.h>
@@ -27,7 +26,6 @@
#include "preferences.h"
#include "ui/interface.h"
-#include "extension/extension.h"
#include "extension/db.h"
namespace Inkscape {
diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp
index 4e4b0278a..df3c4a307 100644
--- a/src/ui/dialog/filedialog.cpp
+++ b/src/ui/dialog/filedialog.cpp
@@ -15,14 +15,15 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "filedialogimpl-win32.h"
+#ifdef WIN32
+# include "filedialogimpl-win32.h"
+# include "preferences.h"
+#endif
+
#include "filedialogimpl-gtkmm.h"
-#include "filedialog.h"
-#include "inkgc/gc-core.h"
#include "ui/dialog-events.h"
#include "extension/output.h"
-#include "preferences.h"
#include <glibmm/convert.h>
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 042637d22..92e9ce834 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -35,7 +35,6 @@
#endif
#include <gtkmm/expander.h>
-#include <gtkmm/stock.h>
#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
@@ -555,7 +554,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName);
gchar *fName = const_cast<gchar *>(
fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat())
- struct stat info;
+ GStatBuf info;
if (g_stat(fName, &info)) // stat returns 0 upon success
{
g_warning("SVGPreview::set() : %s : %s", fName, strerror(errno));
@@ -735,8 +734,8 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window &parentWindow, const Gl
//###### Add the file types menu
createFilterMenu();
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK));
+ add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
+ set_default(*add_button(_("_Open"), Gtk::RESPONSE_OK));
//###### Allow easy access to our examples folder
if (Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS) &&
@@ -754,16 +753,9 @@ FileOpenDialogImplGtk::~FileOpenDialogImplGtk()
void FileOpenDialogImplGtk::addFilterMenu(Glib::ustring name, Glib::ustring pattern)
{
-
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create();
+ auto allFilter = Gtk::FileFilter::create();
allFilter->set_name(_(name.c_str()));
allFilter->add_pattern(pattern);
-#else
- Gtk::FileFilter allFilter;
- allFilter.set_name(_(name.c_str()));
- allFilter.add_pattern(pattern);
-#endif
extensionMap[Glib::ustring(_("All Files"))] = NULL;
add_filter(allFilter);
}
@@ -775,51 +767,27 @@ void FileOpenDialogImplGtk::createFilterMenu()
}
if (_dialogType == EXE_TYPES) {
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create();
+ auto allFilter = Gtk::FileFilter::create();
allFilter->set_name(_("All Files"));
allFilter->add_pattern("*");
-#else
- Gtk::FileFilter allFilter;
- allFilter.set_name(_("All Files"));
- allFilter.add_pattern("*");
-#endif
extensionMap[Glib::ustring(_("All Files"))] = NULL;
add_filter(allFilter);
} else {
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::FileFilter> allInkscapeFilter = Gtk::FileFilter::create();
+ auto allInkscapeFilter = Gtk::FileFilter::create();
allInkscapeFilter->set_name(_("All Inkscape Files"));
- Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create();
+ auto allFilter = Gtk::FileFilter::create();
allFilter->set_name(_("All Files"));
allFilter->add_pattern("*");
- Glib::RefPtr<Gtk::FileFilter> allImageFilter = Gtk::FileFilter::create();
+ auto allImageFilter = Gtk::FileFilter::create();
allImageFilter->set_name(_("All Images"));
- Glib::RefPtr<Gtk::FileFilter> allVectorFilter = Gtk::FileFilter::create();
+ auto allVectorFilter = Gtk::FileFilter::create();
allVectorFilter->set_name(_("All Vectors"));
- Glib::RefPtr<Gtk::FileFilter> allBitmapFilter = Gtk::FileFilter::create();
+ auto allBitmapFilter = Gtk::FileFilter::create();
allBitmapFilter->set_name(_("All Bitmaps"));
-#else
- Gtk::FileFilter allInkscapeFilter;
- allInkscapeFilter.set_name(_("All Inkscape Files"));
-
- Gtk::FileFilter allFilter;
- allFilter.set_name(_("All Files"));
- allFilter.add_pattern("*");
-
- Gtk::FileFilter allImageFilter;
- allImageFilter.set_name(_("All Images"));
-
- Gtk::FileFilter allVectorFilter;
- allVectorFilter.set_name(_("All Vectors"));
-
- Gtk::FileFilter allBitmapFilter;
- allBitmapFilter.set_name(_("All Bitmaps"));
-#endif
extensionMap[Glib::ustring(_("All Inkscape Files"))] = NULL;
add_filter(allInkscapeFilter);
@@ -854,29 +822,16 @@ void FileOpenDialogImplGtk::createFilterMenu()
Glib::ustring uname(_(imod->get_filetypename()));
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
+ auto filter = Gtk::FileFilter::create();
filter->set_name(uname);
filter->add_pattern(upattern);
-#else
- Gtk::FileFilter filter;
- filter.set_name(uname);
- filter.add_pattern(upattern);
-#endif
-
add_filter(filter);
extensionMap[uname] = imod;
// g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str());
-#if WITH_GTKMM_3_0
allInkscapeFilter->add_pattern(upattern);
if (strncmp("image", imod->get_mimetype(), 5) == 0)
allImageFilter->add_pattern(upattern);
-#else
- allInkscapeFilter.add_pattern(upattern);
- if (strncmp("image", imod->get_mimetype(), 5) == 0)
- allImageFilter.add_pattern(upattern);
-#endif
// uncomment this to find out all mime types supported by Inkscape import/open
// g_print ("%s\n", imod->get_mimetype());
@@ -896,17 +851,9 @@ void FileOpenDialogImplGtk::createFilterMenu()
strncmp("image/x-tga", imod->get_mimetype(), 11) == 0 ||
strncmp("image/x-pcx", imod->get_mimetype(), 11) == 0)
{
-#if WITH_GTKMM_3_0
allBitmapFilter->add_pattern(upattern);
-#else
- allBitmapFilter.add_pattern(upattern);
-#endif
} else {
-#if WITH_GTKMM_3_0
allVectorFilter->add_pattern(upattern);
-#else
- allVectorFilter.add_pattern(upattern);
-#endif
}
}
}
@@ -972,18 +919,13 @@ Glib::ustring FileOpenDialogImplGtk::getFilename(void)
*/
std::vector<Glib::ustring> FileOpenDialogImplGtk::getFilenames()
{
-#if WITH_GTKMM_3_0
- std::vector<std::string> result_tmp = get_filenames();
+ auto result_tmp = get_filenames();
// Copy filenames to a vector of type Glib::ustring
std::vector<Glib::ustring> result;
- for (std::vector<std::string>::iterator it = result_tmp.begin(); it != result_tmp.end(); ++it)
- result.push_back(*it);
-
-#else
- std::vector<Glib::ustring> result = get_filenames();
-#endif
+ for (auto it : result_tmp)
+ result.push_back(it);
#ifdef WITH_GNOME_VFS
if (result.empty() && gnome_vfs_initialized())
@@ -1107,8 +1049,8 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl
// if (extension == NULL)
// checkbox.set_sensitive(FALSE);
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK));
+ add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
+ set_default(*add_button(_("_Save"), Gtk::RESPONSE_OK));
show_all_children();
}
@@ -1170,13 +1112,8 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback()
// g_message("selected: %s\n", type.name.c_str());
extension = type.extension;
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create();
+ auto filter = Gtk::FileFilter::create();
filter->add_pattern(type.pattern);
-#else
- Gtk::FileFilter filter;
- filter.add_pattern(type.pattern);
-#endif
set_filter(filter);
updateNameAndExtension();
@@ -1659,8 +1596,8 @@ FileExportDialogImpl::FileExportDialogImpl(Gtk::Window &parentWindow, const Glib
// if (extension == NULL)
// checkbox.set_sensitive(FALSE);
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK));
+ add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
+ set_default(*add_button(_("_Save"), Gtk::RESPONSE_OK));
show_all_children();
}
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index cafc3be4f..1efec7d52 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -18,38 +18,23 @@
#endif
#include "filedialogimpl-win32.h"
//General includes
-#include <list>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <set>
+#include <cairomm/win32_surface.h>
#include <gdk/gdkwin32.h>
-#include <glib/gstdio.h>
-#include <glibmm/i18n.h>
+#include <gdkmm/general.h>
#include <glibmm/fileutils.h>
-#include <gtkmm/window.h>
+#include <glibmm/i18n.h>
//Inkscape includes
-#include "inkscape.h"
-#include "ui/dialog-events.h"
+#include "display/cairo-utils.h"
+#include "document.h"
+#include "extension/db.h"
#include "extension/input.h"
#include "extension/output.h"
-#include "extension/db.h"
-
-//#include "display/drawing-item.h"
-//#include "display/drawing.h"
-#include "sp-item.h"
-#include "display/canvas-arena.h"
-
#include "filedialog.h"
-
-#include "sp-root.h"
+#include "helper/pixbuf-ops.h"
#include "preferences.h"
+#include "util/units.h"
-#include <zlib.h>
-#include <cairomm/win32_surface.h>
-#include <cairomm/context.h>
-#include <gdkmm/general.h>
using namespace std;
using namespace Glib;
@@ -128,11 +113,7 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent,
Glib::RefPtr<const Gdk::Window> parentWindow = parent.get_window();
g_assert(parentWindow->gobj() != NULL);
-#if WITH_GTKMM_3_0
_ownerHwnd = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj());
-#else
- _ownerHwnd = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj());
-#endif
}
FileDialogBaseWin32::~FileDialogBaseWin32()
@@ -811,7 +792,7 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg,
_wsplitpath(pImpl->_path_string, NULL, NULL, szFileName, NULL);
const int iLength = snwprintf(szCaption,
- sizeof(szCaption), L"%s\n%d kB",
+ sizeof(szCaption), L"%ls\n%d kB",
szFileName, pImpl->_preview_file_size);
DrawTextW(dc, szCaption, iLength, &rcCaptionRect,
@@ -1024,15 +1005,11 @@ void FileOpenDialogImplWin32::free_preview()
bool FileOpenDialogImplWin32::set_svg_preview()
{
- return false;
- // NOTE: it's not worth the effort to fix this to use Cairo.
- // Native file dialogs are unmaintainable and should be removed anyway.
- #if 0
const int PreviewSize = 512;
gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string,
_MAX_PATH, NULL, NULL, NULL);
- SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, true);
+ SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, 0);
g_free(utf8string);
// Check the document loaded properly
@@ -1046,87 +1023,39 @@ bool FileOpenDialogImplWin32::set_svg_preview()
}
// Get the size of the document
- const double svgWidth = svgDoc->getWidth();
- const double svgHeight = svgDoc->getHeight();
+ Inkscape::Util::Quantity svgWidth = svgDoc->getWidth();
+ Inkscape::Util::Quantity svgHeight = svgDoc->getHeight();
+ const double svgWidth_px = svgWidth.value("px");
+ const double svgHeight_px = svgHeight.value("px");
// Find the minimum scale to fit the image inside the preview area
- const double scaleFactorX = PreviewSize / svgWidth;
- const double scaleFactorY = PreviewSize / svgHeight;
+ const double scaleFactorX = PreviewSize / svgWidth_px;
+ const double scaleFactorY = PreviewSize / svgHeight_px;
const double scaleFactor = (scaleFactorX > scaleFactorY) ? scaleFactorY : scaleFactorX;
// Now get the resized values
- const double scaledSvgWidth = scaleFactor * svgWidth;
- const double scaledSvgHeight = scaleFactor * svgHeight;
-
- Geom::Rect area(Geom::Point(0, 0), Geom::Point(scaledSvgWidth, scaledSvgHeight));
- NRRectL areaL = {0, 0, scaledSvgWidth, scaledSvgHeight};
- NRRectL bbox = {0, 0, scaledSvgWidth, scaledSvgHeight};
-
- // write object bbox to area
- svgDoc->ensureUpToDate();
- Geom::OptRect maybeArea = area | svgDoc->getRoot()->desktopVisualBounds();
-
- NRArena *const arena = NRArena::create();
-
- unsigned const key = SPItem::display_key_new(1);
-
- NRArenaItem *root = svgDoc->getRoot()->invoke_show(
- arena, key, SP_ITEM_SHOW_DISPLAY);
+ const int scaledSvgWidth = round(scaleFactor * svgWidth_px);
+ const int scaledSvgHeight = round(scaleFactor * svgHeight_px);
- NRGC gc(NULL);
- gc.transform = Geom::Affine(Geom::Scale(scaleFactor, scaleFactor));
-
- nr_arena_item_invoke_update (root, NULL, &gc,
- NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
-
- // Prepare a GDI compatible NRPixBlock
- NRPixBlock pixBlock;
- pixBlock.size = NR_PIXBLOCK_SIZE_BIG;
- pixBlock.mode = NR_PIXBLOCK_MODE_R8G8B8;
- pixBlock.empty = 1;
- pixBlock.visible_area.x0 = pixBlock.area.x0 = 0;
- pixBlock.visible_area.y0 = pixBlock.area.y0 = 0;
- pixBlock.visible_area.x1 = pixBlock.area.x1 = scaledSvgWidth;
- pixBlock.visible_area.y1 = pixBlock.area.y1 = scaledSvgHeight;
- pixBlock.rs = 4 * ((3 * (int)scaledSvgWidth + 3) / 4);
- pixBlock.data.px = g_try_new (unsigned char, pixBlock.rs * scaledSvgHeight);
-
- // Fail if the pixblock failed to allocate
- if(pixBlock.data.px == NULL)
- {
- svgDoc->doUnref();
- return false;
- }
-
- memset(pixBlock.data.px, 0xFF, pixBlock.rs * scaledSvgHeight);
-
- memcpy(&root->bbox, &areaL, sizeof(areaL));
-
- // Render the image
- nr_arena_item_invoke_render(NULL, root, &bbox, &pixBlock, /*0*/NR_ARENA_ITEM_RENDER_NO_CACHE);
+ const double dpi = 96*scaleFactor;
+ Inkscape::Pixbuf * pixbuf = sp_generate_internal_bitmap(svgDoc, NULL, 0, 0, svgWidth_px, svgHeight_px, scaledSvgWidth, scaledSvgHeight, dpi, dpi, (guint32) 0xffffff00, NULL);
// Tidy up
svgDoc->doUnref();
- svgDoc->getRoot()->invoke_hide(key);
- nr_object_unref((NRObject *) arena);
+ if (pixbuf == NULL) {
+ return false;
+ }
// Create the GDK pixbuf
_mutex->lock();
-
- _preview_bitmap_image = Gdk::Pixbuf::create_from_data(
- pixBlock.data.px, Gdk::COLORSPACE_RGB, false, 8,
- (int)scaledSvgWidth, (int)scaledSvgHeight, pixBlock.rs,
- sigc::ptr_fun(destroy_svg_rendering));
-
- _preview_document_width = scaledSvgWidth;
- _preview_document_height = scaledSvgHeight;
- _preview_image_width = svgWidth;
- _preview_image_height = svgHeight;
-
+ _preview_bitmap_image = Glib::wrap(pixbuf->getPixbufRaw());
+ _preview_document_width = svgWidth_px;
+ _preview_document_height = svgHeight_px;
+ _preview_image_width = scaledSvgWidth;
+ _preview_image_height = scaledSvgHeight;
_mutex->unlock();
return true;
- #endif
}
void FileOpenDialogImplWin32::destroy_svg_rendering(const guint8 *buffer)
@@ -1305,17 +1234,8 @@ bool FileOpenDialogImplWin32::set_emf_preview()
const double emfWidth = w;
const double emfHeight = h;
- // Find the minimum scale to fit the image inside the preview area
- const double scaleFactorX = PreviewSize / emfWidth;
- const double scaleFactorY = PreviewSize / emfHeight;
- const double scaleFactor = (scaleFactorX > scaleFactorY) ? scaleFactorY : scaleFactorX;
-
- // Now get the resized values
- const double scaledEmfWidth = scaleFactor * emfWidth;
- const double scaledEmfHeight = scaleFactor * emfHeight;
-
- _preview_document_width = scaledEmfWidth;
- _preview_document_height = scaledEmfHeight;
+ _preview_document_width = emfWidth / 2540 * 96; // width is in units of 0.01 mm
+ _preview_document_height = emfHeight / 2540 * 96; // height is in units of 0.01 mm
_preview_image_width = emfWidth;
_preview_image_height = emfHeight;
@@ -1374,17 +1294,13 @@ void FileOpenDialogImplWin32::render_preview()
}
// Find the minimum scale to fit the image inside the preview area
- const double scaleFactorX =
- ((double)_preview_width - pagePadding * 2 - blurRadius) / _preview_document_width;
- const double scaleFactorY =
- ((double)_preview_height - pagePadding * 2
- - shaddowOffsetY - halfBlurRadius - captionHeight) / _preview_document_height;
- double scaleFactor = (scaleFactorX > scaleFactorY) ? scaleFactorY : scaleFactorX;
- scaleFactor = (scaleFactor > 1.0) ? 1.0 : scaleFactor;
+ const double scaleFactorX = ((double)_preview_width - pagePadding * 2 - blurRadius) / _preview_image_width;
+ const double scaleFactorY = ((double)_preview_height - pagePadding * 2 - shaddowOffsetY - halfBlurRadius - captionHeight) / _preview_image_height;
+ const double scaleFactor = (scaleFactorX > scaleFactorY) ? scaleFactorY : scaleFactorX;
// Now get the resized values
- const double scaledSvgWidth = scaleFactor * _preview_document_width;
- const double scaledSvgHeight = scaleFactor * _preview_document_height;
+ const double scaledSvgWidth = scaleFactor * _preview_image_width;
+ const double scaledSvgHeight = scaleFactor * _preview_image_height;
const int svgX = pagePadding + halfBlurRadius;
const int svgY = pagePadding;
@@ -1569,7 +1485,7 @@ int FileOpenDialogImplWin32::format_caption(wchar_t *caption, int caption_size)
_wsplitpath(_path_string, NULL, NULL, szFileName, NULL);
return snwprintf(caption, caption_size,
- L"%s\n%d kB\n%d \xD7 %d", szFileName, _preview_file_size,
+ L"%ls\n%d\u2009kB\n%d\u2009px \xD7 %d\u2009px", szFileName, _preview_file_size,
(int)_preview_document_width, (int)_preview_document_height);
}
@@ -1975,18 +1891,18 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
if(dlgFont) SendMessage(pImpl->_title_edit, WM_SETFONT, (WPARAM)dlgFont, MAKELPARAM(FALSE, 0));
SetWindowPos(pImpl->_title_edit, NULL, rCB1.left-rROOT.left, rCB1.top+ydelta-rROOT.top,
rCB1.right-rCB1.left, rCB1.bottom-rCB1.top, SWP_SHOWWINDOW|SWP_NOZORDER);
- // TODO: make sure this works for Unicode
- SetWindowText(pImpl->_title_edit, pImpl->myDocTitle.c_str());
+ SetWindowTextW(pImpl->_title_edit,
+ (const wchar_t*)g_utf8_to_utf16(pImpl->myDocTitle.c_str(), -1, NULL, NULL, NULL));
}
}
break;
case WM_DESTROY:
{
if(pImpl->_title_edit) {
- int length = GetWindowTextLength(pImpl->_title_edit)+1;
- char* temp_title = new char[length];
- GetWindowText(pImpl->_title_edit, temp_title, length);
- pImpl->myDocTitle = temp_title;
+ int length = GetWindowTextLengthW(pImpl->_title_edit)+1;
+ wchar_t* temp_title = new wchar_t[length];
+ GetWindowTextW(pImpl->_title_edit, temp_title, length);
+ pImpl->myDocTitle = g_utf16_to_utf8((gunichar2*)temp_title, -1, NULL, NULL, NULL);
delete[] temp_title;
DestroyWindow(pImpl->_title_label);
pImpl->_title_label = NULL;
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index 8141f7696..0b3b468e9 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -22,7 +22,6 @@
#include "fill-and-stroke.h"
#include "filter-chemistry.h"
#include "inkscape.h"
-#include "selection.h"
#include "preferences.h"
#include "style.h"
#include "svg/css-ostringstream.h"
@@ -32,12 +31,9 @@
#include "widgets/icon.h"
#include "widgets/paint-selector.h"
#include "widgets/stroke-style.h"
-#include "xml/repr.h"
#include "ui/view/view-widget.h"
-#include <gtkmm/table.h>
-
namespace Inkscape {
namespace UI {
namespace Dialog {
@@ -111,11 +107,7 @@ void FillAndStroke::setTargetDesktop(SPDesktop *desktop)
}
}
-#if WITH_GTKMM_3_0
void FillAndStroke::_onSwitchPage(Gtk::Widget * /*page*/, guint pagenum)
-#else
-void FillAndStroke::_onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum)
-#endif
{
_savePagePref(pagenum);
}
@@ -132,24 +124,14 @@ void
FillAndStroke::_layoutPageFill()
{
fillWdgt = Gtk::manage(sp_fill_style_widget_new());
-
-#if WITH_GTKMM_3_0
_page_fill->table().attach(*fillWdgt, 0, 0, 1, 1);
-#else
- _page_fill->table().attach(*fillWdgt, 0, 1, 0, 1);
-#endif
}
void
FillAndStroke::_layoutPageStrokePaint()
{
strokeWdgt = Gtk::manage(sp_stroke_style_paint_widget_new());
-
-#if WITH_GTKMM_3_0
_page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1);
-#else
- _page_stroke_paint->table().attach(*strokeWdgt, 0, 1, 0, 1);
-#endif
}
void
@@ -158,12 +140,7 @@ FillAndStroke::_layoutPageStrokeStyle()
//Gtk::Widget *strokeStyleWdgt = manage(Glib::wrap(sp_stroke_style_line_widget_new()));
//Gtk::Widget *strokeStyleWdgt = static_cast<Gtk::Widget *>(sp_stroke_style_line_widget_new());
strokeStyleWdgt = sp_stroke_style_line_widget_new();
-
-#if WITH_GTKMM_3_0
_page_stroke_style->table().attach(*strokeStyleWdgt, 0, 0, 1, 1);
-#else
- _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 1, 0, 1);
-#endif
}
void
diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h
index f2a6bf39d..67e9d60ed 100644
--- a/src/ui/dialog/fill-and-stroke.h
+++ b/src/ui/dialog/fill-and-stroke.h
@@ -64,11 +64,7 @@ protected:
void _layoutPageStrokePaint();
void _layoutPageStrokeStyle();
void _savePagePref(guint page_num);
-#if WITH_GTKMM_3_0
void _onSwitchPage(Gtk::Widget *page, guint pagenum);
-#else
- void _onSwitchPage(GtkNotebookPage *page, guint pagenum);
-#endif
private:
FillAndStroke(FillAndStroke const &d);
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index d3ad5d1da..80dc08ccf 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -16,71 +16,56 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "dialog-manager.h"
#include <gtkmm/imagemenuitem.h>
-#if GTK_CHECK_VERSION(3,0,0)
+#include <gdkmm/display.h>
+#if GTK_CHECK_VERSION(3, 20, 0)
+# include <gdkmm/seat.h>
+#else
# include <gdkmm/devicemanager.h>
#endif
#include "ui/widget/spinbutton.h"
-#include <glibmm/convert.h>
#include <glibmm/i18n.h>
-#include <glibmm/main.h>
#include <glibmm/stringutils.h>
+#include <glibmm/main.h>
+#include <glibmm/convert.h>
#include "desktop.h"
-#include "dir-util.h"
#include "document.h"
#include "document-undo.h"
#include "filter-chemistry.h"
#include "filter-effects-dialog.h"
#include "filter-enums.h"
#include "inkscape.h"
-#include "path-prefix.h"
-#include "preferences.h"
-#include "selection.h"
#include "filters/blend.h"
#include "filters/colormatrix.h"
#include "filters/componenttransfer.h"
#include "filters/componenttransfer-funcnode.h"
-#include "filters/composite.h"
#include "filters/convolvematrix.h"
-#include "filters/displacementmap.h"
#include "filters/distantlight.h"
-#include "filters/gaussian-blur.h"
#include "filters/merge.h"
#include "filters/mergenode.h"
-#include "filters/offset.h"
#include "filters/pointlight.h"
#include "filters/spotlight.h"
-#include "sp-filter-primitive.h"
#include "style.h"
#include "svg/svg-color.h"
-#include "svg/stringstream.h"
#include "ui/dialog/filedialog.h"
#include "verbs.h"
-#include "xml/node.h"
-#include "xml/node-observer.h"
-#include "xml/repr.h"
-#include <sstream>
#include "io/sys.h"
-#include <iostream>
#include "selection-chemistry.h"
-#include <gtkmm/checkbutton.h>
#include <gtkmm/colorbutton.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/stock.h>
#include <gdkmm/general.h>
+#include <gtkmm/checkbutton.h>
using namespace Inkscape::Filters;
@@ -103,9 +88,7 @@ static int input_count(const SPFilterPrimitive* prim)
return 2;
else if(SP_IS_FEMERGE(prim)) {
// Return the number of feMergeNode connections plus an extra
- int count = 1;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){};
- return count;
+ return (int) (prim->children.size() + 1);
}
else
return 1;
@@ -319,15 +302,9 @@ public:
set_tooltip_text(tip_text);
}
-#if WITH_GTKMM_3_0
Gdk::RGBA col;
col.set_rgba_u(65535, 65535, 65535);
set_rgba(col);
-#else
- Gdk::Color col;
- col.set_rgb(65535, 65535, 65535);
- set_color(col);
-#endif
}
// Returns the color in 'rgb(r,g,b)' form.
@@ -336,13 +313,8 @@ public:
// no doubles here, so we can use the standard string stream.
std::ostringstream os;
-#if WITH_GTKMM_3_0
- const Gdk::RGBA c = get_rgba();
- const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256?
-#else
- const Gdk::Color c = get_color();
- const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256?
-#endif
+ const auto c = get_rgba();
+ const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256?
os << "rgb(" << r << "," << g << "," << b << ")";
return os.str();
}
@@ -359,15 +331,9 @@ public:
}
const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i);
-#if WITH_GTKMM_3_0
Gdk::RGBA col;
col.set_rgba_u(r * 256, g * 256, b * 256);
set_rgba(col);
-#else
- Gdk::Color col;
- col.set_rgb(r * 256, g * 256, b * 256);
- set_color(col);
-#endif
}
};
@@ -691,7 +657,7 @@ private:
void select_svg_element(){
Inkscape::Selection* sel = _desktop->getSelection();
if (sel->isEmpty()) return;
- Inkscape::XML::Node* node = sel->reprList()[0];
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node || !node->matchAttributeName("id")) return;
std::ostringstream xlikhref;
@@ -893,6 +859,17 @@ public:
return dss;
}
+ // SpinButton
+ SpinButtonAttr* add_spinbutton(double defalt_value, const SPAttributeEnum attr, const Glib::ustring& label,
+ const double lo, const double hi, const double step_inc,
+ const double climb, const int digits, char* tip = NULL)
+ {
+ SpinButtonAttr* sb = new SpinButtonAttr(lo, hi, step_inc, climb, digits, attr, defalt_value, tip);
+ add_widget(sb, label);
+ add_attr_widget(sb);
+ return sb;
+ }
+
// DualSpinButton
DualSpinButton* add_dualspinbutton(char* defalt_value, const SPAttributeEnum attr, const Glib::ustring& label,
const double lo, const double hi, const double step_inc,
@@ -1060,11 +1037,10 @@ public:
// FuncNode can be in any order so we must search to find correct one.
SPFeFuncNode* find_node(SPFeComponentTransfer* ct)
{
- SPObject* node = ct->children;
SPFeFuncNode* funcNode = NULL;
bool found = false;
- for(;node;node=node->next){
- funcNode = SP_FEFUNCNODE(node);
+ for(auto& node: ct->children) {
+ funcNode = SP_FEFUNCNODE(&node);
if( funcNode->channel == _channel ) {
found = true;
break;
@@ -1228,7 +1204,7 @@ protected:
_locked = true;
- SPObject* child = o->children;
+ SPObject* child = o->firstChild();
if(SP_IS_FEDISTANTLIGHT(child))
_light_source.set_active(0);
@@ -1253,7 +1229,7 @@ private:
if(prim) {
_locked = true;
- SPObject* child = prim->children;
+ SPObject* child = prim->firstChild();
const int ls = _light_source.get_active_row_number();
// Check if the light source type has changed
if(!(ls == -1 && !child) &&
@@ -1287,8 +1263,8 @@ private:
_light_box.show_all();
SPFilterPrimitive* prim = _dialog._primitive_list.get_selected();
- if(prim && prim->children)
- _settings.show_and_update(_light_source.get_active_data()->id, prim->children);
+ if(prim && prim->firstChild())
+ _settings.show_and_update(_light_source.get_active_data()->id, prim->firstChild());
}
FilterEffectsDialog& _dialog;
@@ -1328,7 +1304,7 @@ static Glib::RefPtr<Gtk::Menu> create_popup_menu(Gtk::Widget& parent, sigc::slot
mi->show();
menu->append(*mi);
- mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
menu->append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -1342,7 +1318,7 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d)
: _desktop(NULL),
_deskTrack(),
_dialog(d),
- _add(Gtk::Stock::NEW),
+ _add(_("_New"), true),
_observer(new Inkscape::XML::SignalObserver)
{
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow);
@@ -1474,8 +1450,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel)
}
std::set<SPObject*> used;
- std::vector<SPItem*> itemlist=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= sel->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
SPObject *obj = *i;
SPStyle *style = obj->style;
if (!style || !SP_IS_ITEM(obj)) {
@@ -1555,8 +1531,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
if((*iter)[_columns.sel] == 1)
filter = 0;
- std::vector<SPItem*> itemlist=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= sel->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
SPItem * item = *i;
SPStyle *style = item->style;
g_assert(style != NULL);
@@ -1730,7 +1706,6 @@ Glib::PropertyProxy<void*> FilterEffectsDialog::CellRendererConnection::property
return _primitive.get_proxy();
}
-#if WITH_GTKMM_3_0
void FilterEffectsDialog::CellRendererConnection::get_preferred_width_vfunc(Gtk::Widget& widget,
int& minimum_width,
int& natural_width) const
@@ -1764,27 +1739,6 @@ void FilterEffectsDialog::CellRendererConnection::get_preferred_height_for_width
{
get_preferred_height(widget, minimum_height, natural_height);
}
-#else
-void FilterEffectsDialog::CellRendererConnection::get_size_vfunc(
- Gtk::Widget& widget, const Gdk::Rectangle* /*cell_area*/,
- int* x_offset, int* y_offset, int* width, int* height) const
-{
- PrimitiveList& primlist = dynamic_cast<PrimitiveList&>(widget);
-
- if(x_offset)
- (*x_offset) = 0;
- if(y_offset)
- (*y_offset) = 0;
- if(width)
- (*width) = size * primlist.primitive_count() + (primlist.get_input_type_width()) * 6;
- if(height) {
- // Scale the height depending on the number of inputs, unless it's
- // the first primitive, in which case there are no connections
- SPFilterPrimitive* prim = SP_FILTER_PRIMITIVE(_primitive.get_value());
- (*height) = size * input_count(prim);
- }
-}
-#endif
/*** PrimitiveList ***/
FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d)
@@ -1792,13 +1746,8 @@ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d)
_in_drag(0),
_observer(new Inkscape::XML::SignalObserver)
{
-#if WITH_GTKMM_3_0
d.signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal));
signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal));
-#else
- d.signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal));
- signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal));
-#endif
add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
@@ -1871,26 +1820,25 @@ void FilterEffectsDialog::PrimitiveList::update()
bool active_found = false;
_dialog._primitive_box->set_sensitive(true);
_dialog.update_filter_general_settings_view();
- for(SPObject *prim_obj = f->children;
- prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj);
- prim_obj = prim_obj->next) {
- SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(prim_obj);
- if(prim) {
- Gtk::TreeModel::Row row = *_model->append();
- row[_columns.primitive] = prim;
-
- //XML Tree being used directly here while it shouldn't be.
- row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name());
- row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
-
- if (prim->getId()) {
- row[_columns.id] = Glib::ustring(prim->getId());
- }
-
- if(prim == active_prim) {
- get_selection()->select(row);
- active_found = true;
- }
+ for(auto& prim_obj: f->children) {
+ SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj);
+ if(!prim) {
+ break;
+ }
+ Gtk::TreeModel::Row row = *_model->append();
+ row[_columns.primitive] = prim;
+
+ //XML Tree being used directly here while it shouldn't be.
+ row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name());
+ row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
+
+ if (prim->getId()) {
+ row[_columns.id] = Glib::ustring(prim->getId());
+ }
+
+ if(prim == active_prim) {
+ get_selection()->select(row);
+ active_found = true;
}
}
@@ -1961,25 +1909,9 @@ void FilterEffectsDialog::PrimitiveList::remove_selected()
}
}
-#if !WITH_GTKMM_3_0
-bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose * /*evt*/)
-{
- bool result = false;
-
- if (get_is_drawable())
- {
- Cairo::RefPtr<Cairo::Context> cr = get_bin_window()->create_cairo_context();
- result = on_draw_signal(cr);
- }
-
- return result;
-}
-#endif
-
bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cairo::Context> & cr)
{
cr->set_line_width(1.0);
-#if GTK_CHECK_VERSION(3,0,0)
// In GTK+ 3, the draw function receives the widget window, not the
// bin_window (i.e., just the area under the column headers). We
// therefore translate the origin of our coordinate system to account for this
@@ -1987,7 +1919,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
convert_bin_window_to_widget_coords(0,0,x_origin,y_origin);
cr->translate(x_origin, y_origin);
- GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj()));
+ auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj()));
GdkRGBA bg_color, fg_color;
gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color);
gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color);
@@ -2005,9 +1937,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
(bg_color_active.green + fg_color_active.green)/2.0,
(bg_color_active.blue + fg_color_active.blue)/2.0,
(bg_color_active.alpha + fg_color_active.alpha)/2.0};
-#else
- GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj()));
-#endif
SPFilterPrimitive* prim = get_selected();
int row_count = get_model()->children().size();
@@ -2026,25 +1955,15 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
const int x = text_start_x + get_input_type_width() * i;
cr->save();
cr->rectangle(x, 0, get_input_type_width(), vis.get_height());
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(), &bg_color);
cr->fill_preserve();
gdk_cairo_set_source_rgba(cr->cobj(), &fg_color);
-#else
- gdk_cairo_set_source_color(cr->cobj(), &(style->bg[GTK_STATE_NORMAL]));
- cr->fill_preserve();
- gdk_cairo_set_source_color(cr->cobj(), &(style->text[GTK_STATE_NORMAL]));
-#endif
cr->move_to(x+get_input_type_width(), 0);
cr->rotate_degrees(90);
_vertical_layout->show_in_cairo_context(cr);
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(), &mid_color);
-#else
- gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL]));
-#endif
cr->move_to(x, 0);
cr->line_to(x, vis.get_height());
cr->stroke();
@@ -2061,24 +1980,21 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
int mx, my;
Gdk::ModifierType mask;
-#if GTK_CHECK_VERSION(3,0,0)
- Glib::RefPtr<Gdk::Display> display = get_bin_window()->get_display();
- Glib::RefPtr<Gdk::DeviceManager> dm = display->get_device_manager();
- Glib::RefPtr<const Gdk::Device> device = dm->get_client_pointer();
- get_bin_window()->get_device_position(device, mx, my, mask);
+ auto display = get_bin_window()->get_display();
+#if GTK_CHECK_VERSION(3, 20, 0)
+ auto seat = display->get_default_seat();
+ auto device = seat->get_pointer();
#else
- get_bin_window()->get_pointer(mx, my, mask);
+ auto dm = display->get_device_manager();
+ auto device = dm->get_client_pointer();
#endif
+ get_bin_window()->get_device_position(device, mx, my, mask);
// Outline the bottom of the connection area
const int outline_x = x + fheight * (row_count - row_index);
cr->save();
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(), &mid_color);
-#else
- gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL]));
-#endif
cr->move_to(x, y + h);
cr->line_to(outline_x, y + h);
@@ -2101,17 +2017,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
cr->save();
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(),
inside && mask & GDK_BUTTON1_MASK ?
&mid_color :
&mid_color_active);
-#else
- gdk_cairo_set_source_color(cr->cobj(),
- inside && mask & GDK_BUTTON1_MASK ?
- &(style->dark[GTK_STATE_NORMAL]) :
- &(style->dark[GTK_STATE_ACTIVE]));
-#endif
draw_connection_node(cr, con_poly, inside);
@@ -2137,17 +2046,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
cr->save();
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(),
inside && mask & GDK_BUTTON1_MASK ?
&mid_color :
&mid_color_active);
-#else
- gdk_cairo_set_source_color(cr->cobj(),
- inside && mask & GDK_BUTTON1_MASK ?
- &(style->dark[GTK_STATE_NORMAL]) :
- &(style->dark[GTK_STATE_ACTIVE]));
-#endif
draw_connection_node(cr, con_poly, inside);
@@ -2170,17 +2072,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair
cr->save();
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(),
inside && mask & GDK_BUTTON1_MASK ?
&mid_color :
&mid_color_active);
-#else
- gdk_cairo_set_source_color(cr->cobj(),
- inside && mask & GDK_BUTTON1_MASK ?
- &(style->dark[GTK_STATE_NORMAL]) :
- &(style->dark[GTK_STATE_ACTIVE]));
-#endif
draw_connection_node(cr, con_poly, inside);
@@ -2216,8 +2111,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
{
cr->save();
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj()));
+ auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj()));
GdkRGBA bg_color, fg_color;
gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color);
@@ -2227,9 +2121,6 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
(bg_color.green + fg_color.green)/2.0,
(bg_color.blue + fg_color.blue)/2.0,
(bg_color.alpha + fg_color.alpha)/2.0};
-#else
- GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj()));
-#endif
int src_id = 0;
Gtk::TreeIter res = find_result(input, attr, src_id);
@@ -2245,11 +2136,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1;
if(use_default && is_first)
-#if GTK_CHECK_VERSION(3,0,0)
gdk_cairo_set_source_rgba(cr->cobj(), &mid_color);
-#else
- gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL]));
-#endif
else
cr->set_source_rgb(0.0, 0.0, 0.0);
@@ -2343,11 +2230,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T
if(SP_IS_FEMERGE(prim)) {
int c = 0;
bool found = false;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) {
- if(c == attr && SP_IS_FEMERGENODE(o)) {
- image = SP_FEMERGENODE(o)->input;
+ for (auto& o: prim->children) {
+ if(c == attr && SP_IS_FEMERGENODE(&o)) {
+ image = SP_FEMERGENODE(&o)->input;
found = true;
}
+ ++c;
}
if(!found)
return target;
@@ -2534,21 +2422,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
if(SP_IS_FEMERGE(prim)) {
int c = 1;
bool handled = false;
- for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) {
- if(c == _in_drag && SP_IS_FEMERGENODE(o)) {
+ for (auto& o: prim->children) {
+ if(c == _in_drag && SP_IS_FEMERGENODE(&o)) {
// If input is null, delete it
if(!in_val) {
//XML Tree being used directly here while it shouldn't be.
- sp_repr_unparent(o->getRepr());
+ sp_repr_unparent(o.getRepr());
DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS,
_("Remove merge node"));
(*get_selection()->get_selected())[_columns.primitive] = prim;
+ } else {
+ _dialog.set_attr(&o, SP_ATTR_IN, in_val);
}
- else
- _dialog.set_attr(o, SP_ATTR_IN, in_val);
handled = true;
+ break;
}
+ ++c;
}
// Add new input?
if(!handled && c == _in_drag && in_val) {
@@ -2669,8 +2559,7 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra
bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout()
{
if(_autoscroll_y) {
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> a = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment();
+ auto a = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment();
double v = a->get_value() + _autoscroll_y;
if(v < 0)
@@ -2679,25 +2568,13 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout()
v = a->get_upper() - a->get_page_size();
a->set_value(v);
-#else
- Gtk::Adjustment& a = *dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment();
- double v = a.get_value() + _autoscroll_y;
-
- if(v < 0)
- v = 0;
- if(v > a.get_upper() - a.get_page_size())
- v = a.get_upper() - a.get_page_size();
-
- a.set_value(v);
-#endif
queue_draw();
}
if(_autoscroll_x) {
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> a_h = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment();
+ auto a_h = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment();
double h = a_h->get_value() + _autoscroll_x;
if(h < 0)
@@ -2706,18 +2583,6 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout()
h = a_h->get_upper() - a_h->get_page_size();
a_h->set_value(h);
-#else
- Gtk::Adjustment& a_h = *dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment();
- double h = a_h.get_value() + _autoscroll_x;
-
- if(h < 0)
- h = 0;
- if(h > a_h.get_upper() - a_h.get_page_size())
- h = a_h.get_upper() - a_h.get_page_size();
-
- a_h.set_value(h);
-
-#endif
queue_draw();
}
@@ -2759,13 +2624,8 @@ FilterEffectsDialog::FilterEffectsDialog()
_sizegroup->set_ignore_hidden();
// Initialize widget hierarchy
-#if WITH_GTKMM_3_0
- Gtk::Paned* hpaned = Gtk::manage(new Gtk::Paned);
+ auto hpaned = Gtk::manage(new Gtk::Paned);
_primitive_box = Gtk::manage(new Gtk::Paned);
-#else
- Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned);
- _primitive_box = Gtk::manage(new Gtk::VPaned);
-#endif
_sw_infobox = Gtk::manage(new Gtk::ScrolledWindow);
Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow);
@@ -2935,8 +2795,14 @@ void FilterEffectsDialog::init_settings_widgets()
_settings->type(NR_FILTER_IMAGE);
_settings->add_fileorelement(SP_ATTR_XLINK_HREF, _("Source of Image:"));
-
+ _image_x = _settings->add_entry(SP_ATTR_X,_("X"),_("X"));
+ _image_x->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::image_x_changed));
+ //This commented because we want the default empty value of X or Y and couldent get it from SpinButton
+ //_image_y = _settings->add_spinbutton(0, SP_ATTR_Y, _("Y:"), -DBL_MAX, DBL_MAX, 1, 1, 5, _("Y"));
+ _image_y = _settings->add_entry(SP_ATTR_Y,_("Y"),_("Y"));
+ _image_y->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::image_y_changed));
_settings->type(NR_FILTER_OFFSET);
+ _settings->add_checkbutton(false, SP_ATTR_PRESERVEALPHA, _("Preserve Alpha"), "true", "false", _("If set, the alpha channel won't be altered by this filter primitive."));
_settings->add_spinscale(0, SP_ATTR_DX, _("Delta X:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted to the right"));
_settings->add_spinscale(0, SP_ATTR_DY, _("Delta Y:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted downwards"));
@@ -3076,6 +2942,33 @@ void FilterEffectsDialog::convolve_order_changed()
_convolve_target->get_spinbuttons()[1]->get_adjustment()->set_upper(_convolve_order->get_spinbutton2().get_value() - 1);
}
+bool number_or_empy(const Glib::ustring& text) {
+ if (text.empty()) {
+ return true;
+ }
+ double n = atof( text.c_str() );
+ if (n == 0.0 && strcmp(text.c_str(), "0") != 0 && strcmp(text.c_str(), "0.0") != 0) {
+ return false;
+ }
+ else {
+ return true;
+ }
+}
+
+void FilterEffectsDialog::image_x_changed()
+{
+ if (number_or_empy(_image_x->get_text())) {
+ _image_x->set_from_attribute(_primitive_list.get_selected());
+ }
+}
+
+void FilterEffectsDialog::image_y_changed()
+{
+ if (number_or_empy(_image_y->get_text())) {
+ _image_y->set_from_attribute(_primitive_list.get_selected());
+ }
+}
+
void FilterEffectsDialog::set_attr_direct(const AttrWidget* input)
{
set_attr(_primitive_list.get_selected(), input->get_attribute(), input->get_as_attribute().c_str());
@@ -3097,7 +2990,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input)
void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input)
{
- set_attr(_primitive_list.get_selected()->children, input->get_attribute(), input->get_as_attribute().c_str());
+ set_attr(_primitive_list.get_selected()->firstChild(), input->get_attribute(), input->get_as_attribute().c_str());
}
void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val)
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 7c715327e..32fabb741 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -35,6 +35,8 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
+class EntryAttr;
+//class SpinButtonAttr;
class DualSpinButton;
class MultiSpinButton;
class FilterEffectsDialog : public UI::Widget::Panel {
@@ -163,7 +165,6 @@ private:
static const int size = 24;
protected:
-#if WITH_GTKMM_3_0
virtual void get_preferred_width_vfunc(Gtk::Widget& widget,
int& minimum_width,
int& natural_width) const;
@@ -181,10 +182,6 @@ private:
int width,
int& minimum_height,
int& natural_height) const;
-#else
- virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
- int* x_offset, int* y_offset, int* width, int* height) const;
-#endif
private:
// void* should be SPFilterPrimitive*, some weirdness with properties prevents this
Glib::Property<void*> _primitive;
@@ -211,9 +208,6 @@ private:
protected:
bool on_draw_signal(const Cairo::RefPtr<Cairo::Context> &cr);
-#if !WITH_GTKMM_3_0
- bool on_expose_signal(GdkEventExpose*);
-#endif
bool on_button_press_event(GdkEventButton*);
bool on_motion_notify_event(GdkEventMotion*);
@@ -266,6 +260,8 @@ private:
void remove_primitive();
void duplicate_primitive();
void convolve_order_changed();
+ void image_x_changed();
+ void image_y_changed();
void set_attr_direct(const UI::Widget::AttrWidget*);
void set_child_attr_direct(const UI::Widget::AttrWidget*);
@@ -283,11 +279,7 @@ private:
Gtk::ScrolledWindow* _sw_infobox;
// View/add primitives
-#if WITH_GTKMM_3_0
Gtk::Paned* _primitive_box;
-#else
- Gtk::VPaned* _primitive_box;
-#endif
UI::Widget::ComboBoxEnum<Inkscape::Filters::FilterPrimitiveType> _add_primitive_type;
Gtk::Button _add_primitive;
@@ -320,6 +312,10 @@ private:
DualSpinButton* _convolve_order;
MultiSpinButton* _convolve_target;
+ // Image
+ EntryAttr* _image_x;
+ EntryAttr* _image_y;
+
// For controlling setting sensitivity
Gtk::Widget* _k1, *_k2, *_k3, *_k4;
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 0f368c5ac..b4f7902f5 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -11,30 +11,25 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "find.h"
#include <gtkmm/entry.h>
-#include <gtkmm/widget.h>
#include "verbs.h"
#include "message-stack.h"
#include "helper/window.h"
-#include "macros.h"
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
#include "document-undo.h"
-#include "selection.h"
#include "ui/dialog-events.h"
-#include "verbs.h"
#include "ui/interface.h"
-#include "preferences.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-flowdiv.h"
@@ -51,11 +46,9 @@
#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 "sp-root.h"
-#include "xml/repr.h"
#include "xml/node-iterators.h"
#include "xml/attribute-record.h"
@@ -747,22 +740,22 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- SPItem *item = dynamic_cast<SPItem *>(child);
- if (item && !child->cloned && !desktop->isLayer(item)) {
+ for (auto& child: r->children) {
+ SPItem *item = dynamic_cast<SPItem *>(&child);
+ if (item && !child.cloned && !desktop->isLayer(item)) {
if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) {
- l.insert(l.begin(),(SPItem*)child);
+ l.insert(l.begin(),(SPItem*)&child);
}
}
- l = all_items (child, l, hidden, locked);
+ l = all_items (&child, l, hidden, locked);
}
return l;
}
std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked)
{
- std::vector<SPItem*> itemlist=s->itemList();
- for(std::vector<SPItem*>::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) {
+ auto itemlist= s->items();
+ for(auto i=boost::rbegin(itemlist); boost::rend(itemlist) != i; ++i) {
SPObject *obj = *i;
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h
index 4bcb900b6..94d635037 100644
--- a/src/ui/dialog/find.h
+++ b/src/ui/dialog/find.h
@@ -286,13 +286,7 @@ private:
Gtk::Label status;
UI::Widget::Button button_find;
UI::Widget::Button button_replace;
-
-#if WITH_GTKMM_3_0
Gtk::ButtonBox box_buttons;
-#else
- Gtk::HButtonBox box_buttons;
-#endif
-
Gtk::HBox hboxbutton_row;
/**
diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp
index 55ef0c5bb..9abad3e7b 100644
--- a/src/ui/dialog/floating-behavior.cpp
+++ b/src/ui/dialog/floating-behavior.cpp
@@ -11,13 +11,11 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <gtkmm/dialog.h>
-#include <gtkmm/stock.h>
#include <glibmm/main.h>
-#include <gtk/gtk.h>
#include "floating-behavior.h"
#include "dialog.h"
@@ -26,7 +24,6 @@
#include "desktop.h"
#include "ui/dialog-events.h"
#include "ui/interface.h"
-#include "preferences.h"
#include "verbs.h"
namespace Inkscape {
@@ -140,11 +137,7 @@ FloatingBehavior::create(Dialog &dialog)
inline FloatingBehavior::operator Gtk::Widget &() { return *_d; }
inline GtkWidget *FloatingBehavior::gobj() { return GTK_WIDGET(_d->gobj()); }
inline Gtk::Box* FloatingBehavior::get_vbox() {
-#if WITH_GTKMM_3_0
return _d->get_content_area();
-#else
- return _d->get_vbox();
-#endif
}
inline void FloatingBehavior::present() { _d->present(); }
inline void FloatingBehavior::hide() { _d->hide(); }
@@ -155,12 +148,8 @@ inline void FloatingBehavior::move(int x, int y) { _d->
inline void FloatingBehavior::set_position(Gtk::WindowPosition position) { _d->set_position(position); }
inline void FloatingBehavior::set_size_request(int width, int height) { _d->set_size_request(width, height); }
inline void FloatingBehavior::size_request(Gtk::Requisition &requisition) {
-#if WITH_GTKMM_3_0
Gtk::Requisition requisition_natural;
_d->get_preferred_size(requisition, requisition_natural);
-#else
- requisition = _d->size_request();
-#endif
}
inline void FloatingBehavior::get_position(int &x, int &y) { _d->get_position(x, y); }
inline void FloatingBehavior::get_size(int &width, int &height) { _d->get_size(width, height); }
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index f219f3db6..abae8ea70 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -7,7 +7,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include <gtkmm/messagedialog.h>
@@ -21,16 +21,11 @@
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
-#include "selection.h"
#include "ui/dialog-events.h"
#include "selection-chemistry.h"
-#include "preferences.h"
-#include "xml/repr.h"
-
-#include "sp-defs.h"
#include "sp-root.h"
#include "sp-text.h"
#include "sp-textpath.h"
@@ -106,11 +101,7 @@ FontSubstitution::show(Glib::ustring out, std::vector<SPItem*> &l)
cbWarning->set_label(_("Don't show this warning again"));
cbWarning->show();
-#if GTK_CHECK_VERSION(3,0,0)
- Gtk::Box * box = warning.get_content_area();
-#else
- Gtk::Box * box = warning.get_vbox();
-#endif
+ auto box = warning.get_content_area();
box->set_spacing(2);
box->pack_start(*scrollwindow, true, true, 4);
box->pack_start(*cbSelect, false, false, 0);
@@ -182,7 +173,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli
family = SP_TEXT(parent_text)->layout.getFontFamily(0);
// Add all the spans fonts to the set
gint ii = 0;
- for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: parent_text->children) {
family = SP_TEXT(parent_text)->layout.getFontFamily(ii);
setFontSpans.insert(family);
ii++;
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp
index 56b001291..9c1236ca9 100644
--- a/src/ui/dialog/glyphs.cpp
+++ b/src/ui/dialog/glyphs.cpp
@@ -14,21 +14,11 @@
#include <glibmm/i18n.h>
#include <gtkmm/alignment.h>
#include <gtkmm/comboboxtext.h>
-#include <gtkmm/entry.h>
+#include <gtkmm/grid.h>
#include <gtkmm/iconview.h>
-#include <gtkmm/label.h>
#include <gtkmm/liststore.h>
#include <gtkmm/scrolledwindow.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
-#include <gtkmm/treemodelcolumn.h>
-#include <gtkmm/widget.h>
-
#include "desktop.h"
#include "document.h" // for SPDocumentUndo::done()
#include "document-undo.h"
@@ -342,12 +332,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
instanceConns(),
desktopConns()
{
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = new Gtk::Grid();
-#else
- Gtk::Table *table = new Gtk::Table(3, 1, false);
-#endif
-
+ auto table = new Gtk::Grid();
_getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET);
guint row = 0;
@@ -360,29 +345,16 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
gtk_widget_set_size_request (fontsel, 0, 150);
g_signal_connect( G_OBJECT(fontsel), "font_set", G_CALLBACK(fontChangeCB), this );
-#if WITH_GTKMM_3_0
table->attach(*Gtk::manage(Glib::wrap(fontsel)), 0, row, 3, 1);
-#else
- table->attach(*Gtk::manage(Glib::wrap(fontsel)),
- 0, 3, row, row + 1,
- Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
-#endif
-
row++;
// -------------------------------
{
- Gtk::Label *label = new Gtk::Label(_("Script: "));
+ auto label = new Gtk::Label(_("Script: "));
-#if WITH_GTKMM_3_0
table->attach( *Gtk::manage(label), 0, row, 1, 1);
-#else
- table->attach( *Gtk::manage(label),
- 0, 1, row, row + 1,
- Gtk::SHRINK, Gtk::SHRINK);
-#endif
scriptCombo = new Gtk::ComboBoxText();
for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it)
@@ -396,14 +368,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0));
align->add(*Gtk::manage(scriptCombo));
-#if WITH_GTKMM_3_0
align->set_hexpand();
table->attach( *align, 1, row, 1, 1);
-#else
- table->attach( *align,
- 1, 2, row, row + 1,
- Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK);
-#endif
}
row++;
@@ -411,15 +377,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
// -------------------------------
{
- Gtk::Label *label = new Gtk::Label(_("Range: "));
-
-#if WITH_GTKMM_3_0
+ auto label = new Gtk::Label(_("Range: "));
table->attach( *Gtk::manage(label), 0, row, 1, 1);
-#else
- table->attach( *Gtk::manage(label),
- 0, 1, row, row + 1,
- Gtk::SHRINK, Gtk::SHRINK);
-#endif
rangeCombo = new Gtk::ComboBoxText();
for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) {
@@ -431,15 +390,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
instanceConns.push_back(conn);
Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0);
align->add(*Gtk::manage(rangeCombo));
-
-#if WITH_GTKMM_3_0
align->set_hexpand();
table->attach( *Gtk::manage(align), 1, row, 1, 1);
-#else
- table->attach( *Gtk::manage(align),
- 1, 2, row, row + 1,
- Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK);
-#endif
}
row++;
@@ -462,16 +414,9 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow();
scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
scroller->add(*Gtk::manage(iconView));
-
-#if WITH_GTKMM_3_0
scroller->set_hexpand();
scroller->set_vexpand();
table->attach(*Gtk::manage(scroller), 0, row, 3, 1);
-#else
- table->attach(*Gtk::manage(scroller),
- 0, 3, row, row + 1,
- Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
-#endif
row++;
@@ -501,15 +446,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
insertBtn->set_sensitive(false);
box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK);
-
-#if WITH_GTKMM_3_0
box->set_hexpand();
table->attach( *Gtk::manage(box), 0, row, 3, 1);
-#else
- table->attach( *Gtk::manage(box),
- 0, 3, row, row + 1,
- Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-#endif
row++;
@@ -578,8 +516,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop)
void GlyphsPanel::insertText()
{
SPItem *textItem = 0;
- std::vector<SPItem*> itemlist=targetDesktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= targetDesktop->selection->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
textItem = *i;
break;
@@ -591,12 +529,7 @@ void GlyphsPanel::insertText()
if (entry->get_text_length() > 0) {
glyphs = entry->get_text();
} else {
-
-#if WITH_GTKMM_3_0
- std::vector<Gtk::TreePath> itemArray = iconView->get_selected_items();
-#else
- Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items();
-#endif
+ auto itemArray = iconView->get_selected_items();
if (!itemArray.empty()) {
Gtk::TreeModel::Path const & path = *itemArray.begin();
@@ -641,11 +574,7 @@ void GlyphsPanel::glyphActivated(Gtk::TreeModel::Path const & path)
void GlyphsPanel::glyphSelectionChanged()
{
-#if WITH_GTKMM_3_0
- std::vector<Gtk::TreePath> itemArray = iconView->get_selected_items();
-#else
- Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items();
-#endif
+ auto itemArray = iconView->get_selected_items();
if (itemArray.empty()) {
label->set_text(" ");
@@ -688,8 +617,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags)
void GlyphsPanel::calcCanInsert()
{
int items = 0;
- std::vector<SPItem*> itemlist=targetDesktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= targetDesktop->selection->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
++items;
}
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index 639e463ea..9ec8d3148 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -1,30 +1,24 @@
-/*
- * A simple dialog for creating grid type arrangements of selected objects
- *
- * Authors:
- * Bob Jamison ( based off trace dialog)
- * John Cliff
- * Other dudes from The Inkscape Organization
- * Abhishek Sharma
- * Declara Denis
- *
- * Copyright (C) 2004 Bob Jamison
- * Copyright (C) 2004 John Cliff
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-//#define DEBUG_GRID_ARRANGE 1
+ /*
+ * A simple dialog for creating grid type arrangements of selected objects
+ *
+ * Authors:
+ * Bob Jamison ( based off trace dialog)
+ * John Cliff
+ * Other dudes from The Inkscape Organization
+ * Abhishek Sharma
+ * Declara Denis
+ *
+ * Copyright (C) 2004 Bob Jamison
+ * Copyright (C) 2004 John Cliff
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+ //#define DEBUG_GRID_ARRANGE 1
#include "ui/dialog/grid-arrange-tab.h"
-#include <gtk/gtk.h> //for GTK_RESPONSE* types
#include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include <2geom/transforms.h>
@@ -32,195 +26,197 @@
#include "preferences.h"
#include "inkscape.h"
-#include "selection.h"
#include "document.h"
#include "document-undo.h"
-#include "sp-item.h"
#include "widgets/icon.h"
#include "desktop.h"
-//#include "sp-item-transform.h" FIXME
+ //#include "sp-item-transform.h" FIXME
#include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog
-/*
- * Sort items by their x co-ordinates, taking account of y (keeps rows intact)
- *
- * <0 *elem1 goes before *elem2
- * 0 *elem1 == *elem2
- * >0 *elem1 goes after *elem2
- */
-static bool sp_compare_x_position(SPItem *first, SPItem *second)
-{
- using Geom::X;
- using Geom::Y;
+ /*
+ * Sort items by their x co-ordinates, taking account of y (keeps rows intact)
+ *
+ * <0 *elem1 goes before *elem2
+ * 0 *elem1 == *elem2
+ * >0 *elem1 goes after *elem2
+ */
+ static bool sp_compare_x_position(SPItem *first, SPItem *second)
+ {
+ using Geom::X;
+ using Geom::Y;
- Geom::OptRect a = first->documentVisualBounds();
- Geom::OptRect b = second->documentVisualBounds();
+ Geom::OptRect a = first->documentVisualBounds();
+ Geom::OptRect b = second->documentVisualBounds();
- if ( !a || !b ) {
- // FIXME?
- return false;
- }
+ if ( !a || !b ) {
+ // FIXME?
+ return false;
+ }
- double const a_height = a->dimensions()[Y];
- double const b_height = b->dimensions()[Y];
+ double const a_height = a->dimensions()[Y];
+ double const b_height = b->dimensions()[Y];
- bool a_in_b_vert = false;
- if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) {
- a_in_b_vert = true;
- } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) {
- a_in_b_vert = true;
- } else if (b->min()[Y] == a->min()[Y]) {
- a_in_b_vert = true;
- } else {
- a_in_b_vert = false;
- }
+ bool a_in_b_vert = false;
+ if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) {
+ a_in_b_vert = true;
+ } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) {
+ a_in_b_vert = true;
+ } else if (b->min()[Y] == a->min()[Y]) {
+ a_in_b_vert = true;
+ } else {
+ a_in_b_vert = false;
+ }
- if (!a_in_b_vert) { // a and b are not in the same row
- return (a->min()[Y] < b->min()[Y]);
+ if (!a_in_b_vert) { // a and b are not in the same row
+ return (a->min()[Y] < b->min()[Y]);
+ }
+ return (a->min()[X] < b->min()[X]);
}
- return (a->min()[X] < b->min()[X]);
-}
-/*
- * Sort items by their y co-ordinates.
- */
-static bool sp_compare_y_position(SPItem *first, SPItem *second)
-{
- Geom::OptRect a = first->documentVisualBounds();
- Geom::OptRect b = second->documentVisualBounds();
+ /*
+ * Sort items by their y co-ordinates.
+ */
+ static bool sp_compare_y_position(SPItem *first, SPItem *second)
+ {
+ Geom::OptRect a = first->documentVisualBounds();
+ Geom::OptRect b = second->documentVisualBounds();
- if ( !a || !b ) {
- // FIXME?
- return false;
- }
+ if ( !a || !b ) {
+ // FIXME?
+ return false;
+ }
+
+ if (a->min()[Geom::Y] > b->min()[Geom::Y]) {
+ return false;
+ }
+ if (a->min()[Geom::Y] < b->min()[Geom::Y]) {
+ return true;
+ }
- if (a->min()[Geom::Y] > b->min()[Geom::Y]) {
return false;
}
- if (a->min()[Geom::Y] < b->min()[Geom::Y]) {
- return true;
- }
- return false;
-}
+ namespace Inkscape {
+ namespace UI {
+ namespace Dialog {
-namespace Inkscape {
-namespace UI {
-namespace Dialog {
+ //#########################################################################
+ //## E V E N T S
+ //#########################################################################
-//#########################################################################
-//## E V E N T S
-//#########################################################################
+ /*
+ *
+ * This arranges the selection in a grid pattern.
+ *
+ */
-/*
- *
- * This arranges the selection in a grid pattern.
- *
- */
+ void GridArrangeTab::arrange()
+ {
-void GridArrangeTab::arrange()
-{
+ int cnt,row_cnt,col_cnt,a,row,col;
+ double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y;
+ double total_col_width,total_row_height;
+ col_width = 0;
+ row_height = 0;
+ total_col_width=0;
+ total_row_height=0;
- int cnt,row_cnt,col_cnt,a,row,col;
- double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y;
- double total_col_width,total_row_height;
- col_width = 0;
- row_height = 0;
- total_col_width=0;
- total_row_height=0;
+ // check for correct numbers in the row- and col-spinners
+ on_col_spinbutton_changed();
+ on_row_spinbutton_changed();
- // check for correct numbers in the row- and col-spinners
- on_col_spinbutton_changed();
- on_row_spinbutton_changed();
+ // set padding to manual values
+ paddingx = XPadding.getValue("px");
+ paddingy = YPadding.getValue("px");
- // set padding to manual values
- paddingx = XPadding.getValue("px");
- paddingy = YPadding.getValue("px");
+ std::vector<double> row_heights;
+ std::vector<double> col_widths;
+ std::vector<double> row_ys;
+ std::vector<double> col_xs;
- std::vector<double> row_heights;
- std::vector<double> col_widths;
- std::vector<double> row_ys;
- std::vector<double> col_xs;
+ int NoOfCols = NoOfColsSpinner.get_value_as_int();
+ int NoOfRows = NoOfRowsSpinner.get_value_as_int();
- int NoOfCols = NoOfColsSpinner.get_value_as_int();
- int NoOfRows = NoOfRowsSpinner.get_value_as_int();
+ width = 0;
+ for (a=0;a<NoOfCols; a++){
+ col_widths.push_back(width);
+ }
- width = 0;
- for (a=0;a<NoOfCols; a++){
- col_widths.push_back(width);
- }
+ height = 0;
+ for (a=0;a<NoOfRows; a++){
+ row_heights.push_back(height);
+ }
+ grid_left = 99999;
+ grid_top = 99999;
- height = 0;
- for (a=0;a<NoOfRows; a++){
- row_heights.push_back(height);
- }
- grid_left = 99999;
- grid_top = 99999;
+ SPDesktop *desktop = Parent->getDesktop();
+ desktop->getDocument()->ensureUpToDate();
- SPDesktop *desktop = Parent->getDesktop();
- desktop->getDocument()->ensureUpToDate();
-
- Inkscape::Selection *selection = desktop->getSelection();
- const std::vector<SPItem*> items = selection ? selection->itemList() : std::vector<SPItem*>();
- for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end(); ++i){
- SPItem *item = *i;
- Geom::OptRect b = item->documentVisualBounds();
- if (!b) {
- continue;
+ Inkscape::Selection *selection = desktop->getSelection();
+ std::vector<SPItem*> items;
+ if (selection) {
+ items.insert(items.end(), selection->items().begin(), selection->items().end());
}
- width = b->dimensions()[Geom::X];
- height = b->dimensions()[Geom::Y];
+ for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end(); ++i){
+ SPItem *item = *i;
+ Geom::OptRect b = item->documentVisualBounds();
+ if (!b) {
+ continue;
+ }
+
+ width = b->dimensions()[Geom::X];
+ height = b->dimensions()[Geom::Y];
- if (b->min()[Geom::X] < grid_left) {
- grid_left = b->min()[Geom::X];
- }
- if (b->min()[Geom::Y] < grid_top) {
- grid_top = b->min()[Geom::Y];
- }
- if (width > col_width) {
- col_width = width;
- }
- if (height > row_height) {
- row_height = height;
+ if (b->min()[Geom::X] < grid_left) {
+ grid_left = b->min()[Geom::X];
+ }
+ if (b->min()[Geom::Y] < grid_top) {
+ grid_top = b->min()[Geom::Y];
+ }
+ if (width > col_width) {
+ col_width = width;
+ }
+ if (height > row_height) {
+ row_height = height;
+ }
}
- }
- // require the sorting done before we can calculate row heights etc.
+ // require the sorting done before we can calculate row heights etc.
- g_return_if_fail(selection);
- std::vector<SPItem*> sorted(selection->itemList());
- sort(sorted.begin(),sorted.end(),sp_compare_y_position);
- sort(sorted.begin(),sorted.end(),sp_compare_x_position);
+ g_return_if_fail(selection);
+ std::vector<SPItem*> sorted(selection->items().begin(), selection->items().end());
+ sort(sorted.begin(),sorted.end(),sp_compare_y_position);
+ sort(sorted.begin(),sorted.end(),sp_compare_x_position);
- // Calculate individual Row and Column sizes if necessary
+ // Calculate individual Row and Column sizes if necessary
- cnt=0;
- const std::vector<SPItem*> sizes(sorted);
- for (std::vector<SPItem*>::const_iterator i = sizes.begin();i!=sizes.end(); ++i) {
- SPItem *item = *i;
- Geom::OptRect b = item->documentVisualBounds();
- if (b) {
- width = b->dimensions()[Geom::X];
- height = b->dimensions()[Geom::Y];
- if (width > col_widths[(cnt % NoOfCols)]) {
- col_widths[(cnt % NoOfCols)] = width;
+ cnt=0;
+ const std::vector<SPItem*> sizes(sorted);
+ for (std::vector<SPItem*>::const_iterator i = sizes.begin();i!=sizes.end(); ++i) {
+ SPItem *item = *i;
+ Geom::OptRect b = item->documentVisualBounds();
+ if (b) {
+ width = b->dimensions()[Geom::X];
+ height = b->dimensions()[Geom::Y];
+ if (width > col_widths[(cnt % NoOfCols)]) {
+ col_widths[(cnt % NoOfCols)] = width;
+ }
+ if (height > row_heights[(cnt / NoOfCols)]) {
+ row_heights[(cnt / NoOfCols)] = height;
+ }
}
- if (height > row_heights[(cnt / NoOfCols)]) {
- row_heights[(cnt / NoOfCols)] = height;
- }
- }
- cnt++;
- }
+ cnt++;
+ }
- /// Make sure the top and left of the grid dont move by compensating for align values.
+ /// Make sure the top and left of the grid dont move by compensating for align values.
if (RowHeightButton.get_active()){
grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign));
}
@@ -368,8 +364,7 @@ void GridArrangeTab::on_row_spinbutton_changed()
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
g_return_if_fail( selection );
- std::vector<SPItem*> const items = selection->itemList();
- int selcount = items.size();
+ int selcount = (int) boost::distance(selection->items());
double PerCol = ceil(selcount / NoOfColsSpinner.get_value());
NoOfRowsSpinner.set_value(PerCol);
@@ -394,7 +389,7 @@ void GridArrangeTab::on_col_spinbutton_changed()
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
g_return_if_fail(selection);
- int selcount = selection->itemList().size();
+ int selcount = (int) boost::distance(selection->items());
double PerRow = ceil(selcount / NoOfRowsSpinner.get_value());
NoOfColsSpinner.set_value(PerRow);
@@ -531,7 +526,10 @@ void GridArrangeTab::updateSelection()
updating = true;
SPDesktop *desktop = Parent->getDesktop();
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
- std::vector<SPItem*> const items = selection ? selection->itemList() : std::vector<SPItem*>();
+ std::vector<SPItem*> items;
+ if (selection) {
+ items.insert(items.end(), selection->items().begin(), selection->items().end());
+ }
if (!items.empty()) {
int selcount = items.size();
@@ -570,11 +568,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
: Parent(parent),
XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns", &PaddingUnitMenu),
YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows", &PaddingUnitMenu),
-#if WITH_GTKMM_3_0
PaddingTable(Gtk::manage(new Gtk::Grid()))
-#else
- PaddingTable(Gtk::manage(new Gtk::Table(2, 2, false)))
-#endif
{
// bool used by spin button callbacks to stop loops where they change each other.
updating = false;
@@ -602,7 +596,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
g_return_if_fail( selection );
int selcount = 1;
if (!selection->isEmpty()) {
- selcount = selection->itemList().size();
+ selcount = (int) boost::distance(selection->items());
}
@@ -736,20 +730,11 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
}
PaddingTable->set_border_width(MARGIN);
-
-#if WITH_GTKMM_3_0
PaddingTable->set_row_spacing(MARGIN);
PaddingTable->set_column_spacing(MARGIN);
PaddingTable->attach(XPadding, 0, 0, 1, 1);
PaddingTable->attach(PaddingUnitMenu, 1, 0, 1, 1);
PaddingTable->attach(YPadding, 0, 1, 1, 1);
-#else
- PaddingTable->set_row_spacings(MARGIN);
- PaddingTable->set_col_spacings(MARGIN);
- PaddingTable->attach(XPadding, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
- PaddingTable->attach(PaddingUnitMenu, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
- PaddingTable->attach(YPadding, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
TileBox.pack_start(*PaddingTable, false, false, MARGIN);
diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h
index a137d1694..891849f1a 100644
--- a/src/ui/dialog/grid-arrange-tab.h
+++ b/src/ui/dialog/grid-arrange-tab.h
@@ -111,12 +111,7 @@ private:
Inkscape::UI::Widget::UnitMenu PaddingUnitMenu;
Inkscape::UI::Widget::ScalarUnit XPadding;
Inkscape::UI::Widget::ScalarUnit YPadding;
-
-#if WITH_GTKMM_3_0
Gtk::Grid *PaddingTable;
-#else
- Gtk::Table *PaddingTable;
-#endif
// BBox or manual spacing
Gtk::VBox SpacingVBox;
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index 556d77a28..9c8b14953 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -14,7 +14,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "guides.h"
@@ -30,14 +30,8 @@
#include <glibmm/i18n.h>
#include "ui/dialog-events.h"
#include "message-context.h"
-#include "xml/repr.h"
#include "verbs.h"
-#include <2geom/point.h>
-#include <2geom/angle.h>
-
-#include <gtkmm/stock.h>
-
namespace Inkscape {
namespace UI {
namespace Dialogs {
@@ -124,13 +118,8 @@ void GuidelinePropertiesDialog::_onOK()
g_free((gpointer) name);
-#if WITH_GTKMM_3_0
- const Gdk::RGBA c = _color.get_rgba();
+ const auto c = _color.get_rgba();
unsigned r = c.get_red_u()/257, g = c.get_green_u()/257, b = c.get_blue_u()/257;
-#else
- const Gdk::Color c = _color.get_color();
- unsigned r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257;
-#endif
//TODO: why 257? verify this!
_guide->set_color(r, g, b, true);
@@ -167,19 +156,13 @@ void GuidelinePropertiesDialog::_response(gint response)
void GuidelinePropertiesDialog::_setup() {
set_title(_("Guideline"));
- add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
- add_button(Gtk::Stock::DELETE, -12);
- add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ add_button(_("_OK"), Gtk::RESPONSE_OK);
+ add_button(_("_Delete"), -12);
+ add_button(_("_Cancel"), Gtk::RESPONSE_CANCEL);
-#if WITH_GTKMM_3_0
- Gtk::Box *mainVBox = get_content_area();
+ auto mainVBox = get_content_area();
_layout_table.set_row_spacing(4);
_layout_table.set_column_spacing(4);
-#else
- Gtk::Box *mainVBox = get_vbox();
- _layout_table.set_spacings(4);
- _layout_table.resize (3, 4);
-#endif
mainVBox->pack_start(_layout_table, false, false, 0);
@@ -189,7 +172,6 @@ void GuidelinePropertiesDialog::_setup() {
_label_descr.set_label("foo1");
_label_descr.set_alignment(0, 0.5);
-#if WITH_GTKMM_3_0
_label_name.set_halign(Gtk::ALIGN_FILL);
_label_name.set_valign(Gtk::ALIGN_FILL);
_layout_table.attach(_label_name, 0, 0, 3, 1);
@@ -207,19 +189,6 @@ void GuidelinePropertiesDialog::_setup() {
_color.set_valign(Gtk::ALIGN_FILL);
_color.set_hexpand();
_layout_table.attach(_color, 1, 3, 2, 1);
-#else
- _layout_table.attach(_label_name,
- 0, 3, 0, 1, Gtk::FILL, Gtk::FILL);
-
- _layout_table.attach(_label_descr,
- 0, 3, 1, 2, Gtk::FILL, Gtk::FILL);
-
- _layout_table.attach(_label_entry,
- 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-
- _layout_table.attach(_color,
- 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-#endif
// unitmenus
/* fixme: We should allow percents here too, as percents of the canvas size */
@@ -238,7 +207,6 @@ void GuidelinePropertiesDialog::_setup() {
_spin_button_y.setIncrements(1.0, 10.0);
_spin_button_y.setRange(-1e6, 1e6);
-#if WITH_GTKMM_3_0
_spin_button_x.set_halign(Gtk::ALIGN_FILL);
_spin_button_x.set_valign(Gtk::ALIGN_FILL);
_spin_button_x.set_hexpand();
@@ -252,22 +220,12 @@ void GuidelinePropertiesDialog::_setup() {
_unit_menu.set_halign(Gtk::ALIGN_FILL);
_unit_menu.set_valign(Gtk::ALIGN_FILL);
_layout_table.attach(_unit_menu, 2, 4, 1, 1);
-#else
- _layout_table.attach(_spin_button_x,
- 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_spin_button_y,
- 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-
- _layout_table.attach(_unit_menu,
- 2, 3, 4, 5, Gtk::FILL, Gtk::FILL);
-#endif
// angle spinbutton
_spin_angle.setDigits(3);
_spin_angle.setIncrements(1.0, 10.0);
_spin_angle.setRange(-3600., 3600.);
-#if WITH_GTKMM_3_0
_spin_angle.set_halign(Gtk::ALIGN_FILL);
_spin_angle.set_valign(Gtk::ALIGN_FILL);
_spin_angle.set_hexpand();
@@ -284,18 +242,6 @@ void GuidelinePropertiesDialog::_setup() {
_locked_toggle.set_valign(Gtk::ALIGN_FILL);
_locked_toggle.set_hexpand();
_layout_table.attach(_locked_toggle, 1, 8, 2, 1);
-#else
- _layout_table.attach(_spin_angle,
- 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-
- // mode radio button
- _layout_table.attach(_relative_toggle,
- 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-
- // locked radio button
- _layout_table.attach(_locked_toggle,
- 1, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL);
-#endif
_relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged));
_relative_toggle.set_active(_relative_toggle_status);
@@ -348,15 +294,9 @@ void GuidelinePropertiesDialog::_setup() {
// init name entry
_label_entry.getEntry()->set_text(_guide->getLabel() ? _guide->getLabel() : "");
-#if WITH_GTKMM_3_0
Gdk::RGBA c;
c.set_rgba(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0);
_color.set_rgba(c);
-#else
- Gdk::Color c;
- c.set_rgb_p(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0);
- _color.set_color(c);
-#endif
_modeChanged(); // sets values of spinboxes.
diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h
index 5dce0d6ed..25d32015c 100644
--- a/src/ui/dialog/guides.h
+++ b/src/ui/dialog/guides.h
@@ -16,12 +16,7 @@
#endif
#include <gtkmm/dialog.h>
-
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include <gtkmm/label.h>
#include <gtkmm/colorbutton.h>
@@ -71,12 +66,7 @@ private:
SPDesktop *_desktop;
SPGuide *_guide;
-#if WITH_GTKMM_3_0
- Gtk::Grid _layout_table;
-#else
- Gtk::Table _layout_table;
-#endif
-
+ Gtk::Grid _layout_table;
Gtk::Label _label_name;
Gtk::Label _label_descr;
Inkscape::UI::Widget::CheckButton _locked_toggle;
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 83656a1f2..19050fb1d 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -14,20 +14,19 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include <gtkmm/buttonbox.h>
#include <boost/scoped_ptr.hpp>
#include <glibmm/i18n.h>
-#include <glibmm/main.h>
#include <glibmm/timer.h>
+#include <glibmm/main.h>
#include <gtkmm/alignment.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/frame.h>
-#include <gtkmm/stock.h>
#include "ui/widget/frame.h"
#include "desktop.h"
@@ -35,10 +34,7 @@
#include "display/drawing.h"
#include "document.h"
#include "inkscape.h"
-#include "preferences.h"
-#include "selection.h"
#include "sp-root.h"
-#include "xml/repr.h"
#include "verbs.h"
#include "icon-preview.h"
@@ -362,8 +358,8 @@ void IconPreviewPanel::refreshPreview()
if ( sel ) {
//g_message("found a selection to play with");
- std::vector<SPItem*> const items = sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();++i){
+ auto items = sel->items();
+ for(auto i=items.begin();!target && i!=items.end();++i){
SPItem* item = *i;
gchar const *id = item->getId();
if ( id ) {
diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h
index 8a6e19a25..caec7e3b5 100644
--- a/src/ui/dialog/icon-preview.h
+++ b/src/ui/dialog/icon-preview.h
@@ -66,13 +66,7 @@ private:
gdouble minDelay;
Gtk::VBox iconBox;
-
-#if WITH_GTKMM_3_0
Gtk::Paned splitter;
-#else
- Gtk::HPaned splitter;
-#endif
-
Glib::ustring targetId;
int hot;
int numEntries;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 6dd62d3bb..646439613 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -19,30 +19,22 @@
#include "inkscape-preferences.h"
#include <glibmm/i18n.h>
-#include <glibmm/markup.h>
#include <glibmm/miscutils.h>
+#include <glibmm/markup.h>
#include <gtkmm/main.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/scrolledwindow.h>
#include <gtkmm/alignment.h>
#include "preferences.h"
#include "verbs.h"
#include "selcue.h"
-#include "util/units.h"
-#include <iostream>
-#include "enums.h"
#include "extension/internal/gdkpixbuf-input.h"
#include "message-stack.h"
#include "style.h"
#include "selection.h"
#include "selection-chemistry.h"
-#include "xml/repr.h"
#include "ui/widget/style-swatch.h"
-#include "ui/widget/spinbutton.h"
#include "display/nr-filter-gaussian.h"
-#include "display/nr-filter-types.h"
#include "cms-system.h"
#include "color-profile.h"
#include "display/canvas-grid.h"
@@ -86,12 +78,8 @@ InkscapePreferences::InkscapePreferences()
_getContents()->add(*sb);
show_all_children();
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
sb->get_preferred_size(sreq_natural, sreq);
-#else
- sreq = sb->size_request();
-#endif
_sb_width = sreq.width;
_getContents()->remove(*sb);
delete sb;
@@ -546,7 +534,7 @@ void InkscapePreferences::initPageUI()
_("Hebrew (he)"), _("Hindi (hi)"), _("Hungarian (hu)"),
_("Icelandic (is)"), _("Indonesian (id)"), _("Irish (ga)"), _("Italian (it)"),
_("Japanese (ja)"),
- _("Kannada (kn)"), _("Kashmiri in Peso-Arabic script (ks@aran)"), _("Kashmiri in Devanagari script (ks@deva)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Konkani (kok)"), _("Konkani in Latin script (kok@latin)"), _("Korean (ko)"),
+ _("Kannada (kn)"), _("Kashmiri in Perso-Arabic script (ks@aran)"), _("Kashmiri in Devanagari script (ks@deva)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Konkani (kok)"), _("Konkani in Latin script (kok@latin)"), _("Korean (ko)"),
_("Latvian (lv)"), _("Lithuanian (lt)"),
_("Macedonian (mk)"), _("Maithili (mai)"), _("Malayalam (ml)"), _("Manipuri (mni)"), _("Manipuri in Bengali script (mni@beng)"), _("Marathi (mr)"), _("Mongolian (mn)"),
_("Nepali (ne)"), _("Norwegian Bokmål (nb)"), _("Norwegian Nynorsk (nn)"),
@@ -643,7 +631,7 @@ void InkscapePreferences::initPageUI()
_page_ui.add_line( false, _("Maximum documents in Open _Recent:"), _misc_recent, "",
_("Set the maximum length of the Open Recent list in the File menu, or clear the list"), false, reset_recent);
- _ui_zoom_correction.init(300, 30, 1.00, 200.0, 1.0, 10.0, 1.0);
+ _ui_zoom_correction.init(300, 30, 1.00, 500.0, 1.0, 10.0, 1.0);
_page_ui.add_line( false, _("_Zoom correction factor (in %):"), _ui_zoom_correction, "",
_("Adjust the slider until the length of the ruler on your screen matches its real length. This information is used when zooming to 1:1, 1:2, etc., to display objects in their true sizes"), true);
@@ -863,17 +851,10 @@ static void proofComboChanged( Gtk::ComboBoxText* combo )
}
static void gamutColorChanged( Gtk::ColorButton* btn ) {
-#if WITH_GTKMM_3_0
- Gdk::RGBA rgba = btn->get_rgba();
- gushort r = rgba.get_red_u();
- gushort g = rgba.get_green_u();
- gushort b = rgba.get_blue_u();
-#else
- Gdk::Color color = btn->get_color();
- gushort r = color.get_red();
- gushort g = color.get_green();
- gushort b = color.get_blue();
-#endif
+ auto rgba = btn->get_rgba();
+ auto r = rgba.get_red_u();
+ auto g = rgba.get_green_u();
+ auto b = rgba.get_blue_u();
gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) );
@@ -1043,13 +1024,8 @@ void InkscapePreferences::initPageIO()
Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
-#if WITH_GTKMM_3_0
Gdk::RGBA tmpColor( colorStr.empty() ? "#00ff00" : colorStr);
_cms_gamutcolor.set_rgba( tmpColor );
-#else
- Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr);
- _cms_gamutcolor.set_color( tmpColor );
-#endif
_page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "",
_("Selects the color used for out of gamut warning"), false);
@@ -1331,9 +1307,12 @@ void InkscapePreferences::initPageBehavior()
_steps_rot_relative.init ( _("Relative snapping of guideline angles"), "/options/relativeguiderotationsnap/value", false);
_page_steps.add_line( false, "", _steps_rot_relative, "",
_("When on, the snap angles when rotating a guideline will be relative to the original angle"));
- _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, M_SQRT2, 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);
+ _steps_rotate.init ( "/options/rotateincrement/value", 1, 90, 1.0, 5.0, 15, false, false);
+ _page_steps.add_line( false, _("_Rotate canvas by:"), _steps_rotate, _("degrees"),
+ _("Rotate canvas clockwise and counter-clockwise by this amount."), false);
this->AddPage(_page_steps, _("Steps"), iter_behavior, PREFS_PAGE_BEHAVIOR_STEPS);
// Clones options
@@ -1432,6 +1411,10 @@ void InkscapePreferences::initPageRendering()
_rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 64.0, true, false);
_page_rendering.add_line( false, _("Rendering _cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false);
+ // rendering tile multiplier
+ _rendering_tile_multiplier.init("/options/rendering/tile-multiplier", 1.0, 64.0, 1.0, 4.0, 1.0, true, false);
+ _page_rendering.add_line( false, _("Rendering tile multiplier:"), _rendering_tile_multiplier, _("requires restart"), _("Set the relative size of tiles used to render the canvas. The larger the value, the bigger the tile size."), false);
+
/* blur quality */
_blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value",
BLUR_QUALITY_BEST, false, 0);
@@ -1594,31 +1577,19 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui
int row = 3;
-#if WITH_GTKMM_3_0
scroller->set_hexpand();
scroller->set_vexpand();
_page_keyshortcuts.attach(*scroller, 0, row, 2, 1);
-#else
- _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL);
-#endif
row++;
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *box_buttons = Gtk::manage(new Gtk::ButtonBox);
-#else
- Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox);
-#endif
+ auto box_buttons = Gtk::manage(new Gtk::ButtonBox);
box_buttons->set_layout(Gtk::BUTTONBOX_END);
box_buttons->set_spacing(4);
-#if WITH_GTKMM_3_0
box_buttons->set_hexpand();
_page_keyshortcuts.attach(*box_buttons, 0, row, 3, 1);
-#else
- _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
-#endif
UI::Widget::Button *kb_reset = Gtk::manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above")));
box_buttons->pack_start(*kb_reset, true, true, 6);
@@ -2051,12 +2022,8 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter)
_page_frame.add(*page);
this->show_all_children();
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
this->get_preferred_size(sreq_natural, sreq);
-#else
- sreq = this->size_request();
-#endif
_max_dialog_width=std::max(_max_dialog_width, sreq.width);
_max_dialog_height=std::max(_max_dialog_height, sreq.height);
_page_frame.remove();
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index d1abcfc58..e6ba4e4b2 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -97,11 +97,7 @@ enum {
};
namespace Gtk {
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
namespace Inkscape {
@@ -206,11 +202,7 @@ protected:
UI::Widget::PrefCheckButton _scroll_space;
UI::Widget::PrefCheckButton _wheel_zoom;
-#if WITH_GTKMM_3_0
Gtk::Scale *_slider_snapping_delay;
-#else
- Gtk::HScale *_slider_snapping_delay;
-#endif
UI::Widget::PrefCheckButton _snap_indicator;
UI::Widget::PrefCheckButton _snap_closest_only;
@@ -223,6 +215,7 @@ protected:
UI::Widget::PrefSpinUnit _steps_scale;
UI::Widget::PrefSpinUnit _steps_inset;
UI::Widget::PrefSpinButton _steps_zoom;
+ UI::Widget::PrefSpinButton _steps_rotate;
UI::Widget::PrefRadioButton _t_sel_trans_obj;
UI::Widget::PrefRadioButton _t_sel_trans_outl;
@@ -302,6 +295,7 @@ protected:
UI::Widget::PrefCombo _switcher_style;
UI::Widget::PrefCheckButton _rendering_image_outline;
UI::Widget::PrefSpinButton _rendering_cache_size;
+ UI::Widget::PrefSpinButton _rendering_tile_multiplier;
UI::Widget::PrefSpinButton _filter_multi_threaded;
UI::Widget::PrefCheckButton _trans_scale_stroke;
diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp
index 8343cd6fe..9fd2288e7 100644
--- a/src/ui/dialog/input.cpp
+++ b/src/ui/dialog/input.cpp
@@ -15,35 +15,20 @@
#include "ui/widget/panel.h"
#include "ui/widget/frame.h"
-#include <glib/gprintf.h>
#include <glibmm/i18n.h>
-#include <gtkmm/alignment.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/cellrenderercombo.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
-#include <gtkmm/enums.h>
-#include <gtkmm/eventbox.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/image.h>
+#include <gtkmm/grid.h>
#include <gtkmm/liststore.h>
#include <gtkmm/menubar.h>
#include <gtkmm/notebook.h>
#include <gtkmm/paned.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/scrolledwindow.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
-#include <gtkmm/treemodel.h>
-#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/treestore.h>
-#include <gtkmm/treeview.h>
#include "device-manager.h"
#include "preferences.h"
@@ -431,13 +416,7 @@ private:
Blink watcher;
Gtk::CheckButton useExt;
Gtk::Button save;
-
-#if WITH_GTKMM_3_0
Gtk::Paned pane;
-#else
- Gtk::HPaned pane;
-#endif
-
Gtk::VBox detailsBox;
Gtk::HBox titleFrame;
Gtk::Label titleLabel;
@@ -498,27 +477,14 @@ private:
Inkscape::UI::Widget::Frame axisFrame;
Gtk::ScrolledWindow treeScroller;
Gtk::ScrolledWindow detailScroller;
-
-#if WITH_GTKMM_3_0
Gtk::Paned splitter;
Gtk::Paned split2;
-#else
- Gtk::HPaned splitter;
- Gtk::VPaned split2;
-#endif
-
Gtk::Label devName;
Gtk::Label devKeyCount;
Gtk::Label devAxesCount;
Gtk::ComboBoxText axesCombo;
Gtk::ProgressBar axesValues[6];
-
-#if WITH_GTKMM_3_0
Gtk::Grid axisTable;
-#else
- Gtk::Table axisTable;
-#endif
-
Gtk::ComboBoxText buttonCombo;
Gtk::ComboBoxText linkCombo;
sigc::connection linkConnection;
@@ -528,13 +494,7 @@ private:
Gtk::Image testThumb;
Gtk::Image testButtons[24];
Gtk::Image testAxes[8];
-
-#if WITH_GTKMM_3_0
Gtk::Grid imageTable;
-#else
- Gtk::Table imageTable;
-#endif
-
Gtk::EventBox testDetector;
ConfPanel cfgPanel;
@@ -620,20 +580,11 @@ InputDialogImpl::InputDialogImpl() :
treeScroller(),
detailScroller(),
splitter(),
-#if WITH_GTKMM_3_0
split2(Gtk::ORIENTATION_VERTICAL),
axisTable(),
-#else
- split2(),
- axisTable(11, 2),
-#endif
linkCombo(),
topHolder(),
-#if WITH_GTKMM_3_0
imageTable(),
-#else
- imageTable(8, 7),
-#endif
testDetector(),
cfgPanel()
{
@@ -655,27 +606,16 @@ InputDialogImpl::InputDialogImpl() :
testFrame.add(testDetector);
testThumb.set(getPix(PIX_TABLET));
testThumb.set_padding(24, 24);
-
-#if WITH_GTKMM_3_0
testThumb.set_hexpand();
testThumb.set_vexpand();
imageTable.attach(testThumb, 0, 0, 8, 1);
-#else
- imageTable.attach(testThumb, 0, 8, 0, 1, ::Gtk::EXPAND, ::Gtk::EXPAND);
-#endif
{
guint col = 0;
guint row = 1;
for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) {
testButtons[num].set(getPix(PIX_BUTTONS_NONE));
-
-#if WITH_GTKMM_3_0
imageTable.attach(testButtons[num], col, row, 1, 1);
-#else
- imageTable.attach(testButtons[num], col, col + 1, row, row + 1, ::Gtk::FILL, ::Gtk::FILL);
-#endif
-
col++;
if (col > 7) {
col = 0;
@@ -686,13 +626,7 @@ InputDialogImpl::InputDialogImpl() :
col = 0;
for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) {
testAxes[num].set(getPix(PIX_AXIS_NONE));
-
-#if WITH_GTKMM_3_0
imageTable.attach(testAxes[num], col * 2, row, 2, 1);
-#else
- imageTable.attach(testAxes[num], col * 2, (col + 1) * 2, row, row + 1, ::Gtk::FILL, ::Gtk::FILL);
-#endif
-
col++;
if (col > 3) {
col = 0;
@@ -730,45 +664,17 @@ InputDialogImpl::InputDialogImpl() :
axisFrame.add(axisTable);
Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:")));
-
-#if WITH_GTKMM_3_0
axisTable.attach(*lbl, 0, rowNum, 1, 1);
-#else
- axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
-#endif
-
linkCombo.append(_("None"));
linkCombo.set_active_text(_("None"));
linkCombo.set_sensitive(false);
linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged));
-
-#if WITH_GTKMM_3_0
axisTable.attach(linkCombo, 1, rowNum, 1, 1);
-#else
- axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
-#endif
-
rowNum++;
-
lbl = Gtk::manage(new Gtk::Label(_("Axes count:")));
-
-#if WITH_GTKMM_3_0
axisTable.attach(*lbl, 0, rowNum, 1, 1);
axisTable.attach(devAxesCount, 1, rowNum, 1, 1);
-#else
- axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
- axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1,
- ::Gtk::SHRINK,
- ::Gtk::SHRINK);
-#endif
-
rowNum++;
@@ -786,22 +692,11 @@ InputDialogImpl::InputDialogImpl() :
for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) {
lbl = Gtk::manage(new Gtk::Label(_("axis:")));
-
-#if WITH_GTKMM_3_0
lbl->set_hexpand();
axisTable.attach(*lbl, 0, rowNum, 1, 1);
axesValues[barNum].set_hexpand();
axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1);
-#else
- axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::EXPAND,
- ::Gtk::SHRINK);
- axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1,
- ::Gtk::EXPAND,
- ::Gtk::SHRINK);
-#endif
-
axesValues[barNum].set_sensitive(false);
rowNum++;
@@ -811,17 +706,8 @@ InputDialogImpl::InputDialogImpl() :
lbl = Gtk::manage(new Gtk::Label(_("Button count:")));
-#if WITH_GTKMM_3_0
axisTable.attach(*lbl, 0, rowNum, 1, 1);
axisTable.attach(devKeyCount, 1, rowNum, 1, 1);
-#else
- axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
- axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1,
- ::Gtk::SHRINK,
- ::Gtk::SHRINK);
-#endif
rowNum++;
@@ -837,13 +723,7 @@ InputDialogImpl::InputDialogImpl() :
rowNum++;
*/
-#if WITH_GTKMM_3_0
axisTable.attach(keyVal, 0, rowNum, 2, 1);
-#else
- axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
-#endif
rowNum++;
@@ -857,18 +737,9 @@ InputDialogImpl::InputDialogImpl() :
// TODO: Extension event stuff has been removed from public API in GTK+ 3
// Need to check that this hasn't broken anything
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_extension_events( GTK_WIDGET(testDetector.gobj()), GDK_EXTENSION_EVENTS_ALL );
-#endif
testDetector.add_events(Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK |Gdk::PROXIMITY_IN_MASK|Gdk::PROXIMITY_OUT_MASK|Gdk::SCROLL_MASK);
-#if WITH_GTKMM_3_0
axisTable.attach(keyEntry, 0, rowNum, 2, 1);
-#else
- axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1,
- ::Gtk::FILL,
- ::Gtk::SHRINK);
-#endif
rowNum++;
@@ -1150,12 +1021,7 @@ InputDialogImpl::ConfPanel::ConfPanel() :
useExt.set_active(Preferences::get()->getBool("/options/useextinput/value"));
useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled));
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *buttonBox = Gtk::manage(new Gtk::ButtonBox);
-#else
- Gtk::HButtonBox *buttonBox = Gtk::manage (new Gtk::HButtonBox);
-#endif
-
+ auto buttonBox = Gtk::manage(new Gtk::ButtonBox);
buttonBox->set_layout (Gtk::BUTTONBOX_END);
//Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0);
buttonBox->add(save);
@@ -1939,7 +1805,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
testThumb.set(getPix(PIX_ERASER));
break;
}
-#if WITH_GTKMM_3_0
/// \fixme GTK3 added new GDK_SOURCEs that should be handled here!
case GDK_SOURCE_KEYBOARD:
case GDK_SOURCE_TOUCHSCREEN:
@@ -1947,7 +1812,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
g_warning("InputDialogImpl::eventSnoop : unhandled GDK_SOURCE type!");
break;
}
-#endif
}
updateTestButtons(key, hotButton);
diff --git a/src/ui/dialog/knot-properties.cpp b/src/ui/dialog/knot-properties.cpp
index 9c23c33e1..954fe2a66 100644
--- a/src/ui/dialog/knot-properties.cpp
+++ b/src/ui/dialog/knot-properties.cpp
@@ -14,28 +14,22 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+# include "config.h"
#endif
+
#include "ui/dialog/knot-properties.h"
+
#include <boost/lexical_cast.hpp>
-#include <gtkmm/stock.h>
-#include <glibmm/main.h>
#include <glibmm/i18n.h>
+#include <glibmm/main.h>
#include "inkscape.h"
#include "util/units.h"
#include "desktop.h"
#include "document.h"
#include "document-undo.h"
#include "layer-manager.h"
-#include "message-stack.h"
-#include "sp-object.h"
-#include "sp-item.h"
-#include "verbs.h"
-#include "selection.h"
#include "selection-chemistry.h"
-#include "ui/icon-names.h"
-#include "ui/widget/imagetoggler.h"
//#include "event-context.h"
@@ -44,7 +38,10 @@ namespace UI {
namespace Dialogs {
KnotPropertiesDialog::KnotPropertiesDialog()
-: _desktop(NULL), _knotpoint(NULL), _position_visible(false)
+ : _desktop(NULL),
+ _knotpoint(NULL),
+ _position_visible(false),
+ _close_button(_("_Close"), true)
{
Gtk::Box *mainVBox = get_vbox();
@@ -77,8 +74,6 @@ KnotPropertiesDialog::KnotPropertiesDialog()
mainVBox->pack_start(_layout_table, true, true, 4);
// Buttons
- _close_button.set_use_stock(true);
- _close_button.set_label(Gtk::Stock::CANCEL.id);
_close_button.set_can_default();
_apply_button.set_use_underline(true);
@@ -145,7 +140,7 @@ KnotPropertiesDialog::_close()
destroy_();
Glib::signal_idle().connect(
sigc::bind_return(
- sigc::bind(sigc::ptr_fun(&::operator delete), this),
+ sigc::bind(sigc::ptr_fun<void*, void>(&::operator delete), this),
false
)
);
diff --git a/src/ui/dialog/knot-properties.h b/src/ui/dialog/knot-properties.h
index fd87df03d..f6157168f 100644
--- a/src/ui/dialog/knot-properties.h
+++ b/src/ui/dialog/knot-properties.h
@@ -12,11 +12,10 @@
#ifndef INKSCAPE_DIALOG_KNOT_PROPERTIES_H
#define INKSCAPE_DIALOG_KNOT_PROPERTIES_H
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gtkmm.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/label.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/table.h>
#include <2geom/point.h>
#include "knot.h"
#include "ui/tools/measure-tool.h"
@@ -40,7 +39,7 @@ class KnotPropertiesDialog : public Gtk::Dialog {
protected:
SPDesktop *_desktop;
- SPKnot *_knotpoint;
+ SPKnot *_knotpoint;
Gtk::Label _knot_x_label;
Gtk::SpinButton _knot_x_entry;
diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp
index 1b8fbb3f7..c8c42ef90 100644
--- a/src/ui/dialog/layer-properties.cpp
+++ b/src/ui/dialog/layer-properties.cpp
@@ -14,9 +14,9 @@
*/
#include "layer-properties.h"
-#include <gtkmm/stock.h>
-#include <glibmm/main.h>
#include <glibmm/i18n.h>
+#include <glibmm/main.h>
+
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
@@ -24,10 +24,7 @@
#include "layer-manager.h"
#include "message-stack.h"
-#include "sp-object.h"
-#include "sp-item.h"
#include "verbs.h"
-#include "selection.h"
#include "selection-chemistry.h"
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
@@ -38,24 +35,21 @@ namespace UI {
namespace Dialogs {
LayerPropertiesDialog::LayerPropertiesDialog()
-: _strategy(NULL), _desktop(NULL), _layer(NULL), _position_visible(false)
+ : _strategy(NULL),
+ _desktop(NULL),
+ _layer(NULL),
+ _position_visible(false),
+ _close_button(_("_Cancel"), true)
{
-#if WITH_GTKMM_3_0
- Gtk::Box *mainVBox = get_content_area();
+ auto mainVBox = get_content_area();
_layout_table.set_row_spacing(4);
_layout_table.set_column_spacing(4);
-#else
- Gtk::Box *mainVBox = get_vbox();
- _layout_table.set_spacings(4);
- _layout_table.resize (1, 2);
-#endif
// Layer name widgets
_layer_name_entry.set_activates_default(true);
_layer_name_label.set_label(_("Layer name:"));
_layer_name_label.set_alignment(1.0, 0.5);
-#if WITH_GTKMM_3_0
_layer_name_label.set_halign(Gtk::ALIGN_FILL);
_layer_name_label.set_valign(Gtk::ALIGN_FILL);
_layout_table.attach(_layer_name_label, 0, 0, 1, 1);
@@ -64,18 +58,10 @@ LayerPropertiesDialog::LayerPropertiesDialog()
_layer_name_entry.set_valign(Gtk::ALIGN_FILL);
_layer_name_entry.set_hexpand();
_layout_table.attach(_layer_name_entry, 1, 0, 1, 1);
-#else
- _layout_table.attach(_layer_name_label,
- 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_layer_name_entry,
- 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
-#endif
mainVBox->pack_start(_layout_table, true, true, 4);
// Buttons
- _close_button.set_use_stock(true);
- _close_button.set_label(Gtk::Stock::CANCEL.id);
_close_button.set_can_default();
_apply_button.set_use_underline(true);
@@ -146,7 +132,7 @@ LayerPropertiesDialog::_close()
destroy_();
Glib::signal_idle().connect(
sigc::bind_return(
- sigc::bind(sigc::ptr_fun(&::operator delete), this),
+ sigc::bind(sigc::ptr_fun<void*, void>(&::operator delete), this),
false
)
);
@@ -166,10 +152,6 @@ LayerPropertiesDialog::_setup_position_controls() {
_layer_position_combo.set_cell_data_func(_label_renderer,
sigc::mem_fun(*this, &LayerPropertiesDialog::_prepareLabelRenderer));
-#if !WITH_GTKMM_3_0
- _layout_table.resize (2, 2);
-#endif
-
Gtk::ListStore::iterator row;
row = _dropdown_list->append();
row->set_value(_dropdown_columns.position, LPOS_ABOVE);
@@ -185,7 +167,6 @@ LayerPropertiesDialog::_setup_position_controls() {
_layer_position_label.set_label(_("Position:"));
_layer_position_label.set_alignment(1.0, 0.5);
-#if WITH_GTKMM_3_0
_layer_position_combo.set_halign(Gtk::ALIGN_FILL);
_layer_position_combo.set_valign(Gtk::ALIGN_FILL);
_layer_position_combo.set_hexpand();
@@ -194,12 +175,6 @@ LayerPropertiesDialog::_setup_position_controls() {
_layer_position_label.set_halign(Gtk::ALIGN_FILL);
_layer_position_label.set_valign(Gtk::ALIGN_FILL);
_layout_table.attach(_layer_position_label, 0, 1, 1, 1);
-#else
- _layout_table.attach(_layer_position_combo,
- 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
- _layout_table.attach(_layer_position_label,
- 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
-#endif
show_all_children();
}
@@ -254,16 +229,11 @@ LayerPropertiesDialog::_setup_layers_controls() {
_layout_table.remove(_layer_name_entry);
_layout_table.remove(_layer_name_label);
-#if WITH_GTKMM_3_0
_scroller.set_halign(Gtk::ALIGN_FILL);
_scroller.set_valign(Gtk::ALIGN_FILL);
_scroller.set_hexpand();
_scroller.set_vexpand();
_layout_table.attach(_scroller, 0, 1, 2, 1);
-#else
- _layout_table.attach(_scroller,
- 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND);
-#endif
show_all_children();
}
@@ -415,7 +385,7 @@ void LayerPropertiesDialog::Move::setup(LayerPropertiesDialog &dialog) {
void LayerPropertiesDialog::Move::perform(LayerPropertiesDialog &dialog) {
SPObject *moveto = dialog._selectedLayer();
- sp_selection_to_layer(dialog._desktop, moveto, false);
+ dialog._desktop->selection->toLayer(moveto);
}
void LayerPropertiesDialog::_setDesktop(SPDesktop *desktop) {
diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h
index c75a7f190..f62f22782 100644
--- a/src/ui/dialog/layer-properties.h
+++ b/src/ui/dialog/layer-properties.h
@@ -19,12 +19,7 @@
#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
#include <gtkmm/label.h>
-
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include <gtkmm/combobox.h>
#include <gtkmm/liststore.h>
@@ -102,12 +97,7 @@ protected:
Gtk::Entry _layer_name_entry;
Gtk::Label _layer_position_label;
Gtk::ComboBox _layer_position_combo;
-
-#if WITH_GTKMM_3_0
Gtk::Grid _layout_table;
-#else
- Gtk::Table _layout_table;
-#endif
bool _position_visible;
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index 1c022ecad..dd9d7ec25 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -10,16 +10,13 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "layers.h"
-#include <gtkmm/widget.h>
#include <gtkmm/icontheme.h>
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
-
-#include <glibmm/i18n.h>
#include <glibmm/main.h>
#include "desktop.h"
@@ -27,19 +24,14 @@
#include "document.h"
#include "document-undo.h"
#include "helper/action.h"
-#include "helper/action-context.h"
#include "inkscape.h"
#include "layer-fns.h"
#include "layer-manager.h"
-#include "preferences.h"
-#include "sp-item.h"
-#include "sp-object.h"
#include "svg/css-ostringstream.h"
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
#include "widgets/icon.h"
-#include "xml/repr.h"
#include "sp-root.h"
#include "ui/tools/tool-base.h"
#include "selection-chemistry.h"
@@ -866,12 +858,8 @@ LayersPanel::LayersPanel() :
_scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
_scroller.set_shadow_type(Gtk::SHADOW_IN);
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
_scroller.get_preferred_size(sreq_natural, sreq);
-#else
- sreq = _scroller.size_request();
-#endif
int minHeight = 70;
if (sreq.height < minHeight) {
// Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar
diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h
index 9cd2c3b92..893b31557 100644
--- a/src/ui/dialog/layers.h
+++ b/src/ui/dialog/layers.h
@@ -124,15 +124,9 @@ private:
Gtk::TreeView _tree;
Gtk::CellRendererText *_text_renderer;
Gtk::TreeView::Column *_name_column;
-#if WITH_GTKMM_3_0
Gtk::Box _buttonsRow;
Gtk::Box _buttonsPrimary;
Gtk::Box _buttonsSecondary;
-#else
- Gtk::HBox _buttonsRow;
- Gtk::HBox _buttonsPrimary;
- Gtk::HBox _buttonsSecondary;
-#endif
Gtk::ScrolledWindow _scroller;
Gtk::Menu _popupMenu;
Inkscape::UI::Widget::SpinButton _spinBtn;
diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp
index c558eddaf..ba9d33f0a 100644
--- a/src/ui/dialog/livepatheffect-add.cpp
+++ b/src/ui/dialog/livepatheffect-add.cpp
@@ -9,23 +9,21 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "livepatheffect-add.h"
#include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
#include "desktop.h"
-#include "live_effects/effect-enum.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
LivePathEffectAdd::LivePathEffectAdd() :
- add_button(Gtk::Stock::ADD),
- close_button(Gtk::Stock::CANCEL),
+ add_button(_("_Add"), true),
+ close_button(_("_Cancel"), true),
converter(Inkscape::LivePathEffect::LPETypeConverter),
applied(false)
{
@@ -54,13 +52,21 @@ LivePathEffectAdd::LivePathEffectAdd() :
/**
* Initialize Effect list
*/
+ int show = LivePathEffect::ATTACH_PATH;
+#ifdef LPE_ENABLE_TEST_EFFECTS
+ //TODO: Handle when showing the experimental effects without setting flag
+ show = LivePathEffect::ANGLE_BISECTOR;
+#elif WITH_LPETOOL
+ //TODO: Handle when showing the experimental effects without setting flag
+ show = LivePathEffect::ANGLE_BISECTOR;
+#endif
+
for(int i = 0; i < static_cast<int>(converter._length); ++i) {
Gtk::TreeModel::Row row = *(effectlist_store->append());
const Util::EnumData<LivePathEffect::EffectType>* data = &converter.data(i);
row[_columns.name] = _( converter.get_label(data->id).c_str() );
row[_columns.data] = data;
-
- if (i == 0) {
+ if (i == show) {
Glib::RefPtr<Gtk::TreeSelection> select = effectlist_treeview.get_selection();
select->select(row);
}
@@ -69,16 +75,11 @@ LivePathEffectAdd::LivePathEffectAdd() :
/**
* Buttons
*/
- close_button.set_use_stock(true);
//close_button.set_can_default();
add_button.set_use_underline(true);
add_button.set_can_default();
-#if WITH_GTKMM_3_0
- Gtk::Box *mainVBox = get_content_area();
-#else
- Gtk::Box *mainVBox = get_vbox();
-#endif
+ auto mainVBox = get_content_area();
mainVBox->pack_start(scrolled_window, true, true);
add_action_widget(close_button, Gtk::RESPONSE_CLOSE);
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 422ec10ae..bb9b61504 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -13,20 +13,15 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "livepatheffect-editor.h"
-#include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/toolbar.h>
-#include <vector>
#include "desktop.h"
-
+#include <gtkmm/expander.h>
#include "document.h"
#include "document-undo.h"
-#include "gtkmm/widget.h"
#include "helper/action.h"
#include "inkscape.h"
#include "live_effects/effect.h"
@@ -34,19 +29,14 @@
#include "live_effects/lpeobject-reference.h"
#include "path-chemistry.h"
#include "selection-chemistry.h"
-#include "selection.h"
#include "sp-item-group.h"
-#include "sp-lpe-item.h"
#include "sp-path.h"
#include "sp-rect.h"
-#include "sp-use.h"
#include "sp-text.h"
-#include "sp-shape.h"
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
#include "widgets/icon.h"
-#include "xml/node.h"
#include "livepatheffect-add.h"
namespace Inkscape {
@@ -57,16 +47,21 @@ namespace Dialog {
/*####################
* Callback functions
*/
+
+
void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)
{
LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
lpeeditor->lpe_list_locked = false;
+ lpeeditor->lpe_changed = true;
lpeeditor->onSelectionChanged(selection);
}
-static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
+void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
{
+
LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
+ lpeeditor->lpe_list_locked = false;
lpeeditor->onSelectionChanged(selection);
}
@@ -90,6 +85,7 @@ LivePathEffectEditor::LivePathEffectEditor()
: UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
deskTrack(),
lpe_list_locked(false),
+ lpe_changed(true),
effectwidget(NULL),
status_label("", Gtk::ALIGN_CENTER),
effectcontrol_frame(""),
@@ -98,7 +94,8 @@ LivePathEffectEditor::LivePathEffectEditor()
button_up(),
button_down(),
current_desktop(NULL),
- current_lpeitem(NULL)
+ current_lpeitem(NULL),
+ current_lperef(NULL)
{
Gtk::Box *contents = _getContents();
contents->set_spacing(4);
@@ -134,13 +131,6 @@ LivePathEffectEditor::LivePathEffectEditor()
// Add toolbar items to toolbar
toolbar_hbox.set_layout (Gtk::BUTTONBOX_END);
-
-#if !WITH_GTKMM_3_0
- // TODO: This has been removed from Gtkmm 3.0. Check that
- // everything still looks OK!
- toolbar_hbox.set_child_min_width( 16 );
-#endif
-
toolbar_hbox.add( button_add );
toolbar_hbox.set_child_secondary( button_add , true);
toolbar_hbox.add( button_remove );
@@ -206,7 +196,22 @@ LivePathEffectEditor::~LivePathEffectEditor()
void
LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
{
+ if (!effect.upd_params && !lpe_changed) {
+ lpe_changed = false;
+ return;
+ }
+ bool expanderopen = false;
+ Gtk::Widget * defaultswidget = effect.defaultParamSet();
+
if (effectwidget) {
+ if (defaultswidget) {
+ Gtk::Expander * expander = NULL;
+ std::vector<Gtk::Widget *> childs = dynamic_cast<Gtk::Box *> (effectwidget)->get_children();
+ std::vector<Gtk::Widget *> childs_default = dynamic_cast<Gtk::Box *> (childs[childs.size()-1])->get_children();
+ if ((expander = dynamic_cast<Gtk::Expander *>(childs_default[childs_default.size()-1]))){
+ expanderopen = expander->get_expanded();
+ }
+ }
effectcontrol_vbox.remove(*effectwidget);
delete effectwidget;
effectwidget = NULL;
@@ -216,6 +221,15 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
effectwidget = effect.newWidget();
if (effectwidget) {
+
+ if (defaultswidget) {
+ Gtk::Expander * expander = NULL;
+ std::vector<Gtk::Widget *> childs_default = dynamic_cast<Gtk::Box *> (defaultswidget)->get_children();
+ if ((expander = dynamic_cast<Gtk::Expander *>(childs_default[childs_default.size()-1]))){
+ expander->set_expanded(expanderopen);
+ }
+ dynamic_cast<Gtk::Box *> (effectwidget)->pack_start(*defaultswidget, true, true);
+ }
effectcontrol_vbox.pack_start(*effectwidget, true, true);
}
button_remove.show();
@@ -224,6 +238,8 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
effectcontrol_frame.show();
effectcontrol_vbox.show_all_children();
// fixme: add resizing of dialog
+ effect.upd_params = false;
+ lpe_changed = false;
}
void
@@ -265,7 +281,6 @@ LivePathEffectEditor::set_sensitize_all(bool sensitive)
button_down.set_sensitive(sensitive);
}
-
void
LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
{
@@ -274,9 +289,8 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
lpe_list_locked = false;
return;
}
-
- effectlist_store->clear();
current_lpeitem = NULL;
+ effectlist_store->clear();
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
@@ -428,7 +442,7 @@ LivePathEffectEditor::onAdd()
// If item is a SPRect, convert it to path first:
if ( dynamic_cast<SPRect *>(item) ) {
- sp_selected_path_to_curves(sel, current_desktop, false);
+ sel->toCurves();
item = sel->singleItem(); // get new item
}
@@ -460,7 +474,7 @@ LivePathEffectEditor::onAdd()
item = NULL;
// run sp_selection_clone_original_path_lpe
- sp_selection_clone_original_path_lpe(current_desktop);
+ sel->cloneOriginalPathLPE();
SPItem *new_item = sel->singleItem();
// Check that the cloning was successful. We don't want to change the ID of the original referenced path!
@@ -495,11 +509,11 @@ LivePathEffectEditor::onRemove()
SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
if ( lpeitem ) {
lpeitem->removeCurrentPathEffect(false);
-
+ current_lperef = NULL;
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Remove path effect") );
-
- effect_list_reload(lpeitem);
+ lpe_list_locked = false;
+ onSelectionChanged(sel);
}
}
@@ -516,7 +530,7 @@ void LivePathEffectEditor::onUp()
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Move path effect up") );
-
+
effect_list_reload(lpeitem);
}
}
@@ -533,7 +547,6 @@ void LivePathEffectEditor::onDown()
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Move path effect down") );
-
effect_list_reload(lpeitem);
}
}
@@ -542,23 +555,32 @@ void LivePathEffectEditor::onDown()
void LivePathEffectEditor::on_effect_selection_changed()
{
Glib::RefPtr<Gtk::TreeSelection> sel = effectlist_view.get_selection();
- if (sel->count_selected_rows () == 0)
+ if (sel->count_selected_rows () == 0) {
+ button_remove.set_sensitive(false);
return;
-
+ }
+ button_remove.set_sensitive(true);
Gtk::TreeModel::iterator it = sel->get_selected();
LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
- if (lperef && current_lpeitem) {
- if (lperef->lpeobject->get_lpe()) {
+ if (lperef && current_lpeitem && current_lperef != lperef) {
+ //The last condition ignore Gtk::TreeModel may occasionally be changed emitted when nothing has happened
+ if (lperef->getObject()) {
lpe_list_locked = true; // prevent reload of the list which would lose selection
current_lpeitem->setCurrentPathEffect(lperef);
- showParams(*lperef->lpeobject->get_lpe());
+ current_lperef = lperef;
+ LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe();
+ if (effect) {
+ lpe_changed = true;
+ showParams(*effect);
+ }
}
}
}
void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
{
+
Gtk::TreeModel::Children::iterator iter = effectlist_view.get_model()->get_iter(str);
Gtk::TreeModel::Row row = *iter;
@@ -570,6 +592,14 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
/* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
* So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
+ Inkscape::Selection *sel = _getSelection();
+ if ( sel && !sel->isEmpty() ) {
+ SPItem *item = sel->singleItem();
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
+ lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem);
+ }
+ }
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
newValue ? _("Activate path effect") : _("Deactivate path effect"));
}
diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h
index 4aac25eaa..7f6f56fd2 100644
--- a/src/ui/dialog/livepatheffect-editor.h
+++ b/src/ui/dialog/livepatheffect-editor.h
@@ -46,6 +46,7 @@ public:
static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); }
void onSelectionChanged(Inkscape::Selection *sel);
+ void onSelectionModified(Inkscape::Selection *sel);
virtual void on_effect_selection_changed();
void setDesktop(SPDesktop *desktop);
@@ -63,15 +64,15 @@ private:
sigc::connection selection_changed_connection;
sigc::connection selection_modified_connection;
+ // void add_entry(const char* name );
+ void effect_list_reload(SPLPEItem *lpeitem);
+
void set_sensitize_all(bool sensitive);
void showParams(LivePathEffect::Effect& effect);
void showText(Glib::ustring const &str);
void selectInList(LivePathEffect::Effect* effect);
- // void add_entry(const char* name );
- void effect_list_reload(SPLPEItem *lpeitem);
-
// callback methods for buttons on grids page.
void onAdd();
void onRemove();
@@ -95,7 +96,7 @@ private:
};
bool lpe_list_locked;
-
+ bool lpe_changed;
//Inkscape::UI::Widget::ComboBoxEnum<LivePathEffect::EffectType> combo_effecttype;
Gtk::Widget * effectwidget;
@@ -112,11 +113,7 @@ private:
void on_visibility_toggled( Glib::ustring const& str );
-#if WITH_GTKMM_3_0
Gtk::ButtonBox toolbar_hbox;
-#else
- Gtk::HButtonBox toolbar_hbox;
-#endif
Gtk::Button button_add;
Gtk::Button button_remove;
Gtk::Button button_up;
@@ -126,7 +123,10 @@ private:
SPLPEItem * current_lpeitem;
+ LivePathEffect::LPEObjectReference * current_lperef;
+
friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data);
+ friend void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data);
LivePathEffectEditor(LivePathEffectEditor const &d);
LivePathEffectEditor& operator=(LivePathEffectEditor const &d);
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index 5ccee103c..82c6035d4 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -5,30 +5,20 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include <gtkmm.h>
#include "lpe-fillet-chamfer-properties.h"
#include <boost/lexical_cast.hpp>
-#include <glibmm/main.h>
#include <glibmm/i18n.h>
#include "inkscape.h"
#include "desktop.h"
-#include "document.h"
#include "document-undo.h"
#include "layer-manager.h"
#include "message-stack.h"
-#include "sp-object.h"
-#include "sp-item.h"
-#include "verbs.h"
-#include "selection.h"
#include "selection-chemistry.h"
-#include "ui/icon-names.h"
-#include "ui/widget/imagetoggler.h"
-#include "live_effects/parameter/parameter.h"
-#include <cmath>
//#include "event-context.h"
@@ -37,38 +27,37 @@ namespace UI {
namespace Dialogs {
FilletChamferPropertiesDialog::FilletChamferPropertiesDialog()
- : _desktop(NULL), _knotpoint(NULL), _position_visible(false)
+ : _desktop(NULL),
+ _knotpoint(NULL),
+ _position_visible(false),
+ _close_button(_("_Cancel"), true)
{
Gtk::Box *mainVBox = get_vbox();
mainVBox->set_homogeneous(false);
- _layout_table.set_spacings(4);
- _layout_table.resize(3, 3);
+ _layout_table.set_row_spacing(4);
+ _layout_table.set_column_spacing(4);
// Layer name widgets
_fillet_chamfer_position_numeric.set_digits(4);
_fillet_chamfer_position_numeric.set_increments(1,1);
//todo: get tha max aloable infinity freeze the widget
_fillet_chamfer_position_numeric.set_range(0., SCALARPARAM_G_MAXDOUBLE);
-
+ _fillet_chamfer_position_numeric.set_hexpand();
_fillet_chamfer_position_label.set_label(_("Radius (pixels):"));
_fillet_chamfer_position_label.set_alignment(1.0, 0.5);
- _layout_table.attach(_fillet_chamfer_position_label, 0, 1, 0, 1, Gtk::FILL,
- Gtk::FILL);
- _layout_table.attach(_fillet_chamfer_position_numeric, 1, 2, 0, 1,
- Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _layout_table.attach(_fillet_chamfer_position_label, 0, 0, 1, 1);
+ _layout_table.attach(_fillet_chamfer_position_numeric, 1, 0, 1, 1);
_fillet_chamfer_chamfer_subdivisions.set_digits(0);
_fillet_chamfer_chamfer_subdivisions.set_increments(1,1);
//todo: get tha max aloable infinity freeze the widget
_fillet_chamfer_chamfer_subdivisions.set_range(0, SCALARPARAM_G_MAXDOUBLE);
-
+ _fillet_chamfer_chamfer_subdivisions.set_hexpand();
_fillet_chamfer_chamfer_subdivisions_label.set_label(_("Chamfer subdivisions:"));
_fillet_chamfer_chamfer_subdivisions_label.set_alignment(1.0, 0.5);
- _layout_table.attach(_fillet_chamfer_chamfer_subdivisions_label, 0, 1, 1, 2, Gtk::FILL,
- Gtk::FILL);
- _layout_table.attach(_fillet_chamfer_chamfer_subdivisions, 1, 2, 1, 2,
- Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _layout_table.attach(_fillet_chamfer_chamfer_subdivisions_label, 0, 1, 1, 1);
+ _layout_table.attach(_fillet_chamfer_chamfer_subdivisions, 1, 1, 1, 1);
_fillet_chamfer_type_fillet.set_label(_("Fillet"));
_fillet_chamfer_type_fillet.set_group(_fillet_chamfer_type_group);
_fillet_chamfer_type_inverse_fillet.set_label(_("Inverse fillet"));
@@ -86,8 +75,6 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog()
mainVBox->pack_start(_fillet_chamfer_type_inverse_chamfer, true, true, 4);
// Buttons
- _close_button.set_use_stock(true);
- _close_button.set_label(Gtk::Stock::CANCEL.id);
_close_button.set_can_default();
_apply_button.set_use_underline(true);
@@ -115,23 +102,26 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog()
FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog()
{
- _set_desktop(NULL);
+ _setDesktop(NULL);
}
void FilletChamferPropertiesDialog::showDialog(
- SPDesktop *desktop, Geom::Point knotpoint,
+ SPDesktop *desktop,
+ double _amount,
const Inkscape::LivePathEffect::
- FilletChamferPointArrayParamKnotHolderEntity *pt,
- bool use_distance,
- bool aprox_radius)
+ FilletChamferKnotHolderEntity *pt,
+ bool _use_distance,
+ bool _aprox_radius,
+ Satellite _satellite)
{
FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog();
- dialog->_set_desktop(desktop);
- dialog->_set_use_distance(use_distance);
- dialog->_set_aprox(aprox_radius);
- dialog->_set_knot_point(knotpoint);
- dialog->_set_pt(pt);
+ dialog->_setDesktop(desktop);
+ dialog->_setUseDistance(_use_distance);
+ dialog->_setAprox(_aprox_radius);
+ dialog->_setAmount(_amount);
+ dialog->_setSatellite(_satellite);
+ dialog->_setPt(pt);
dialog->set_title(_("Modify Fillet-Chamfer"));
dialog->_apply_button.set_label(_("_Modify"));
@@ -146,38 +136,42 @@ void FilletChamferPropertiesDialog::showDialog(
void FilletChamferPropertiesDialog::_apply()
{
- double d_width;
+
double d_pos = _fillet_chamfer_position_numeric.get_value();
- if (d_pos) {
+ if (d_pos >= 0) {
if (_fillet_chamfer_type_fillet.get_active() == true) {
- d_width = 1;
+ _satellite.satellite_type = FILLET;
} else if (_fillet_chamfer_type_inverse_fillet.get_active() == true) {
- d_width = 2;
+ _satellite.satellite_type = INVERSE_FILLET;
} else if (_fillet_chamfer_type_inverse_chamfer.get_active() == true) {
- d_width = _fillet_chamfer_chamfer_subdivisions.get_value() + 4000;
+ _satellite.satellite_type = INVERSE_CHAMFER;
} else {
- d_width = _fillet_chamfer_chamfer_subdivisions.get_value() + 3000;
+ _satellite.satellite_type = CHAMFER;
}
if (_flexible) {
if (d_pos > 99.99999 || d_pos < 0) {
d_pos = 0;
}
- d_pos = _index + (d_pos / 100);
- } else {
- d_pos = d_pos * -1;
+ d_pos = d_pos / 100;
+ }
+ _satellite.amount = d_pos;
+ size_t steps = (size_t)_fillet_chamfer_chamfer_subdivisions.get_value();
+ if (steps < 1) {
+ steps = 1;
}
- _knotpoint->knot_set_offset(Geom::Point(d_pos, d_width));
+ _satellite.steps = steps;
+ _knotpoint->knot_set_offset(_satellite);
}
_close();
}
void FilletChamferPropertiesDialog::_close()
{
- _set_desktop(NULL);
+ _setDesktop(NULL);
destroy_();
Glib::signal_idle().connect(
sigc::bind_return(
- sigc::bind(sigc::ptr_fun(&::operator delete), this),
+ sigc::bind(sigc::ptr_fun<void*, void>(&::operator delete), this),
false
)
);
@@ -195,62 +189,68 @@ void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event)
}
}
-void FilletChamferPropertiesDialog::_set_knot_point(Geom::Point knotpoint)
+void FilletChamferPropertiesDialog::_setSatellite(Satellite satellite)
{
double position;
std::string distance_or_radius = std::string(_("Radius"));
- if(aprox){
+ if (_aprox) {
distance_or_radius = std::string(_("Radius approximated"));
}
- if(use_distance){
+ if (_use_distance) {
distance_or_radius = std::string(_("Knot distance"));
}
- if (knotpoint.x() > 0) {
- double intpart;
- position = modf(knotpoint[Geom::X], &intpart) * 100;
+ if (satellite.is_time) {
+ position = _amount * 100;
_flexible = true;
- _index = intpart;
_fillet_chamfer_position_label.set_label(_("Position (%):"));
} else {
_flexible = false;
std::string posConcat = Glib::ustring::compose (_("%1:"), distance_or_radius);
_fillet_chamfer_position_label.set_label(_(posConcat.c_str()));
- position = knotpoint[Geom::X] * -1;
+ position = _amount;
}
_fillet_chamfer_position_numeric.set_value(position);
- if (knotpoint.y() == 1) {
+ _fillet_chamfer_chamfer_subdivisions.set_value(satellite.steps);
+ if (satellite.satellite_type == FILLET) {
_fillet_chamfer_type_fillet.set_active(true);
- } else if (knotpoint.y() == 2) {
+ } else if (satellite.satellite_type == INVERSE_FILLET) {
_fillet_chamfer_type_inverse_fillet.set_active(true);
- } else if (knotpoint.y() >= 3000 && knotpoint.y() < 4000) {
- _fillet_chamfer_chamfer_subdivisions.set_value(knotpoint.y() - 3000);
+ } else if (satellite.satellite_type == CHAMFER) {
_fillet_chamfer_type_chamfer.set_active(true);
- } else if (knotpoint.y() >= 4000 && knotpoint.y() < 5000) {
- _fillet_chamfer_chamfer_subdivisions.set_value(knotpoint.y() - 4000);
+ } else if (satellite.satellite_type == INVERSE_CHAMFER) {
_fillet_chamfer_type_inverse_chamfer.set_active(true);
}
+ _satellite = satellite;
}
-void FilletChamferPropertiesDialog::_set_pt(
+void FilletChamferPropertiesDialog::_setPt(
const Inkscape::LivePathEffect::
- FilletChamferPointArrayParamKnotHolderEntity *pt)
+ FilletChamferKnotHolderEntity *pt)
{
_knotpoint = const_cast<
- Inkscape::LivePathEffect::FilletChamferPointArrayParamKnotHolderEntity *>(
+ Inkscape::LivePathEffect::FilletChamferKnotHolderEntity *>(
pt);
}
-void FilletChamferPropertiesDialog::_set_use_distance(bool use_knot_distance)
+
+void FilletChamferPropertiesDialog::_setAmount(double amount)
+{
+ _amount = amount;
+}
+
+
+
+void FilletChamferPropertiesDialog::_setUseDistance(bool use_knot_distance)
{
- use_distance = use_knot_distance;
+ _use_distance = use_knot_distance;
}
-void FilletChamferPropertiesDialog::_set_aprox(bool aprox_radius)
+void FilletChamferPropertiesDialog::_setAprox(bool _aprox_radius)
{
- aprox = aprox_radius;
+ _aprox = _aprox_radius;
}
-void FilletChamferPropertiesDialog::_set_desktop(SPDesktop *desktop)
+void FilletChamferPropertiesDialog::_setDesktop(SPDesktop *desktop)
{
if (desktop) {
Inkscape::GC::anchor(desktop);
@@ -274,6 +274,4 @@ void FilletChamferPropertiesDialog::_set_desktop(SPDesktop *desktop)
fill-column:99
End:
*/
-// vim:
-// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99
-// :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 99494bd63..4021d6152 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -10,7 +10,7 @@
#include <2geom/point.h>
#include <gtkmm.h>
-#include "live_effects/parameter/filletchamferpointarray.h"
+#include "live_effects/parameter/satellitesarray.h"
class SPDesktop;
@@ -23,20 +23,22 @@ public:
FilletChamferPropertiesDialog();
virtual ~FilletChamferPropertiesDialog();
- Glib::ustring getName() const {
+ Glib::ustring getName() const
+ {
return "LayerPropertiesDialog";
}
- static void showDialog(SPDesktop *desktop, Geom::Point knotpoint,
+ static void showDialog(SPDesktop *desktop, double _amount,
const Inkscape::LivePathEffect::
- FilletChamferPointArrayParamKnotHolderEntity *pt,
- bool use_distance,
- bool aprox_radius);
+ FilletChamferKnotHolderEntity *pt,
+ bool _use_distance,
+ bool _aprox_radius,
+ Satellite _satellite);
protected:
SPDesktop *_desktop;
- Inkscape::LivePathEffect::FilletChamferPointArrayParamKnotHolderEntity *
+ Inkscape::LivePathEffect::FilletChamferKnotHolderEntity *
_knotpoint;
Gtk::Label _fillet_chamfer_position_label;
@@ -49,38 +51,42 @@ protected:
Gtk::Label _fillet_chamfer_chamfer_subdivisions_label;
Gtk::SpinButton _fillet_chamfer_chamfer_subdivisions;
- Gtk::Table _layout_table;
+ Gtk::Grid _layout_table;
bool _position_visible;
- double _index;
Gtk::Button _close_button;
Gtk::Button _apply_button;
sigc::connection _destroy_connection;
- static FilletChamferPropertiesDialog &_instance() {
+ static FilletChamferPropertiesDialog &_instance()
+ {
static FilletChamferPropertiesDialog instance;
return instance;
}
- void _set_desktop(SPDesktop *desktop);
- void _set_pt(const Inkscape::LivePathEffect::
- FilletChamferPointArrayParamKnotHolderEntity *pt);
- void _set_use_distance(bool use_knot_distance);
- void _set_aprox(bool aprox_radius);
- void _apply();
- void _close();
- bool _flexible;
- bool use_distance;
- bool aprox;
- void _set_knot_point(Geom::Point knotpoint);
+ void _setDesktop(SPDesktop *desktop);
+ void _setPt(const Inkscape::LivePathEffect::
+ FilletChamferKnotHolderEntity *pt);
+ void _setUseDistance(bool use_knot_distance);
+ void _setAprox(bool aprox_radius);
+ void _setAmount(double amount);
+ void _setSatellite(Satellite satellite);
void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
bool _handleKeyEvent(GdkEventKey *event);
void _handleButtonEvent(GdkEventButton *event);
+ void _apply();
+ void _close();
+ bool _flexible;
+ Satellite _satellite;
+ bool _use_distance;
+ double _amount;
+ bool _aprox;
+
friend class Inkscape::LivePathEffect::
- FilletChamferPointArrayParamKnotHolderEntity;
+ FilletChamferKnotHolderEntity;
private:
FilletChamferPropertiesDialog(
diff --git a/src/ui/dialog/lpe-powerstroke-properties.cpp b/src/ui/dialog/lpe-powerstroke-properties.cpp
index cfc972547..0757aa1c3 100644
--- a/src/ui/dialog/lpe-powerstroke-properties.cpp
+++ b/src/ui/dialog/lpe-powerstroke-properties.cpp
@@ -14,29 +14,18 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "lpe-powerstroke-properties.h"
#include <boost/lexical_cast.hpp>
-#include <gtkmm/stock.h>
-#include <glibmm/main.h>
#include <glibmm/i18n.h>
#include "inkscape.h"
#include "desktop.h"
-#include "document.h"
#include "document-undo.h"
#include "layer-manager.h"
-#include "message-stack.h"
-#include "sp-object.h"
-#include "sp-item.h"
-#include "verbs.h"
-#include "selection.h"
#include "selection-chemistry.h"
-#include "ui/icon-names.h"
-#include "ui/widget/imagetoggler.h"
-#include "live_effects/parameter/parameter.h"
//#include "event-context.h"
namespace Inkscape {
@@ -44,18 +33,22 @@ namespace UI {
namespace Dialogs {
PowerstrokePropertiesDialog::PowerstrokePropertiesDialog()
-: _desktop(NULL), _knotpoint(NULL), _position_visible(false)
+ : _desktop(NULL),
+ _knotpoint(NULL),
+ _position_visible(false),
+ _close_button(_("_Cancel"), true)
{
Gtk::Box *mainVBox = get_vbox();
- _layout_table.set_spacings(4);
- _layout_table.resize (2, 2);
+ _layout_table.set_row_spacing(4);
+ _layout_table.set_column_spacing(4);
// Layer name widgets
_powerstroke_position_entry.set_activates_default(true);
_powerstroke_position_entry.set_digits(4);
_powerstroke_position_entry.set_increments(1,1);
_powerstroke_position_entry.set_range(-SCALARPARAM_G_MAXDOUBLE, SCALARPARAM_G_MAXDOUBLE);
+ _powerstroke_position_entry.set_hexpand();
_powerstroke_position_label.set_label(_("Position:"));
_powerstroke_position_label.set_alignment(1.0, 0.5);
@@ -63,22 +56,18 @@ PowerstrokePropertiesDialog::PowerstrokePropertiesDialog()
_powerstroke_width_entry.set_digits(4);
_powerstroke_width_entry.set_increments(1,1);
_powerstroke_width_entry.set_range(-SCALARPARAM_G_MAXDOUBLE, SCALARPARAM_G_MAXDOUBLE);
+ _powerstroke_width_entry.set_hexpand();
_powerstroke_width_label.set_label(_("Width:"));
_powerstroke_width_label.set_alignment(1.0, 0.5);
- _layout_table.attach(_powerstroke_position_label,
- 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_powerstroke_position_entry,
- 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
-
- _layout_table.attach(_powerstroke_width_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
- _layout_table.attach(_powerstroke_width_entry, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _layout_table.attach(_powerstroke_position_label,0,0,1,1);
+ _layout_table.attach(_powerstroke_position_entry,1,0,1,1);
+ _layout_table.attach(_powerstroke_width_label, 0,1,1,1);
+ _layout_table.attach(_powerstroke_width_entry, 1,1,1,1);
mainVBox->pack_start(_layout_table, true, true, 4);
// Buttons
- _close_button.set_use_stock(true);
- _close_button.set_label(Gtk::Stock::CANCEL.id);
_close_button.set_can_default();
_apply_button.set_use_underline(true);
@@ -146,7 +135,7 @@ PowerstrokePropertiesDialog::_close()
destroy_();
Glib::signal_idle().connect(
sigc::bind_return(
- sigc::bind(sigc::ptr_fun(&::operator delete), this),
+ sigc::bind(sigc::ptr_fun<void*, void>(&::operator delete), this),
false
)
);
diff --git a/src/ui/dialog/lpe-powerstroke-properties.h b/src/ui/dialog/lpe-powerstroke-properties.h
index 1e4c1df5b..56b6e499d 100644
--- a/src/ui/dialog/lpe-powerstroke-properties.h
+++ b/src/ui/dialog/lpe-powerstroke-properties.h
@@ -40,7 +40,7 @@ protected:
Gtk::SpinButton _powerstroke_position_entry;
Gtk::Label _powerstroke_width_label;
Gtk::SpinButton _powerstroke_width_entry;
- Gtk::Table _layout_table;
+ Gtk::Grid _layout_table;
bool _position_visible;
Gtk::Button _close_button;
diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp
index c0bc884fa..f08089774 100644
--- a/src/ui/dialog/memory.cpp
+++ b/src/ui/dialog/memory.cpp
@@ -11,12 +11,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "ui/dialog/memory.h"
-#include <glibmm/main.h>
#include <glibmm/i18n.h>
+#include <glibmm/main.h>
+
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp
index df02215fe..3a8e7338d 100644
--- a/src/ui/dialog/messages.cpp
+++ b/src/ui/dialog/messages.cpp
@@ -11,7 +11,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "messages.h"
diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp
index 74ec7111e..2b33fd54d 100644
--- a/src/ui/dialog/new-from-template.cpp
+++ b/src/ui/dialog/new-from-template.cpp
@@ -9,14 +9,13 @@
*/
#if HAVE_CONFIG_H
- #include "config.h"
+#include "config.h"
#endif
#include "new-from-template.h"
#include "file.h"
#include <gtkmm/alignment.h>
-#include <glibmm/i18n.h>
namespace Inkscape {
@@ -31,20 +30,12 @@ NewFromTemplate::NewFromTemplate()
_main_widget = new TemplateLoadTab(this);
-#if WITH_GTKMM_3_0
get_content_area()->pack_start(*_main_widget);
-#else
- get_vbox()->pack_start(*_main_widget);
-#endif
Gtk::Alignment *align;
align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0));
-#if WITH_GTKMM_3_0
get_content_area()->pack_end(*align, Gtk::PACK_SHRINK);
-#else
- get_vbox()->pack_end(*align, Gtk::PACK_SHRINK);
-#endif
align->set_padding(0, 0, 0, 15);
align->add(_create_template_button);
diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp
index 1bc570f43..72520d3d0 100644
--- a/src/ui/dialog/object-attributes.cpp
+++ b/src/ui/dialog/object-attributes.cpp
@@ -23,15 +23,12 @@
#include "ui/dialog/dialog-manager.h"
#include "desktop.h"
-#include "macros.h"
#include "sp-anchor.h"
#include "sp-image.h"
#include "verbs.h"
-#include "xml/repr.h"
#include "ui/dialog/object-attributes.h"
#include "widgets/sp-attribute-widget.h"
#include "inkscape.h"
-#include "selection.h"
#include <glibmm/i18n.h>
namespace Inkscape {
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index be46129c4..191216eea 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -33,19 +33,11 @@
#include "document-undo.h"
#include "verbs.h"
#include "inkscape.h"
-#include "selection.h"
#include "desktop.h"
-#include "sp-item.h"
#include "sp-image.h"
-#include "xml/repr.h"
#include <glibmm/i18n.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
+#include <gtkmm/grid.h>
namespace Inkscape {
namespace UI {
@@ -106,16 +98,9 @@ void ObjectProperties::_init()
Gtk::Box *contents = _getContents();
contents->set_spacing(0);
-#if WITH_GTKMM_3_0
- Gtk::Grid *grid_top = Gtk::manage(new Gtk::Grid());
+ auto grid_top = Gtk::manage(new Gtk::Grid());
grid_top->set_row_spacing(4);
grid_top->set_column_spacing(0);
-#else
- Gtk::Table *grid_top = Gtk::manage(new Gtk::Table(4, 4));
- grid_top->set_row_spacings(4);
- grid_top->set_col_spacings(0);
-#endif
-
grid_top->set_border_width(4);
contents->pack_start(*grid_top, false, false, 0);
@@ -124,29 +109,14 @@ void ObjectProperties::_init()
/* Create the label for the object id */
_label_id.set_label(_label_id.get_label() + " ");
_label_id.set_alignment(1, 0.5);
-
-#if WITH_GTKMM_3_0
_label_id.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_label_id, 0, 0, 1, 1);
-#else
- grid_top->attach(_label_id, 0, 1, 0, 1,
- Gtk::SHRINK | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
-
/* Create the entry box for the object id */
_entry_id.set_tooltip_text(_("The id= attribute (only letters, digits, and the characters .-_: allowed)"));
_entry_id.set_max_length(64);
-
-#if WITH_GTKMM_3_0
_entry_id.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_entry_id, 1, 0, 1, 1);
-#else
- grid_top->attach(_entry_id, 1, 2, 0, 1,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_label_id.set_mnemonic_widget(_entry_id);
@@ -160,29 +130,16 @@ void ObjectProperties::_init()
_label_label.set_label(_label_label.get_label() + " ");
_label_label.set_alignment(1, 0.5);
-#if WITH_GTKMM_3_0
_label_label.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_label_label, 0, 1, 1, 1);
-#else
- grid_top->attach(_label_label, 0, 1, 1, 2,
- Gtk::SHRINK | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
-
/* Create the entry box for the object label */
_entry_label.set_tooltip_text(_("A freeform label for the object"));
_entry_label.set_max_length(256);
-#if WITH_GTKMM_3_0
_entry_label.set_hexpand();
_entry_label.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_entry_label, 1, 1, 1, 1);
-#else
- grid_top->attach(_entry_label, 1, 2, 1, 2,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_label_label.set_mnemonic_widget(_entry_label);
@@ -194,28 +151,16 @@ void ObjectProperties::_init()
_label_title.set_label(_label_title.get_label() + " ");
_label_title.set_alignment (1, 0.5);
-#if WITH_GTKMM_3_0
_label_title.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_label_title, 0, 2, 1, 1);
-#else
- grid_top->attach(_label_title, 0, 1, 2, 3,
- Gtk::SHRINK | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
/* Create the entry box for the object title */
_entry_title.set_sensitive (FALSE);
_entry_title.set_max_length (256);
-#if WITH_GTKMM_3_0
_entry_title.set_hexpand();
_entry_title.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_entry_title, 1, 2, 1, 1);
-#else
- grid_top->attach(_entry_title, 1, 2, 2, 3,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_label_title.set_mnemonic_widget(_entry_title);
// pressing enter in the label field is the same as clicking Set:
@@ -244,14 +189,8 @@ void ObjectProperties::_init()
_label_image_rendering.set_label(_label_image_rendering.get_label() + " ");
_label_image_rendering.set_alignment(1, 0.5);
-#if WITH_GTKMM_3_0
_label_image_rendering.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_label_image_rendering, 0, 3, 1, 1);
-#else
- grid_top->attach(_label_image_rendering, 0, 1, 3, 4,
- Gtk::SHRINK | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
/* Create the combo box text for the 'image-rendering' property */
_combo_image_rendering.append( "auto" );
@@ -259,14 +198,8 @@ void ObjectProperties::_init()
_combo_image_rendering.append( "optimizeSpeed" );
_combo_image_rendering.set_tooltip_text(_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation."));
-#if WITH_GTKMM_3_0
_combo_image_rendering.set_valign(Gtk::ALIGN_CENTER);
grid_top->attach(_combo_image_rendering, 1, 3, 1, 1);
-#else
- grid_top->attach(_combo_image_rendering, 1, 2, 3, 4,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_label_image_rendering.set_mnemonic_widget(_combo_image_rendering);
@@ -278,60 +211,36 @@ void ObjectProperties::_init()
Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox());
contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0);
-#if WITH_GTKMM_3_0
- Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid());
+ auto grid_cb = Gtk::manage(new Gtk::Grid());
grid_cb->set_row_homogeneous();
grid_cb->set_column_homogeneous(true);
-#else
- Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true));
-#endif
grid_cb->set_border_width(4);
hb_checkboxes->pack_start(*grid_cb, true, true, 0);
/* Hide */
_cb_hide.set_tooltip_text (_("Check to make the object invisible"));
-
-#if WITH_GTKMM_3_0
_cb_hide.set_hexpand();
_cb_hide.set_valign(Gtk::ALIGN_CENTER);
grid_cb->attach(_cb_hide, 0, 0, 1, 1);
-#else
- grid_cb->attach(_cb_hide, 0, 1, 0, 1,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_cb_hide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_hiddenToggled));
/* Lock */
// TRANSLATORS: "Lock" is a verb here
_cb_lock.set_tooltip_text(_("Check to make the object insensitive (not selectable by mouse)"));
-
-#if WITH_GTKMM_3_0
_cb_lock.set_hexpand();
_cb_lock.set_valign(Gtk::ALIGN_CENTER);
grid_cb->attach(_cb_lock, 1, 0, 1, 1);
-#else
- grid_cb->attach(_cb_lock, 1, 2, 0, 1,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
_cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled));
/* Button for setting the object's id, label, title and description. */
Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), 1));
-#if WITH_GTKMM_3_0
btn_set->set_hexpand();
btn_set->set_valign(Gtk::ALIGN_CENTER);
grid_cb->attach(*btn_set, 2, 0, 1, 1);
-#else
- grid_cb->attach(*btn_set, 2, 3, 0, 1,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::AttachOptions(), 0, 0 );
-#endif
btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged));
diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h
index dc28c0bad..8551d5fca 100644
--- a/src/ui/dialog/object-properties.h
+++ b/src/ui/dialog/object-properties.h
@@ -50,11 +50,7 @@ class SPDesktop;
class SPItem;
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 27694a9ac..fd78fec90 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -10,17 +10,13 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "objects.h"
-#include <gtkmm/widget.h>
#include <gtkmm/icontheme.h>
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
-#include <gtkmm/stock.h>
-
-#include <glibmm/i18n.h>
#include <glibmm/main.h>
#include "desktop.h"
@@ -34,12 +30,9 @@
#include "helper/action.h"
#include "inkscape.h"
#include "layer-manager.h"
-#include "preferences.h"
-#include "selection.h"
+#include "shortcuts.h"
#include "sp-clippath.h"
#include "sp-mask.h"
-#include "sp-item.h"
-#include "sp-object.h"
#include "sp-root.h"
#include "sp-shape.h"
#include "style.h"
@@ -52,13 +45,10 @@
#include "ui/widget/clipmaskicon.h"
#include "ui/widget/highlight-picker.h"
#include "ui/tools/node-tool.h"
-#include "ui/tools/tool-base.h"
#include "verbs.h"
#include "ui/widget/color-notebook.h"
#include "widgets/icon.h"
-#include "xml/node.h"
#include "xml/node-observer.h"
-#include "xml/repr.h"
//#define DUMP_LAYERS 1
@@ -319,11 +309,13 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/)
SPRoot* root = document->getRoot();
if ( root ) {
_selectedConnection.block();
+ _documentChangedCurrentLayer.block();
//Clear the tree store
_store->clear();
//Add all items recursively
_addObject( root, 0 );
_selectedConnection.unblock();
+ _documentChangedCurrentLayer.unblock();
//Set the tree selection
_objectsSelected(_desktop->selection);
//Handle button sensitivity
@@ -340,12 +332,11 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/)
void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow)
{
if ( _desktop && obj ) {
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
-
- if (SP_IS_ITEM(child))
+ for(auto& child: obj->children) {
+ if (SP_IS_ITEM(&child))
{
- SPItem * item = SP_ITEM(child);
- SPGroup * group = SP_IS_GROUP(child) ? SP_GROUP(child) : 0;
+ SPItem * item = SP_ITEM(&child);
+ SPGroup * group = SP_IS_GROUP(&child) ? SP_GROUP(&child) : 0;
//Add the item to the tree and set the column information
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
@@ -362,24 +353,28 @@ void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow)
row[_model->_colLocked] = !item->isSensitive();
row[_model->_colType] = group ? (group->layerMode() == SPGroup::LAYER ? 2 : 1) : 0;
row[_model->_colHighlight] = item->isHighlightSet() ? item->highlight_color() : item->highlight_color() & 0xffffff00;
- row[_model->_colClipMask] = item->clip_ref && item->clip_ref->getObject() ? 1 : (item->mask_ref && item->mask_ref->getObject() ? 2 : 0);
+ row[_model->_colClipMask] = item ? (
+ (item->clip_ref && item->clip_ref->getObject() ? 1 : 0) |
+ (item->mask_ref && item->mask_ref->getObject() ? 2 : 0)
+ ) : 0;
//row[_model->_colInsertOrder] = group ? (group->insertBottom() ? 2 : 1) : 0;
//If our parent object is a group and it's expanded, expand the tree
if (SP_IS_GROUP(obj) && SP_GROUP(obj)->expanded())
{
_tree.expand_to_path( _store->get_path(iter) );
+ _tree.collapse_row( _store->get_path(iter) );
}
//Add an object watcher to the item
- ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, child);
- child->getRepr()->addObserver(*w);
+ ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, &child);
+ child.getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
//If the item is a group, recursively add its children
if (group)
{
- _addObject( child, &row );
+ _addObject( &child, &row );
}
}
}
@@ -399,9 +394,8 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) {
//end mark
if (recurse)
{
- for (SPObject * iter = obj->children; iter != NULL; iter = iter->next)
- {
- _updateObject(iter, recurse);
+ for (auto& iter: obj->children) {
+ _updateObject(&iter, recurse);
}
}
}
@@ -426,7 +420,10 @@ bool ObjectsPanel::_checkForUpdated(const Gtk::TreeIter& iter, SPObject* obj)
row[_model->_colLocked] = item ? !item->isSensitive() : false;
row[_model->_colType] = group ? (group->layerMode() == SPGroup::LAYER ? 2 : 1) : 0;
row[_model->_colHighlight] = item ? (item->isHighlightSet() ? item->highlight_color() : item->highlight_color() & 0xffffff00) : 0;
- row[_model->_colClipMask] = item ? (item->clip_ref && item->clip_ref->getObject() ? 1 : (item->mask_ref && item->mask_ref->getObject() ? 2 : 0)) : 0;
+ row[_model->_colClipMask] = item ? (
+ (item->clip_ref && item->clip_ref->getObject() ? 1 : 0) |
+ (item->mask_ref && item->mask_ref->getObject() ? 2 : 0)
+ ) : 0;
//row[_model->_colInsertOrder] = group ? (group->insertBottom() ? 2 : 1) : 0;
return true;
@@ -478,21 +475,21 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) {
_selectedConnection.block();
_tree.get_selection()->unselect_all();
SPItem *item = NULL;
- std::vector<SPItem*> const items = sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); ++i){
+ auto items = sel->items();
+ for(auto i=items.begin(); i!=items.end(); ++i){
item = *i;
if (setOpacity)
{
_setCompositingValues(item);
setOpacity = false;
}
- _store->foreach(sigc::bind<SPItem *, bool>( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, (*i)==items.back()));
+ _store->foreach(sigc::bind<SPItem *, bool>( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, (*i)==items.back(), false));
}
if (!item) {
if (_desktop->currentLayer() && SP_IS_ITEM(_desktop->currentLayer())) {
item = SP_ITEM(_desktop->currentLayer());
_setCompositingValues(item);
- _store->foreach(sigc::bind<SPItem *, bool>( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, true));
+ _store->foreach(sigc::bind<SPItem *, bool>( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, false, true));
}
}
_selectedConnection.unblock();
@@ -511,28 +508,27 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
_blurConnection.block();
//Set the opacity
-#if WITH_GTKMM_3_0
_opacity_adjustment->set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment->get_upper());
-#else
- _opacity_adjustment.set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment.get_upper());
-#endif
SPFeBlend *spblend = NULL;
SPGaussianBlur *spblur = NULL;
if (item->style->getFilter())
{
- for(SPObject *primitive_obj = item->style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) {
- if(SP_IS_FEBLEND(primitive_obj) && !spblend) {
- //Get the blend mode
- spblend = SP_FEBLEND(primitive_obj);
- }
-
- if(SP_IS_GAUSSIANBLUR(primitive_obj) && !spblur) {
- //Get the blur value
- spblur = SP_GAUSSIANBLUR(primitive_obj);
- }
+ for (auto& primitive_obj: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) {
+ break;
}
+ if(SP_IS_FEBLEND(&primitive_obj) && !spblend) {
+ //Get the blend mode
+ spblend = SP_FEBLEND(&primitive_obj);
+ }
+
+ if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) {
+ //Get the blur value
+ spblur = SP_GAUSSIANBLUR(&primitive_obj);
+ }
+ }
}
-
+
//Set the blend mode
_fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL);
@@ -559,7 +555,7 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
* @param scrollto Whether to scroll to the item
* @return Whether to continue searching the tree
*/
-bool ObjectsPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPItem* item, bool scrollto)
+bool ObjectsPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPItem* item, bool scrollto, bool expand)
{
bool stopGoing = false;
@@ -568,13 +564,16 @@ bool ObjectsPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeI
{
//We found the item! Expand to the path and select it in the tree.
_tree.expand_to_path( path );
+ if (!expand)
+ // but don't expand itself, just the path
+ _tree.collapse_row(path);
Glib::RefPtr<Gtk::TreeSelection> select = _tree.get_selection();
select->select(iter);
if (scrollto) {
//Scroll to the item in the tree
- _tree.scroll_to_row(path);
+ _tree.scroll_to_row(path, 0.5);
}
stopGoing = true;
@@ -591,6 +590,7 @@ void ObjectsPanel::_pushTreeSelectionToCurrent()
if ( _desktop && _desktop->currentRoot() ) {
//block connections for selection and compositing values to prevent interference
_selectionChangedConnection.block();
+ _documentChangedCurrentLayer.block();
//Clear the selection and then iterate over the tree selection, pushing each item to the desktop
_desktop->selection->clear();
@@ -598,6 +598,7 @@ void ObjectsPanel::_pushTreeSelectionToCurrent()
_tree.get_selection()->selected_foreach_iter( sigc::bind<bool *>(sigc::mem_fun(*this, &ObjectsPanel::_selected_row_callback), &setOpacity));
//unblock connections
_selectionChangedConnection.unblock();
+ _documentChangedCurrentLayer.unblock();
_checkTreeSelection();
}
@@ -696,53 +697,63 @@ void ObjectsPanel::_setLockedIter( const Gtk::TreeModel::iterator& iter, const b
*/
bool ObjectsPanel::_handleKeyEvent(GdkEventKey *event)
{
+ if (!_desktop)
+ return false;
+
+ unsigned int shortcut;
+ shortcut = Inkscape::UI::Tools::get_group0_keyval(event) |
+ ( event->state & GDK_SHIFT_MASK ?
+ SP_SHORTCUT_SHIFT_MASK : 0 ) |
+ ( event->state & GDK_CONTROL_MASK ?
+ SP_SHORTCUT_CONTROL_MASK : 0 ) |
+ ( event->state & GDK_MOD1_MASK ?
+ SP_SHORTCUT_ALT_MASK : 0 );
+
+ switch (shortcut) {
+ // how to get users key binding for the action “start-interactive-search” ??
+ // ctrl+f is just the default
+ case GDK_KEY_f | SP_SHORTCUT_CONTROL_MASK:
+ return false;
+ break;
+ // shall we slurp ctrl+w to close panel?
+
+ // defocus:
+ case GDK_KEY_Escape:
+ if (_desktop->canvas) {
+ gtk_widget_grab_focus (GTK_WIDGET(_desktop->canvas));
+ return true;
+ }
+ break;
+ }
+
+ // invoke user defined shortcuts first
+ bool done = sp_shortcut_invoke(shortcut, _desktop);
+ if (done)
+ return true;
+ // handle events for the treeview
bool empty = _desktop->selection->isEmpty();
switch (Inkscape::UI::Tools::get_group0_keyval(event)) {
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
- case GDK_KEY_F2:
{
- Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
- if (iter && !_text_renderer->property_editable()) {
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn *focus_column = 0;
+
+ _tree.get_cursor(path, focus_column);
+ if (focus_column == _name_column && !_text_renderer->property_editable()) {
//Rename item
- Gtk::TreeModel::Path *path = new Gtk::TreeModel::Path(iter);
_text_renderer->property_editable() = true;
- _tree.set_cursor(*path, *_name_column, true);
+ _tree.set_cursor(path, *_name_column, true);
grab_focus();
return true;
}
- }
- break;
- case GDK_KEY_Home:
- //Move item(s) to top of containing group/layer
- _fireAction( empty ? SP_VERB_LAYER_TO_TOP : SP_VERB_SELECTION_TO_FRONT );
- break;
- case GDK_KEY_End:
- //Move item(s) to bottom of containing group/layer
- _fireAction( empty ? SP_VERB_LAYER_TO_BOTTOM : SP_VERB_SELECTION_TO_BACK );
- break;
- case GDK_KEY_Page_Up:
- {
- //Move item(s) up in containing group/layer
- int ch = event->state & GDK_SHIFT_MASK ? SP_VERB_LAYER_MOVE_TO_NEXT : SP_VERB_SELECTION_RAISE;
- _fireAction( empty ? SP_VERB_LAYER_RAISE : ch );
- break;
- }
- case GDK_KEY_Page_Down:
- {
- //Move item(s) down in containing group/layer
- int ch = event->state & GDK_SHIFT_MASK ? SP_VERB_LAYER_MOVE_TO_PREV : SP_VERB_SELECTION_LOWER;
- _fireAction( empty ? SP_VERB_LAYER_LOWER : ch );
+ return false;
break;
}
-
- //TODO: Handle Ctrl-A, etc.
- default:
- return false;
}
- return true;
+ return false;
}
/**
@@ -1186,7 +1197,7 @@ bool ObjectsPanel::_executeAction()
}
else
{
- _fireAction( SP_VERB_SELECTION_RAISE );
+ _fireAction( SP_VERB_SELECTION_STACK_UP );
}
}
break;
@@ -1198,7 +1209,7 @@ bool ObjectsPanel::_executeAction()
}
else
{
- _fireAction( SP_VERB_SELECTION_LOWER );
+ _fireAction( SP_VERB_SELECTION_STACK_DOWN );
}
}
break;
@@ -1292,9 +1303,9 @@ bool ObjectsPanel::_executeAction()
break;
case BUTTON_COLLAPSE_ALL:
{
- for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) {
- if (SP_IS_GROUP(obj)) {
- _setCollapsed(SP_GROUP(obj));
+ for (auto& obj: _document->getRoot()->children) {
+ if (SP_IS_GROUP(&obj)) {
+ _setCollapsed(SP_GROUP(&obj));
}
}
_objectsChanged(_document->getRoot());
@@ -1404,9 +1415,10 @@ void ObjectsPanel::_setCollapsed(SPGroup * group)
{
group->setExpanded(false);
group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
- for (SPObject *iter = group->children; iter != NULL; iter = iter->next)
- {
- if (SP_IS_GROUP(iter)) _setCollapsed(SP_GROUP(iter));
+ for (auto& iter: group->children) {
+ if (SP_IS_GROUP(&iter)) {
+ _setCollapsed(SP_GROUP(&iter));
+ }
}
}
@@ -1481,11 +1493,7 @@ void ObjectsPanel::_opacityChangedIter(const Gtk::TreeIter& iter)
if (item)
{
item->style->opacity.set = TRUE;
-#if WITH_GTKMM_3_0
item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment->get_value() / _opacity_adjustment->get_upper());
-#else
- item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment.get_value() / _opacity_adjustment.get_upper());
-#endif
item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
}
}
@@ -1521,25 +1529,38 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl
if (blendmode != "normal") {
gdouble radius = 0;
if (item->style->getFilter()) {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_GAUSSIANBLUR(primitive)) {
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_GAUSSIANBLUR(&primitive)) {
Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX);
if (bbox) {
- radius = SP_GAUSSIANBLUR(primitive)->stdDeviation.getNumber();
+ double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
+ radius = _fe_blur.get_blur_value() * perimeter / 400;
}
}
}
}
+ if (radius != 0) {
+ // The modify function expects radius to be in display pixels.
+ Geom::Affine i2d (item->i2dt_affine());
+ double expansion = i2d.descrim();
+ radius *= expansion;
+ }
SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius);
sp_style_set_property_url(item, "filter", filter, false);
} else {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_FEBLEND(primitive)) {
- primitive->deleteObject();
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_FEBLEND(&primitive)) {
+ primitive.deleteObject();
break;
}
}
- if (!item->style->getFilter()->children) {
+ if (!item->style->getFilter()->firstChild()) {
remove_filter(item, false);
}
}
@@ -1590,13 +1611,16 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur)
SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius);
sp_style_set_property_url(item, "filter", filter, false);
} else if (item->style->filter.set && item->style->getFilter()) {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_GAUSSIANBLUR(primitive)) {
- primitive->deleteObject();
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_GAUSSIANBLUR(&primitive)) {
+ primitive.deleteObject();
break;
}
}
- if (!item->style->getFilter()->children) {
+ if (!item->style->getFilter()->firstChild()) {
remove_filter(item, false);
}
}
@@ -1628,11 +1652,7 @@ ObjectsPanel::ObjectsPanel() :
_opacity_vbox(false, 0),
_opacity_label(_("Opacity:")),
_opacity_label_unit(_("%")),
-#if WITH_GTKMM_3_0
_opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)),
-#else
- _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0),
-#endif
_opacity_hscale(_opacity_adjustment),
_opacity_spin_button(_opacity_adjustment, 0.01, 1),
_fe_cb(UI::Widget::SimpleFilterModifier::BLEND),
@@ -1739,6 +1759,8 @@ ObjectsPanel::ObjectsPanel() :
//Set the expander and search columns
_tree.set_expander_column( *_tree.get_column(nameColNum) );
_tree.set_search_column(_model->_colLabel);
+ // use ctrl+f to start search
+ _tree.set_enable_search(false);
//Set up the tree selection
_tree.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
@@ -1762,12 +1784,8 @@ ObjectsPanel::ObjectsPanel() :
_scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
_scroller.set_shadow_type(Gtk::SHADOW_IN);
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
_scroller.get_preferred_size(sreq_natural, sreq);
-#else
- sreq = _scroller.size_request();
-#endif
int minHeight = 70;
if (sreq.height < minHeight) {
// Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar
@@ -1800,13 +1818,8 @@ ObjectsPanel::ObjectsPanel() :
_opacity_hbox.pack_start(_opacity_spin_button, false, false, 0);
_opacity_hbox.pack_start(_opacity_label_unit, false, false, 3);
_opacity_hscale.set_draw_value(false);
-#if WITH_GTKMM_3_0
_opacityConnection = _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged));
_opacity_label.set_mnemonic_widget(_opacity_hscale);
-#else
- _opacityConnection = _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged));
- _opacity_label.set_mnemonic_widget(_opacity_hscale);
-#endif
//Keep the labels aligned
GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
@@ -1907,8 +1920,8 @@ ObjectsPanel::ObjectsPanel() :
_popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem()));
- _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_RAISE, "gtk-go-up", _("Up"), (int)BUTTON_UP ) );
- _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_LOWER, "gtk-go-down", _("Down"), (int)BUTTON_DOWN ) );
+ _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_STACK_UP, "gtk-go-up", _("Up"), (int)BUTTON_UP ) );
+ _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_STACK_DOWN, "gtk-go-down", _("Down"), (int)BUTTON_DOWN ) );
_popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem()));
@@ -2047,6 +2060,7 @@ void ObjectsPanel::setDesktop( SPDesktop* desktop )
if ( desktop != _desktop ) {
_documentChangedConnection.disconnect();
+ _documentChangedCurrentLayer.disconnect();
_selectionChangedConnection.disconnect();
if ( _desktop ) {
_desktop = 0;
@@ -2056,6 +2070,9 @@ void ObjectsPanel::setDesktop( SPDesktop* desktop )
if ( _desktop ) {
//Connect desktop signals
_documentChangedConnection = _desktop->connectDocumentReplaced( sigc::mem_fun(*this, &ObjectsPanel::setDocument));
+
+ _documentChangedCurrentLayer = _desktop->connectCurrentLayerChanged( sigc::mem_fun(*this, &ObjectsPanel::_objectsChanged));
+
_selectionChangedConnection = _desktop->selection->connectChanged( sigc::mem_fun(*this, &ObjectsPanel::_objectsSelected));
setDocument(_desktop, _desktop->doc());
diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h
index 9b9a6025a..21305669e 100644
--- a/src/ui/dialog/objects.h
+++ b/src/ui/dialog/objects.h
@@ -77,6 +77,9 @@ private:
//Connection for when the document changes
sigc::connection _documentChangedConnection;
+ //Connection for when the active layer changes
+ sigc::connection _documentChangedCurrentLayer;
+
//Connection for when the active selection in the document changes
sigc::connection _selectionChangedConnection;
@@ -134,15 +137,9 @@ private:
Gtk::TreeView _tree;
Gtk::CellRendererText *_text_renderer;
Gtk::TreeView::Column *_name_column;
-#if WITH_GTKMM_3_0
Gtk::Box _buttonsRow;
Gtk::Box _buttonsPrimary;
Gtk::Box _buttonsSecondary;
-#else
- Gtk::HBox _buttonsRow;
- Gtk::HBox _buttonsPrimary;
- Gtk::HBox _buttonsSecondary;
-#endif
Gtk::ScrolledWindow _scroller;
Gtk::Menu _popupMenu;
Inkscape::UI::Widget::SpinButton _spinBtn;
@@ -161,11 +158,7 @@ private:
Gtk::HBox _opacity_hbox;
Gtk::Label _opacity_label;
Gtk::Label _opacity_label_unit;
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment;
-#else
- Gtk::Adjustment _opacity_adjustment;
-#endif
Gtk::HScale _opacity_hscale;
Inkscape::UI::Widget::SpinButton _opacity_spin_button;
@@ -226,7 +219,7 @@ private:
bool _checkForUpdated(const Gtk::TreeIter& iter, SPObject* obj);
void _objectsSelected(Selection *sel);
- bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPItem* item, bool scrollto);
+ bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPItem* item, bool scrollto, bool expand);
void _objectsChanged(SPObject *obj);
void _addObject( SPObject* obj, Gtk::TreeModel::Row* parentRow );
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index f2ee79d06..72a2814ed 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -18,31 +18,25 @@
#include "ocaldialogs.h"
-#include <stdio.h> // rename()
-#include <unistd.h> // close()
-#include <errno.h> // errno
-#include <string.h> // strerror()
-
#include "path-prefix.h"
#include "filedialogimpl-gtkmm.h"
#include "ui/interface.h"
#include "inkgc/gc-core.h"
-#include "ui/dialog-events.h"
#include "io/sys.h"
#include "preferences.h"
#include <gtkmm/notebook.h>
#include <gtkmm/spinner.h>
-#include <gtkmm/stock.h>
#include <gdkmm/general.h>
#include <libxml/tree.h>
+#include <glibmm/i18n.h>
+#include <glibmm/miscutils.h>
+#include <glibmm/markup.h>
#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
-#include <glibmm/i18n.h>
#include <glibmm/main.h>
-#include <glibmm/markup.h>
-#include <glibmm/miscutils.h>
+
#include "ui/icon-names.h"
namespace Inkscape
@@ -316,27 +310,10 @@ LoadingBox::LoadingBox() : Gtk::EventBox()
draw_spinner = false;
spinner_step = 0;
-#if WITH_GTKMM_3_0
signal_draw().connect(sigc::mem_fun(*this, &LoadingBox::_on_draw), false);
-#else
- signal_expose_event().connect(sigc::mem_fun(*this, &LoadingBox::_on_expose_event), false);
-#endif
}
-#if !WITH_GTKMM_3_0
-bool LoadingBox::_on_expose_event(GdkEventExpose* /*event*/)
-{
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
-
- return _on_draw(cr);
-}
-#endif
-
-bool LoadingBox::_on_draw(const Cairo::RefPtr<Cairo::Context> &
-#if WITH_GTKMM_3_0
-cr
-#endif
-)
+bool LoadingBox::_on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
{
// Draw shadow
int x = get_allocation().get_x();
@@ -344,27 +321,14 @@ cr
int width = get_allocation().get_width();
int height = get_allocation().get_height();
-#if WITH_GTKMM_3_0
get_style_context()->render_frame(cr, x, y, width, height);
-#else
- get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN,
- Gdk::Rectangle(x, y, width, height),
- *this, Glib::ustring("viewport"), x, y, width, height);
-#endif
if (draw_spinner) {
int spinner_size = 16;
int spinner_x = x + (width - spinner_size) / 2;
int spinner_y = y + (height - spinner_size) / 2;
-#if WITH_GTKMM_3_0
get_style_context()->render_activity(cr, spinner_x, spinner_y, spinner_size, spinner_size);
-#else
- gtk_paint_spinner(gtk_widget_get_style(GTK_WIDGET(gobj())),
- gtk_widget_get_window(GTK_WIDGET(gobj())),
- gtk_widget_get_state(GTK_WIDGET(gobj())), NULL, GTK_WIDGET(gobj()),
- NULL, spinner_step, spinner_x, spinner_y, spinner_size, spinner_size);
-#endif
}
return false;
@@ -434,11 +398,7 @@ PreviewWidget::PreviewWidget() : Gtk::VBox(false, 12)
box_loading->set_size_request(90, 90);
set_border_width(12);
-#if WITH_GTKMM_3_0
signal_draw().connect(sigc::mem_fun(*this, &PreviewWidget::_on_draw), false);
-#else
- signal_expose_event().connect(sigc::mem_fun(*this, &PreviewWidget::_on_expose_event), false);
-#endif
clear();
}
@@ -482,15 +442,6 @@ void PreviewWidget::clear()
image->hide();
}
-#if !WITH_GTKMM_3_0
-bool PreviewWidget::_on_expose_event(GdkEventExpose* /*event*/)
-{
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
-
- return _on_draw(cr);
-}
-#endif
-
bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
// Draw background
@@ -499,16 +450,10 @@ bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
int width = get_allocation().get_width();
int height = get_allocation().get_height();
-#if WITH_GTKMM_3_0
Gdk::RGBA background_fill;
get_style_context()->lookup_color("base_color", background_fill);
cr->rectangle(x, y, width, height);
Gdk::Cairo::set_source_rgba(cr, background_fill);
-#else
- Gdk::Color background_fill = get_style()->get_base(get_state());
- cr->rectangle(x, y, width, height);
- Gdk::Cairo::set_source_color(cr, background_fill);
-#endif
cr->fill();
@@ -517,7 +462,8 @@ bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
StatusWidget::StatusWidget() : Gtk::HBox(false, 6)
{
- image = new Gtk::Image(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_MENU);
+ image = new Gtk::Image();
+ image->set_from_icon_name("dialog-error", Gtk::ICON_SIZE_MENU);
spinner = new Gtk::Spinner();
label = new Gtk::Label();
@@ -542,7 +488,7 @@ void StatusWidget::set_info(Glib::ustring text)
spinner->hide();
image->show();
label->show();
- image->set(Gtk::Stock::DIALOG_INFO, Gtk::ICON_SIZE_MENU);
+ image->set_from_icon_name("dialog-information", Gtk::ICON_SIZE_MENU);
label->set_text(text);
}
@@ -551,7 +497,7 @@ void StatusWidget::set_error(Glib::ustring text)
spinner->hide();
image->show();
label->show();
- image->set(Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_MENU);
+ image->set_from_icon_name("dialog-error", Gtk::ICON_SIZE_MENU);
label->set_text(text);
}
@@ -573,57 +519,12 @@ void StatusWidget::end_process()
clear();
}
-#if !GTK_CHECK_VERSION(3,0,0)
-SearchEntry::SearchEntry() : Gtk::Entry()
-{
- signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed));
- signal_icon_press().connect(sigc::mem_fun(*this, &SearchEntry::_on_icon_pressed));
-
- set_icon_from_icon_name(INKSCAPE_ICON("edit-find"), Gtk::ENTRY_ICON_PRIMARY);
- gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL);
-}
-
-void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* /*event*/)
-{
- if (icon_position == Gtk::ENTRY_ICON_SECONDARY) {
- grab_focus();
- delete_text(0, -1);
- } else if (icon_position == Gtk::ENTRY_ICON_PRIMARY) {
- select_region(0, -1);
- grab_focus();
- }
-}
-
-void SearchEntry::_on_changed()
-{
- if (get_text().empty()) {
- gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL);
- } else {
- set_icon_from_icon_name(INKSCAPE_ICON("edit-clear"), Gtk::ENTRY_ICON_SECONDARY);
- }
-}
-#endif
-
-
BaseBox::BaseBox() : Gtk::EventBox()
{
-#if WITH_GTKMM_3_0
signal_draw().connect(sigc::mem_fun(*this, &BaseBox::_on_draw), false);
-#else
- signal_expose_event().connect(sigc::mem_fun(*this, &BaseBox::_on_expose_event), false);
-#endif
set_visible_window(false);
}
-#if !WITH_GTKMM_3_0
-bool BaseBox::_on_expose_event(GdkEventExpose* /*event*/)
-{
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
-
- return _on_draw(cr);
-}
-#endif
-
bool BaseBox::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
// Draw background and shadow
@@ -632,23 +533,12 @@ bool BaseBox::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
int width = get_allocation().get_width();
int height = get_allocation().get_height();
-#if WITH_GTKMM_3_0
Gdk::RGBA background_fill;
get_style_context()->lookup_color("base_color", background_fill);
cr->rectangle(x, y, width, height);
Gdk::Cairo::set_source_rgba(cr, background_fill);
cr->fill();
get_style_context()->render_frame(cr, x, y, width, height);
-#else
- Gdk::Color background_fill = get_style()->get_base(get_state());
- cr->rectangle(x, y, width, height);
- Gdk::Cairo::set_source_color(cr, background_fill);
- cr->fill();
-
- get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN,
- Gdk::Rectangle(x, y, width, height),
- *this, Glib::ustring("viewport"), x, y, width, height);
-#endif
return false;
}
@@ -665,23 +555,10 @@ LogoArea::LogoArea() : Gtk::EventBox()
draw_logo = false;
}
-#if WITH_GTKMM_3_0
signal_draw().connect(sigc::mem_fun(*this, &LogoArea::_on_draw));
-#else
- signal_expose_event().connect(sigc::mem_fun(*this, &LogoArea::_on_expose_event));
-#endif
set_visible_window(false);
}
-#if !WITH_GTKMM_3_0
-bool LogoArea::_on_expose_event(GdkEventExpose* /*event*/)
-{
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
-
- return _on_draw(cr);
-}
-#endif
-
bool LogoArea::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
if (draw_logo) {
@@ -692,16 +569,9 @@ bool LogoArea::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
int x_logo = x + (width - 220) / 2;
int y_logo = y + (height - 76) / 2;
- // Draw logo, we mask [read fill] it with the mid colour from the
- // user's GTK theme
-#if WITH_GTKMM_3_0
- // For GTK+ 3, use grey
+ // Draw logo, we mask [read fill] it with grey
Gdk::RGBA logo_fill("grey");
Gdk::Cairo::set_source_rgba(cr, logo_fill);
-#else
- Gdk::Color logo_fill = get_style()->get_mid(get_state());
- Gdk::Cairo::set_source_color(cr, logo_fill);
-#endif
cr->mask(logo_mask, x_logo, y_logo);
}
@@ -1179,16 +1049,9 @@ void ImportDialog::update_label_no_search_results()
Glib::ustring msg_two = _("Please make sure all keywords are spelled correctly,"
" or try again with different keywords.");
-#if WITH_GTKMM_3_0
- Glib::ustring markup = Glib::ustring::compose(
+ auto markup = Glib::ustring::compose(
"<span size=\"large\">%1</span>\n<span>%2</span>",
msg_one, msg_two);
-#else
- Gdk::Color grey = entry_search->get_style()->get_text_aa(entry_search->get_state());
- Glib::ustring markup = Glib::ustring::compose(
- "<span size=\"large\">%1</span>\n<span color=\"%2\">%3</span>",
- msg_one, grey.to_string(), msg_two);
-#endif
label_not_found->set_markup(markup);
}
@@ -1208,38 +1071,22 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types
dialogType = file_types;
// Creation
- Gtk::VBox *vbox = new Gtk::VBox(false, 0);
-
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *hbuttonbox_bottom = new Gtk::ButtonBox();
-#else
- Gtk::HButtonBox *hbuttonbox_bottom = new Gtk::HButtonBox();
-#endif
-
- Gtk::HBox *hbox_bottom = new Gtk::HBox(false, 12);
+ auto vbox = new Gtk::VBox(false, 0);
+ auto hbuttonbox_bottom = new Gtk::ButtonBox();
+ auto hbox_bottom = new Gtk::HBox(false, 12);
BaseBox *basebox_logo = new BaseBox();
BaseBox *basebox_no_search_results = new BaseBox();
label_not_found = new Gtk::Label();
label_description = new Gtk::Label();
-
-#if GTK_CHECK_VERSION(3,0,0)
entry_search = new Gtk::SearchEntry();
-#else
- entry_search = new SearchEntry();
-#endif
-
button_search = new Gtk::Button(_("Search"));
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox* hbuttonbox_search = new Gtk::ButtonBox();
-#else
- Gtk::HButtonBox* hbuttonbox_search = new Gtk::HButtonBox();
-#endif
+ auto hbuttonbox_search = new Gtk::ButtonBox();
Gtk::ScrolledWindow* scrolledwindow_preview = new Gtk::ScrolledWindow();
preview_files = new PreviewWidget();
/// Add the buttons in the bottom of the dialog
- button_cancel = new Gtk::Button(Gtk::Stock::CANCEL);
+ button_cancel = new Gtk::Button(_("_Cancel"), true);
button_close = new Gtk::Button(_("Close"));
button_import = new Gtk::Button(_("Import"));
list_results = new SearchResultList(RESULTS_COLUMN_LENGTH);
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
index 9de24d821..db3c60786 100644
--- a/src/ui/dialog/ocaldialogs.h
+++ b/src/ui/dialog/ocaldialogs.h
@@ -17,19 +17,16 @@
# include <config.h>
#endif
-//Gtk includes
+// Gtkmm includes
#include <gtkmm/box.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/listviewtext.h>
#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/searchentry.h>
#include <gtkmm/window.h>
#include <cairomm/refptr.h>
-#if GTK_CHECK_VERSION(3,0,0)
-# include <gtkmm/searchentry.h>
-#endif
-
#include <giomm/file.h>
//Inkscape includes
@@ -283,10 +280,6 @@ private:
sigc::connection timeout;
bool draw_spinner;
-#if !WITH_GTKMM_3_0
- bool _on_expose_event(GdkEventExpose* event);
-#endif
-
bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
bool on_timeout();
};
@@ -310,10 +303,6 @@ private:
WrapLabel* label_description;
WrapLabel* label_time;
-#if !WITH_GTKMM_3_0
- bool _on_expose_event(GdkEventExpose* event);
-#endif
-
bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
@@ -336,21 +325,6 @@ public:
Gtk::Label* label;
};
-#if !GTK_CHECK_VERSION(3,0,0)
-/**
- * A Gtk::Entry with search & clear icons
- */
-class SearchEntry : public Gtk::Entry
-{
-public:
- SearchEntry();
-
-private:
- void _on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* event);
- void _on_changed();
-};
-#endif
-
/**
* A box which paints an overlay of the OCAL logo
*/
@@ -359,9 +333,6 @@ class LogoArea : public Gtk::EventBox
public:
LogoArea();
private:
-#if !WITH_GTKMM_3_0
- bool _on_expose_event(GdkEventExpose* event);
-#endif
bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
bool draw_logo;
Cairo::RefPtr<Cairo::ImageSurface> logo_mask;
@@ -375,9 +346,6 @@ class BaseBox : public Gtk::EventBox
public:
BaseBox();
private:
-#if !WITH_GTKMM_3_0
- bool _on_expose_event(GdkEventExpose* event);
-#endif
bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
@@ -459,12 +427,7 @@ protected:
private:
Glib::ustring filename_image;
Glib::ustring filename_thumbnail;
-
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::SearchEntry *entry_search;
-#else
- SearchEntry *entry_search;
-#endif
LogoArea *drawingarea_logo;
SearchResultList *list_results;
diff --git a/src/ui/dialog/panel-dialog.h b/src/ui/dialog/panel-dialog.h
index 39110f47a..5919fcaeb 100644
--- a/src/ui/dialog/panel-dialog.h
+++ b/src/ui/dialog/panel-dialog.h
@@ -15,8 +15,8 @@
# include <config.h>
#endif
+#include <glibmm/i18n.h>
#include <gtkmm/dialog.h>
-#include <gtkmm/stock.h>
#include "verbs.h"
#include "dialog.h"
@@ -165,7 +165,7 @@ PanelDialog<B>::PanelDialog(Widget::Panel &panel, char const *prefs_path, int co
panel.addResponseButton(apply_label, Gtk::RESPONSE_APPLY);
panel.setDefaultResponse(Gtk::RESPONSE_APPLY);
}
- panel.addResponseButton(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
+ panel.addResponseButton(_("_Close"), Gtk::RESPONSE_CLOSE);
}
show_all_children();
@@ -214,7 +214,7 @@ PanelDialog<Behavior::FloatingBehavior>::PanelDialog(UI::Widget::Panel &panel, c
panel.addResponseButton(apply_label, Gtk::RESPONSE_APPLY);
panel.setDefaultResponse(Gtk::RESPONSE_APPLY);
}
- panel.addResponseButton(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
+ panel.addResponseButton(_("_Close"), Gtk::RESPONSE_CLOSE);
}
show_all_children();
diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp
index f557ff0fc..3e6617cfe 100644
--- a/src/ui/dialog/pixelartdialog.cpp
+++ b/src/ui/dialog/pixelartdialog.cpp
@@ -28,10 +28,8 @@
#include "pixelartdialog.h"
#include <gtkmm/radiobutton.h>
-#include <gtkmm/stock.h>
#include <gtkmm/messagedialog.h>
-#include <gtk/gtk.h> //for GTK_RESPONSE* types
#include <glibmm/i18n.h>
#include "ui/widget/spinbutton.h"
@@ -41,18 +39,13 @@
#include "desktop-tracker.h"
#include "message-stack.h"
#include "selection.h"
-#include "preferences.h"
#include "sp-image.h"
#include "display/cairo-utils.h"
#include "libdepixelize/kopftracer2011.h"
-#include <algorithm>
#include "document.h"
-#include "xml/repr.h"
-#include "xml/document.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
-#include "color.h"
#include "svg/css-ostringstream.h"
#include "document-undo.h"
@@ -297,12 +290,12 @@ PixelArtDialogImpl::PixelArtDialogImpl() :
mainResetButton ->set_tooltip_text(_("Reset all settings to defaults"));
//## The OK button
- mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
+ mainCancelButton = addResponseButton(_("_Stop"), GTK_RESPONSE_CANCEL);
if (mainCancelButton) {
mainCancelButton->set_tooltip_text(_("Abort a trace in progress"));
mainCancelButton->set_sensitive(false);
}
- mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK);
+ mainOkButton = addResponseButton(_("_OK"), GTK_RESPONSE_OK);
mainOkButton->set_tooltip_text(_("Execute the trace"));
contents->pack_start(buttonsHBox);
@@ -372,8 +365,8 @@ void PixelArtDialogImpl::vectorize()
return;
}
- std::vector<SPItem*> const items = desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();++i){
+ auto items = desktop->selection->items();
+ for(auto i=items.begin(); i!=items.end();++i){
if ( !SP_IS_IMAGE(*i) )
continue;
diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp
index 5ec1285c1..9485b6ba3 100644
--- a/src/ui/dialog/polar-arrange-tab.cpp
+++ b/src/ui/dialog/polar-arrange-tab.cpp
@@ -17,10 +17,8 @@
#include "preferences.h"
#include "inkscape.h"
-#include "selection.h"
#include "document.h"
#include "document-undo.h"
-#include "sp-item.h"
#include "widgets/icon.h"
#include "desktop.h"
#include "sp-ellipse.h"
@@ -33,11 +31,7 @@ namespace Dialog {
PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
: parent(parent_),
-#if WITH_GTKMM_3_0
parametersTable(),
-#else
- parametersTable(3, 3, false),
-#endif
centerY("", C_("Polar arrange tab", "Y coordinate of the center"), UNIT_TYPE_LINEAR),
centerX("", C_("Polar arrange tab", "X coordinate of the center"), centerY),
radiusY("", C_("Polar arrange tab", "Y coordinate of the radius"), UNIT_TYPE_LINEAR),
@@ -49,14 +43,14 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
anchorPointLabel.set_alignment(Gtk::ALIGN_START);
pack_start(anchorPointLabel, false, false);
- anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Object's bounding box:"));
+ anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Objects' bounding boxes:"));
anchorRadioGroup = anchorBoundingBoxRadio.get_group();
anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed));
pack_start(anchorBoundingBoxRadio, false, false);
pack_start(anchorSelector, false, false);
- anchorObjectPivotRadio.set_label(C_("Polar arrange tab", "Object's rotational center"));
+ anchorObjectPivotRadio.set_label(C_("Polar arrange tab", "Objects' rotational centers"));
anchorObjectPivotRadio.set_group(anchorRadioGroup);
anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed));
pack_start(anchorObjectPivotRadio, false, false);
@@ -81,11 +75,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
pack_start(arrangeOnParametersRadio, false, false);
centerLabel.set_text(C_("Polar arrange tab", "Center X/Y:"));
-#if WITH_GTKMM_3_0
parametersTable.attach(centerLabel, 0, 0, 1, 1);
-#else
- parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL);
-#endif
centerX.setDigits(2);
centerX.setIncrements(0.2, 0);
centerX.setRange(-10000, 10000);
@@ -94,20 +84,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
centerY.setIncrements(0.2, 0);
centerY.setRange(-10000, 10000);
centerY.setValue(0, "px");
-#if WITH_GTKMM_3_0
parametersTable.attach(centerX, 1, 0, 1, 1);
parametersTable.attach(centerY, 2, 0, 1, 1);
-#else
- parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL);
- parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL);
-#endif
radiusLabel.set_text(C_("Polar arrange tab", "Radius X/Y:"));
-#if WITH_GTKMM_3_0
parametersTable.attach(radiusLabel, 0, 1, 1, 1);
-#else
- parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL);
-#endif
radiusX.setDigits(2);
radiusX.setIncrements(0.2, 0);
radiusX.setRange(0.001, 10000);
@@ -116,20 +97,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
radiusY.setIncrements(0.2, 0);
radiusY.setRange(0.001, 10000);
radiusY.setValue(100, "px");
-#if WITH_GTKMM_3_0
parametersTable.attach(radiusX, 1, 1, 1, 1);
parametersTable.attach(radiusY, 2, 1, 1, 1);
-#else
- parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL);
- parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL);
-#endif
angleLabel.set_text(_("Angle X/Y:"));
-#if WITH_GTKMM_3_0
parametersTable.attach(angleLabel, 0, 2, 1, 1);
-#else
- parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL);
-#endif
angleX.setDigits(2);
angleX.setIncrements(0.2, 0);
angleX.setRange(-10000, 10000);
@@ -138,13 +110,8 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_)
angleY.setIncrements(0.2, 0);
angleY.setRange(-10000, 10000);
angleY.setValue(180, "°");
-#if WITH_GTKMM_3_0
parametersTable.attach(angleX, 1, 2, 1, 1);
parametersTable.attach(angleY, 2, 2, 1, 1);
-#else
- parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL);
- parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL);
-#endif
pack_start(parametersTable, false, false);
rotateObjectsCheckBox.set_label(_("Rotate objects"));
@@ -297,7 +264,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p)
void PolarArrangeTab::arrange()
{
Inkscape::Selection *selection = parent->getDesktop()->getSelection();
- const std::vector<SPItem*> tmp(selection->itemList());
+ const std::vector<SPItem*> tmp(selection->items().begin(), selection->items().end());
SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection
bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active();
diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h
index f7d7bf11f..1a4e04eda 100644
--- a/src/ui/dialog/polar-arrange-tab.h
+++ b/src/ui/dialog/polar-arrange-tab.h
@@ -20,12 +20,7 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/radiobuttongroup.h>
-
-#if WITH_GTKMM_3_0
- #include <gtkmm/grid.h>
-#else
- #include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
namespace Inkscape {
namespace UI {
@@ -75,11 +70,7 @@ private:
Gtk::RadioButton arrangeOnLastCircleRadio;
Gtk::RadioButton arrangeOnParametersRadio;
-#if WITH_GTKMM_3_0
Gtk::Grid parametersTable;
-#else
- Gtk::Table parametersTable;
-#endif
Gtk::Label centerLabel;
Inkscape::UI::Widget::ScalarUnit centerY;
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index c44d645a5..9ebbf040c 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -11,7 +11,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include <gtkmm.h>
@@ -26,7 +26,6 @@
#include "extension/internal/cairo-render-context.h"
#include "extension/internal/cairo-renderer.h"
-#include "ui/widget/rendering-options.h"
#include "document.h"
#include "util/units.h"
diff --git a/src/ui/dialog/prototype.cpp b/src/ui/dialog/prototype.cpp
new file mode 100644
index 000000000..b3bf60aab
--- /dev/null
+++ b/src/ui/dialog/prototype.cpp
@@ -0,0 +1,171 @@
+/*
+ * A bare minimum example of deriving from Inkscape::UI:Widget::Panel.
+ *
+ * Author:
+ * Tavmjong Bah
+ *
+ * Copyright (C) Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Released under the GNU GPL, read the file 'COPYING' for more information.
+ */
+
+#include "ui/dialog/prototype.h"
+#include "verbs.h"
+#include "desktop.h"
+#include "document.h"
+#include "selection.h"
+
+// Only for use in demonstration widget.
+#include "sp-root.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+Prototype::Prototype() :
+ // UI::Widget::Panel("Prototype Label", "/dialogs/prototype", SP_VERB_DIALOG_PROTOTYPE,
+ // "Prototype Apply Label", true),
+ UI::Widget::Panel("Prototype Label", "/dialogs/prototype", SP_VERB_DIALOG_PROTOTYPE),
+
+ desktopTracker() //,
+ // desktopChangedConnection()
+{
+ std::cout << "Prototype::Prototype()" << std::endl;
+
+ // A widget for demonstration that displays the current SVG's id.
+ _getContents()->pack_start(label); // Panel::_getContents()
+
+ // desktop is set by Panel constructor so this should never be NULL.
+ // Note, we need to use getDesktop() since _desktop is private in Panel.h.
+ // It should probably be protected instead... but need to verify in doesn't break anything.
+ if (getDesktop() == NULL) {
+ std::cerr << "Prototype::Prototype: desktop is NULL!" << std::endl;
+ }
+
+ connectionDesktopChanged = desktopTracker.connectDesktopChanged(
+ sigc::mem_fun(*this, &Prototype::handleDesktopChanged) );
+ desktopTracker.connect(GTK_WIDGET(gobj()));
+
+ // This results in calling handleDocumentReplaced twice. Fix me!
+ connectionDocumentReplaced = getDesktop()->connectDocumentReplaced(
+ sigc::mem_fun(this, &Prototype::handleDocumentReplaced));
+
+ // Alternative mechanism but results in calling handleDocumentReplaced four times.
+ // signalDocumentReplaced().connect(
+ // sigc::mem_fun(this, &Prototype::handleDocumentReplaced));
+
+ connectionSelectionChanged = getDesktop()->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &Prototype::handleSelectionChanged)));
+
+ updateLabel();
+}
+
+Prototype::~Prototype()
+{
+ // Never actually called.
+ std::cout << "Prototype::~Prototype()" << std::endl;
+ connectionDesktopChanged.disconnect();
+ connectionDocumentReplaced.disconnect();
+ connectionSelectionChanged.disconnect();
+}
+
+/*
+ * Called when a dialog is displayed, including when a dialog is reopened.
+ * (When a dialog is closed, it is not destroyed so the contructor is not called.
+ * This function can handle any reinitialization needed.)
+ */
+void
+Prototype::present()
+{
+ std::cout << "Prototype::present()" << std::endl;
+ UI::Widget::Panel::present();
+}
+
+/*
+ * When Inkscape is first opened, a default document is shown. If another document is immediately
+ * opened, it will replace the default document in the same desktop. This function handles the
+ * change. Bug: This is called twice for some reason.
+ */
+void
+Prototype::handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */)
+{
+ std::cout << "Prototype::handleDocumentReplaced()" << std::endl;
+ if (getDesktop() != desktop) {
+ std::cerr << "Prototype::handleDocumentReplaced(): Error: panel desktop not equal to existing desktop!" << std::endl;
+ }
+
+ connectionSelectionChanged.disconnect();
+
+ connectionSelectionChanged = desktop->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &Prototype::handleSelectionChanged)));
+
+ // Update demonstration widget.
+ updateLabel();
+}
+
+/*
+ * When a dialog is floating, it is connected to the active desktop.
+ */
+void
+Prototype::handleDesktopChanged(SPDesktop* desktop) {
+ std::cout << "Prototype::handleDesktopChanged(): " << desktop << std::endl;
+
+ if (getDesktop() == desktop) {
+ // This will happen after construction of Prototype. We've already
+ // set up signals so just return.
+ std::cout << " getDesktop() == desktop" << std::endl;
+ return;
+ }
+
+ // Connections are disconnect safe.
+ connectionSelectionChanged.disconnect();
+ connectionDocumentReplaced.disconnect();
+
+ setDesktop( desktop );
+
+ connectionSelectionChanged = desktop->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &Prototype::handleSelectionChanged)));
+ connectionDocumentReplaced = desktop->connectDocumentReplaced(
+ sigc::mem_fun(this, &Prototype::handleDocumentReplaced));
+
+ // Update demonstration widget.
+ updateLabel();
+}
+
+/*
+ * Handle a change in which objects are selected in a document.
+ */
+void
+Prototype::handleSelectionChanged() {
+ std::cout << "Prototype::handleSelectionChanged()" << std::endl;
+
+ // Update demonstration widget.
+ label.set_label("Selection Changed!");
+}
+
+/*
+ * Update label... just a utility function for this example.
+ */
+void
+Prototype::updateLabel() {
+
+ const gchar* root_id = getDesktop()->getDocument()->getRoot()->getId();
+ Glib::ustring label_string("Document's SVG id: ");
+ label_string += (root_id?root_id:"null");
+ label.set_label(label_string);
+}
+
+} // 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/prototype.h b/src/ui/dialog/prototype.h
new file mode 100644
index 000000000..95c3856f8
--- /dev/null
+++ b/src/ui/dialog/prototype.h
@@ -0,0 +1,80 @@
+/*
+ * A bare minimum example of deriving from Inkscape::UI:Widget::Panel.
+ *
+ * Author:
+ * Tavmjong Bah
+ *
+ * Copyright (C) Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Released under the GNU GPL, read the file 'COPYING' for more information.
+ */
+
+#ifndef SEEN_PROTOTYPE_PANEL_H
+#define SEEN_PROTOTYPE_PANEL_H
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <iostream>
+#include "ui/widget/panel.h"
+#include "ui/dialog/desktop-tracker.h"
+
+// Only to display status.
+#include <gtkmm/label.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * A panel that does almost nothing!
+ */
+class Prototype : public UI::Widget::Panel
+{
+public:
+ virtual ~Prototype();
+
+ static Prototype& getInstance() { return *new Prototype(); };
+
+ virtual void present();
+
+private:
+
+ // No default constructor, noncopyable, nonassignable
+ Prototype();
+ Prototype(Prototype const &d);
+ Prototype operator=(Prototype const &d);
+
+ // Signals and handlers
+ sigc::connection connectionDocumentReplaced;
+ sigc::connection connectionDesktopChanged;
+ sigc::connection connectionSelectionChanged;
+
+ void handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
+ void handleDesktopChanged(SPDesktop* desktop);
+ void handleSelectionChanged();
+
+ DesktopTracker desktopTracker;
+
+ // Just for example
+ Gtk::Label label;
+ void updateLabel();
+};
+
+} //namespace Dialogs
+} //namespace UI
+} //namespace Inkscape
+
+#endif // SEEN_PROTOTYPE_PANEL_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 6da8acb20..045ce3459 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -17,25 +17,18 @@
#include "message-stack.h"
#include "helper/window.h"
-#include "macros.h"
#include "inkscape.h"
#include "document.h"
-#include "selection.h"
#include "desktop.h"
#include "ui/tools-switch.h"
#include "ui/tools/text-tool.h"
#include "ui/interface.h"
-#include "preferences.h"
-#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
-#include "sp-tspan.h"
#include "sp-tref.h"
#include "sp-defs.h"
#include "selection-chemistry.h"
-#include <xml/repr.h>
-#include "display/canvas-bpath.h"
#include "display/curve.h"
#include "document-undo.h"
#include "sp-root.h"
@@ -47,7 +40,7 @@
#endif
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
@@ -234,14 +227,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->next) {
- if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) {
- if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) {
- if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child))
- l = g_slist_prepend (l, child);
+ for (auto& child: r->children) {
+ if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) {
+ if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) {
+ if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child))
+ l = g_slist_prepend (l, &child);
}
}
- l = allTextItems (child, l, hidden, locked);
+ l = allTextItems (&child, l, hidden, locked);
}
return l;
}
diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h
index e98a9d80e..834f23c24 100644
--- a/src/ui/dialog/spellcheck.h
+++ b/src/ui/dialog/spellcheck.h
@@ -225,11 +225,7 @@ private:
* Dialogs widgets
*/
Gtk::Label banner_label;
-#if WITH_GTKMM_3_0
Gtk::ButtonBox banner_hbox;
-#else
- Gtk::HButtonBox banner_hbox;
-#endif
Gtk::ScrolledWindow scrolled_window;
Gtk::TreeView tree_view;
Glib::RefPtr<Gtk::ListStore> model;
@@ -243,21 +239,10 @@ private:
Gtk::Button add_button;
GtkWidget * dictionary_combo;
Gtk::HBox dictionary_hbox;
-
-#if WITH_GTKMM_3_0
Gtk::Separator action_sep;
-#else
- Gtk::HSeparator action_sep;
-#endif
-
Gtk::Button stop_button;
Gtk::Button start_button;
-
-#if WITH_GTKMM_3_0
Gtk::ButtonBox actionbutton_hbox;
-#else
- Gtk::HButtonBox actionbutton_hbox;
-#endif
SPDesktop * desktop;
DesktopTracker deskTrack;
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
new file mode 100644
index 000000000..4576671e7
--- /dev/null
+++ b/src/ui/dialog/styledialog.cpp
@@ -0,0 +1,1395 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ * Tavmjong Bah
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ * Copyright (C) Tavmjong Bah 2017 <tavmjong@free.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "styledialog.h"
+#include "ui/widget/addtoicon.h"
+#include "widgets/icon.h"
+#include "verbs.h"
+#include "sp-object.h"
+#include "selection.h"
+#include "xml/attribute-record.h"
+#include "xml/node-observer.h"
+#include "attribute-rel-svg.h"
+#include "inkscape.h"
+#include "document-undo.h"
+
+#include <glibmm/i18n.h>
+#include <glibmm/regex.h>
+
+#include <map>
+
+//#define DEBUG_STYLEDIALOG
+
+using Inkscape::DocumentUndo;
+using Inkscape::Util::List;
+using Inkscape::XML::AttributeRecord;
+
+/**
+ * This macro is used to remove spaces around selectors or any strings when
+ * parsing is done to update XML style element or row labels in this dialog.
+ */
+#define REMOVE_SPACES(x) x.erase(0, x.find_first_not_of(' ')); \
+ x.erase(x.find_last_not_of(' ') + 1);
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+class StyleDialog::NodeObserver : public Inkscape::XML::NodeObserver {
+public:
+ NodeObserver(StyleDialog* styleDialog) :
+ _styleDialog(styleDialog)
+ {
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::NodeObserver: Constructor" << std::endl;
+#endif
+ };
+
+ virtual void notifyContentChanged(Inkscape::XML::Node &node,
+ Inkscape::Util::ptr_shared<char> old_content,
+ Inkscape::Util::ptr_shared<char> new_content);
+
+ StyleDialog * _styleDialog;
+};
+
+
+void
+StyleDialog::NodeObserver::notifyContentChanged(
+ Inkscape::XML::Node &/*node*/,
+ Inkscape::Util::ptr_shared<char> /*old_content*/,
+ Inkscape::Util::ptr_shared<char> /*new_content*/ ) {
+
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::NodeObserver::notifyContentChanged" << std::endl;
+#endif
+
+ _styleDialog->_readStyleElement();
+ _styleDialog->_selectRow();
+}
+
+
+StyleDialog::TreeStore::TreeStore()
+{
+}
+
+
+/**
+ * Allow dragging only selectors.
+ */
+bool
+StyleDialog::TreeStore::row_draggable_vfunc(const Gtk::TreeModel::Path& path) const
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::TreeStore::row_draggable_vfunc" << std::endl;
+#endif
+ auto unconstThis = const_cast<StyleDialog::TreeStore*>(this);
+ const_iterator iter = unconstThis->get_iter(path);
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ bool is_draggable = row[_styledialog->_mColumns._colIsSelector];
+ return is_draggable;
+ }
+ return Gtk::TreeStore::row_draggable_vfunc(path);
+}
+
+
+/**
+ * Allow dropping only inbetween other selectors.
+ */
+bool
+StyleDialog::TreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
+ const Gtk::SelectionData& selection_data) const
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::TreeStore::row_drop_possible_vfunc" << std::endl;
+#endif
+
+ Gtk::TreeModel::Path dest_parent = dest;
+ dest_parent.up();
+ return dest_parent.empty();
+}
+
+
+// This is only here to handle updating style element after a drag and drop.
+void
+StyleDialog::TreeStore::on_row_deleted(const TreeModel::Path& path)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "on_row_deleted" << std::endl;
+#endif
+
+ if (_styledialog->_updating) return; // Don't write if we deleted row (other than from DND)
+
+ _styledialog->_writeStyleElement();
+}
+
+
+Glib::RefPtr<StyleDialog::TreeStore> StyleDialog::TreeStore::create(StyleDialog *styledialog)
+{
+ StyleDialog::TreeStore * store = new StyleDialog::TreeStore();
+ store->_styledialog = styledialog;
+ store->set_column_types( store->_styledialog->_mColumns );
+ return Glib::RefPtr<StyleDialog::TreeStore>( store );
+}
+
+/**
+ * Constructor
+ * A treeview and a set of two buttons are added to the dialog. _addSelector
+ * adds selectors to treeview. _delSelector deletes the selector from the dialog.
+ * Any addition/deletion of the selectors updates XML style element accordingly.
+ */
+StyleDialog::StyleDialog() :
+ UI::Widget::Panel("", "/dialogs/style", SP_VERB_DIALOG_STYLE),
+ _updating(false),
+ _textNode(NULL),
+ _desktopTracker()
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::StyleDialog" << std::endl;
+#endif
+
+ // Tree
+ Inkscape::UI::Widget::AddToIcon * addRenderer = manage(
+ new Inkscape::UI::Widget::AddToIcon() );
+
+ _store = TreeStore::create(this);
+ _treeView.set_model(_store);
+ _treeView.set_headers_visible(true);
+ _treeView.enable_model_drag_source();
+ _treeView.enable_model_drag_dest( Gdk::ACTION_MOVE );
+
+ int addCol = _treeView.append_column("", *addRenderer) - 1;
+ Gtk::TreeViewColumn *col = _treeView.get_column(addCol);
+ if ( col ) {
+ col->add_attribute( addRenderer->property_active(), _mColumns._colIsSelector );
+ }
+ _treeView.append_column("CSS Selector", _mColumns._colSelector);
+ _treeView.set_expander_column(*(_treeView.get_column(1)));
+
+ // Pack widgets
+ _paned.pack1(_mainBox, Gtk::SHRINK);
+ _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
+ _scrolledWindow.add(_treeView);
+ _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+
+ create = manage( new Gtk::Button() );
+ _styleButton(*create, "list-add", "Add a new CSS Selector");
+ create->signal_clicked().connect(sigc::mem_fun(*this, &StyleDialog::_addSelector));
+
+ del = manage( new Gtk::Button() );
+ _styleButton(*del, "list-remove", "Remove a CSS Selector");
+ del->signal_clicked().connect(sigc::mem_fun(*this, &StyleDialog::_delSelector));
+ del->set_sensitive(false);
+
+ _mainBox.pack_end(_buttonBox, Gtk::PACK_SHRINK);
+
+ _buttonBox.pack_start(*create, Gtk::PACK_SHRINK);
+ _buttonBox.pack_start(*del, Gtk::PACK_SHRINK);
+
+ _getContents()->pack_start(_paned, Gtk::PACK_EXPAND_WIDGET);
+
+ // Dialog size request
+ Gtk::Requisition sreq1, sreq2;
+ get_preferred_size(sreq1, sreq2);
+ int minWidth = 300;
+ int minHeight = 300;
+ minWidth = (sreq2.width > minWidth ? sreq2.width : minWidth );
+ minHeight = (sreq2.height > minHeight ? sreq2.height : minHeight);
+ set_size_request(minWidth, minHeight);
+
+ // Signal handlers
+ _treeView.signal_button_release_event().connect( // Needs to be release, not press.
+ sigc::mem_fun(*this, &StyleDialog::_handleButtonEvent),
+ false);
+
+ _treeView.signal_button_release_event().connect_notify(
+ sigc::mem_fun(*this, &StyleDialog::_buttonEventsSelectObjs),
+ false);
+
+ //_treeView.get_selection()->signal_changed().connect(
+ // sigc::mem_fun(*this, &StyleDialog::_selChanged));
+
+ _objObserver.signal_changed().connect(sigc::mem_fun(*this, &StyleDialog::_objChanged));
+
+
+ // Add CSS dialog
+ _cssPane = new CssDialog;
+ _paned.pack2(*_cssPane, Gtk::SHRINK);
+ _cssPane->show_all();
+
+ _cssPane->_propRenderer->signal_edited().connect(
+ sigc::mem_fun(*this, &StyleDialog::_handleProp));
+ _cssPane->_sheetRenderer->signal_edited().connect(
+ sigc::mem_fun(*this, &StyleDialog::_handleSheet));
+ _cssPane->_attrRenderer->signal_edited().connect(
+ sigc::mem_fun(*this, &StyleDialog::_handleAttr));
+ _cssPane->_treeView.signal_button_release_event().connect(
+ sigc::mem_fun(*this, &StyleDialog::_delProperty),
+ false);
+
+ // Document & Desktop
+ _desktop_changed_connection = _desktopTracker.connectDesktopChanged(
+ sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged) );
+ _desktopTracker.connect(GTK_WIDGET(gobj()));
+
+ _document_replaced_connection = getDesktop()->connectDocumentReplaced(
+ sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced));
+
+ _selection_changed_connection = getDesktop()->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
+
+ // Load tree
+ _readStyleElement();
+ _selectRow();
+
+ if (!_store->children().empty()) {
+ del->set_sensitive(true);
+ }
+
+}
+
+
+/**
+ * @brief StyleDialog::~StyleDialog
+ * Class destructor
+ */
+StyleDialog::~StyleDialog()
+{
+#ifdef DEBUG_STYLEDIALOOG
+ std::cout << "StyleDialog::~StyleDialog" << std::endl;
+#endif
+ _desktop_changed_connection.disconnect();
+ _document_replaced_connection.disconnect();
+ _selection_changed_connection.disconnect();
+}
+
+
+/**
+ * @brief StyleDialog::_styleTextNode
+ * @return Inkscape::XML::Node* pointing to a style element's text node.
+ * Returns the style element's text node. If there is no style element, one is created.
+ * Ditto for text node.
+ */
+Inkscape::XML::Node* StyleDialog::_getStyleTextNode()
+{
+
+ Inkscape::XML::Node *styleNode = NULL;
+ Inkscape::XML::Node *textNode = NULL;
+
+ Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot();
+ for (unsigned i = 0; i < root->childCount(); ++i) {
+ if (Glib::ustring(root->nthChild(i)->name()) == "svg:style") {
+
+ styleNode = root->nthChild(i);
+
+ for (unsigned j = 0; j < styleNode->childCount(); ++j) {
+ if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
+ textNode = styleNode->nthChild(j);
+ }
+ }
+
+ if (textNode == NULL) {
+ // Style element found but does not contain text node!
+ std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+ }
+ }
+ }
+
+ if (styleNode == NULL) {
+ // Style element not found, create one
+ styleNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createElement("svg:style");
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+
+ root->addChild(styleNode, NULL);
+ Inkscape::GC::release(styleNode);
+ }
+
+ if (_textNode != textNode) {
+ _textNode = textNode;
+ NodeObserver *no = new NodeObserver(this);
+ textNode->addObserver(*no);
+ }
+
+ return textNode;
+}
+
+
+/**
+ * @brief StyleDialog::_readStyleElement
+ * Fill the Gtk::TreeStore from the svg:style element.
+ */
+void StyleDialog::_readStyleElement()
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_readStyleElement: updating " << (_updating?"true":"false")<< std::endl;
+#endif
+
+ if (_updating) return; // Don't read if we wrote style element.
+ _updating = true;
+ _store->clear();
+
+ Inkscape::XML::Node * textNode = _getStyleTextNode();
+ if (textNode == NULL) {
+ std::cerr << "StyleDialog::_readStyleElement: No text node!" << std::endl;
+ }
+
+ // Get content from style text node.
+ std::string content = (textNode->content() ? textNode->content() : "");
+
+ // Remove end-of-lines (check it works on Windoze).
+ content.erase(std::remove(content.begin(), content.end(), '\n'), content.end());
+
+ // First split into selector/value chunks.
+ // An attempt to use Glib::Regex failed. A C++11 version worked but
+ // reportedly has problems on Windows. Using split_simple() is simpler
+ // and probably faster.
+ //
+ // Glib::RefPtr<Glib::Regex> regex1 =
+ // Glib::Regex::create("([^\\{]+)\\{([^\\{]+)\\}");
+ //
+ // Glib::MatchInfo minfo;
+ // regex1->match(content, minfo);
+
+ // Split on curly brackets. Even tokens are selectors, odd are values.
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[}{]", content);
+
+ // If text node is empty, return (avoids problem with negative below).
+ if (tokens.size() == 0) {
+ _updating = false;
+ return;
+ }
+
+ for (unsigned i = 0; i < tokens.size()-1; i += 2) {
+
+ Glib::ustring selector = tokens[i];
+ REMOVE_SPACES(selector); // Remove leading/trailing spaces
+
+ // Get list of objects selector matches
+ std::vector<SPObject *> objVec = _getObjVec( selector );
+
+ Glib::ustring properties;
+ // Check to make sure we do have a value to match selector.
+ if ((i+1) < tokens.size()) {
+ properties = tokens[i+1];
+ } else {
+ std::cerr << "StyleDialog::_readStyleElement: Missing values "
+ "for last selector!" << std::endl;
+ }
+ REMOVE_SPACES(properties);
+
+ Gtk::TreeModel::Row row = *(_store->append());
+ row[_mColumns._colSelector] = selector;
+ row[_mColumns._colIsSelector] = true;
+ row[_mColumns._colObj] = objVec;
+ row[_mColumns._colProperties] = properties;
+
+ // Add as children, objects that match selector.
+ for (auto& obj: objVec) {
+ Gtk::TreeModel::Row childrow = *(_store->append(row->children()));
+ childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId());
+ childrow[_mColumns._colIsSelector] = false;
+ childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj);
+ childrow[_mColumns._colProperties] = ""; // Unused
+ }
+ }
+ _updating = false;
+}
+
+
+/**
+ * @brief StyleDialog::_writeStyleElement
+ * Update the content of the style element as selectors (or objects) are added/removed.
+ */
+void StyleDialog::_writeStyleElement()
+{
+ _updating = true;
+
+ Glib::ustring styleContent;
+ for (auto& row: _store->children()) {
+ styleContent = styleContent + row[_mColumns._colSelector] +
+ " { " + row[_mColumns._colProperties] + " }\n";
+ }
+ // We could test if styleContent is empty and then delete the style node here but there is no
+ // harm in keeping it around ...
+
+ Inkscape::XML::Node *textNode = _getStyleTextNode();
+ textNode->setContent(styleContent.c_str());
+
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_STYLE, _("Edited style element."));
+
+ _updating = false;
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_writeStyleElement(): |" << styleContent << "|" << std::endl;
+#endif
+}
+
+
+/**
+ * @brief StyleDialog::_addToSelector
+ * @param row
+ * Add selected objects on the desktop to the selector corresponding to 'row'.
+ */
+void StyleDialog::_addToSelector(Gtk::TreeModel::Row row)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_addToSelector: Entrance" << std::endl;
+#endif
+ if (*row) {
+
+ Glib::ustring selector = row[_mColumns._colSelector];
+
+ if (selector[0] == '#') {
+ // 'id' selector... add selected object's id's to list.
+ Inkscape::Selection* selection = getDesktop()->getSelection();
+ for (auto& obj: selection->objects()) {
+
+ Glib::ustring id = (obj->getId()?obj->getId():"");
+
+ std::vector<SPObject *> objVec = row[_mColumns._colObj];
+ bool found = false;
+ for (auto& obj: objVec) {
+ if (id == obj->getId()) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ // Update row
+ objVec.push_back(obj); // Adding to copy so need to update tree
+ row[_mColumns._colObj] = objVec;
+ row[_mColumns._colSelector] = _getIdList( objVec );
+
+ // Add child row
+ Gtk::TreeModel::Row childrow = *(_store->append(row->children()));
+ childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId());
+ childrow[_mColumns._colIsSelector] = false;
+ childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj);
+ childrow[_mColumns._colProperties] = ""; // Unused
+ }
+ }
+ }
+
+ else if (selector[0] == '.') {
+ // 'class' selector... add value to class attribute of selected objects.
+
+ // Get first class (split on white space or comma)
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[,\\s]+", selector);
+ Glib::ustring className = tokens[0];
+ className.erase(0,1);
+
+ // Get list of objects to modify
+ Inkscape::Selection* selection = getDesktop()->getSelection();
+ std::vector<SPObject *> objVec( selection->objects().begin(),
+ selection->objects().end() );
+
+ _insertClass( objVec, className );
+
+ row[_mColumns._colObj] = _getObjVec( selector );
+
+ for (auto& obj: objVec) {
+ // Add child row
+ Gtk::TreeModel::Row childrow = *(_store->append(row->children()));
+ childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId());
+ childrow[_mColumns._colIsSelector] = false;
+ childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj);
+ childrow[_mColumns._colProperties] = ""; // Unused
+ }
+ }
+
+ else {
+ // Do nothing for element selectors.
+ // std::cout << " Element selector... doing nothing!" << std::endl;
+ }
+ }
+
+ _writeStyleElement();
+}
+
+
+/**
+ * @brief StyleDialog::_removeFromSelector
+ * @param row
+ * Remove the object corresponding to 'row' from the parent selector.
+ */
+void StyleDialog::_removeFromSelector(Gtk::TreeModel::Row row)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_removeFromSelector: Entrance" << std::endl;
+#endif
+ if (*row) {
+
+ Glib::ustring objectLabel = row[_mColumns._colSelector];
+ Gtk::TreeModel::iterator iter = row->parent();
+ if (iter) {
+ Gtk::TreeModel::Row parent = *iter;
+ Glib::ustring selector = parent[_mColumns._colSelector];
+
+ if (selector[0] == '#') {
+ // 'id' selector... remove selected object's id's to list.
+
+ // Erase from selector label.
+ auto i = selector.find(objectLabel);
+ if (i != Glib::ustring::npos) {
+ selector.erase(i, objectLabel.length());
+ }
+ // Erase any comma/space
+ if (i != Glib::ustring::npos && selector[i] == ',') {
+ selector.erase(i, 1);
+ }
+ if (i != Glib::ustring::npos && selector[i] == ' ') {
+ selector.erase(i, 1);
+ }
+
+ // Update store
+ if (selector.empty()) {
+ _store->erase(parent);
+ } else {
+ // Save new selector and update object vector.
+ parent[_mColumns._colSelector] = selector;
+ parent[_mColumns._colObj] = _getObjVec( selector );
+ _store->erase(row);
+ }
+ }
+
+ else if (selector[0] == '.') {
+ // 'class' selector... remove value to class attribute of selected objects.
+
+ std::vector<SPObject *> objVec = row[_mColumns._colObj]; // Just one
+
+ // Get first class (split on white space or comma)
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[,\\s]+", selector);
+ Glib::ustring className = tokens[0];
+ className.erase(0,1); // Erase '.'
+
+ // Erase class name from 'class' attribute.
+ Glib::ustring classAttr = objVec[0]->getRepr()->attribute("class");
+ auto i = classAttr.find( className );
+ if (i != Glib::ustring::npos) {
+ classAttr.erase(i, className.length());
+ }
+ if (i != Glib::ustring::npos && classAttr[i] == ' ') {
+ classAttr.erase(i, 1);
+ }
+ objVec[0]->getRepr()->setAttribute("class", classAttr);
+
+ parent[_mColumns._colObj] = _getObjVec( selector );
+ _store->erase(row);
+ }
+
+ else {
+ // Do nothing for element selectors.
+ // std::cout << " Element selector... doing nothing!" << std::endl;
+ }
+ }
+ }
+
+ _writeStyleElement();
+
+}
+
+
+/**
+ * @brief StyleDialog::_getIdList
+ * @param sel
+ * @return This function returns a comma seperated list of ids for objects in input vector.
+ * It is used in creating an 'id' selector. It relies on objects having 'id's.
+ */
+Glib::ustring StyleDialog::_getIdList(std::vector<SPObject*> sel)
+{
+ Glib::ustring str;
+ for (auto& obj: sel) {
+ str += "#" + Glib::ustring(obj->getId()) + ", ";
+ }
+ if (!str.empty()) {
+ str.erase(str.size()-1); // Remove space at end. c++11 has pop_back() but not ustring.
+ str.erase(str.size()-1); // Remove comma at end.
+ }
+ return str;
+}
+
+/**
+ * @brief StyleDialog::_getObjVec
+ * @param selector: a valid CSS selector string.
+ * @return objVec: a vector of pointers to SPObject's the selector matches.
+ * Return a vector of all objects that selector matches.
+ */
+std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) {
+
+ std::vector<SPObject *> objVec = SP_ACTIVE_DOCUMENT->getObjectsBySelector( selector );
+
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_getObjVec: |" << selector << "|" << std::endl;
+ for (auto& obj: objVec) {
+ std::cout << " " << (obj->getId()?obj->getId():"null") << std::endl;
+ }
+#endif
+
+ return objVec;
+}
+
+
+/**
+ * @brief StyleDialog::_insertClass
+ * @param objs: list of objects to insert class
+ * @param class: class to insert
+ * Insert a class name into objects' 'class' attribute.
+ */
+void StyleDialog::_insertClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className) {
+
+ for (auto& obj: objVec) {
+
+ if (!obj->getRepr()->attribute("class")) {
+ // 'class' attribute does not exist, create it.
+ obj->getRepr()->setAttribute("class", className);
+ } else {
+ // 'class' attribute exists, append.
+ Glib::ustring classAttr = obj->getRepr()->attribute("class");
+
+ // Split on white space.
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s+", classAttr);
+ bool add = true;
+ for (auto& token: tokens) {
+ if (token == className) {
+ add = false; // Might be useful to still add...
+ break;
+ }
+ }
+ if (add) {
+ obj->getRepr()->setAttribute("class", classAttr + " " + className );
+ }
+ }
+ }
+ }
+
+
+/**
+ * @brief StyleDialog::_selectObjects
+ * @param eventX
+ * @param eventY
+ * This function selects objects in the drawing corresponding to the selector
+ * selected in the treeview.
+ */
+void StyleDialog::_selectObjects(int eventX, int eventY)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_selectObjects: " << eventX << ", " << eventY << std::endl;
+#endif
+
+ getDesktop()->selection->clear();
+ Gtk::TreeViewColumn *col = _treeView.get_column(1);
+ Gtk::TreeModel::Path path;
+ int x2 = 0;
+ int y2 = 0;
+ // To do: We should be able to do this via passing in row.
+ if (_treeView.get_path_at_pos(eventX, eventY, path, col, x2, y2)) {
+ if (col == _treeView.get_column(1)) {
+ Gtk::TreeModel::iterator iter = _store->get_iter(path);
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ Gtk::TreeModel::Children children = row.children();
+ std::vector<SPObject *> objVec = row[_mColumns._colObj];
+ for (unsigned i = 0; i < objVec.size(); ++i) {
+ SPObject *obj = objVec[i];
+ getDesktop()->selection->add(obj);
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * @brief StyleDialog::_addSelector
+ *
+ * This function opens a dialog to add a selector. The dialog is prefilled
+ * with an 'id' selector containing a list of the id's of selected objects
+ * or with a 'class' selector if no objects are selected.
+ */
+void StyleDialog::_addSelector()
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_addSelector: Entrance" << std::endl;
+#endif
+
+ // Store list of selected elements on desktop (not to be confused with selector).
+ Inkscape::Selection* selection = getDesktop()->getSelection();
+ std::vector<SPObject *> objVec( selection->objects().begin(),
+ selection->objects().end() );
+
+ // ==== Create popup dialog ====
+ Gtk::Dialog *textDialogPtr = new Gtk::Dialog();
+ textDialogPtr->add_button(_("Cancel"), Gtk::RESPONSE_CANCEL);
+ textDialogPtr->add_button(_("Add"), Gtk::RESPONSE_OK);
+
+ Gtk::Entry *textEditPtr = manage ( new Gtk::Entry() );
+ textDialogPtr->get_vbox()->pack_start(*textEditPtr, Gtk::PACK_SHRINK);
+
+ Gtk::Label *textLabelPtr = manage ( new Gtk::Label(
+ _("Invalid entry: Not an id (#), class (.), or element CSS selector.")
+ ) );
+ textDialogPtr->get_vbox()->pack_start(*textLabelPtr, Gtk::PACK_SHRINK);
+
+ /**
+ * By default, the entrybox contains 'Class1' as text. However, if object(s)
+ * is(are) selected and user clicks '+' at the bottom of dialog, the
+ * entrybox will have the id(s) of the selected objects as text.
+ */
+ if (getDesktop()->getSelection()->isEmpty()) {
+ textEditPtr->set_text(".Class1");
+ } else {
+ textEditPtr->set_text(_getIdList(objVec));
+ }
+
+ Gtk::Requisition sreq1, sreq2;
+ textDialogPtr->get_preferred_size(sreq1, sreq2);
+ int minWidth = 200;
+ int minHeight = 100;
+ minWidth = (sreq2.width > minWidth ? sreq2.width : minWidth );
+ minHeight = (sreq2.height > minHeight ? sreq2.height : minHeight);
+ textDialogPtr->set_size_request(minWidth, minHeight);
+ textEditPtr->show();
+ textLabelPtr->hide();
+ textDialogPtr->show();
+
+
+ // ==== Get response ====
+ int result = -1;
+ bool invalid = true;
+ Glib::ustring selectorValue;
+
+ while (invalid) {
+ result = textDialogPtr->run();
+ if (result != Gtk::RESPONSE_OK) { // Cancel, close dialog, etc.
+ textDialogPtr->hide();
+ return;
+ }
+ /**
+ * @brief selectorName
+ * This string stores selector name. The text from entrybox is saved as name
+ * for selector. If the entrybox is empty, the text (thus selectorName) is
+ * set to ".Class1"
+ */
+ selectorValue = textEditPtr->get_text();
+ Glib::ustring firstWord = selectorValue.substr(0, selectorValue.find(" "));
+
+ del->set_sensitive(true);
+
+ if (selectorValue[0] == '.' ||
+ selectorValue[0] == '#' ||
+ selectorValue[0] == '*' ||
+ SPAttributeRelSVG::isSVGElement( firstWord ) ) {
+ invalid = false;
+ } else {
+ textLabelPtr->show();
+ }
+ }
+ delete textDialogPtr;
+
+ // ==== Handle response ====
+
+ // If class selector, add selector name to class attribute for each object
+ if (selectorValue[0] == '.') {
+
+ Glib::ustring className = selectorValue;
+ className.erase(0,1);
+ _insertClass(objVec, className);
+ }
+
+ // Generate a new object vector (we could have an element selector,
+ // the user could have edited the id selector list, etc.).
+ objVec = _getObjVec( selectorValue );
+
+ // Add entry to GUI tree
+ Gtk::TreeModel::Row row = *(_store->append());
+ row[_mColumns._colSelector] = selectorValue;
+ row[_mColumns._colIsSelector] = true;
+ row[_mColumns._colObj] = objVec;
+
+ // Add as children objects that match selector.
+ for (auto& obj: objVec) {
+ Gtk::TreeModel::Row childrow = *(_store->append(row->children()));
+ childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId());
+ childrow[_mColumns._colIsSelector] = false;
+ childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj);
+ }
+
+ // Add entry to style element
+ _writeStyleElement();
+}
+
+/**
+ * @brief StyleDialog::_delSelector
+ * This function deletes selector when '-' at the bottom is clicked.
+ * Note: If deleting a class selector, class attributes are NOT changed.
+ */
+void StyleDialog::_delSelector()
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_delSelector" << std::endl;
+#endif
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = _treeView.get_selection();
+ Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ _updating = true;
+ _store->erase(iter);
+ _updating = false;
+ _writeStyleElement();
+ }
+}
+
+/**
+ * @brief StyleDialog::_handleButtonEvent
+ * @param event
+ * @return
+ * Handles the event when '+' button in front of a selector name is clicked or when a '-' button in
+ * front of a child object is clicked. In the first case, the selected objects on the desktop (if
+ * any) are added as children of the selector in the treeview. In the latter case, the object
+ * corresponding to the row is removed from the selector.
+ */
+bool StyleDialog::_handleButtonEvent(GdkEventButton *event)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_handleButtonEvent: Entrance" << std::endl;
+#endif
+ if (event->type == GDK_BUTTON_RELEASE && event->button == 1) {
+ Gtk::TreeViewColumn *col = 0;
+ Gtk::TreeModel::Path path;
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ int x2 = 0;
+ int y2 = 0;
+ if (_treeView.get_path_at_pos(x, y, path, col, x2, y2)) {
+ if (col == _treeView.get_column(0)) {
+ Gtk::TreeModel::iterator iter = _store->get_iter(path);
+ Gtk::TreeModel::Row row = *iter;
+
+ // Add or remove objects from a
+ if (!row.parent()) {
+ // Add selected objects to selector.
+ _addToSelector(row);
+ } else {
+ // Remove object from selector
+ _removeFromSelector(row);
+ }
+ }
+ }
+ }
+ return false;
+}
+
+// -------------------------------------------------------------------
+
+class PropertyData
+{
+public:
+ PropertyData() {};
+ PropertyData(Glib::ustring name) : _name(name) {};
+
+ void _setSheetValue(Glib::ustring value) { _sheetValue = value; };
+ void _setAttrValue(Glib::ustring value) { _attrValue = value; };
+ Glib::ustring _getName() { return _name; };
+ Glib::ustring _getSheetValue() { return _sheetValue; };
+ Glib::ustring _getAttrValue() { return _attrValue; };
+
+private:
+ Glib::ustring _name;
+ Glib::ustring _sheetValue;
+ Glib::ustring _attrValue;
+};
+
+// -------------------------------------------------------------------
+
+
+/**
+ * @brief StyleDialog::_updateCSSPanel
+ * Updates CSS panel according to row in Style panel.
+ */
+void StyleDialog::_updateCSSPanel()
+{
+ // This should probably be in a member function of CSSDialog.
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_updateCSSPanel" << std::endl;
+#endif
+ _updating = true;
+
+ _cssPane->_store->clear();
+
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = _treeView.get_selection();
+ Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ Glib::ustring properties;
+ Glib::ustring sheet;
+ Glib::ustring attr;
+ if (row[_mColumns._colIsSelector]) {
+ _cssPane->_propRenderer->property_editable() = true;
+ _cssPane->_sheetRenderer->property_editable() = true;
+ _cssPane->_sheetRenderer->property_foreground_rgba() = Gdk::RGBA("black");
+ _cssPane->_attrRenderer->property_editable() = false;
+ _cssPane->_buttonAddProperty.set_sensitive(true);
+
+ properties = row[_mColumns._colProperties];
+ sheet = row[_mColumns._colProperties];
+ _objObserver.set( NULL );
+ } else {
+ _cssPane->_propRenderer->property_editable() = false;
+ _cssPane->_sheetRenderer->property_editable() = false;
+ _cssPane->_sheetRenderer->property_foreground_rgba() = Gdk::RGBA("gray");
+ _cssPane->_attrRenderer->property_editable() = false; // false for now...
+ _cssPane->_buttonAddProperty.set_sensitive(false);
+
+ std::vector<SPObject *> objects = row[_mColumns._colObj];
+ Gtk::TreeModel::iterator piter = row.parent();
+ if (piter) {
+ Gtk::TreeModel::Row prow = *piter;
+ sheet = prow[_mColumns._colProperties];
+ }
+ _objObserver.set( objects[0] );
+ if (objects[0] && objects[0]->getAttribute("style") != NULL) {
+ properties = objects[0]->getAttribute("style");
+ attr = objects[0]->getAttribute("style");
+ }
+ }
+ REMOVE_SPACES(properties); // Remove leading/trailing spaces
+
+ std::map<Glib::ustring, PropertyData> propMap;
+
+ std::vector<Glib::ustring> sheetList = Glib::Regex::split_simple("\\s*;\\s*", sheet);
+ for (auto& token: sheetList) {
+
+ if (token.empty()) break;
+
+ std::vector<Glib::ustring> pair =
+ Glib::Regex::split_simple("\\s*:\\s*", token);
+ if( pair.size() > 1) {
+ PropertyData temp( pair[0] );
+ temp._setSheetValue( pair[1] );
+ propMap[pair[0]] = temp;
+ }
+ }
+
+ std::vector<Glib::ustring> attrList = Glib::Regex::split_simple("\\s*;\\s*", attr);
+ for (auto& token: attrList) {
+
+ if (token.empty()) break;
+
+ std::vector<Glib::ustring> pair =
+ Glib::Regex::split_simple("\\s*:\\s*", token);
+
+ if( pair.size() > 1) {
+ auto it = propMap.find(pair[0]);
+ if (it != propMap.end()) {
+ (*it).second._setAttrValue( pair[1] );
+ } else {
+ PropertyData temp(pair[0]);
+ temp._setAttrValue( pair[1] );
+ propMap[pair[0]] = temp;
+ }
+ }
+ }
+
+ for (auto it : propMap) {
+ // std::cout << " " << it.first
+ // << " " << it.second._getName()
+ // << " " << it.second._getSheetValue()
+ // << " " << it.second._getAttrValue()
+ // << std::endl;
+ _cssPane->_propRow = *(_cssPane->_store->append());
+ _cssPane->_propRow[_cssPane->_cssColumns._colUnsetProp] = false;
+ _cssPane->_propRow[_cssPane->_cssColumns._propertyLabel] = it.second._getName();
+ _cssPane->_propRow[_cssPane->_cssColumns._styleSheetVal] = it.second._getSheetValue();
+ _cssPane->_propRow[_cssPane->_cssColumns._styleAttrVal ] = it.second._getAttrValue();
+ }
+ }
+
+ _updating = false;
+}
+
+
+/**
+ * Handle document replaced. (Happens when a default document is immediately replaced by another
+ * document in a new window.)
+ */
+void
+StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::handleDocumentReplaced()" << std::endl;
+#endif
+
+ _selection_changed_connection.disconnect();
+
+ _selection_changed_connection = desktop->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
+
+ _readStyleElement();
+ _selectRow();
+}
+
+
+/*
+ * When a dialog is floating, it is connected to the active desktop.
+ */
+void
+StyleDialog::_handleDesktopChanged(SPDesktop* desktop) {
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::handleDesktopReplaced()" << std::endl;
+#endif
+
+ if (getDesktop() == desktop) {
+ // This will happen after construction of dialog. We've already
+ // set up signals so just return.
+ return;
+ }
+
+ _selection_changed_connection.disconnect();
+ _document_replaced_connection.disconnect();
+
+ setDesktop( desktop );
+
+ _selection_changed_connection = desktop->getSelection()->connectChanged(
+ sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
+ _document_replaced_connection = desktop->connectDocumentReplaced(
+ sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced));
+
+ _readStyleElement();
+ _selectRow();
+}
+
+
+/*
+ * Handle a change in which objects are selected in a document.
+ */
+void
+StyleDialog::_handleSelectionChanged() {
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_handleSelectionChanged()" << std::endl;
+#endif
+
+ _selectRow();
+}
+
+
+/**
+ * @brief StyleDialog::_buttonEventsSelectObjs
+ * @param event
+ * This function detects single or double click on a selector in any row. Clicking
+ * on a selector selects the matching objects on the desktop. A double click will
+ * in addition open the CSS dialog.
+ */
+void StyleDialog::_buttonEventsSelectObjs(GdkEventButton* event )
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_buttonEventsSelectObjs" << std::endl;
+#endif
+
+ _updating = true;
+
+ if (event->type == GDK_BUTTON_RELEASE && event->button == 1) {
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ _selectObjects(x, y);
+ //}
+ //else if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
+ //int x = static_cast<int>(event->x);
+ //int y = static_cast<int>(event->y);
+ //_selectObjects(x, y);
+
+ _updateCSSPanel();
+ }
+ _updating = false;
+}
+
+
+/**
+ * @brief StyleDialog::_selectRow
+ * This function selects the row in treeview corresponding to an object selected
+ * in the drawing. If more than one row matches, the first is chosen.
+ */
+void StyleDialog::_selectRow()
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_selectRow: updating: " << (_updating?"true":"false") << std::endl;
+#endif
+ if (_updating || !getDesktop()) return; // Avoid updating if we have set row via dialog.
+
+ if (SP_ACTIVE_DESKTOP != getDesktop()) {
+ std::cerr << "StyleDialog::_selectRow: SP_ACTIVE_DESKTOP != getDesktop()" << std::endl;
+ return;
+ }
+
+ Inkscape::Selection* selection = getDesktop()->getSelection();
+ if (!selection->isEmpty()) {
+ SPObject *obj = selection->objects().back();
+
+ Gtk::TreeModel::Children children = _store->children();
+ for(Gtk::TreeModel::Children::iterator iter = children.begin();
+ iter != children.end(); ++iter) {
+
+ Gtk::TreeModel::Row row = *iter;
+ std::vector<SPObject *> objVec = row[_mColumns._colObj];
+ for (unsigned i = 0; i < objVec.size(); ++i) {
+ if (obj->getId() == objVec[i]->getId()) {
+ _treeView.get_selection()->select(row);
+ _updateCSSPanel();
+ return;
+ }
+ }
+ }
+ }
+
+ // Selection empty or no row matches.
+ _treeView.get_selection()->unselect_all();
+ _updateCSSPanel();
+}
+
+
+void StyleDialog::_objChanged() {
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_objChanged" << std::endl;
+#endif
+ if (_updating) return;
+ _updateCSSPanel();
+}
+
+
+/**
+ * @brief StyleDialog::_handleProp
+ * @param path
+ * @param new_text
+ * Called when new text is entered into a "prop" cell..
+ */
+void StyleDialog::_handleProp(const Glib::ustring& path, const Glib::ustring& new_text)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_handleProp: path: " << path
+ << " new_text: " << new_text << std::endl;
+#endif
+
+ Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path);
+ if (iterCss) {
+ Gtk::TreeModel::Row row = *iterCss;
+ row[_cssPane->_cssColumns._propertyLabel] = new_text;
+ }
+
+ // To do: validate.
+}
+
+/**
+ * @brief StyleDialog::_handleSheet
+ * @param path
+ * @param new_text
+ * Called when new text is entered into a "sheet" cell..
+ */
+void StyleDialog::_handleSheet(const Glib::ustring& path, const Glib::ustring& new_text)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_handleSheet: path: " << path
+ << " new_text: " << new_text << std::endl;
+#endif
+
+ Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path);
+ if (iterCss) {
+ Gtk::TreeModel::Row row = *iterCss;
+ row[_cssPane->_cssColumns._styleSheetVal] = new_text;
+ }
+
+ // To do: validate (run through style.read()/style.write()?).
+
+ Glib::ustring properties;
+ for (auto& crow: _cssPane->_store->children()) {
+ properties = properties +
+ crow[_cssPane->_cssColumns._propertyLabel] + ": " +
+ crow[_cssPane->_cssColumns._styleSheetVal] + "; ";
+ }
+
+ // Update selector data.
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = _treeView.get_selection();
+ Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ row[_mColumns._colProperties] = properties;
+ _writeStyleElement();
+ }
+}
+
+/**
+ * @brief StyleDialog::_handleAttr
+ * @param path
+ * @param new_text
+ * Called when new text is entered into an "attr" cell..
+ */
+void StyleDialog::_handleAttr(const Glib::ustring& path, const Glib::ustring& new_text)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_handleAttr: path: " << path
+ << " new_text: " << new_text << std::endl;
+#endif
+
+ Gtk::TreeModel::iterator iterCss = _cssPane->_treeView.get_model()->get_iter(path);
+ if (iterCss) {
+ Gtk::TreeModel::Row row = *iterCss;
+ row[_cssPane->_cssColumns._styleAttrVal] = new_text;
+ }
+
+ // To do: validate (run through style.read()/style.write()?).
+
+ Glib::ustring properties;
+ for (auto& crow: _cssPane->_store->children()) {
+ properties = properties +
+ crow[_cssPane->_cssColumns._propertyLabel] + ": ";
+ crow[_cssPane->_cssColumns._styleAttrVal] + "; ";
+ }
+
+ std::cout << "StyleDialog::_handlerAttr(): Unimplemented write." << std::endl;
+}
+
+/**
+ * @brief StyleDialog::_delProperty
+ * @param event
+ * @return
+ * Delete a property from the CSS dialog and then update trees.
+ */
+bool StyleDialog::_delProperty(GdkEventButton *event)
+{
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_delProperty" << std::endl;
+#endif
+
+ if (event->type == GDK_BUTTON_RELEASE && event->button == 1) {
+ Gtk::TreeViewColumn *col = 0;
+ Gtk::TreeModel::Path path;
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ int x2 = 0;
+ int y2 = 0;
+ Gtk::TreeModel::Row cssRow;
+ Glib::ustring toDelProperty;
+ if (_cssPane->_treeView.get_path_at_pos(x, y, path, col, x2, y2)) {
+ if (col == _cssPane->_treeView.get_column(0)) {
+ Gtk::TreeModel::iterator cssIter =
+ _cssPane->_treeView.get_selection()->get_selected();
+ if (cssIter) {
+
+ Gtk::TreeModel::Row cssRow = *cssIter;
+
+ // Update selector data.
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = _treeView.get_selection();
+ Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
+ if (iter) {
+
+ Gtk::TreeModel::Row row = *iter;
+
+ if ( row[_mColumns._colIsSelector]) {
+
+ // We only care about style sheet for selectors so erase row in CSS pane.
+ _cssPane->_store->erase(cssIter);
+
+ // Update style sheet
+ Glib::ustring properties;
+ for (auto& crow: _cssPane->_store->children()) {
+ Glib::ustring sheetVal = crow[_cssPane->_cssColumns._styleSheetVal];
+ if (!sheetVal.empty()) {
+ properties = properties +
+ crow[_cssPane->_cssColumns._propertyLabel] + ": " +
+ crow[_cssPane->_cssColumns._styleSheetVal] + "; ";
+ }
+ }
+
+ row[_mColumns._colProperties] = properties;
+ _writeStyleElement();
+
+ } else {
+
+ // We only erase row if style sheet does not contain deleted property.
+ // Otherwise we set style attr value to empty string.
+ Gtk::TreeModel::Row cssRow = *cssIter;
+ Glib::ustring val = cssRow[_cssPane->_cssColumns._styleSheetVal];
+ if (val.empty()) {
+ _cssPane->_store->erase(cssIter);
+ } else {
+ cssRow[_cssPane->_cssColumns._styleAttrVal] = Glib::ustring();
+ }
+
+ // Update style attribute
+ std::vector<SPObject *> objects = row[_mColumns._colObj];
+ Glib::ustring properties;
+ for (auto& crow: _cssPane->_store->children()) {
+ Glib::ustring attrVal = crow[_cssPane->_cssColumns._styleAttrVal];
+ if (!attrVal.empty()) {
+ properties = properties +
+ crow[_cssPane->_cssColumns._propertyLabel] + ": " +
+ crow[_cssPane->_cssColumns._styleAttrVal] + "; ";
+ }
+ }
+
+ if (objects[0]) {
+ if (properties.empty()) {
+ objects[0]->setAttribute("style", NULL);
+ } else {
+ objects[0]->setAttribute("style", properties);
+ }
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_STYLE,
+ _("Deleted property from style attribute."));
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+
+/**
+ * @brief StyleDialog::_styleButton
+ * @param btn
+ * @param iconName
+ * @param tooltip
+ * Set the style of '+' and '-' buttons at the bottom of dialog.
+ */
+void StyleDialog::_styleButton(Gtk::Button& btn, char const* iconName,
+ char const* tooltip)
+{
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show(child);
+ btn.add(*manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
+ btn.set_tooltip_text (tooltip);
+}
+
+
+} // 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
new file mode 100644
index 000000000..e84489e66
--- /dev/null
+++ b/src/ui/dialog/styledialog.h
@@ -0,0 +1,175 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ * Tavmjong Bah
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ * Copyright (C) Tavmjong Bah 2017 <tavmjong@free.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef STYLEDIALOG_H
+#define STYLEDIALOG_H
+
+#include <ui/widget/panel.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/treeselection.h>
+#include <gtkmm/paned.h>
+
+#include "ui/dialog/desktop-tracker.h"
+#include "ui/dialog/cssdialog.h"
+
+#include "xml/helper-observer.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * @brief The StyleDialog class
+ * A list of CSS selectors will show up in this dialog. This dialog allows one to
+ * add and delete selectors. Elements can be added to and removed from the selectors
+ * in the dialog. Selection of any selector row selects the matching objects in
+ * the drawing and vice-versa. (Only simple selectors supported for now.)
+ *
+ * This class must keep two things in sync:
+ * 1. The text node of the style element.
+ * 2. The Gtk::TreeModel.
+ */
+class StyleDialog : public Widget::Panel {
+
+public:
+ ~StyleDialog();
+
+ static StyleDialog &getInstance() { return *new StyleDialog(); }
+
+private:
+ // No default constructor, noncopyable, nonassignable
+ StyleDialog();
+ StyleDialog(StyleDialog const &d);
+ StyleDialog operator=(StyleDialog const &d);
+
+ // Monitor <style> element for changes.
+ class NodeObserver;
+
+ // Data structure
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ ModelColumns() {
+ add(_colSelector);
+ add(_colIsSelector);
+ add(_colObj);
+ add(_colProperties);
+ }
+ Gtk::TreeModelColumn<Glib::ustring> _colSelector; // Selector or matching object id.
+ Gtk::TreeModelColumn<bool> _colIsSelector; // Selector row or child object row.
+ Gtk::TreeModelColumn<std::vector<SPObject *> > _colObj; // List of matching objects.
+ Gtk::TreeModelColumn<Glib::ustring> _colProperties; // List of properties.
+ };
+ ModelColumns _mColumns;
+
+ // Override Gtk::TreeStore to control drag-n-drop (only allow dragging and dropping of selectors).
+ // See: https://developer.gnome.org/gtkmm-tutorial/stable/sec-treeview-examples.html.en
+ //
+ // TreeStore implements simple drag and drop (DND) but there appears no way to know when a DND
+ // has been completed (other than doing the whole DND ourselves). As a hack, we use
+ // on_row_deleted to trigger write of style element.
+ class TreeStore : public Gtk::TreeStore {
+ protected:
+ TreeStore();
+ bool row_draggable_vfunc(const Gtk::TreeModel::Path& path) const override;
+ bool row_drop_possible_vfunc(const Gtk::TreeModel::Path& path,
+ const Gtk::SelectionData& selection_data) const override;
+ void on_row_deleted(const TreeModel::Path& path) override;
+
+ public:
+ static Glib::RefPtr<StyleDialog::TreeStore> create(StyleDialog *styledialog);
+
+ private:
+ StyleDialog *_styledialog;
+ };
+
+ // TreeView
+ Gtk::TreeView _treeView;
+ Glib::RefPtr<TreeStore> _store;
+
+ // Widgets
+ Gtk::VPaned _paned;
+ Gtk::VBox _mainBox;
+ Gtk::HBox _buttonBox;
+ Gtk::ScrolledWindow _scrolledWindow;
+ Gtk::Button* del;
+ Gtk::Button* create;
+ CssDialog *_cssPane;
+
+ // Reading and writing the style element.
+ Inkscape::XML::Node *_getStyleTextNode();
+ void _readStyleElement();
+ void _writeStyleElement();
+
+ // Manipulate Tree
+ void _addToSelector(Gtk::TreeModel::Row row);
+ void _removeFromSelector(Gtk::TreeModel::Row row);
+ Glib::ustring _getIdList(std::vector<SPObject *>);
+ std::vector<SPObject *> _getObjVec(Glib::ustring selector);
+ void _insertClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className);
+ void _selectObjects(int, int);
+ void _updateCSSPanel();
+
+ // Variables
+ bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop
+ Inkscape::XML::Node *_textNode; // Track so we know when to add a NodeObserver.
+
+ // Signals and handlers - External
+ sigc::connection _document_replaced_connection;
+ sigc::connection _desktop_changed_connection;
+ sigc::connection _selection_changed_connection;
+
+ void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
+ void _handleDesktopChanged(SPDesktop* desktop);
+ void _handleSelectionChanged();
+
+ DesktopTracker _desktopTracker;
+
+ Inkscape::XML::SignalObserver _objObserver; // Track object in selected row (for style change).
+
+ // Signal and handlers - Internal
+ void _addSelector();
+ void _delSelector();
+ bool _handleButtonEvent(GdkEventButton *event);
+ void _buttonEventsSelectObjs(GdkEventButton *event);
+ void _selectRow(); // Select row in tree when selection changed.
+ void _objChanged();
+
+ // Signal handlers for CssDialog
+ void _handleProp( const Glib::ustring& path, const Glib::ustring& new_text);
+ void _handleSheet(const Glib::ustring& path, const Glib::ustring& new_text);
+ void _handleAttr( const Glib::ustring& path, const Glib::ustring& new_text);
+ bool _delProperty(GdkEventButton *event);
+
+ // GUI
+ void _styleButton(Gtk::Button& btn, char const* iconName, char const* tooltip);
+};
+
+} // namespace Dialogc
+} // namespace UI
+} // namespace Inkscape
+
+#endif // STYLEDIALOG_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 790c0e5fb..791677807 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -12,25 +12,23 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "svg-fonts-dialog.h"
#include "document-private.h"
#include "document-undo.h"
#include <gtkmm/notebook.h>
-#include <gtkmm/imagemenuitem.h>
#include <gtkmm/scale.h>
-#include <gtkmm/stock.h>
+#include <gtkmm/imagemenuitem.h>
#include <message-stack.h>
#include "selection.h"
-#include <string.h>
#include "svg/svg.h"
-#include "xml/node.h"
#include "xml/repr.h"
#include "sp-font-face.h"
#include "desktop.h"
+#include <sstream>
#include "display/nr-svgfonts.h"
#include "verbs.h"
#include "sp-glyph.h"
@@ -76,6 +74,15 @@ bool SvgFontDrawingArea::on_expose_event (GdkEventExpose */*event*/){
cr->set_font_size (_y-20);
cr->move_to (10, 10);
cr->show_text (_text.c_str());
+
+ // Draw some lines to show line area.
+ cr->set_source_rgb( 0.5, 0.5, 0.5 );
+ cr->move_to ( 0, 10);
+ cr->line_to (_x, 10);
+ cr->stroke();
+ cr->move_to ( 0, _y-10);
+ cr->line_to (_x, _y-10);
+ cr->stroke();
}
return TRUE;
}
@@ -112,14 +119,15 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){
entry.set_text(t);
}
+// 'font-family' has a problem as it is also a presentation attribute for <text>
void SvgFontsDialog::AttrEntry::on_attr_changed(){
SPObject* o = NULL;
- for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: dialog->get_selected_spfont()->children) {
switch(this->attr){
case SP_PROP_FONT_FAMILY:
- if (SP_IS_FONTFACE(node)){
- o = node;
+ if (SP_IS_FONTFACE(&node)){
+ o = &node;
continue;
}
break;
@@ -141,6 +149,74 @@ void SvgFontsDialog::AttrEntry::on_attr_changed(){
}
+SvgFontsDialog::AttrSpin::AttrSpin(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr) {
+
+ this->dialog = d;
+ this->attr = attr;
+ this->add(* Gtk::manage(new Gtk::Label(lbl)) );
+ this->add(spin);
+ this->show_all();
+ spin.set_range(0, 4096);
+ spin.set_increments(16, 0);
+ spin.signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::AttrSpin::on_attr_changed));
+}
+
+void SvgFontsDialog::AttrSpin::set_range(double low, double high){
+ spin.set_range(low, high);
+}
+
+void SvgFontsDialog::AttrSpin::set_value(double v){
+ spin.set_value(v);
+}
+
+void SvgFontsDialog::AttrSpin::on_attr_changed(){
+
+ SPObject* o = NULL;
+ switch (this->attr) {
+
+ // <font> attributes
+ case SP_ATTR_HORIZ_ORIGIN_X:
+ case SP_ATTR_HORIZ_ORIGIN_Y:
+ case SP_ATTR_HORIZ_ADV_X:
+ case SP_ATTR_VERT_ORIGIN_X:
+ case SP_ATTR_VERT_ORIGIN_Y:
+ case SP_ATTR_VERT_ADV_Y:
+ o = this->dialog->get_selected_spfont();
+ break;
+
+ // <font-face> attributes
+ case SP_ATTR_UNITS_PER_EM:
+ case SP_ATTR_ASCENT:
+ case SP_ATTR_DESCENT:
+ case SP_ATTR_CAP_HEIGHT:
+ case SP_ATTR_X_HEIGHT:
+ for (auto& node: dialog->get_selected_spfont()->children){
+ if (SP_IS_FONTFACE(&node)){
+ o = &node;
+ continue;
+ }
+ }
+ break;
+
+ default:
+ o = NULL;
+ }
+
+ const gchar* name = (const gchar*)sp_attribute_name(this->attr);
+ if(name && o) {
+ std::ostringstream temp;
+ temp << this->spin.get_value();
+ o->getRepr()->setAttribute((const gchar*) name, temp.str().c_str() );
+ o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ Glib::ustring undokey = "svgfonts:";
+ undokey += name;
+ DocumentUndo::maybeDone(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS,
+ _("Set SVG Font attribute"));
+ }
+
+}
+
Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/){
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
@@ -164,15 +240,13 @@ GlyphComboBox::GlyphComboBox(){
}
void GlyphComboBox::update(SPFont* spfont){
- if (!spfont) return
-//TODO: figure out why do we need to append("") before clearing items properly...
+ if (!spfont) return;
- this->append(""); //Gtk is refusing to clear the combobox when I comment out this line
this->remove_all();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
- this->append((static_cast<SPGlyph*>(node))->unicode);
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
+ this->append((static_cast<SPGlyph*>(&node))->unicode);
}
}
}
@@ -224,7 +298,7 @@ void SvgFontsDialog::fonts_list_button_release(GdkEventButton* event)
void SvgFontsDialog::create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ auto mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_GlyphsContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -233,7 +307,7 @@ void SvgFontsDialog::create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<vo
void SvgFontsDialog::create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ auto mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_KerningPairsContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -242,7 +316,7 @@ void SvgFontsDialog::create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::
void SvgFontsDialog::create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
{
- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
+ auto mi = Gtk::manage(new Gtk::MenuItem(_("_Remove"), true));
_FontsContextMenu.append(*mi);
mi->signal_activate().connect(rem);
mi->show();
@@ -266,7 +340,7 @@ void SvgFontsDialog::update_fonts()
{
SPDesktop* desktop = this->getDesktop();
SPDocument* document = desktop->getDocument();
- std::vector<SPObject *> fonts = document->getResourceList( "fonts" );
+ std::vector<SPObject *> fonts = document->getResourceList( "font" );
_model->clear();
for (std::vector<SPObject *>::const_iterator it = fonts.begin(); it != fonts.end(); ++it) {
@@ -283,7 +357,6 @@ void SvgFontsDialog::update_fonts()
}
void SvgFontsDialog::on_preview_text_changed(){
- _font_da.set_text((gchar*) _preview_entry.get_text().c_str());
_font_da.set_text(_preview_entry.get_text());
}
@@ -308,10 +381,18 @@ void SvgFontsDialog::update_global_settings_tab(){
SPFont* font = get_selected_spfont();
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- _familyname_entry->set_text((SP_FONTFACE(obj))->font_family);
+ _horiz_adv_x_spin->set_value(font->horiz_adv_x);
+ _horiz_origin_x_spin->set_value(font->horiz_origin_x);
+ _horiz_origin_y_spin->set_value(font->horiz_origin_y);
+
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
+ _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family);
+ _units_per_em_spin->set_value((SP_FONTFACE(&obj))->units_per_em);
+ _ascent_spin->set_value((SP_FONTFACE(&obj))->ascent);
+ _descent_spin->set_value((SP_FONTFACE(&obj))->descent);
+ _x_height_spin->set_value((SP_FONTFACE(&obj))->x_height);
+ _cap_height_spin->set_value((SP_FONTFACE(&obj))->cap_height);
}
}
}
@@ -326,11 +407,8 @@ void SvgFontsDialog::on_font_selection_changed(){
kerning_preview.set_svgfont(svgfont);
_font_da.set_svgfont(svgfont);
_font_da.redraw();
-
- double set_width = spfont->horiz_adv_x;
- setwidth_spin.set_value(set_width);
-
- kerning_slider->set_range(0, set_width);
+
+ kerning_slider->set_range(0, spfont->horiz_adv_x);
kerning_slider->set_draw_value(false);
kerning_slider->set_value(0);
@@ -340,17 +418,6 @@ void SvgFontsDialog::on_font_selection_changed(){
update_sensitiveness();
}
-void SvgFontsDialog::on_setwidth_changed(){
- SPFont* spfont = this->get_selected_spfont();
- if (spfont){
- spfont->horiz_adv_x = setwidth_spin.get_value();
- //TODO: tell cairo that the glyphs cache has to be invalidated
- // The current solution is to recreate the whole cairo svgfont.
- // This is not a good solution to the issue because big fonts will result in poor performance.
- update_glyphs();
- }
-}
-
SPGlyphKerning* SvgFontsDialog::get_selected_kerning_pair()
{
Gtk::TreeModel::iterator i = _KerningPairsList.get_selection()->get_selected();
@@ -384,24 +451,37 @@ SPGlyph* SvgFontsDialog::get_selected_glyph()
}
Gtk::VBox* SvgFontsDialog::global_settings_tab(){
- _familyname_entry = new AttrEntry(this, (gchar*) _("Family Name:"), SP_PROP_FONT_FAMILY);
+ _font_label = new Gtk::Label( _("Font Attributes") );
+ _horiz_adv_x_spin = new AttrSpin( this, (gchar*) _("Horiz. Advance X"), SP_ATTR_HORIZ_ADV_X);
+ _horiz_origin_x_spin = new AttrSpin( this, (gchar*) _("Horiz. Origin X "), SP_ATTR_HORIZ_ORIGIN_X);
+ _horiz_origin_y_spin = new AttrSpin( this, (gchar*) _("Horiz. Origin Y "), SP_ATTR_HORIZ_ORIGIN_Y);
+ _font_face_label = new Gtk::Label( _("Font Face Attributes") );
+ _familyname_entry = new AttrEntry(this, (gchar*) _("Family Name:"), SP_PROP_FONT_FAMILY);
+ _units_per_em_spin = new AttrSpin( this, (gchar*) _("Units per em"), SP_ATTR_UNITS_PER_EM);
+ _ascent_spin = new AttrSpin( this, (gchar*) _("Ascent:"), SP_ATTR_ASCENT);
+ _descent_spin = new AttrSpin( this, (gchar*) _("Descent:"), SP_ATTR_DESCENT);
+ _cap_height_spin = new AttrSpin( this, (gchar*) _("Cap Height:"), SP_ATTR_CAP_HEIGHT);
+ _x_height_spin = new AttrSpin( this, (gchar*) _("x Height:"), SP_ATTR_X_HEIGHT);
+
+ //_descent_spin->set_range(-4096,0);
+
+ global_vbox.pack_start(*_font_label, false, false);
+ global_vbox.pack_start(*_horiz_adv_x_spin, false, false);
+ global_vbox.pack_start(*_horiz_origin_x_spin, false, false);
+ global_vbox.pack_start(*_horiz_origin_y_spin, false, false);
+ global_vbox.pack_start(*_font_face_label, false, false);
+ global_vbox.pack_start(*_familyname_entry, false, false);
+ global_vbox.pack_start(*_units_per_em_spin, false, false);
+ global_vbox.pack_start(*_ascent_spin, false, false);
+ global_vbox.pack_start(*_descent_spin, false, false);
+ global_vbox.pack_start(*_cap_height_spin, false, false);
+ global_vbox.pack_start(*_x_height_spin, false, false);
- global_vbox.pack_start(*_familyname_entry, false, false);
/* 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());
- setwidth_hbox->add(*Gtk::manage(new Gtk::Label(_("Set width:"))));
- setwidth_hbox->add(setwidth_spin);
-
- setwidth_spin.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_setwidth_changed));
- setwidth_spin.set_range(0, 4096);
- setwidth_spin.set_increments(10, 0);
- global_vbox.pack_start(*setwidth_hbox, false, false);
-
return &global_vbox;
}
@@ -414,12 +494,13 @@ SvgFontsDialog::populate_glyphs_box()
SPFont* spfont = this->get_selected_spfont();
_glyphs_observer.set(spfont);
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
Gtk::TreeModel::Row row = *(_GlyphsListStore->append());
- row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(node);
- row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(node))->glyph_name;
- row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(node))->unicode;
+ row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(&node);
+ row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(&node))->glyph_name;
+ row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(&node))->unicode;
+ row[_GlyphsListColumns.advance] = (static_cast<SPGlyph*>(&node))->horiz_adv_x;
}
}
}
@@ -432,13 +513,13 @@ SvgFontsDialog::populate_kerning_pairs_box()
SPFont* spfont = this->get_selected_spfont();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_HKERN(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_HKERN(&node)){
Gtk::TreeModel::Row row = *(_KerningPairsListStore->append());
- row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str();
- row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str();
- row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(node))->k;
- row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(node);
+ row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(&node))->u1->attribute_string().c_str();
+ row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(&node))->u2->attribute_string().c_str();
+ row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(&node))->k;
+ row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(&node);
}
}
}
@@ -492,17 +573,14 @@ void SvgFontsDialog::add_glyph(){
Geom::PathVector
SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){
- double units_per_em = 1000;
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ double units_per_em = 1024;
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em);
+ sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em);
}
}
-
double baseline_offset = units_per_em - get_selected_spfont()->horiz_origin_y;
-
//This matrix flips y-axis and places the origin at baseline
Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset));
return pathv*m;
@@ -524,7 +602,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -566,7 +644,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -576,13 +654,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
gchar *str = sp_svg_write_path (flip_coordinate_system(pathv));
- obj->getRepr()->setAttribute("d", str);
+ obj.getRepr()->setAttribute("d", str);
g_free(str);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
}
@@ -599,11 +676,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){
}
SPDocument* doc = desktop->getDocument();
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
+ obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph"));
}
}
@@ -639,6 +715,26 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin
update_glyphs();
}
+void SvgFontsDialog::glyph_advance_edit(const Glib::ustring&, const Glib::ustring& str){
+ Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected();
+ if (!i) return;
+
+ SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
+ //XML Tree being directly used here while it shouldn't be.
+ std::istringstream is(str);
+ double value;
+ // Check if input valid
+ if ((is >> value)) {
+ glyph->getRepr()->setAttribute("horiz-adv-x", str.c_str());
+ SPDocument* doc = this->getDesktop()->getDocument();
+ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph advance"));
+
+ update_glyphs();
+ } else {
+ std::cerr << "SvgFontDialog::glyph_advance_edit: Error in input: " << str << std::endl;
+ }
+}
+
void SvgFontsDialog::remove_selected_font(){
SPFont* font = get_selected_spfont();
if (!font) return;
@@ -707,9 +803,9 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){
_GlyphsListScroller.add(_GlyphsList);
_GlyphsListStore = Gtk::ListStore::create(_GlyphsListColumns);
_GlyphsList.set_model(_GlyphsListStore);
- _GlyphsList.append_column_editable(_("Glyph name"), _GlyphsListColumns.glyph_name);
+ _GlyphsList.append_column_editable(_("Glyph name"), _GlyphsListColumns.glyph_name);
_GlyphsList.append_column_editable(_("Matching string"), _GlyphsListColumns.unicode);
-
+ _GlyphsList.append_column_numeric_editable(_("Advance"), _GlyphsListColumns.advance, "%.2f");
Gtk::HBox* hb = Gtk::manage(new Gtk::HBox());
add_glyph_button.set_label(_("Add Glyph"));
add_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_glyph));
@@ -727,6 +823,9 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){
dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect(
sigc::mem_fun(*this, &SvgFontsDialog::glyph_unicode_edit));
+ dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(2))->signal_edited().connect(
+ sigc::mem_fun(*this, &SvgFontsDialog::glyph_advance_edit));
+
_glyphs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_glyphs));
return &glyphs_vbox;
@@ -738,12 +837,12 @@ void SvgFontsDialog::add_kerning_pair(){
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
- for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: get_selected_spfont()->children) {
//TODO: It is not really correct to get only the first byte of each string.
//TODO: We should also support vertical kerning
- if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
- && (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
- this->kerning_pair = static_cast<SPGlyphKerning*>(node);
+ if (SP_IS_HKERN(&node) && (static_cast<SPGlyphKerning*>(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
+ && (static_cast<SPGlyphKerning*>(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
+ this->kerning_pair = static_cast<SPGlyphKerning*>(&node);
continue;
}
}
@@ -806,7 +905,7 @@ Gtk::VBox* SvgFontsDialog::kerning_tab(){
kerning_amount_hbox->add(*kerning_slider);
kerning_preview.set_size(300 + 20, 150 + 20);
- _font_da.set_size(150 + 20, 50 + 20);
+ _font_da.set_size(300 + 50 + 20, 60 + 20);
return &kerning_vbox;
}
@@ -852,11 +951,10 @@ SPFont *new_font(SPDocument *document)
void set_font_family(SPFont* font, char* str){
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", str);
+ obj.getRepr()->setAttribute("font-family", str);
}
}
@@ -873,11 +971,10 @@ void SvgFontsDialog::add_font(){
font->setLabel(os.str().c_str());
os2 << "SVGFont " << count;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", os2.str().c_str());
+ obj.getRepr()->setAttribute("font-family", os2.str().c_str());
}
}
@@ -888,14 +985,10 @@ void SvgFontsDialog::add_font(){
}
SvgFontsDialog::SvgFontsDialog()
- : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS), _add(Gtk::Stock::NEW)
+ : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS),
+ _add(_("_New"), true)
{
-#if WITH_GTKMM_3_0
kerning_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- kerning_slider = Gtk::manage(new Gtk::HScale);
-#endif
-
_add.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_font));
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h
index e5c4631e4..a0f1586d8 100644
--- a/src/ui/dialog/svg-fonts-dialog.h
+++ b/src/ui/dialog/svg-fonts-dialog.h
@@ -27,11 +27,7 @@
#include "xml/helper-observer.h"
namespace Gtk {
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
class SPGlyph;
@@ -69,64 +65,79 @@ public:
SvgFontsDialog();
~SvgFontsDialog();
- static SvgFontsDialog &getInstance()
- { return *new SvgFontsDialog(); }
+ static SvgFontsDialog &getInstance() { return *new SvgFontsDialog(); }
void update_fonts();
SvgFont* get_selected_svgfont();
SPFont* get_selected_spfont();
- SPGlyph* get_selected_glyph();
- SPGlyphKerning* get_selected_kerning_pair();
+ SPGlyph* get_selected_glyph();
+ SPGlyphKerning* get_selected_kerning_pair();
- //TODO: these methods should be private, right?!
+ //TODO: these methods should be private, right?!
void on_font_selection_changed();
- void on_kerning_pair_selection_changed();
+ void on_kerning_pair_selection_changed();
void on_preview_text_changed();
void on_kerning_pair_changed();
void on_kerning_value_changed();
- void on_setwidth_changed();
- void add_font();
- Geom::PathVector flip_coordinate_system(Geom::PathVector pathv);
+ void on_setfontdata_changed();
+ void add_font();
+ Geom::PathVector flip_coordinate_system(Geom::PathVector pathv);
+ bool updating;
- //TODO: AttrEntry is currently unused. Should we remove it?
+ // Used for font-family
class AttrEntry : public Gtk::HBox
- {
- public:
- AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr);
- void set_text(char*);
- private:
- SvgFontsDialog* dialog;
- void on_attr_changed();
- Gtk::Entry entry;
- SPAttributeEnum attr;
+ {
+ public:
+ AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr);
+ void set_text(char*);
+ private:
+ SvgFontsDialog* dialog;
+ void on_attr_changed();
+ Gtk::Entry entry;
+ SPAttributeEnum attr;
+ };
+
+ class AttrSpin : public Gtk::HBox
+ {
+ public:
+ AttrSpin(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr);
+ void set_value(double v);
+ void set_range(double low, double high);
+ Inkscape::UI::Widget::SpinButton* getSpin() { return &spin; }
+ private:
+ SvgFontsDialog* dialog;
+ void on_attr_changed();
+ Inkscape::UI::Widget::SpinButton spin;
+ SPAttributeEnum attr;
};
private:
- void update_glyphs();
- void update_sensitiveness();
- void update_global_settings_tab();
- void populate_glyphs_box();
+ void update_glyphs();
+ void update_sensitiveness();
+ void update_global_settings_tab();
+ void populate_glyphs_box();
void populate_kerning_pairs_box();
- void set_glyph_description_from_selected_path();
- void missing_glyph_description_from_selected_path();
- void reset_missing_glyph_description();
- void add_glyph();
- void glyph_unicode_edit(const Glib::ustring&, const Glib::ustring&);
- void glyph_name_edit(const Glib::ustring&, const Glib::ustring&);
- void remove_selected_glyph();
- void remove_selected_font();
- void remove_selected_kerning_pair();
+ void set_glyph_description_from_selected_path();
+ void missing_glyph_description_from_selected_path();
+ void reset_missing_glyph_description();
+ void add_glyph();
+ void glyph_unicode_edit(const Glib::ustring&, const Glib::ustring&);
+ void glyph_name_edit( const Glib::ustring&, const Glib::ustring&);
+ void glyph_advance_edit(const Glib::ustring&, const Glib::ustring&);
+ void remove_selected_glyph();
+ void remove_selected_font();
+ void remove_selected_kerning_pair();
- void add_kerning_pair();
+ void add_kerning_pair();
- void create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
- void glyphs_list_button_release(GdkEventButton* event);
+ void create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
+ void glyphs_list_button_release(GdkEventButton* event);
- void create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
- void fonts_list_button_release(GdkEventButton* event);
+ void create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
+ void fonts_list_button_release(GdkEventButton* event);
- void create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
- void kerning_pairs_list_button_release(GdkEventButton* event);
+ void create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
+ void kerning_pairs_list_button_release(GdkEventButton* event);
Inkscape::XML::SignalObserver _defs_observer; //in order to update fonts
Inkscape::XML::SignalObserver _glyphs_observer;
@@ -134,47 +145,63 @@ private:
Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr);
// Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr);
Gtk::VBox* global_settings_tab();
- AttrEntry* _familyname_entry;
+
+ // <font>
+ Gtk::Label* _font_label;
+ AttrSpin* _horiz_adv_x_spin;
+ AttrSpin* _horiz_origin_x_spin;
+ AttrSpin* _horiz_origin_y_spin;
+
+ // <font-face>
+ Gtk::Label* _font_face_label;
+ AttrEntry* _familyname_entry;
+ AttrSpin* _units_per_em_spin;
+ AttrSpin* _ascent_spin;
+ AttrSpin* _descent_spin;
+ AttrSpin* _cap_height_spin;
+ AttrSpin* _x_height_spin;
Gtk::VBox* kerning_tab();
Gtk::VBox* glyphs_tab();
Gtk::Button _add;
Gtk::Button add_glyph_button;
- Gtk::Button glyph_from_path_button;
- Gtk::Button missing_glyph_button;
- Gtk::Button missing_glyph_reset_button;
+ Gtk::Button glyph_from_path_button;
+ Gtk::Button missing_glyph_button;
+ Gtk::Button missing_glyph_reset_button;
class Columns : public Gtk::TreeModel::ColumnRecord
- {
- public:
- Columns()
- {
- add(spfont);
- add(svgfont);
- add(label);
- }
-
- Gtk::TreeModelColumn<SPFont*> spfont;
- Gtk::TreeModelColumn<SvgFont*> svgfont;
- Gtk::TreeModelColumn<Glib::ustring> label;
+ {
+ public:
+ Columns()
+ {
+ add(spfont);
+ add(svgfont);
+ add(label);
+ }
+
+ Gtk::TreeModelColumn<SPFont*> spfont;
+ Gtk::TreeModelColumn<SvgFont*> svgfont;
+ Gtk::TreeModelColumn<Glib::ustring> label;
};
Glib::RefPtr<Gtk::ListStore> _model;
Columns _columns;
Gtk::TreeView _FontsList;
class GlyphsColumns : public Gtk::TreeModel::ColumnRecord
- {
- public:
- GlyphsColumns()
- {
- add(glyph_node);
- add(glyph_name);
- add(unicode);
- }
-
- Gtk::TreeModelColumn<SPGlyph*> glyph_node;
- Gtk::TreeModelColumn<Glib::ustring> glyph_name;
- Gtk::TreeModelColumn<Glib::ustring> unicode;
+ {
+ public:
+ GlyphsColumns()
+ {
+ add(glyph_node);
+ add(glyph_name);
+ add(unicode);
+ add(advance);
+ }
+
+ Gtk::TreeModelColumn<SPGlyph*> glyph_node;
+ Gtk::TreeModelColumn<Glib::ustring> glyph_name;
+ Gtk::TreeModelColumn<Glib::ustring> unicode;
+ Gtk::TreeModelColumn<double> advance;
};
GlyphsColumns _GlyphsListColumns;
Glib::RefPtr<Gtk::ListStore> _GlyphsListStore;
@@ -182,30 +209,30 @@ private:
Gtk::ScrolledWindow _GlyphsListScroller;
class KerningPairColumns : public Gtk::TreeModel::ColumnRecord
- {
- public:
- KerningPairColumns()
- {
- add(first_glyph);
- add(second_glyph);
- add(kerning_value);
- add(spnode);
- }
-
- Gtk::TreeModelColumn<Glib::ustring> first_glyph;
- Gtk::TreeModelColumn<Glib::ustring> second_glyph;
- Gtk::TreeModelColumn<double> kerning_value;
- Gtk::TreeModelColumn<SPGlyphKerning*> spnode;
+ {
+ public:
+ KerningPairColumns()
+ {
+ add(first_glyph);
+ add(second_glyph);
+ add(kerning_value);
+ add(spnode);
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> first_glyph;
+ Gtk::TreeModelColumn<Glib::ustring> second_glyph;
+ Gtk::TreeModelColumn<double> kerning_value;
+ Gtk::TreeModelColumn<SPGlyphKerning*> spnode;
};
KerningPairColumns _KerningPairsListColumns;
Glib::RefPtr<Gtk::ListStore> _KerningPairsListStore;
Gtk::TreeView _KerningPairsList;
Gtk::ScrolledWindow _KerningPairsListScroller;
- Gtk::Button add_kernpair_button;
+ Gtk::Button add_kernpair_button;
Gtk::VBox _font_settings;
- Gtk::VBox global_vbox;
- Gtk::VBox glyphs_vbox;
+ Gtk::VBox global_vbox;
+ Gtk::VBox glyphs_vbox;
Gtk::VBox kerning_vbox;
Gtk::Entry _preview_entry;
@@ -217,28 +244,23 @@ private:
GlyphComboBox first_glyph, second_glyph;
SPGlyphKerning* kerning_pair;
Inkscape::UI::Widget::SpinButton setwidth_spin;
-
-#if WITH_GTKMM_3_0
Gtk::Scale* kerning_slider;
-#else
- Gtk::HScale* kerning_slider;
-#endif
class EntryWidget : public Gtk::HBox
- {
- public:
- EntryWidget()
- {
- this->add(this->_label);
- this->add(this->_entry);
- }
- void set_label(const gchar* l){
- this->_label.set_text(l);
- }
- private:
- Gtk::Label _label;
- Gtk::Entry _entry;
- };
+ {
+ public:
+ EntryWidget()
+ {
+ this->add(this->_label);
+ this->add(this->_entry);
+ }
+ void set_label(const gchar* l){
+ this->_label.set_text(l);
+ }
+ private:
+ Gtk::Label _label;
+ Gtk::Entry _entry;
+ };
EntryWidget _font_family, _font_variant;
};
@@ -247,3 +269,14 @@ private:
} // namespace Inkscape
#endif //#ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 6577c8d4e..87bfa9252 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -24,7 +24,6 @@
#include <glibmm/i18n.h>
#include <glibmm/main.h>
#include <glibmm/timer.h>
-#include <gdkmm/pixbuf.h>
#include "color-item.h"
#include "desktop.h"
@@ -35,28 +34,20 @@
#include "document-undo.h"
#include "extension/db.h"
#include "inkscape.h"
-#include "inkscape.h"
#include "io/sys.h"
#include "io/resource.h"
#include "message-context.h"
#include "path-prefix.h"
-#include "preferences.h"
-#include "sp-item.h"
-#include "sp-gradient.h"
-#include "sp-gradient-vector.h"
#include "style.h"
#include "ui/previewholder.h"
#include "widgets/desktop-widget.h"
#include "widgets/gradient-vector.h"
-#include "widgets/eek-preview.h"
#include "display/cairo-utils.h"
#include "sp-gradient-reference.h"
#include "dialog-manager.h"
-#include "selection.h"
#include "verbs.h"
#include "gradient-chemistry.h"
#include "helper/action.h"
-#include "helper/action-context.h"
namespace Inkscape {
namespace UI {
@@ -123,7 +114,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
bool shown = false;
if ( desktop && desktop->doc() ) {
Inkscape::Selection *selection = desktop->getSelection();
- std::vector<SPItem*> const items = selection->itemList();
+ std::vector<SPItem*> const items(selection->items().begin(), selection->items().end());
if (!items.empty()) {
SPStyle query( desktop->doc() );
int result = objects_query_fillstroke((items), &query, true);
@@ -607,7 +598,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
}
loadEmUp();
- if ( !systemSwatchPages.empty() ) {
+ if ( !systemSwatchPages.empty() || !userSwatchPages.empty()) {
SwatchPage* first = 0;
int index = 0;
Glib::ustring targetName;
@@ -658,12 +649,8 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
if (Glib::ustring(prefsPath) == "/dialogs/swatches") {
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
get_preferred_size(sreq_natural, sreq);
-#else
- sreq = size_request();
-#endif
int minHeight = 60;
if (sreq.height < minHeight) {
set_size_request(70, minHeight);
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 06c17611f..e9a13620b 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -15,25 +15,17 @@
#include <iostream>
#include <algorithm>
#include <locale>
-#include <functional>
#include <sstream>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/togglebutton.h>
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
+#include <gtkmm/togglebutton.h>
+#include <gtkmm/grid.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/iconview.h>
#include <gtkmm/liststore.h>
-#include <gtkmm/treemodelcolumn.h>
-#include <gtkmm/clipboard.h>
+#include <glibmm/regex.h>
#include <glibmm/stringutils.h>
#include <glibmm/markup.h>
#include <glibmm/i18n.h>
@@ -65,7 +57,10 @@
#include <librevenge-stream/librevenge-stream.h>
using librevenge::RVNGFileStream;
+ using librevenge::RVNGString;
using librevenge::RVNGStringVector;
+ using librevenge::RVNGPropertyList;
+ using librevenge::RVNGSVGDrawingGenerator;
#else
#include <libwpd-stream/libwpd-stream.h>
@@ -76,8 +71,6 @@
#include "verbs.h"
#include "helper/action.h"
-#include "helper/action-context.h"
-#include "xml/repr.h"
namespace Inkscape {
namespace UI {
@@ -121,11 +114,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
{
/******************** Table *************************/
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = new Gtk::Grid();
-#else
- Gtk::Table *table = new Gtk::Table(2, 4, false);
-#endif
+ auto table = new Gtk::Grid();
// panel is a cloked Gtk::VBox
_getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET);
@@ -133,28 +122,16 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
/******************** Symbol Sets *************************/
Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: "));
-
-#if WITH_GTKMM_3_0
table->attach(*Gtk::manage(labelSet),0,row,1,1);
-#else
- table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK);
-#endif
-
symbolSet = new Gtk::ComboBoxText(); // Fill in later
symbolSet->append(_("Current Document"));
symbolSet->set_active_text(_("Current Document"));
-
-#if WITH_GTKMM_3_0
symbolSet->set_hexpand();
table->attach(*Gtk::manage(symbolSet),1,row,1,1);
-#else
- table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK);
-#endif
-
sigc::connection connSet = symbolSet->signal_changed().connect(
sigc::mem_fun(*this, &SymbolsDialog::rebuild));
instanceConns.push_back(connSet);
-
+
++row;
/********************* Icon View **************************/
@@ -183,14 +160,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow();
scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
scroller->add(*Gtk::manage(iconView));
-
-#if WITH_GTKMM_3_0
scroller->set_hexpand();
scroller->set_vexpand();
table->attach(*Gtk::manage(scroller),0,row,2,1);
-#else
- table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL);
-#endif
++row;
@@ -199,12 +171,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
Gtk::HBox* tools = new Gtk::HBox();
//tools->set_layout( Gtk::BUTTONBOX_END );
-#if WITH_GTKMM_3_0
scroller->set_hexpand();
table->attach(*Gtk::manage(tools),0,row,2,1);
-#else
- table->attach(*Gtk::manage(tools),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL);
-#endif
addSymbol = Gtk::manage(new Gtk::Button());
addSymbol->add(*Gtk::manage(Glib::wrap(
@@ -378,7 +346,7 @@ void SymbolsDialog::rebuild() {
addSymbol->set_sensitive( true );
removeSymbol->set_sensitive( true );
} else {
- addSymbol->set_sensitive( false );
+ addSymbol->set_sensitive( false );
removeSymbol->set_sensitive( false );
}
add_symbols( symbolDocument );
@@ -398,11 +366,7 @@ void SymbolsDialog::revertSymbol() {
void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/)
{
-#if WITH_GTKMM_3_0
- std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
-#else
- Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items();
-#endif
+ auto iconArray = iconView->get_selected_items();
if( iconArray.empty() ) {
//std::cout << " iconArray empty: huh? " << std::endl;
@@ -455,11 +419,7 @@ SPDocument* SymbolsDialog::selectedSymbols() {
Glib::ustring SymbolsDialog::selectedSymbolId() {
-#if WITH_GTKMM_3_0
- std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
-#else
- Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items();
-#endif
+ auto iconArray = iconView->get_selected_items();
if( !iconArray.empty() ) {
Gtk::TreeModel::Path const & path = *iconArray.begin();
@@ -476,11 +436,6 @@ void SymbolsDialog::iconChanged() {
SPObject* symbol = symbolDocument->getObjectById(symbol_id);
if( symbol ) {
- if( symbolDocument == currentDocument ) {
- // Select the symbol on the canvas so it can be manipulated
- currentDesktop->selection->set( symbol, false );
- }
-
// Find style for use in <use>
// First look for default style stored in <symbol>
gchar const* style = symbol->getAttribute("inkscape:symbol-style");
@@ -499,18 +454,55 @@ void SymbolsDialog::iconChanged() {
}
#ifdef WITH_LIBVISIO
+
+#if WITH_LIBVISIO01
+// Extend libvisio's native RVNGSVGDrawingGenerator with support for extracting stencil names (to be used as ID/title)
+class REVENGE_API RVNGSVGDrawingGenerator_WithTitle : public RVNGSVGDrawingGenerator {
+ public:
+ RVNGSVGDrawingGenerator_WithTitle(RVNGStringVector &output, RVNGStringVector &titles, const RVNGString &nmSpace)
+ : RVNGSVGDrawingGenerator(output, nmSpace)
+ , _titles(titles)
+ {}
+
+ void startPage(const RVNGPropertyList &propList)
+ {
+ RVNGSVGDrawingGenerator::startPage(propList);
+ if (propList["draw:name"]) {
+ _titles.append(propList["draw:name"]->getStr());
+ } else {
+ _titles.append("");
+ }
+ }
+
+ private:
+ RVNGStringVector &_titles;
+};
+#endif
+
// Read Visio stencil files
-SPDocument* read_vss( gchar* fullname, gchar* filename ) {
+SPDocument* read_vss( gchar* fullname, Glib::ustring name ) {
+
+ #ifdef WIN32
+ // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows
+ // therefore attempt to convert uri to the system codepage
+ // even if this is not possible the alternate short (8.3) file name will be used if available
+ fullname = g_win32_locale_filename_from_utf8(fullname);
+ #endif
RVNGFileStream input(fullname);
+ #ifdef WIN32
+ g_free(fullname);
+ #endif
+
if (!libvisio::VisioDocument::isSupported(&input)) {
return NULL;
}
RVNGStringVector output;
+ RVNGStringVector titles;
#if WITH_LIBVISIO01
- librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
+ RVNGSVGDrawingGenerator_WithTitle generator(output, titles, "svg");
if (!libvisio::VisioDocument::parseStencils(&input, &generator)) {
#else
@@ -523,6 +515,12 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) {
return NULL;
}
+ // prepare a valid title for the symbol file
+ Glib::ustring title = Glib::Markup::escape_text(name);
+ // prepare a valid id prefix for symbols libvisio doesn't give us a name for
+ Glib::RefPtr<Glib::Regex> regex1 = Glib::Regex::create("[^a-zA-Z0-9_-]");
+ Glib::ustring id = regex1->replace(name, 0, "_", Glib::REGEX_MATCH_PARTIAL);
+
Glib::ustring tmpSVGOutput;
tmpSVGOutput += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
tmpSVGOutput += "<svg\n";
@@ -532,36 +530,34 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) {
tmpSVGOutput += " version=\"1.1\"\n";
tmpSVGOutput += " style=\"fill:none;stroke:#000000;stroke-width:2\">\n";
tmpSVGOutput += " <title>";
- tmpSVGOutput += filename;
+ tmpSVGOutput += title;
tmpSVGOutput += "</title>\n";
tmpSVGOutput += " <defs>\n";
- // Create a string we can use for the symbol id (libvisio doesn't give us a name)
- std::string sanitized( filename );
- sanitized.erase( sanitized.find_last_of(".vss")-3 );
- sanitized.erase( std::remove_if( sanitized.begin(), sanitized.end(), ispunct ), sanitized.end() );
- std::replace( sanitized.begin(), sanitized.end(), ' ', '_' );
- // std::cout << filename << " |" << sanitized << "|" << std::endl;
-
- // Each "symbol" is in it's own SVG file, we wrap with <symbol> and merge into one file.
+ // Each "symbol" is in its own SVG file, we wrap with <symbol> and merge into one file.
for (unsigned i=0; i<output.size(); ++i) {
std::stringstream ss;
- ss << i;
+ if (titles.size() == output.size() && titles[i] != "") {
+ // TODO: Do we need to check for duplicated titles?
+ ss << regex1->replace(titles[i].cstr(), 0, "_", Glib::REGEX_MATCH_PARTIAL);
+ } else {
+ ss << id << "_" << i;
+ }
+
+ tmpSVGOutput += " <symbol id=\"" + ss.str() + "\">\n";
- tmpSVGOutput += " <symbol id=\"";
- tmpSVGOutput += sanitized;
- tmpSVGOutput += "_";
- tmpSVGOutput += ss.str();
- tmpSVGOutput += "\">\n";
+#if WITH_LIBVISIO01
+ if (titles.size() == output.size() && titles[i] != "") {
+ tmpSVGOutput += " <title>" + Glib::ustring(RVNGString::escapeXML(titles[i].cstr()).cstr()) + "</title>\n";
+ }
+#endif
std::istringstream iss( output[i].cstr() );
std::string line;
while( std::getline( iss, line ) ) {
- // std::cout << line << std::endl;
if( line.find( "svg:svg" ) == std::string::npos ) {
- tmpSVGOutput += line;
- tmpSVGOutput += "\n";
+ tmpSVGOutput += " " + line + "\n";
}
}
@@ -570,12 +566,12 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) {
tmpSVGOutput += " </defs>\n";
tmpSVGOutput += "</svg>\n";
-
+
return SPDocument::createNewDocFromMem( tmpSVGOutput.c_str(), strlen( tmpSVGOutput.c_str()), 0 );
}
#endif
-
+
/* Hunts preference directories for symbol files */
void SymbolsDialog::get_symbols() {
@@ -614,11 +610,14 @@ void SymbolsDialog::get_symbols() {
#ifdef WITH_LIBVISIO
if( tag.compare( "vss" ) == 0 ) {
+ // strip extension from filename and use it as name for the symbol set
+ Glib::ustring name = Glib::ustring(filename);
+ name = name.erase(name.rfind('.'));
- symbol_doc = read_vss( fullname, filename );
+ symbol_doc = read_vss( fullname, name );
if( symbol_doc ) {
- symbolSets[Glib::ustring(filename)]= symbol_doc;
- symbolSet->append(filename);
+ symbolSets[name]= symbol_doc;
+ symbolSet->append(name);
}
}
#endif
@@ -663,8 +662,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = symbols_in_doc_recursive( child, l );
+ for (auto& child: r->children) {
+ l = symbols_in_doc_recursive( &child, l );
}
return l;
@@ -679,14 +678,14 @@ GSList* SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) {
}
GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l)
-{
+{
if ( dynamic_cast<SPUse *>(r) ) {
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = use_in_doc_recursive( child, l );
+ for (auto& child: r->children) {
+ l = use_in_doc_recursive( &child, l );
}
return l;
@@ -865,7 +864,7 @@ SPDocument* SymbolsDialog::symbols_preview_doc()
" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\""
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\""
" xmlns:xlink=\"http://www.w3.org/1999/xlink\">"
-" <defs id=\"defs\">"
+" <defs id=\"defs\">"
" <symbol id=\"the_symbol\"/>"
" </defs>"
" <use id=\"the_use\" xlink:href=\"#the_symbol\"/>"
diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp
index c99c1bff3..dfe71bddb 100644
--- a/src/ui/dialog/tags.cpp
+++ b/src/ui/dialog/tags.cpp
@@ -10,17 +10,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "tags.h"
-#include <gtkmm/widget.h>
#include <gtkmm/icontheme.h>
#include <gtkmm/imagemenuitem.h>
-#include <gtkmm/separatormenuitem.h>
-
#include <glibmm/main.h>
-#include <glibmm/i18n.h>
#include "desktop.h"
#include "desktop-style.h"
@@ -30,28 +26,19 @@
#include "inkscape.h"
#include "layer-fns.h"
#include "layer-manager.h"
-#include "preferences.h"
-#include "sp-item.h"
-#include "sp-object.h"
#include "sp-shape.h"
#include "svg/css-ostringstream.h"
-#include "ui/icon-names.h"
#include "ui/widget/layertypeicon.h"
#include "ui/widget/addtoicon.h"
#include "verbs.h"
#include "widgets/icon.h"
-#include "xml/node.h"
#include "xml/node-observer.h"
-#include "xml/repr.h"
#include "sp-root.h"
#include "ui/tools/tool-base.h" //"event-context.h"
-#include "selection.h"
//#include "dialogs/dialog-events.h"
#include "ui/widget/color-notebook.h"
#include "style.h"
#include "filter-chemistry.h"
-#include "filters/blend.h"
-#include "filters/gaussian-blur.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-tag.h"
@@ -348,8 +335,8 @@ void TagsPanel::_objectsSelected( Selection *sel ) {
_selectedConnection.block();
_tree.get_selection()->unselect_all();
- std::vector<SPObject*> tmp=sel->list();
- for(std::vector<SPObject*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp = sel->objects();
+ for(auto i = tmp.begin(); i != tmp.end(); ++i)
{
SPObject *obj = *i;
_store->foreach(sigc::bind<SPObject *>( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj));
@@ -399,26 +386,26 @@ void TagsPanel::_objectsChanged(SPObject* root)
void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow )
{
if ( _desktop && obj ) {
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG(child))
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG(&child))
{
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
Gtk::TreeModel::Row row = *iter;
- row[_model->_colObject] = child;
+ row[_model->_colObject] = &child;
row[_model->_colParentObject] = NULL;
- row[_model->_colLabel] = child->label() ? child->label() : child->getId();
+ row[_model->_colLabel] = child.label() ? child.label() : child.getId();
row[_model->_colAddRemove] = true;
row[_model->_colAllowAddRemove] = true;
_tree.expand_to_path( _store->get_path(iter) );
- TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child);
- child->getRepr()->addObserver(*w);
+ TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child);
+ child.getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
- _addObject( doc, child, &row );
+ _addObject( doc, &child, &row );
}
}
- if (SP_IS_TAG(obj) && obj->children)
+ if (SP_IS_TAG(obj) && obj->firstChild())
{
Gtk::TreeModel::iterator iteritems = parentRow ? _store->append(parentRow->children()) : _store->prepend();
Gtk::TreeModel::Row rowitems = *iteritems;
@@ -429,16 +416,16 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
rowitems[_model->_colAllowAddRemove] = false;
_tree.expand_to_path( _store->get_path(iteritems) );
-
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG_USE(child))
+
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG_USE(&child))
{
- SPItem *item = SP_TAG_USE(child)->ref->getObject();
+ SPItem *item = SP_TAG_USE(&child)->ref->getObject();
Gtk::TreeModel::iterator iter = _store->prepend(rowitems->children());
Gtk::TreeModel::Row row = *iter;
- row[_model->_colObject] = child;
+ row[_model->_colObject] = &child;
row[_model->_colParentObject] = NULL;
- row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(child)->href;
+ row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(&child)->href;
row[_model->_colAddRemove] = false;
row[_model->_colAllowAddRemove] = true;
@@ -447,7 +434,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
}
if (item) {
- TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child, item->getRepr());
+ TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child, item->getRepr());
item->getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
}
@@ -459,12 +446,11 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
void TagsPanel::_select_tag( SPTag * tag )
{
- for (SPObject * child = tag->children; child != NULL; child = child->next)
- {
- if (SP_IS_TAG(child)) {
- _select_tag(SP_TAG(child));
- } else if (SP_IS_TAG_USE(child)) {
- SPObject * obj = SP_TAG_USE(child)->ref->getObject();
+ for (auto& child: tag->children) {
+ if (SP_IS_TAG(&child)) {
+ _select_tag(SP_TAG(&child));
+ } else if (SP_IS_TAG_USE(&child)) {
+ SPObject * obj = SP_TAG_USE(&child)->ref->getObject();
if (obj) {
if (_desktop->selection->isEmpty()) _desktop->setCurrentLayer(obj->parent);
_desktop->selection->add(obj);
@@ -646,12 +632,12 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event)
if (col == _tree.get_column(COL_ADD - 1) && down_at_add) {
if (SP_IS_TAG(obj)) {
bool wasadded = false;
- std::vector<SPItem*> items=_desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= _desktop->selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *newobj = *i;
bool addchild = true;
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG_USE(child) && SP_TAG_USE(child)->ref->getObject() == newobj) {
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) {
addchild = false;
}
}
@@ -980,12 +966,8 @@ TagsPanel::TagsPanel() :
_scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
_scroller.set_shadow_type(Gtk::SHADOW_IN);
Gtk::Requisition sreq;
-#if WITH_GTKMM_3_0
Gtk::Requisition sreq_natural;
_scroller.get_preferred_size(sreq_natural, sreq);
-#else
- sreq = _scroller.size_request();
-#endif
int minHeight = 70;
if (sreq.height < minHeight) {
// Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar
diff --git a/src/ui/dialog/tags.h b/src/ui/dialog/tags.h
index 3576bd111..bdda22dd4 100644
--- a/src/ui/dialog/tags.h
+++ b/src/ui/dialog/tags.h
@@ -141,15 +141,9 @@ private:
Gtk::TreeView _tree;
Gtk::CellRendererText *_text_renderer;
Gtk::TreeView::Column *_name_column;
-#if WITH_GTKMM_3_0
Gtk::Box _buttonsRow;
Gtk::Box _buttonsPrimary;
Gtk::Box _buttonsSecondary;
-#else
- Gtk::HBox _buttonsRow;
- Gtk::HBox _buttonsPrimary;
- Gtk::HBox _buttonsSecondary;
-#endif
Gtk::ScrolledWindow _scroller;
Gtk::Menu _popupMenu;
Inkscape::UI::Widget::SpinButton _spinBtn;
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index 7eb04ff79..7b96c2b97 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -9,28 +9,20 @@
*/
#include "template-widget.h"
-#include "template-load-tab.h"
#include "new-from-template.h"
-#include <gtkmm/messagedialog.h>
-#include <gtkmm/scrolledwindow.h>
-#include <glibmm/i18n.h>
-#include <glibmm/fileutils.h>
#include <glibmm/miscutils.h>
#include <glibmm/stringutils.h>
+#include <glibmm/fileutils.h>
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/scrolledwindow.h>
#include <iostream>
-#include <list>
#include "extension/db.h"
-#include "extension/effect.h"
#include "inkscape.h"
#include "ui/interface.h"
#include "file.h"
#include "path-prefix.h"
-#include "preferences.h"
-#include "xml/repr.h"
-#include "xml/document.h"
-#include "xml/node.h"
namespace Inkscape {
namespace UI {
diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp
index 0d110d853..3b7fbe88c 100644
--- a/src/ui/dialog/template-widget.cpp
+++ b/src/ui/dialog/template-widget.cpp
@@ -10,15 +10,10 @@
#include "template-widget.h"
+#include <glibmm/miscutils.h>
#include <gtkmm/alignment.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
#include <gtkmm/messagedialog.h>
-#include <glibmm/i18n.h>
-#include <glibmm/miscutils.h>
-
-#include "template-load-tab.h"
#include "desktop.h"
#include "document.h"
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index c01da8864..94f307828 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -22,7 +22,6 @@
#include "text-edit.h"
#include <libnrtype/font-instance.h>
-#include <gtk/gtk.h>
#ifdef WITH_GTKSPELL
extern "C" {
@@ -30,12 +29,8 @@ extern "C" {
}
#endif
-#include <gtkmm/stock.h>
-#include <libnrtype/font-instance.h>
#include <libnrtype/font-lister.h>
-#include <xml/repr.h>
-#include "macros.h"
#include "helper/window.h"
#include "inkscape.h"
#include "document.h"
@@ -43,13 +38,10 @@ extern "C" {
#include "desktop-style.h"
#include "document-undo.h"
-#include "selection.h"
-#include "style.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
#include "ui/icon-names.h"
-#include "preferences.h"
#include "verbs.h"
#include "ui/interface.h"
#include "svg/css-ostringstream.h"
@@ -71,8 +63,8 @@ TextEdit::TextEdit()
text_label(_("_Text"), true),
vari_label(_("_Variants"), true),
setasdefault_button(_("Set as _default")),
- close_button(Gtk::Stock::CLOSE),
- apply_button(Gtk::Stock::APPLY),
+ close_button(_("_Close"), true),
+ apply_button(_("_Apply"), true),
desktop(NULL),
deskTrack(),
selectChangedConn(),
@@ -99,9 +91,7 @@ TextEdit::TextEdit()
styleButton(&align_right, _("Align right"), INKSCAPE_ICON("format-justify-right"), &align_left);
styleButton(&align_justify, _("Justify (only flowed text)"), INKSCAPE_ICON("format-justify-fill"), &align_left);
-#if WITH_GTKMM_3_0
align_sep.set_orientation(Gtk::ORIENTATION_VERTICAL);
-#endif
layout_hbox.pack_start(align_sep, false, false, 10);
@@ -109,13 +99,12 @@ TextEdit::TextEdit()
styleButton(&text_horizontal, _("Horizontal text"), INKSCAPE_ICON("format-text-direction-horizontal"), NULL);
styleButton(&text_vertical, _("Vertical text"), INKSCAPE_ICON("format-text-direction-vertical"), &text_horizontal);
-#if WITH_GTKMM_3_0
text_sep.set_orientation(Gtk::ORIENTATION_VERTICAL);
-#endif
layout_hbox.pack_start(text_sep, false, false, 10);
/* Line Spacing */
+ /* Commented out as this does not handle non-percentage values
GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") );
layout_hbox.pack_start(*Gtk::manage(Glib::wrap(px)), false, false);
@@ -132,6 +121,7 @@ TextEdit::TextEdit()
layout_hbox.pack_start(*Gtk::manage(Glib::wrap(spacing_combo)), false, false);
layout_frame.set_padding(4,4,4,4);
layout_frame.add(layout_hbox);
+ */
// Text start Offset
{
@@ -146,12 +136,8 @@ TextEdit::TextEdit()
gtk_widget_set_tooltip_text(startOffset, _("Text path offset"));
-#if WITH_GTKMM_3_0
- Gtk::Separator *sep = Gtk::manage(new Gtk::Separator());
+ auto sep = Gtk::manage(new Gtk::Separator());
sep->set_orientation(Gtk::ORIENTATION_VERTICAL);
-#else
- Gtk::VSeparator *sep = Gtk::manage(new Gtk::VSeparator);
-#endif
layout_hbox.pack_start(*sep, false, false, 10);
layout_hbox.pack_start(*Gtk::manage(Glib::wrap(startOffset)), false, false);
@@ -175,7 +161,6 @@ TextEdit::TextEdit()
gtk_text_view_set_wrap_mode ((GtkTextView *) text_view, GTK_WRAP_WORD);
#ifdef WITH_GTKSPELL
-#ifdef WITH_GTKMM_3_0
/*
TODO: Use computed xml:lang attribute of relevant element, if present, to specify the
language (either as 2nd arg of gtkspell_new_attach, or with explicit
@@ -187,20 +172,6 @@ TextEdit::TextEdit()
if (! gtk_spell_checker_attach(speller, GTK_TEXT_VIEW(text_view))) {
g_print("gtkspell error:\n");
}
-#else
- GError *error = NULL;
-
-/*
- TODO: Use computed xml:lang attribute of relevant element, if present, to specify the
- language (either as 2nd arg of gtkspell_new_attach, or with explicit
- gtkspell_set_language call in; see advanced.c example in gtkspell docs).
- onReadSelection looks like a suitable place.
-*/
- if (gtkspell_new_attach(GTK_TEXT_VIEW(text_view), NULL, &error) == NULL) {
- g_print("gtkspell error: %s\n", error->message);
- g_error_free(error);
- }
-#endif
#endif
gtk_widget_set_size_request (text_view, -1, 64);
@@ -226,7 +197,7 @@ TextEdit::TextEdit()
/* Signal handlers */
g_signal_connect ( G_OBJECT (fontsel), "font_set", G_CALLBACK (onFontChange), this );
- g_signal_connect ( G_OBJECT (spacing_combo), "changed", G_CALLBACK (onLineSpacingChange), this );
+ // g_signal_connect ( G_OBJECT (spacing_combo), "changed", G_CALLBACK (onLineSpacingChange), this );
g_signal_connect ( G_OBJECT (text_buffer), "changed", G_CALLBACK (onTextChange), this );
g_signal_connect(startOffset, "changed", G_CALLBACK(onStartOffsetChange), this);
setasdefault_button.signal_clicked().connect(sigc::mem_fun(*this, &TextEdit::onSetDefault));
@@ -392,6 +363,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
text_vertical.set_active();
}
+ /*
double height;
if (query.line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
else if (query.line_height.unit == SP_CSS_UNIT_PERCENT)
@@ -401,6 +373,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) spacing_combo), sstr);
g_free(sstr);
+ */
// Update font variant widget
//int result_variants =
@@ -443,8 +416,8 @@ SPItem *TextEdit::getSelectedTextItem (void)
if (!SP_ACTIVE_DESKTOP)
return NULL;
- std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i)
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
return *i;
@@ -461,8 +434,8 @@ unsigned TextEdit::getSelectedTextCount (void)
unsigned int items = 0;
- std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i)
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
++items;
@@ -535,11 +508,9 @@ SPCSSAttr *TextEdit::fillTextStyle ()
sp_repr_css_set_property (css, "writing-mode", "tb");
}
- // Note that SVG 1.1 does not support line-height; we set it for consistency, but also set
- // sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext
-
- const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo);
- sp_repr_css_set_property (css, "line-height", sstr);
+ // Note that SVG 1.1 does not support line-height but we use it.
+ // const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo);
+ // sp_repr_css_set_property (css, "line-height", sstr);
// Font variants
vari_vbox.fill_css( css );
@@ -568,22 +539,15 @@ void TextEdit::onApply()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
unsigned items = 0;
- const std::vector<SPItem*> item_list = desktop->getSelection()->itemList();
+ auto item_list = desktop->getSelection()->items();
SPCSSAttr *css = fillTextStyle ();
sp_desktop_set_style(desktop, css, true);
- for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();++i){
+ for(auto i=item_list.begin();i!=item_list.end();++i){
// apply style to the reprs of all text objects in the selection
- if (SP_IS_TEXT (*i)) {
-
- // backwards compatibility:
- (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
-
+ if (SP_IS_TEXT (*i) || (SP_IS_FLOWTEXT (*i)) ) {
++items;
}
- else if (SP_IS_FLOWTEXT (*i))
- // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext
- ++items;
}
if (items == 0) {
diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h
index cfe612268..1fc0099fb 100644
--- a/src/ui/dialog/text-edit.h
+++ b/src/ui/dialog/text-edit.h
@@ -22,6 +22,7 @@
# include <config.h>
#endif
+#include <gtkmm/alignment.h>
#include <gtkmm/box.h>
#include <gtkmm/notebook.h>
#include <gtkmm/button.h>
@@ -198,21 +199,10 @@ private:
Gtk::RadioButton align_center;
Gtk::RadioButton align_right;
Gtk::RadioButton align_justify;
-
-#if WITH_GTKMM_3_0
Gtk::Separator align_sep;
-#else
- Gtk::VSeparator align_sep;
-#endif
-
Gtk::RadioButton text_vertical;
Gtk::RadioButton text_horizontal;
-
-#if WITH_GTKMM_3_0
Gtk::Separator text_sep;
-#else
- Gtk::VSeparator text_sep;
-#endif
GtkWidget *spacing_combo;
diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h
index de1d3028b..2c29f85b8 100644
--- a/src/ui/dialog/tile.h
+++ b/src/ui/dialog/tile.h
@@ -29,12 +29,7 @@
namespace Gtk {
class Button;
-
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp
index 11e75391b..a1d4d88b8 100644
--- a/src/ui/dialog/tracedialog.cpp
+++ b/src/ui/dialog/tracedialog.cpp
@@ -12,18 +12,16 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "tracedialog.h"
#include <gtkmm/notebook.h>
#include <gtkmm/frame.h>
+#include <gtkmm/radiobutton.h>
#include "ui/widget/spinbutton.h"
#include "ui/widget/frame.h"
-#include <gtkmm/radiobutton.h>
-#include <gtkmm/stock.h>
-#include <gtk/gtk.h> //for GTK_RESPONSE* types
#include <glibmm/i18n.h>
#include "desktop.h"
@@ -814,12 +812,12 @@ TraceDialogImpl::TraceDialogImpl() :
mainResetButton ->set_tooltip_text(_("Reset all settings to defaults"));
//## The OK button
- mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
+ mainCancelButton = addResponseButton(_("_Stop"), GTK_RESPONSE_CANCEL);
if (mainCancelButton) {
mainCancelButton->set_tooltip_text(_("Abort a trace in progress"));
mainCancelButton->set_sensitive(false);
}
- mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK);
+ mainOkButton = addResponseButton(_("_OK"), GTK_RESPONSE_OK);
mainOkButton->set_tooltip_text(_("Execute the trace"));
show_all_children();
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index b7638e8c1..d209a450c 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -12,11 +12,10 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include <gtkmm/dialog.h>
-#include <gtkmm/stock.h>
#include <2geom/transforms.h>
#include "document.h"
@@ -26,15 +25,11 @@
#include "transformation.h"
#include "align-and-distribute.h"
#include "inkscape.h"
-#include "selection.h"
#include "selection-chemistry.h"
#include "message-stack.h"
#include "verbs.h"
-#include "preferences.h"
#include "sp-namedview.h"
#include "sp-item-transform.h"
-#include "macros.h"
-#include "sp-item.h"
#include "ui/icon-names.h"
#include "widgets/icon.h"
@@ -138,14 +133,14 @@ Transformation::Transformation()
updateSelection(PAGE_MOVE, _getSelection());
- resetButton = addResponseButton(Gtk::Stock::CLEAR, 0);
+ resetButton = addResponseButton(_("_Clear"), 0);
if (resetButton) {
resetButton->set_tooltip_text(_("Reset the values on the current tab to defaults"));
resetButton->set_sensitive(true);
resetButton->signal_clicked().connect(sigc::mem_fun(*this, &Transformation::onClear));
}
- applyButton = addResponseButton(Gtk::Stock::APPLY, Gtk::RESPONSE_APPLY);
+ applyButton = addResponseButton(_("_Apply"), Gtk::RESPONSE_APPLY);
if (applyButton) {
applyButton->set_tooltip_text(_("Apply transformation to selection"));
applyButton->set_sensitive(false);
@@ -216,38 +211,20 @@ void Transformation::layoutPageMove()
//_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_HOR );
-#if WITH_GTKMM_3_0
_page_move.table().attach(_scalar_move_horizontal, 0, 0, 2, 1);
_page_move.table().attach(_units_move, 2, 0, 1, 1);
-#else
- _page_move.table()
- .attach(_scalar_move_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
-
- _page_move.table()
- .attach(_units_move, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_move_horizontal.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged));
//_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_VER );
-#if WITH_GTKMM_3_0
_page_move.table().attach(_scalar_move_vertical, 0, 1, 2, 1);
-#else
- _page_move.table()
- .attach(_scalar_move_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
-#endif
_scalar_move_vertical.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged));
// Relative moves
-#if WITH_GTKMM_3_0
_page_move.table().attach(_check_move_relative, 0, 2, 2, 1);
-#else
- _page_move.table()
- .attach(_check_move_relative, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
-#endif
_check_move_relative.set_active(true);
_check_move_relative.signal_toggled()
@@ -273,36 +250,18 @@ void Transformation::layoutPageScale()
_scalar_scale_vertical.setAbsoluteIsIncrement(true);
_scalar_scale_vertical.setPercentageIsIncrement(true);
-#if WITH_GTKMM_3_0
_page_scale.table().attach(_scalar_scale_horizontal, 0, 0, 2, 1);
-#else
- _page_scale.table()
- .attach(_scalar_scale_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
-#endif
_scalar_scale_horizontal.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onScaleXValueChanged));
-#if WITH_GTKMM_3_0
_page_scale.table().attach(_units_scale, 2, 0, 1, 1);
_page_scale.table().attach(_scalar_scale_vertical, 0, 1, 2, 1);
-#else
- _page_scale.table()
- .attach(_units_scale, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _page_scale.table()
- .attach(_scalar_scale_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
-#endif
_scalar_scale_vertical.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onScaleYValueChanged));
-#if WITH_GTKMM_3_0
_page_scale.table().attach(_check_scale_proportional, 0, 2, 2, 1);
-#else
- _page_scale.table()
- .attach(_check_scale_proportional, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
-#endif
_check_scale_proportional.set_active(false);
_check_scale_proportional.signal_toggled()
@@ -334,24 +293,10 @@ void Transformation::layoutPageRotate()
Gtk::RadioButton::Group group = _counterclockwise_rotate.get_group();
_clockwise_rotate.set_group(group);
-#if WITH_GTKMM_3_0
_page_rotate.table().attach(_scalar_rotate, 0, 0, 2, 1);
_page_rotate.table().attach(_units_rotate, 2, 0, 1, 1);
_page_rotate.table().attach(_counterclockwise_rotate, 3, 0, 1, 1);
_page_rotate.table().attach(_clockwise_rotate, 4, 0, 1, 1);
-#else
- _page_rotate.table()
- .attach(_scalar_rotate, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
-
- _page_rotate.table()
- .attach(_units_rotate, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _page_rotate.table()
- .attach(_counterclockwise_rotate, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _page_rotate.table()
- .attach(_clockwise_rotate, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-#endif
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/dialogs/transformation/rotateCounterClockwise", TRUE)) {
@@ -385,26 +330,13 @@ void Transformation::layoutPageSkew()
_scalar_skew_vertical.setDigits(3);
_scalar_skew_vertical.setIncrements(0.1, 1.0);
-#if WITH_GTKMM_3_0
_page_skew.table().attach(_scalar_skew_horizontal, 0, 0, 2, 1);
-#else
- _page_skew.table()
- .attach(_scalar_skew_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK);
-#endif
_scalar_skew_horizontal.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged));
-#if WITH_GTKMM_3_0
_page_skew.table().attach(_units_skew, 2, 0, 1, 1);
_page_skew.table().attach(_scalar_skew_vertical, 0, 1, 2, 1);
-#else
- _page_skew.table()
- .attach(_units_skew, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
- _page_skew.table()
- .attach(_scalar_skew_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK);
-#endif
_scalar_skew_vertical.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged));
@@ -422,12 +354,7 @@ void Transformation::layoutPageTransform()
_scalar_transform_a.setIncrements(0.1, 1.0);
_scalar_transform_a.setValue(1.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_a, 0, 0, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_a, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_a.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
@@ -438,12 +365,7 @@ void Transformation::layoutPageTransform()
_scalar_transform_b.setIncrements(0.1, 1.0);
_scalar_transform_b.setValue(0.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_b, 0, 1, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_b, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_b.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
@@ -454,12 +376,7 @@ void Transformation::layoutPageTransform()
_scalar_transform_c.setIncrements(0.1, 1.0);
_scalar_transform_c.setValue(0.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_c, 1, 0, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_c, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_c.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
@@ -471,12 +388,7 @@ void Transformation::layoutPageTransform()
_scalar_transform_d.setIncrements(0.1, 1.0);
_scalar_transform_d.setValue(1.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_d, 1, 1, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_d, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_d.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
@@ -488,12 +400,7 @@ void Transformation::layoutPageTransform()
_scalar_transform_e.setIncrements(0.1, 1.0);
_scalar_transform_e.setValue(0.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_e, 2, 0, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_e, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_e.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
@@ -505,23 +412,13 @@ void Transformation::layoutPageTransform()
_scalar_transform_f.setIncrements(0.1, 1.0);
_scalar_transform_f.setValue(0.0);
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_scalar_transform_f, 2, 1, 1, 1);
-#else
- _page_transform.table()
- .attach(_scalar_transform_f, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_scalar_transform_f.signal_value_changed()
.connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged));
// Edit existing matrix
-#if WITH_GTKMM_3_0
_page_transform.table().attach(_check_replace_matrix, 0, 2, 2, 1);
-#else
- _page_transform.table()
- .attach(_check_replace_matrix, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK);
-#endif
_check_replace_matrix.set_active(false);
_check_replace_matrix.signal_toggled()
@@ -568,11 +465,7 @@ void Transformation::updateSelection(PageType page, Inkscape::Selection *selecti
selection && !selection->isEmpty());
}
-#if WITH_GTKMM_3_0
void Transformation::onSwitchPage(Gtk::Widget * /*page*/, guint pagenum)
-#else
-void Transformation::onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum)
-#endif
{
updateSelection((PageType)pagenum, getDesktop()->getSelection());
}
@@ -650,7 +543,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection)
{
if (selection && !selection->isEmpty()) {
if (_check_replace_matrix.get_active()) {
- Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection
+ Geom::Affine current (selection->items().front()->transform); // take from the first item in selection
Geom::Affine new_displayed = current;
@@ -723,19 +616,18 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
if (!prefs->getBool("/dialogs/transformation/applyseparately")) {
// move selection as a whole
if (_check_move_relative.get_active()) {
- sp_selection_move_relative(selection, x, y);
+ selection->moveRelative(x, y);
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_selection_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ selection->moveRelative(x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
} else {
if (_check_move_relative.get_active()) {
// shift each object relatively to the previous one
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
if (fabs(x) > 1e-6) {
@@ -791,8 +683,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_selection_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ selection->moveRelative(x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
}
@@ -810,8 +701,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
bool transform_stroke = prefs->getBool("/options/transform/stroke", true);
bool preserve = prefs->getBool("/options/preservetransform/value", false);
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp= selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
Geom::OptRect bbox_pref = item->desktopPreferredBounds();
Geom::OptRect bbox_geom = item->desktopGeometricBounds();
@@ -856,7 +747,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2;
Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1);
- sp_selection_apply_affine(selection, scaler);
+ selection->applyAffine(scaler);
}
}
@@ -874,15 +765,15 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection)
}
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp= selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0));
}
} else {
boost::optional<Geom::Point> center = selection->center();
if (center) {
- sp_selection_rotate_relative(selection, *center, angle);
+ selection->rotateRelative(*center, angle);
}
}
@@ -894,8 +785,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i = items.begin();i!=items.end();++i){
SPItem *item = *i;
if (!_units_skew.isAbsolute()) { // percentage
@@ -949,7 +840,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY);
+ selection->skewRelative(*center, 0.01 * skewX, 0.01 * skewY);
} else if (_units_skew.isRadial()) { //deg or rad
double angleX = _scalar_skew_horizontal.getValue("rad");
double angleY = _scalar_skew_vertical.getValue("rad");
@@ -962,7 +853,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
}
double skewX = tan(-angleX);
double skewY = tan(angleY);
- sp_selection_skew_relative(selection, *center, skewX, skewY);
+ selection->skewRelative(*center, skewX, skewY);
} else { // absolute displacement
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
@@ -970,7 +861,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_selection_skew_relative(selection, *center, skewX/height, skewY/width);
+ selection->skewRelative(*center, skewX / height, skewY / width);
}
}
}
@@ -996,14 +887,14 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
}
if (_check_replace_matrix.get_active()) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp = selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
item->set_item_transform(displayed);
item->updateRepr();
}
} else {
- sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform
+ selection->applyAffine(displayed); // post-multiply each object's transform
}
DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
@@ -1149,7 +1040,7 @@ void Transformation::onReplaceMatrixToggled()
double f = _scalar_transform_f.getValue();
Geom::Affine displayed (a, b, c, d, e, f);
- Geom::Affine current = selection->itemList()[0]->transform; // take from the first item in selection
+ Geom::Affine current = selection->items().front()->transform; // take from the first item in selection
Geom::Affine new_displayed;
if (_check_replace_matrix.get_active()) {
diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h
index 89aa95d90..9595e87bc 100644
--- a/src/ui/dialog/transformation.h
+++ b/src/ui/dialog/transformation.h
@@ -169,11 +169,7 @@ protected:
virtual void _apply();
void presentPage(PageType page);
-#if WITH_GTKMM_3_0
void onSwitchPage(Gtk::Widget *page, guint pagenum);
-#else
- void onSwitchPage(GtkNotebookPage *page, guint pagenum);
-#endif
/**
* Callbacks for when a user changes values on the panels
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index a50a169eb..bf5bdc76d 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -12,43 +12,30 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include "config.h"
#endif
#include "undo-history.h"
-#include <glibmm/i18n.h>
-#include <stddef.h>
-#include <sigc++/sigc++.h>
#include "document.h"
#include "document-undo.h"
#include "inkscape.h"
-#include "verbs.h"
#include "util/signal-blocker.h"
#include "desktop.h"
-#include <gtkmm/invisible.h>
+#include <gtkmm/icontheme.h>
namespace Inkscape {
namespace UI {
namespace Dialog {
/* Rendering functions for custom cell renderers */
-#if WITH_GTKMM_3_0
void CellRendererSPIcon::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags)
-#else
-void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags)
-#endif
{
// if this event type doesn't have an icon...
if ( !Inkscape::Verb::get(_property_event_type)->get_image() ) return;
@@ -56,8 +43,8 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
// if the icon isn't cached, render it to a pixbuf
if ( !_icon_cache[_property_event_type] ) {
- Glib::ustring image = Inkscape::Verb::get(_property_event_type)->get_image();
- Gtk::Widget* icon = sp_icon_get_icon(image, Inkscape::ICON_SIZE_MENU);
+ Glib::ustring image_name = Inkscape::Verb::get(_property_event_type)->get_image();
+ Gtk::Widget* icon = sp_icon_get_icon(image_name, Inkscape::ICON_SIZE_MENU);
if (icon) {
@@ -67,13 +54,8 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
sp_icon_fetch_pixbuf(sp_icon);
_property_icon = Glib::wrap(sp_icon->pb, true);
} else if ( GTK_IS_IMAGE(icon->gobj()) ) {
-#if WITH_GTKMM_3_0
- _property_icon = Gtk::Invisible().render_icon_pixbuf(Gtk::StockID(image),
- Gtk::ICON_SIZE_MENU);
-#else
- _property_icon = Gtk::Invisible().render_icon(Gtk::StockID(image),
- Gtk::ICON_SIZE_MENU);
-#endif
+ auto icon_theme = Gtk::IconTheme::get_default();
+ _property_icon = icon_theme->load_icon(image_name, 16);
} else {
delete icon;
return;
@@ -87,42 +69,23 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
property_pixbuf() = _icon_cache[_property_event_type];
}
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc(cr, widget, background_area,
cell_area, flags);
-#else
- Gtk::CellRendererPixbuf::render_vfunc(window, widget, background_area,
- cell_area, expose_area, flags);
-#endif
}
-#if WITH_GTKMM_3_0
void CellRendererInt::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags)
-#else
-void CellRendererInt::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags)
-#endif
{
if( _filter(_property_number) ) {
std::ostringstream s;
s << _property_number << std::flush;
property_text() = s.str();
-#if WITH_GTKMM_3_0
Gtk::CellRendererText::render_vfunc(cr, widget, background_area,
cell_area, flags);
-#else
- Gtk::CellRendererText::render_vfunc(window, widget, background_area,
- cell_area, expose_area, flags);
-#endif
}
}
diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h
index b0cc283cf..48929a0d0 100644
--- a/src/ui/dialog/undo-history.h
+++ b/src/ui/dialog/undo-history.h
@@ -50,20 +50,11 @@ public:
property_event_type() { return _property_event_type.get_proxy(); }
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags);
-#else
- virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags);
-#endif
private:
Glib::Property<Glib::RefPtr<Gdk::Pixbuf> > _property_icon;
@@ -95,20 +86,11 @@ public:
static const Filter& no_filter;
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags);
-#else
- virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags);
-#endif
private:
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index 99a4acc69..fa35b092a 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -18,9 +18,7 @@
#include "xml-tree.h"
#include "widgets/icon.h"
-#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
#include "desktop.h"
@@ -31,18 +29,14 @@
#include "helper/window.h"
#include "inkscape.h"
#include "ui/interface.h"
-#include "macros.h"
#include "message-context.h"
#include "message-stack.h"
-#include "preferences.h"
-#include "selection.h"
#include "shortcuts.h"
#include "sp-root.h"
#include "sp-string.h"
#include "sp-tspan.h"
#include "ui/icon-names.h"
#include "verbs.h"
-#include "widgets/icon.h"
#include "widgets/sp-xmlview-attr-list.h"
#include "widgets/sp-xmlview-content.h"
@@ -79,11 +73,7 @@ XmlTree::XmlTree (void) :
xml_attribute_delete_button (_("Delete attribute")),
text_container (),
attr_container (),
-#if WITH_GTKMM_3_0
attr_subpaned_container(Gtk::ORIENTATION_VERTICAL),
-#else
- attr_subpaned_container(),
-#endif
set_attr (_("Set")),
new_window(NULL)
{
@@ -100,9 +90,7 @@ XmlTree::XmlTree (void) :
status.set_alignment( 0.0, 0.5);
status.set_size_request(1, -1);
status.set_markup("");
-#if WITH_GTKMM_3_0
status.set_line_wrap(true);
-#endif
status_box.pack_start( status, TRUE, TRUE, 0);
contents->pack_end(status_box, false, false, 2);
@@ -801,7 +789,8 @@ void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * n
void XmlTree::on_attr_unselect_row_clear_text()
{
attr_name.set_text("");
- attr_value.get_buffer()->set_text("", 0);
+ // Set text with empty Glib::ustring
+ attr_value.get_buffer()->set_text( Glib::ustring() );
}
void XmlTree::onNameChanged()
@@ -881,31 +870,19 @@ void XmlTree::cmd_new_element_node()
g_signal_connect(G_OBJECT(new_window), "destroy", gtk_main_quit, NULL);
g_signal_connect(G_OBJECT(new_window), "key-press-event", G_CALLBACK(quit_on_esc), new_window);
-#if GTK_CHECK_VERSION(3,0,0)
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
-#else
- vbox = gtk_vbox_new(FALSE, 4);
-#endif
gtk_container_add(GTK_CONTAINER(new_window), vbox);
name_entry = new Gtk::Entry();
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(name_entry->gobj()), FALSE, TRUE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
-#else
- sep = gtk_hseparator_new();
-#endif
gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 0);
-#if GTK_CHECK_VERSION(3,0,0)
bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
-#else
- bbox = gtk_hbutton_box_new();
-#endif
gtk_container_set_border_width(GTK_CONTAINER(bbox), 4);
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h
index 58ef3aef8..a4c3fffcb 100644
--- a/src/ui/dialog/xml-tree.h
+++ b/src/ui/dialog/xml-tree.h
@@ -218,13 +218,7 @@ private:
Gtk::Button *create_button;
Gtk::Entry *name_entry;
-
-#if WITH_GTKMM_3_0
Gtk::Paned paned;
-#else
- Gtk::HPaned paned;
-#endif
-
Gtk::VBox left_box;
Gtk::VBox right_box;
Gtk::HBox status_box;
@@ -248,12 +242,7 @@ private:
Gtk::ScrolledWindow text_container;
Gtk::HBox attr_hbox;
Gtk::VBox attr_container;
-
-#if WITH_GTKMM_3_0
Gtk::Paned attr_subpaned_container;
-#else
- Gtk::VPaned attr_subpaned_container;
-#endif
Gtk::Button set_attr;
diff --git a/src/ui/event-debug.h b/src/ui/event-debug.h
new file mode 100644
index 000000000..dd33ca0e3
--- /dev/null
+++ b/src/ui/event-debug.h
@@ -0,0 +1,132 @@
+#ifndef SEEN_UI_EVENT_DEBUG_H
+#define SEEN_UI_EVENT_DEBUG_H
+
+/**
+ * @file
+ * Dump event data.
+ */
+/*
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtk/gtk.h>
+#include <glibmm/ustring.h>
+
+// See: https://developer.gnome.org/gdk3/stable/gdk3-Events.html
+
+inline void ui_dump_event (GdkEvent *event, Glib::ustring const &prefix, bool merge = true) {
+
+ static GdkEventType old_type = GDK_NOTHING;
+ static unsigned count = 0;
+
+ // Doesn't usually help to dump a zillion events of the same type (e.g. GDK_MOTION_NOTIFY).
+ ++count;
+ if (merge && event->type == old_type) {
+ if ( count == 1 ) {
+ std::cout << prefix << " ... ditto" << std::endl;
+ }
+ return;
+ }
+ count = 0;
+ old_type = event->type;
+
+ std::cout << prefix << ": ";
+
+ switch (event->type) {
+
+ case GDK_KEY_PRESS:
+ std::cout << "GDK_KEY_PRESS: " << event->key.hardware_keycode << std::endl;
+ break;
+ case GDK_KEY_RELEASE:
+ std::cout << "GDK_KEY_RELEASE: " << event->key.hardware_keycode << std::endl;
+ break;
+
+ case GDK_BUTTON_PRESS:
+ std::cout << "GDK_BUTTON_PRESS: " << event->button.button << std::endl;
+ break;
+ case GDK_2BUTTON_PRESS:
+ std::cout << "GDK_2BUTTON_PRESS: " << event->button.button << std::endl;
+ break;
+ case GDK_3BUTTON_PRESS:
+ std::cout << "GDK_3BUTTON_PRESS: " << event->button.button << std::endl;
+ break;
+ case GDK_BUTTON_RELEASE:
+ std::cout << "GDK_BUTTON_RELEASE: " << event->button.button << std::endl;
+ break;
+
+ case GDK_SCROLL:
+ std::cout << "GDK_SCROLL" << std::endl;
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ std::cout << "GDK_MOTION_NOTIFY" << std::endl;
+ break;
+ case GDK_ENTER_NOTIFY:
+ std::cout << "GDK_ENTER_NOTIFY" << std::endl;
+ break;
+ case GDK_LEAVE_NOTIFY:
+ std::cout << "GDK_LEAVE_NOTIFY" << std::endl;
+ break;
+
+ case GDK_TOUCH_BEGIN:
+ std::cout << "GDK_TOUCH_BEGIN" << std::endl;
+ break;
+ case GDK_TOUCH_UPDATE:
+ std::cout << "GDK_TOUCH_UPDATE" << std::endl;
+ break;
+ case GDK_TOUCH_END:
+ std::cout << "GDK_TOUCH_END" << std::endl;
+ break;
+ case GDK_TOUCH_CANCEL:
+ std::cout << "GDK_TOUCH_CANCEL" << std::endl;
+ break;
+
+#if GTK_CHECK_VERSION(3,18,0)
+
+ case GDK_TOUCHPAD_SWIPE:
+ std::cout << "GDK_TOUCHPAD_SWIPE" << std::endl;
+ break;
+ case GDK_TOUCHPAD_PINCH:
+ std::cout << "GDK_TOUCHPAD_PINCH" << std::endl;
+ break;
+
+#endif
+
+#if GTK_CHECK_VERSION(3,22,0)
+
+ case GDK_PAD_BUTTON_PRESS:
+ std::cout << "GDK_PAD_BUTTON_PRESS" << std::endl;
+ break;
+ case GDK_PAD_BUTTON_RELEASE:
+ std::cout << "GDK_PAD_BUTTON_RELEASE" << std::endl;
+ break;
+ case GDK_PAD_RING:
+ std::cout << "GDK_PAD_RING" << std::endl;
+ break;
+ case GDK_PAD_STRIP:
+ std::cout << "GDK_PAD_STRIP" << std::endl;
+ break;
+ case GDK_PAD_GROUP_MODE:
+ std::cout << "GDK_PAD_GROUP_MODE" << std::endl;
+ break;
+
+#endif
+
+ default:
+ std::cout << "GDK event not recognized!" << std::endl;
+ break;
+ }
+}
+
+#endif // SEEN_UI_EVENT_DEBUG_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 :
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index ab29471ed..5e85065d1 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -20,12 +20,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "ui/dialog/dialog-manager.h"
#include <gtkmm/icontheme.h>
#include "file.h"
+#include <glibmm/miscutils.h>
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
@@ -35,25 +36,20 @@
#include "extension/input.h"
#include "widgets/icon.h"
#include "preferences.h"
-#include "path-prefix.h"
#include "shortcuts.h"
#include "document.h"
#include "ui/interface.h"
#include "desktop.h"
-#include "selection.h"
#include "selection-chemistry.h"
#include "svg-view-widget.h"
#include "widgets/desktop-widget.h"
#include "sp-item-group.h"
#include "sp-text.h"
-#include "sp-gradient.h"
#include "sp-flowtext.h"
#include "sp-namedview.h"
#include "sp-root.h"
-#include "ui/view/view.h"
#include "helper/action.h"
-#include "helper/action-context.h"
#include "helper/gnome-utils.h"
#include "helper/window.h"
#include "io/sys.h"
@@ -63,7 +59,6 @@
#include "ui/clipboard.h"
#include "display/sp-canvas.h"
-#include "color.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "style.h"
@@ -74,18 +69,10 @@
#include "sp-anchor.h"
#include "sp-clippath.h"
#include "sp-image.h"
-#include "sp-item.h"
#include "sp-mask.h"
#include "message-stack.h"
#include "ui/dialog/layer-properties.h"
-
-#if GTK_CHECK_VERSION(3,0,0)
- #include "widgets/image-menu-item.h"
-#endif
-
-#include <gdk/gdkkeysyms.h>
-
-#include <glibmm/miscutils.h>
+#include "extension/find_extension_by_mime.h"
using Inkscape::DocumentUndo;
@@ -417,11 +404,7 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name )
icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name );
gtk_widget_show(icon);
-#if GTK_CHECK_VERSION(3,0,0)
- image_menu_item_set_image((ImageMenuItem *) item, icon);
-#else
gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon);
-#endif
} // end of sp_ui_menu_add_icon
void
@@ -475,11 +458,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
if (radio) {
item = gtk_radio_menu_item_new_with_mnemonic(group, action->name);
} else {
-#if GTK_CHECK_VERSION(3,0,0)
- item = image_menu_item_new_with_mnemonic(action->name);
-#else
item = gtk_image_menu_item_new_with_mnemonic(action->name);
-#endif
}
gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name);
@@ -570,11 +549,7 @@ static bool getViewStateFromPref(Inkscape::UI::View::View *view, gchar const *pr
return prefs->getBool(pref_path, true);
}
-#if GTK_CHECK_VERSION(3,0,0)
static gboolean checkitem_update(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data)
-#else
-static gboolean checkitem_update(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data)
-#endif
{
GtkCheckMenuItem *menuitem=GTK_CHECK_MENU_ITEM(widget);
@@ -631,11 +606,7 @@ static void taskToggled(GtkCheckMenuItem *menuitem, gpointer userData)
/**
* Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode.
*/
-#if GTK_CHECK_VERSION(3,0,0)
static gboolean update_view_menu(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data)
-#else
-static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data)
-#endif
{
SPAction *action = (SPAction *) user_data;
g_assert(action->id != NULL);
@@ -679,11 +650,7 @@ static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/,
static void
sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref,
void (*callback_toggle)(GtkCheckMenuItem *, gpointer user_data),
-#if GTK_CHECK_VERSION(3,0,0)
gboolean (*callback_update)(GtkWidget *widget, cairo_t *cr, gpointer user_data),
-#else
- gboolean (*callback_update)(GtkWidget *widget, GdkEventExpose *event, gpointer user_data),
-#endif
Inkscape::Verb *verb)
{
unsigned int shortcut = (verb) ? sp_shortcut_get_primary(verb) : 0;
@@ -707,11 +674,7 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
g_signal_connect( G_OBJECT(item), "toggled", (GCallback) callback_toggle, (void *) pref);
-#if GTK_CHECK_VERSION(3,0,0)
g_signal_connect( G_OBJECT(item), "draw", (GCallback) callback_update, (void *) pref);
-#else
- g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) callback_update, (void *) pref);
-#endif
(*callback_update)(item, NULL, (void *)pref);
@@ -854,11 +817,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I
}
if (verb->get_code() != SP_VERB_NONE) {
SPAction *action = verb->get_action(Inkscape::ActionContext(view));
-#if GTK_CHECK_VERSION(3,0,0)
g_signal_connect( G_OBJECT(item), "draw", (GCallback) update_view_menu, (void *) action);
-#else
- g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) update_view_menu, (void *) action);
-#endif
}
} else if (menu_pntr->attribute("check") != NULL) {
if (verb->get_code() != SP_VERB_NONE) {
@@ -1250,7 +1209,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
- sp_selection_move_relative(selection, m, false);
+ selection->moveRelative(m, false);
}
}
@@ -1276,15 +1235,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
case PNG_DATA:
case JPEG_DATA:
case IMAGE_DATA: {
- const char *mime = (info == JPEG_DATA ? "image/jpeg" : "image/png");
-
- Inkscape::Extension::DB::InputList o;
- Inkscape::Extension::db.get_input_list(o);
- Inkscape::Extension::DB::InputList::const_iterator i = o.begin();
- while (i != o.end() && strcmp( (*i)->get_mimetype(), mime ) != 0) {
- ++i;
- }
- Inkscape::Extension::Extension *ext = *i;
+ Inkscape::Extension::Extension *ext = Inkscape::Extension::find_by_mime((info == JPEG_DATA ? "image/jpeg" : "image/png"));
bool save = (strcmp(ext->get_param_optiongroup("link"), "embed") == 0);
ext->set_param_optiongroup("link", "embed");
ext->set_gui(false);
@@ -1881,28 +1832,28 @@ void ContextMenu::ItemCreateLink(void)
void ContextMenu::SetMask(void)
{
- sp_selection_set_mask(_desktop, false, false);
+ _desktop->selection->setMask(false, false);
}
void ContextMenu::ReleaseMask(void)
{
- sp_selection_unset_mask(_desktop, false);
+ _desktop->selection->unsetMask(false);
}
void ContextMenu::CreateGroupClip(void)
{
- sp_selection_set_clipgroup(_desktop);
+ _desktop->selection->setClipGroup();
}
void ContextMenu::SetClip(void)
{
- sp_selection_set_mask(_desktop, true, false);
+ _desktop->selection->setMask(true, false);
}
void ContextMenu::ReleaseClip(void)
{
- sp_selection_unset_mask(_desktop, true);
+ _desktop->selection->unsetMask(true);
}
void ContextMenu::MakeGroupMenu(void)
@@ -1916,7 +1867,7 @@ void ContextMenu::MakeGroupMenu(void)
void ContextMenu::ActivateGroup(void)
{
- sp_selection_group(_desktop->selection, _desktop);
+ _desktop->selection->group();
}
void ContextMenu::ActivateUngroup(void)
@@ -1929,7 +1880,7 @@ void ContextMenu::ActivateUngroup(void)
void ContextMenu::ActivateUngroupPopSelection(void)
{
- sp_selection_ungroup_pop_selection(_desktop->selection, _desktop);
+ _desktop->selection->popFromGroup();
}
@@ -2096,8 +2047,8 @@ void ContextMenu::ImageEdit(void)
}
#endif
- std::vector<SPItem*> itemlist=_desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ auto itemlist= _desktop->selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
Inkscape::XML::Node *ir = (*i)->getRepr();
const gchar *href = ir->attribute("xlink:href");
diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp
index 459acf002..c1d85a896 100644
--- a/src/ui/object-edit.cpp
+++ b/src/ui/object-edit.cpp
@@ -12,11 +12,9 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
-
-
#include "sp-item.h"
#include "sp-rect.h"
#include "box3d.h"
@@ -32,11 +30,8 @@
#include "sp-namedview.h"
#include "live_effects/effect.h"
#include "sp-pattern.h"
-#include "sp-path.h"
#include <glibmm/i18n.h>
#include "ui/object-edit.h"
-#include "xml/repr.h"
-#include <2geom/math-utils.h>
#include "knot-holder-entity.h"
#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m)))
@@ -48,7 +43,7 @@ static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop)
KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL);
Inkscape::LivePathEffect::Effect *effect = item->getCurrentLPE();
- effect->addHandles(knot_holder, desktop, item);
+ effect->addHandles(knot_holder, item);
return knot_holder;
}
@@ -787,6 +782,12 @@ public:
virtual void knot_click(unsigned int state);
};
+class ArcKnotHolderEntityCenter : public KnotHolderEntity {
+public:
+ virtual Geom::Point knot_get() const;
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state);
+};
+
/*
* return values:
* 1 : inside
@@ -800,8 +801,11 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p)
gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed;
gdouble s = dx * dx + dy * dy;
- if (s < 1.0) return 1;
- if (s > 1.0) return -1;
+ // We add a bit of a buffer, so there's a decent chance the user will
+ // be able to adjust the arc without the closed status flipping between
+ // open and closed during micro mouse movements.
+ if (s < 0.75) return 1;
+ if (s > 1.25) return -1;
return 0;
}
@@ -813,16 +817,23 @@ ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*or
SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item);
g_assert(arc != NULL);
- arc->setClosed(sp_genericellipse_side(arc, p) == -1);
+ gint side = sp_genericellipse_side(arc, p);
+ if(side != 0) { arc->setArcType( (side == -1) ?
+ SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE :
+ SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); }
Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed);
Geom::Scale sc(arc->rx.computed, arc->ry.computed);
- arc->start = atan2(delta * sc.inverse());
+ double offset = arc->start - atan2(delta * sc.inverse());
+ arc->start -= offset;
if ((state & GDK_CONTROL_MASK) && snaps) {
arc->start = sp_round(arc->start, M_PI / snaps);
}
+ if (state & GDK_SHIFT_MASK) {
+ arc->end -= offset;
+ }
arc->normalize();
arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -857,16 +868,23 @@ ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*orig
SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item);
g_assert(arc != NULL);
- arc->setClosed(sp_genericellipse_side(arc, p) == -1);
+ gint side = sp_genericellipse_side(arc, p);
+ if(side != 0) { arc->setArcType( (side == -1) ?
+ SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE :
+ SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); }
Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed);
Geom::Scale sc(arc->rx.computed, arc->ry.computed);
- arc->end = atan2(delta * sc.inverse());
+ double offset = arc->end - atan2(delta * sc.inverse());
+ arc->end -= offset;
if ((state & GDK_CONTROL_MASK) && snaps) {
arc->end = sp_round(arc->end, M_PI/snaps);
}
+ if (state & GDK_SHIFT_MASK) {
+ arc->start -= offset;
+ }
arc->normalize();
arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -971,6 +989,30 @@ ArcKnotHolderEntityRY::knot_click(unsigned int state)
}
}
+void
+ArcKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
+{
+ SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
+
+ Geom::Point const s = snap_knot_position(p, state);
+
+ ge->cx = s[Geom::X];
+ ge->cy = s[Geom::Y];
+
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+}
+
+Geom::Point
+ArcKnotHolderEntityCenter::knot_get() const
+{
+ SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse *>(item);
+ g_assert(ge != NULL);
+
+ return Geom::Point(ge->cx.computed, ge->cy.computed);
+}
+
+
ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
KnotHolder(desktop, item, relhandler)
{
@@ -978,6 +1020,7 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea
ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY();
ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart();
ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd();
+ ArcKnotHolderEntityCenter *entity_center = new ArcKnotHolderEntityCenter();
entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER,
_("Adjust ellipse <b>width</b>, with <b>Ctrl</b> to make circle"),
@@ -988,19 +1031,26 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea
SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR);
entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE,
- _("Position the <b>start point</b> of the arc or segment; with <b>Ctrl</b> "
- "to snap angle; drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"),
+ _("Position the <b>start point</b> of the arc or segment; with <b>Shift</b> to move "
+ "with <b>end point</b>; with <b>Ctrl</b> to snap angle; drag <b>inside</b> the "
+ "ellipse for arc, <b>outside</b> for segment"),
SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR);
entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE,
- _("Position the <b>end point</b> of the arc or segment; with <b>Ctrl</b> to snap angle; "
- "drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"),
+ _("Position the <b>end point</b> of the arc or segment; with <b>Shift</b> to move "
+ "with <b>start point</b>; with <b>Ctrl</b> to snap angle; drag <b>inside</b> the "
+ "ellipse for arc, <b>outside</b> for segment"),
SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR);
+ entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
+ _("Move the ellipse"),
+ SP_KNOT_SHAPE_CROSS);
+
entity.push_back(entity_rx);
entity.push_back(entity_ry);
entity.push_back(entity_start);
entity.push_back(entity_end);
+ entity.push_back(entity_center);
add_pattern_knotholder();
}
@@ -1021,6 +1071,12 @@ public:
virtual void knot_click(unsigned int state);
};
+class StarKnotHolderEntityCenter : public KnotHolderEntity {
+public:
+ virtual Geom::Point knot_get() const;
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state);
+};
+
void
StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
@@ -1078,6 +1134,17 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi
}
}
+void
+StarKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
+{
+ SPStar *star = dynamic_cast<SPStar *>(item);
+ g_assert(star != NULL);
+
+ star->center = snap_knot_position(p, state);
+
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+}
+
Geom::Point
StarKnotHolderEntity1::knot_get() const
{
@@ -1101,6 +1168,17 @@ StarKnotHolderEntity2::knot_get() const
return sp_star_get_xy(star, SP_STAR_POINT_KNOT2, 0);
}
+Geom::Point
+StarKnotHolderEntityCenter::knot_get() const
+{
+ g_assert(item != NULL);
+
+ SPStar const *star = dynamic_cast<SPStar const *>(item);
+ g_assert(star != NULL);
+
+ return star->center;
+}
+
static void
sp_star_knot_click(SPItem *item, unsigned int state)
{
@@ -1152,6 +1230,12 @@ StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel
entity.push_back(entity2);
}
+ StarKnotHolderEntityCenter *entity_center = new StarKnotHolderEntityCenter();
+ entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
+ _("Move the star"),
+ SP_KNOT_SHAPE_CROSS);
+ entity.push_back(entity_center);
+
add_pattern_knotholder();
}
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index 5e75179a3..6fec65124 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -12,18 +12,12 @@
#include "previewholder.h"
-#include "preferences.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
#include <gtkmm/scrollbar.h>
#include <gtkmm/adjustment.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#define COLUMNS_FOR_SMALL 16
#define COLUMNS_FOR_LARGE 8
@@ -55,7 +49,6 @@ PreviewHolder::PreviewHolder() :
((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
_insides->set_name( "PreviewHolderGrid" );
_insides->set_column_spacing(8);
@@ -66,21 +59,9 @@ PreviewHolder::PreviewHolder() :
_scroller->set_hexpand();
_scroller->set_vexpand();
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
- _insides->set_col_spacings( 8 );
-
- // Add a container with the scroller and a spacer
- Gtk::Table* spaceHolder = Gtk::manage( new Gtk::Table(1, 2) );
-#endif
-
_scroller->add( *_insides );
-#if WITH_GTKMM_3_0
spaceHolder->attach( *_scroller, 0, 0, 1, 1);
-#else
- spaceHolder->attach( *_scroller, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
pack_start(*spaceHolder, Gtk::PACK_EXPAND_WIDGET);
}
@@ -93,11 +74,7 @@ PreviewHolder::~PreviewHolder()
bool PreviewHolder::on_scroll_event(GdkEventScroll *event)
{
// Scroll horizontally by page on mouse wheel
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
-#else
- Gtk::Adjustment *adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
-#endif
+ auto adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
if (!adj) {
return FALSE;
@@ -141,7 +118,6 @@ void PreviewHolder::addPreview( Previewable* preview )
Gtk::Widget* label = Gtk::manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
Gtk::Widget* thing = Gtk::manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach(*thing, 0, i, 1, 1);
@@ -149,10 +125,6 @@ void PreviewHolder::addPreview( Previewable* preview )
label->set_hexpand();
label->set_valign(Gtk::ALIGN_CENTER);
_insides->attach(*label, 1, i, 1, 1);
-#else
- _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
- _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK );
-#endif
}
break;
@@ -168,44 +140,25 @@ void PreviewHolder::addPreview( Previewable* preview )
int col = i % width;
int row = i / width;
-#if !WITH_GTKMM_3_0
- // If the existing grid isn't wide enough, we need to resize
- // it and re-pack the existing widgets
- if ( _insides && width > (int)_insides->property_n_columns() ) {
- _insides->resize( height, width );
-#endif
- std::vector<Gtk::Widget*>kids = _insides->get_children();
- int childCount = (int)kids.size();
- // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
-
- // Loop through the existing widgets and move them to new location
- for ( int j = 1; j < childCount; j++ ) {
- Gtk::Widget* target = kids[childCount - (j + 1)];
- int col2 = j % width;
- int row2 = j / width;
- Glib::RefPtr<Gtk::Widget> handle(target);
- _insides->remove( *target );
-
-#if WITH_GTKMM_3_0
- target->set_hexpand();
- target->set_vexpand();
- _insides->attach( *target, col2, row2, 1, 1);
-#else
- _insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
- }
-#if WITH_GTKMM_3_0
- thing->set_hexpand();
- thing->set_vexpand();
- _insides->attach(*thing, col, row, 1, 1);
-#else
- } else if ( col == 0 ) {
- // we just started a new row
- _insides->resize( row + 1, width );
- }
-
- _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
+ auto kids = _insides->get_children();
+ int childCount = (int)kids.size();
+ // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
+
+ // Loop through the existing widgets and move them to new location
+ for ( int j = 1; j < childCount; j++ ) {
+ auto target = kids[childCount - (j + 1)];
+ int col2 = j % width;
+ int row2 = j / width;
+ Glib::RefPtr<Gtk::Widget> handle(target);
+ _insides->remove( *target );
+
+ target->set_hexpand();
+ target->set_vexpand();
+ _insides->attach( *target, col2, row2, 1, 1);
+ }
+ thing->set_hexpand();
+ thing->set_vexpand();
+ _insides->attach(*thing, col, row, 1, 1);
}
}
@@ -303,14 +256,10 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation )
// g_message(" anchor:%d", _anchor);
Gtk::VBox::on_size_allocate( allocation );
- if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
+/* if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
Gtk::Requisition req;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req_natural;
_insides->get_preferred_size(req, req_natural);
-#else
- req = _insides->size_request();
-#endif
gint delta = allocation.get_width() - req.width;
if ( (delta > 4) && req.height < allocation.get_height() ) {
@@ -318,7 +267,7 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation )
} else {
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER );
}
- }
+ }*/
}
//void PreviewHolder::on_size_request( Gtk::Requisition* requisition )
@@ -352,43 +301,27 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) {
Gtk::Requisition req;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req_natural;
_scroller->get_preferred_size(req, req_natural);
-#else
- req = _scroller->size_request();
-#endif
int currW = _scroller->get_width();
if ( currW > req.width ) {
req.width = currW;
}
-#if GTK_CHECK_VERSION(3,0,0)
- Gtk::Scrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
-#else
- Gtk::HScrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
-#endif
+ auto hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
if ( hs ) {
Gtk::Requisition scrollReq;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition scrollReq_natural;
hs->get_preferred_size(scrollReq, scrollReq_natural);
-#else
- scrollReq = hs->size_request();
-#endif
// the +8 is a temporary hack
req.height -= scrollReq.height + 8;
}
Gtk::Requisition req2;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req2_natural;
const_cast<Gtk::Widget*>(thing)->get_preferred_size(req2, req2_natural);
-#else
- req2 = const_cast<Gtk::Widget*>(thing)->size_request();
-#endif
int h2 = ((req2.height > 0) && (req.height > req2.height)) ? (req.height / req2.height) : 1;
int w2 = ((req2.width > 0) && (req.width > req2.width)) ? (req.width / req2.width) : 1;
@@ -416,21 +349,11 @@ void PreviewHolder::rebuildUI()
switch(_view) {
case VIEW_TYPE_LIST:
{
-
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
_insides->set_column_spacing(8);
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
- _insides->set_col_spacings( 8 );
-#endif
if (_border == BORDER_WIDE) {
-#if WITH_GTKMM_3_0
_insides->set_row_spacing(1);
-#else
- _insides->set_row_spacings( 1 );
-#endif
}
for ( unsigned int i = 0; i < items.size(); i++ ) {
@@ -439,7 +362,6 @@ void PreviewHolder::rebuildUI()
Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border));
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach(*thing, 0, i, 1, 1);
@@ -447,10 +369,6 @@ void PreviewHolder::rebuildUI()
label->set_hexpand();
label->set_valign(Gtk::ALIGN_CENTER);
_insides->attach(*label, 1, i, 1, 1);
-#else
- _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
- _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK );
-#endif
}
_scroller->add( *_insides );
@@ -473,28 +391,16 @@ void PreviewHolder::rebuildUI()
if ( !_insides ) {
calcGridSize( thing, items.size(), width, height );
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
if (_border == BORDER_WIDE) {
_insides->set_column_spacing(1);
_insides->set_row_spacing(1);
}
-#else
- _insides = Gtk::manage(new Gtk::Table( height, width ));
- if (_border == BORDER_WIDE) {
- _insides->set_col_spacings( 1 );
- _insides->set_row_spacings( 1 );
- }
-#endif
}
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach( *thing, col, row, 1, 1);
-#else
- _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
if ( ++col >= width ) {
col = 0;
@@ -502,11 +408,7 @@ void PreviewHolder::rebuildUI()
}
}
if ( !_insides ) {
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
-#endif
}
_scroller->add( *_insides );
diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h
index 28c0fd865..d370e8fc8 100644
--- a/src/ui/previewholder.h
+++ b/src/ui/previewholder.h
@@ -21,11 +21,7 @@
#include <gtkmm/bin.h>
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
#include "previewfillable.h"
@@ -68,12 +64,7 @@ private:
std::vector<Previewable*> items;
Gtk::Bin *_scroller;
-
-#if WITH_GTKMM_3_0
Gtk::Grid *_insides;
-#else
- Gtk::Table *_insides;
-#endif
int _prefCols;
bool _updatesFrozen;
diff --git a/src/ui/selected-color.cpp b/src/ui/selected-color.cpp
index 846d50a5b..08f4bd979 100644
--- a/src/ui/selected-color.cpp
+++ b/src/ui/selected-color.cpp
@@ -11,7 +11,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <glibmm/ustring.h>
diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp
index aec5cde27..98320ed8c 100644
--- a/src/ui/shape-editor.cpp
+++ b/src/ui/shape-editor.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <string.h>
@@ -16,11 +16,8 @@
#include "desktop.h"
#include "document.h"
-#include "gc-anchored.h"
#include "knotholder.h"
#include "ui/object-edit.h"
-#include "sp-item.h"
-#include "sp-object.h"
#include "ui/shape-editor.h"
#include "xml/node-event-vector.h"
diff --git a/src/ui/tool-factory.cpp b/src/ui/tool-factory.cpp
index c6c579c9e..f101e5a24 100644
--- a/src/ui/tool-factory.cpp
+++ b/src/ui/tool-factory.cpp
@@ -27,14 +27,12 @@
#include "ui/tools/mesh-tool.h"
#include "ui/tools/node-tool.h"
#include "ui/tools/pencil-tool.h"
-#include "ui/tools/pen-tool.h"
#include "ui/tools/rect-tool.h"
#include "ui/tools/select-tool.h"
#include "ui/tools/spiral-tool.h"
#include "ui/tools/spray-tool.h"
#include "ui/tools/star-tool.h"
#include "ui/tools/text-tool.h"
-#include "ui/tools/tool-base.h"
#include "ui/tools/tweak-tool.h"
#include "ui/tools/zoom-tool.h"
diff --git a/src/ui/tool/Makefile_insert b/src/ui/tool/Makefile_insert
deleted file mode 100644
index f46f48b72..000000000
--- a/src/ui/tool/Makefile_insert
+++ /dev/null
@@ -1,30 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/tool/control-point.cpp \
- ui/tool/control-point.h \
- ui/tool/control-point-selection.cpp \
- ui/tool/control-point-selection.h \
- ui/tool/commit-events.h \
- ui/tool/curve-drag-point.cpp \
- ui/tool/curve-drag-point.h \
- ui/tool/event-utils.cpp \
- ui/tool/event-utils.h \
- ui/tool/manipulator.cpp \
- ui/tool/manipulator.h \
- ui/tool/modifier-tracker.cpp \
- ui/tool/modifier-tracker.h \
- ui/tool/multi-path-manipulator.cpp \
- ui/tool/multi-path-manipulator.h \
- ui/tool/node.cpp \
- ui/tool/node.h \
- ui/tool/node-types.h \
- ui/tool/path-manipulator.cpp \
- ui/tool/path-manipulator.h \
- ui/tool/selectable-control-point.cpp \
- ui/tool/selectable-control-point.h \
- ui/tool/selector.cpp \
- ui/tool/selector.h \
- ui/tool/shape-record.h \
- ui/tool/transform-handle-set.cpp \
- ui/tool/transform-handle-set.h
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp
index f36ad7374..a5611addc 100644
--- a/src/ui/tool/control-point-selection.cpp
+++ b/src/ui/tool/control-point-selection.cpp
@@ -13,7 +13,6 @@
#include "ui/tool/selectable-control-point.h"
#include <2geom/transforms.h>
#include "desktop.h"
-#include "preferences.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/transform-handle-set.h"
diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp
index 636595016..d9374c790 100644
--- a/src/ui/tool/control-point.cpp
+++ b/src/ui/tool/control-point.cpp
@@ -16,8 +16,6 @@
#include "display/snap-indicator.h"
#include "ui/tools/tool-base.h"
#include "message-context.h"
-#include "preferences.h"
-#include "snap-preferences.h"
#include "sp-namedview.h"
#include "ui/control-manager.h"
#include "ui/tool/control-point.h"
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index e460b0fb7..908e18474 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -8,15 +8,12 @@
#include "ui/tool/curve-drag-point.h"
#include <glib/gi18n.h>
-#include <2geom/bezier-curve.h>
#include "desktop.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/path-manipulator.h"
-#include "ui/tool/node.h"
#include "sp-namedview.h"
-#include "snap.h"
namespace Inkscape {
namespace UI {
diff --git a/src/ui/tool/manipulator.cpp b/src/ui/tool/manipulator.cpp
index 11dd220f4..82ff014e4 100644
--- a/src/ui/tool/manipulator.cpp
+++ b/src/ui/tool/manipulator.cpp
@@ -8,8 +8,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/tool/node.h"
-#include "ui/tool/manipulator.h"
+//#include "ui/tool/node.h"
+//#include "ui/tool/manipulator.h"
namespace Inkscape {
namespace UI {
diff --git a/src/ui/tool/modifier-tracker.cpp b/src/ui/tool/modifier-tracker.cpp
index cc4e4d0b2..f502acab2 100644
--- a/src/ui/tool/modifier-tracker.cpp
+++ b/src/ui/tool/modifier-tracker.cpp
@@ -12,7 +12,6 @@
#include <gdk/gdkkeysyms.h>
#include "ui/tool/event-utils.h"
#include "ui/tool/modifier-tracker.h"
-#include <gtk/gtk.h>
namespace Inkscape {
namespace UI {
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index 9ec6f733f..f30c7e349 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -19,13 +19,11 @@
#include "document-undo.h"
#include "live_effects/lpeobject.h"
#include "message-stack.h"
-#include "preferences.h"
#include "sp-path.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/path-manipulator.h"
-#include "util/unordered-containers.h"
#include "verbs.h"
#include <gdk/gdkkeysyms.h>
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index c908cede2..4f152e0a2 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -82,8 +82,19 @@ private:
template <typename R>
void invokeForAll(R (PathManipulator::*method)()) {
- for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
- ((i->second.get())->*method)();
+ for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ) {
+ // Sometimes the PathManipulator got freed at loop end, thus
+ // invalidating the iterator so make sure that next_i will
+ // be a valid iterator and then assign i to it.
+ MapType::iterator next_i = i;
+ ++next_i;
+ // i->second is a boost::shared_ptr so try to hold on to it so
+ // it won't get freed prematurely by the WriteXML() method or
+ // whatever. See https://bugs.launchpad.net/inkscape/+bug/1617615
+ // Applicable to empty paths.
+ boost::shared_ptr<PathManipulator> hold(i->second);
+ ((hold.get())->*method)();
+ i = next_i;
}
}
template <typename R, typename A>
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 9268d9730..d6e491ac3 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -12,25 +12,20 @@
#include "multi-path-manipulator.h"
#include <glib/gi18n.h>
#include <2geom/bezier-utils.h>
-#include <2geom/transforms.h>
#include "display/sp-ctrlline.h"
#include "display/sp-canvas.h"
#include "display/sp-canvas-util.h"
#include "desktop.h"
-#include "preferences.h"
#include "snap.h"
-#include "snap-preferences.h"
#include "sp-namedview.h"
#include "ui/control-manager.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
-#include "ui/tool/node.h"
#include "ui/tool/path-manipulator.h"
#include "ui/tools/node-tool.h"
#include "ui/tools-switch.h"
#include <gdk/gdkkeysyms.h>
-#include <cmath>
namespace {
@@ -331,10 +326,7 @@ bool Handle::grabbed(GdkEventMotion *)
void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
{
- if (tools_isactive(_desktop, TOOLS_NODES)) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context);
- nt->update_helperpath();
- }
+ Inkscape::UI::Tools::sp_update_helperpath();
Geom::Point parent_pos = _parent->position();
Geom::Point origin = _last_drag_origin();
SnapManager &sm = _desktop->namedview->snap_manager;
@@ -1204,10 +1196,7 @@ bool Node::grabbed(GdkEventMotion *event)
void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event)
{
- if (tools_isactive(_desktop, TOOLS_NODES)) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context);
- nt->update_helperpath();
- }
+ Inkscape::UI::Tools::sp_update_helperpath();
// For a note on how snapping is implemented in Inkscape, see snap.h.
SnapManager &sm = _desktop->namedview->snap_manager;
// even if we won't really snap, we might still call the one of the
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 025c460e2..a05f0e3b9 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -20,12 +20,7 @@
#include <iosfwd>
#include <stdexcept>
#include <cstddef>
-
-#if __cplusplus >= 201103L
#include <functional>
-#else
-#include <tr1/functional>
-#endif
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index de071dad3..f2899dd01 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -12,37 +12,23 @@
#include "live_effects/lpe-powerstroke.h"
#include "live_effects/lpe-bspline.h"
-#include "live_effects/lpe-fillet-chamfer.h"
-#include <string>
-#include <sstream>
-#include <deque>
-#include <stdexcept>
-#include <boost/shared_ptr.hpp>
-#include <2geom/bezier-curve.h>
#include <2geom/bezier-utils.h>
#include <2geom/path-sink.h>
-#include <glibmm/i18n.h>
#include "ui/tool/path-manipulator.h"
-#include "desktop.h"
#include "display/sp-canvas.h"
#include "display/sp-canvas-util.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
-#include "document.h"
-#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
-#include "sp-path.h"
#include "helper/geom.h"
-#include "preferences.h"
#include "style.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/curve-drag-point.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/multi-path-manipulator.h"
-#include "xml/node.h"
#include "xml/node-observer.h"
namespace Inkscape {
@@ -1377,13 +1363,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
lpe_pwr->adjustForNewPath(pathv);
}
}
- this_effect = _path->getPathEffectOfType(Inkscape::LivePathEffect::FILLET_CHAMFER);
- if(this_effect){
- LivePathEffect::LPEFilletChamfer *lpe_fll = dynamic_cast<LivePathEffect::LPEFilletChamfer*>(this_effect->getLPEObj()->get_lpe());
- if (lpe_fll) {
- lpe_fll->adjustForNewPath(pathv);
- }
- }
}
}
@@ -1505,11 +1484,14 @@ void PathManipulator::_setGeometry()
}
} else {
if (empty()) return;
- //XML Tree being used here directly while it shouldn't be.
- if (_path->getRepr()->attribute("inkscape:original-d"))
- _path->set_original_curve(_spcurve, false, false);
- else
+ if (SPCurve * original = _path->get_original_curve()){
+ if(!_spcurve->is_equal(original)) {
+ _path->set_original_curve(_spcurve, false, false);
+ delete original;
+ }
+ } else if(!_spcurve->is_equal(_path->get_curve())) {
_path->setCurve(_spcurve, false);
+ }
}
}
diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp
index 9acf7de88..84e96173d 100644
--- a/src/ui/tool/selector.cpp
+++ b/src/ui/tool/selector.cpp
@@ -14,7 +14,6 @@
#include "display/sodipodi-ctrlrect.h"
#include "ui/tools/tool-base.h"
-#include "preferences.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/selector.h"
diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp
index 748b9d4cc..083a7d0ba 100644
--- a/src/ui/tool/transform-handle-set.cpp
+++ b/src/ui/tool/transform-handle-set.cpp
@@ -18,11 +18,7 @@
#include "sp-namedview.h"
#include "display/sodipodi-ctrlrect.h"
-#include "preferences.h"
#include "pure-transform.h"
-#include "snap.h"
-#include "snap-candidate.h"
-#include "sp-namedview.h"
#include "ui/tool/commit-events.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/selectable-control-point.h"
@@ -187,6 +183,11 @@ void TransformHandle::ungrabbed(GdkEventButton *)
_setState(_state);
endTransform();
_th.signal_commit.emit(getCommitEvent());
+
+ //updates the positions of the nodes
+ Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context);
+ ControlPointSelection* selection = nt->_selected_nodes;
+ selection->setOriginalPoints();
}
diff --git a/src/ui/tools-switch.cpp b/src/ui/tools-switch.cpp
index ea0431b0a..d87bcc51d 100644
--- a/src/ui/tools-switch.cpp
+++ b/src/ui/tools-switch.cpp
@@ -13,16 +13,11 @@
#include <gtkmm.h> // prevents deprecation warnings
-#include <cstring>
-#include <string>
-
#include "inkscape.h"
#include "desktop.h"
#include <glibmm/i18n.h>
-#include <xml/repr.h>
-
#include "ui/tools-switch.h"
#include "box3d.h"
@@ -52,7 +47,6 @@
#include "ui/tools/measure-tool.h"
#include "ui/tools/mesh-tool.h"
#include "ui/tools/node-tool.h"
-#include "ui/tools/pen-tool.h"
#include "ui/tools/pencil-tool.h"
#include "ui/tools/rect-tool.h"
#include "ui/tools/select-tool.h"
diff --git a/src/ui/tools/Makefile_insert b/src/ui/tools/Makefile_insert
deleted file mode 100644
index 686dfedd8..000000000
--- a/src/ui/tools/Makefile_insert
+++ /dev/null
@@ -1,34 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/tools/arc-tool.cpp ui/tools/arc-tool.h \
- ui/tools/box3d-tool.cpp ui/tools/box3d-tool.h \
- ui/tools/calligraphic-tool.cpp ui/tools/calligraphic-tool.h \
- ui/tools/connector-tool.cpp ui/tools/connector-tool.h \
- ui/tools/dropper-tool.cpp ui/tools/dropper-tool.h \
- ui/tools/dynamic-base.cpp ui/tools/dynamic-base.h \
- ui/tools/eraser-tool.cpp ui/tools/eraser-tool.h \
- ui/tools/freehand-base.cpp ui/tools/freehand-base.h \
- ui/tools/gradient-tool.cpp ui/tools/gradient-tool.h \
- ui/tools/lpe-tool.cpp ui/tools/lpe-tool.h \
- ui/tools/measure-tool.cpp ui/tools/measure-tool.h \
- ui/tools/mesh-tool.cpp ui/tools/mesh-tool.h \
- ui/tools/node-tool.cpp ui/tools/node-tool.h \
- ui/tools/pen-tool.cpp ui/tools/pen-tool.h \
- ui/tools/pencil-tool.cpp ui/tools/pencil-tool.h \
- ui/tools/rect-tool.cpp ui/tools/rect-tool.h \
- ui/tools/select-tool.cpp ui/tools/select-tool.h \
- ui/tools/spiral-tool.cpp ui/tools/spiral-tool.h \
- ui/tools/spray-tool.cpp ui/tools/spray-tool.h \
- ui/tools/star-tool.cpp ui/tools/star-tool.h \
- ui/tools/text-tool.cpp ui/tools/text-tool.h \
- ui/tools/tool-base.cpp ui/tools/tool-base.h \
- ui/tools/tweak-tool.cpp ui/tools/tweak-tool.h \
- ui/tools/zoom-tool.cpp ui/tools/zoom-tool.h
-
-if HAVE_POTRACE
-
-ink_common_sources += \
- ui/tools/flood-tool.cpp ui/tools/flood-tool.h
-
-endif
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index c6a9bb23a..6652f7ab5 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
@@ -30,7 +30,6 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "pixmaps/cursor-ellipse.xpm"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 27e755add..425695a2c 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -15,8 +15,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include "macros.h"
@@ -27,8 +25,6 @@
#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
-#include "display/curve.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
#include "message-context.h"
@@ -36,17 +32,12 @@
#include "box3d.h"
#include "ui/tools/box3d-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "desktop-style.h"
-#include "transf_mat_3x4.h"
#include "perspective-line.h"
-#include "persp3d.h"
#include "box3d-side.h"
#include "document-private.h"
-#include "line-geometry.h"
#include "ui/shape-editor.h"
#include "verbs.h"
@@ -118,8 +109,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
SPDefs *defs = document->getDefs();
bool has_persp = false;
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
+ for (auto& child: defs->children) {
+ if (SP_IS_PERSP3D(&child)) {
has_persp = true;
break;
}
@@ -409,7 +400,7 @@ bool Box3dTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 28195eb75..7228a52bc 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -23,8 +23,6 @@
#define noDYNA_DRAW_VERBOSE
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -35,12 +33,10 @@
#include "svg/svg.h"
#include "display/canvas-bpath.h"
#include "display/cairo-utils.h"
-#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
#include <2geom/bezier-utils.h>
#include <2geom/circle.h>
#include "display/curve.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -50,25 +46,21 @@
#include "desktop-style.h"
#include "message-context.h"
-#include "preferences.h"
#include "pixmaps/cursor-calligraphy.xpm"
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
-#include "color.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "sp-text.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "livarot/Shape.h"
#include "verbs.h"
#include "ui/tools/calligraphic-tool.h"
+#include "ui/tools/freehand-base.h"
using Inkscape::DocumentUndo;
@@ -144,7 +136,7 @@ void CalligraphicTool::setup() {
SPCurve *c = new SPCurve(path);
- this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c);
+ this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c, true);
c->unref();
@@ -780,6 +772,8 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
this->message_context->clear();
ret = TRUE;
+ } else if (!this->dragging && event->button.button == 1 && !this->space_panning){
+ spdc_create_single_dot(this, this->desktop->w2d(motion_w), "/tools/calligraphic", event->button.state);
}
break;
}
@@ -930,10 +924,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
if (unionize) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ desktop->getSelection()->pathUnion(true);
} else if (subtract) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop);
+ desktop->getSelection()->pathDiff(true);
} else {
if (this->keep_selected) {
desktop->getSelection()->set(this->repr);
@@ -1099,7 +1093,7 @@ void CalligraphicTool::fit_and_split(bool release) {
add_cap(this->currentcurve, b2[0], b1[0], this->cap_rounding);
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
/* Current calligraphic */
@@ -1135,7 +1129,7 @@ void CalligraphicTool::fit_and_split(bool release) {
SP_TYPE_CANVAS_BPATH,
NULL);
SPCurve *curve = this->currentcurve->copy();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true);
curve->unref();
guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/calligraphic", true);
@@ -1179,7 +1173,7 @@ void CalligraphicTool::draw_temporary_box() {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
}
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 74f2664fe..7e6fb4b72 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -75,7 +75,6 @@
#include "ui/tools/connector-tool.h"
#include "pixmaps/cursor-connector.xpm"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
#include "svg/svg.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -86,19 +85,13 @@
#include "message-stack.h"
#include "selection.h"
#include "inkscape.h"
-#include "preferences.h"
#include "sp-path.h"
#include "display/sp-canvas.h"
#include "display/canvas-bpath.h"
-#include "display/sodipodi-ctrl.h"
#include <glibmm/i18n.h>
#include <glibmm/stringutils.h>
#include "snap.h"
-#include "knot.h"
#include "sp-conn-end.h"
-#include "sp-conn-end-pair.h"
-#include "conn-avoid-ref.h"
-#include "libavoid/vertices.h"
#include "libavoid/router.h"
#include "context-fns.h"
#include "sp-namedview.h"
@@ -627,7 +620,7 @@ bool ConnectorTool::_handleMotionNotify(GdkEventMotion const &mevent) {
this->red_curve = path->get_curve_for_edit();
this->red_curve->transform(i2d);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
ret = true;
break;
}
@@ -818,7 +811,7 @@ void ConnectorTool::_setSubsequentPoint(Geom::Point const p) {
// Recreate curve from libavoid route.
recreateCurve( this->red_curve, this->newConnRef, this->curvature );
this->red_curve->transform(desktop->doc2dt());
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
}
@@ -1042,7 +1035,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc)
cc->red_curve = SP_PATH(cc->clickeditem)->get_curve_for_edit();
Geom::Affine i2d = (cc->clickeditem)->i2dt_affine();
cc->red_curve->transform(i2d);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve, true);
cc->clickeditem->setHidden(true);
@@ -1114,9 +1107,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) {
// The idea here is to try and add a group's children to solidify
// connection handling. We react to path objects with only one node.
- for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) {
- this->_activeShapeAddKnot((SPItem *) child);
+ for (auto& child: item->children) {
+ if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) {
+ this->_activeShapeAddKnot((SPItem *) &child);
}
}
this->_activeShapeAddKnot(item);
@@ -1306,8 +1299,8 @@ void cc_selection_set_avoid(bool const set_avoid)
int changes = 0;
- std::vector<SPItem*> l = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end(); ++i) {
+ auto l = selection->items();
+ for(auto i=l.begin();i!=l.end(); ++i) {
SPItem *item = *i;
char const *value = (set_avoid) ? "true" : NULL;
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index c838c27d5..99177dc75 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -12,7 +12,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <glibmm/i18n.h>
@@ -27,7 +27,6 @@
#include "display/curve.h"
#include "display/cairo-utils.h"
#include "svg/svg-color.h"
-#include "color.h"
#include "color-rgba.h"
#include "desktop-style.h"
#include "preferences.h"
@@ -36,7 +35,6 @@
#include "desktop.h"
#include "selection.h"
-#include "document.h"
#include "document-undo.h"
#include "pixmaps/cursor-dropper-f.xpm"
@@ -45,7 +43,6 @@
#include "ui/tools/dropper-tool.h"
#include "message-context.h"
#include "verbs.h"
-#include "ui/tools/tool-base.h"
using Inkscape::DocumentUndo;
@@ -121,20 +118,12 @@ void DropperTool::finish() {
}
if (cursor_dropper_fill) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor_dropper_fill);
-#else
- gdk_cursor_unref (cursor_dropper_fill);
-#endif
cursor_dropper_fill = NULL;
}
if (cursor_dropper_stroke) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor_dropper_stroke);
-#else
- gdk_cursor_unref (cursor_dropper_stroke);
-#endif
cursor_dropper_fill = NULL;
}
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index eb789d850..6627a470e 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -1,13 +1,7 @@
#include "ui/tools/dynamic-base.h"
-#include <gtk/gtk.h>
-
-#include "config.h"
-
#include "message-context.h"
-#include "streq.h"
-#include "preferences.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
#include "display/curve.h"
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 6b32b5901..ae312e054 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -24,8 +24,6 @@
#define noERASER_VERBOSE
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -38,7 +36,6 @@
#include "display/canvas-bpath.h"
#include <2geom/bezier-utils.h>
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "selection.h"
@@ -47,30 +44,28 @@
#include "desktop-style.h"
#include "message-context.h"
-#include "preferences.h"
#include "pixmaps/cursor-eraser.xpm"
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
-#include "color.h"
#include "rubberband.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-clippath.h"
+#include "sp-rect.h"
#include "sp-text.h"
+#include "sp-root.h"
#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
-#include "livarot/Shape.h"
#include "document-undo.h"
#include "verbs.h"
#include "style.h"
-#include "style-enums.h"
-#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
#include "path-chemistry.h"
+#include "selection-chemistry.h"
#include "display/curve.h"
-
+#include "layer-model.h"
+#include "layer-manager.h"
#include "ui/tools/eraser-tool.h"
using Inkscape::DocumentUndo;
@@ -380,7 +375,7 @@ void EraserTool::cancel() {
bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", 2);
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !this->space_panning) {
@@ -400,7 +395,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
if (this->repr) {
this->repr = NULL;
}
- if ( ! eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
}
@@ -448,7 +443,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
this->accumulated->reset();
Inkscape::Rubberband::get(desktop)->move(motion_dt);
}
@@ -491,7 +486,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) {
+ if (eraser_mode == ERASER_MODE_DELETE && Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::Rubberband::get(desktop)->stop();
}
@@ -578,7 +573,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->stop();
}
if (this->is_drawing) {
@@ -640,65 +635,66 @@ void EraserTool::clear_current() {
void EraserTool::set_to_accumulated() {
bool workDone = false;
-
+ SPDocument *document = this->desktop->doc();
if (!this->accumulated->is_empty()) {
if (!this->repr) {
/* Create object */
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
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 (this->desktop, repr, "/tools/eraser", false);
this->repr = repr;
}
- SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr));
+ SPObject * top_layer = desktop->layer_manager->nthChildOf(desktop->layers->currentRoot(), 0);
+ SPItem *item_repr = SP_ITEM(top_layer->appendChildRepr(this->repr));
Inkscape::GC::release(this->repr);
- item->updateRepr();
- Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc();
- pathv *= item->i2doc_affine().inverse();
+ item_repr->updateRepr();
+ Geom::PathVector pathv = this->accumulated->get_pathvector() * this->desktop->dt2doc();
+ pathv *= item_repr->i2doc_affine().inverse();
gchar *str = sp_svg_write_path(pathv);
g_assert( str != NULL );
this->repr->setAttribute("d", str);
g_free(str);
-
+ Geom::OptRect eraserBbox;
if ( this->repr ) {
bool wasSelection = false;
- Inkscape::Selection *selection = desktop->getSelection();
+ Inkscape::Selection *selection = this->desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", ERASER_MODE_CLIP);
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
- SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr));
- Geom::OptRect eraserBbox = acid->desktopVisualBounds();
+ SPItem* acid = SP_ITEM(this->desktop->doc()->getObjectByRepr(this->repr));
+ eraserBbox = acid->desktopVisualBounds();
std::vector<SPItem*> remainingItems;
std::vector<SPItem*> toWorkOn;
if (selection->isEmpty()) {
- if ( eraserMode ) {
- toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox);
+ if (eraser_mode == ERASER_MODE_CUT || eraser_mode == ERASER_MODE_CLIP) {
+ toWorkOn = document->getItemsPartiallyInBox(this->desktop->dkey, *eraserBbox);
} else {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
- toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
+ toWorkOn = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
}
toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end());
} else {
- if ( !eraserMode ) {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
std::vector<SPItem*> touched;
- touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ touched = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
for (std::vector<SPItem*>::const_iterator i = touched.begin();i!=touched.end();++i) {
if(selection->includes(*i)){
toWorkOn.push_back((*i));
}
}
} else {
- toWorkOn = selection->itemList();
+ toWorkOn.insert(toWorkOn.end(), selection->items().begin(), selection->items().end());
}
wasSelection = true;
}
if ( !toWorkOn.empty() ) {
- if ( eraserMode ) {
+ if (eraser_mode == ERASER_MODE_CUT) {
for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
SPItem *item = *i;
SPUse *use = dynamic_cast<SPUse *>(item);
@@ -708,7 +704,6 @@ void EraserTool::set_to_accumulated() {
item->deleteObject(true);
sp_object_unref(item);
workDone = true;
- workDone = true;
} else if (SP_IS_GROUP(item) || use ) {
/*Do nothing*/
} else {
@@ -719,33 +714,33 @@ void EraserTool::set_to_accumulated() {
Inkscape::GC::release(dup); // parent takes over
selection->set(dup);
if (!this->nowidth) {
- sp_selected_path_union_skip_undo(selection, desktop);
+ selection->pathUnion(true);
}
selection->add(item);
if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-rule", "evenodd");
- sp_desktop_set_style(desktop, css);
+ sp_desktop_set_style(this->desktop, css);
sp_repr_css_attr_unref(css);
css = 0;
}
if (this->nowidth) {
- sp_selected_path_cut_skip_undo(selection, desktop);
+ selection->pathCut(true);
} else {
- sp_selected_path_diff_skip_undo(selection, desktop);
+ selection->pathDiff(true);
}
workDone = true; // TODO set this only if something was cut.
bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
if(!break_apart){
- sp_selected_path_combine(desktop, true);
+ selection->combine(true);
} else {
if(!this->nowidth){
- sp_selected_path_break_apart(desktop, true);
+ selection->breakApart(true);
}
}
if ( !selection->isEmpty() ) {
// If the item was not completely erased, track the new remainder.
- std::vector<SPItem*> nowSel(selection->itemList());
+ std::vector<SPItem*> nowSel(selection->items().begin(), selection->items().end());
for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) {
remainingItems.push_back(*i2);
}
@@ -755,6 +750,78 @@ void EraserTool::set_to_accumulated() {
}
}
}
+ } else if (eraser_mode == ERASER_MODE_CLIP) {
+ if (!this->nowidth) {
+ remainingItems.clear();
+ for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
+ selection->clear();
+ SPItem *item = *i;
+ Geom::OptRect bbox = item->desktopVisualBounds();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
+ Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc);
+ this->repr->parent()->appendChild(dup);
+ Inkscape::GC::release(dup); // parent takes over
+ selection->set(dup);
+ selection->pathUnion(true);
+ if (bbox && bbox->intersects(*eraserBbox)) {
+ SPClipPath *clip_path = item->clip_ref->getObject();
+ if (clip_path) {
+ std::vector<SPItem*> selected;
+ selected.push_back(SP_ITEM(clip_path->firstChild()));
+ std::vector<Inkscape::XML::Node*> to_select;
+ std::vector<SPItem*> items(selected);
+ sp_item_list_to_curves(items, selected, to_select);
+ Inkscape::XML::Node * clip_data = SP_ITEM(clip_path->firstChild())->getRepr();
+ if (!clip_data && !to_select.empty()) {
+ clip_data = *(to_select.begin());
+ }
+ if (clip_data) {
+ Inkscape::XML::Node *dup_clip = clip_data->duplicate(xml_doc);
+ if (dup_clip) {
+ SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip));
+ if (dup_clip_obj) {
+ dup_clip_obj->doWriteTransform(dup_clip, item->transform);
+ sp_object_ref(clip_path, 0);
+ clip_path->deleteObject(true);
+ sp_object_unref(clip_path);
+ selection->raiseToTop(true);
+ selection->add(dup_clip);
+ selection->pathDiff(true);
+ SPItem * clip = SP_ITEM(*(selection->items().begin()));
+ }
+ }
+ }
+ } else {
+ Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect");
+ sp_desktop_apply_style_tool (this->desktop, rect_repr, "/tools/eraser", false);
+ SPRect * rect = SP_RECT(item_repr->parent->appendChildRepr(rect_repr));
+ Inkscape::GC::release(rect_repr);
+ rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height());
+ rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse();
+ rect->updateRepr();
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ selection->raiseToTop(true);
+ selection->add(rect);
+ selection->pathDiff(true);
+ }
+ selection->raiseToTop(true);
+ selection->add(item);
+ selection->setMask(true, false, true);
+ } else {
+ SPItem *erase_clip = selection->singleItem();
+ if (erase_clip) {
+ sp_object_ref(erase_clip, 0);
+ erase_clip->deleteObject(true);
+ sp_object_unref(erase_clip);
+ }
+ }
+ workDone = true;
+ selection->clear();
+ if (wasSelection) {
+ remainingItems.push_back(item);
+ }
+ }
+ }
} else {
for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) {
sp_object_ref( *i, 0 );
@@ -768,8 +835,8 @@ void EraserTool::set_to_accumulated() {
}
}
- if ( !eraserMode ) {
- //sp_selection_delete(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ selection->deleteItems();
remainingItems.clear();
}
@@ -791,12 +858,10 @@ void EraserTool::set_to_accumulated() {
this->repr = 0;
}
}
-
-
if ( workDone ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
+ DocumentUndo::done(document, SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
} else {
- DocumentUndo::cancel(desktop->getDocument());
+ DocumentUndo::cancel(document);
}
}
@@ -955,7 +1020,7 @@ void EraserTool::fit_and_split(bool release) {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
/* Current eraser */
@@ -987,12 +1052,12 @@ void EraserTool::fit_and_split(bool release) {
g_print("[%d]Yup\n", this->npoints);
#endif
if (!release) {
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode",2);
g_assert(!this->currentcurve->is_empty());
SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
SPCurve *curve = this->currentcurve->copy();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true);
curve->unref();
guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/eraser", true);
@@ -1009,7 +1074,7 @@ void EraserTool::fit_and_split(bool release) {
this->segments = g_slist_prepend(this->segments, cbp);
- if ( !eraserMode ) {
+ if (eraser_mode == ERASER_MODE_DELETE) {
sp_canvas_item_hide(cbp);
sp_canvas_item_hide(this->currentshape);
}
@@ -1041,7 +1106,7 @@ void EraserTool::draw_temporary_box() {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
}
diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h
index 50ce6b6e3..bd0e98057 100644
--- a/src/ui/tools/eraser-tool.h
+++ b/src/ui/tools/eraser-tool.h
@@ -31,6 +31,10 @@
#define ERC_MAX_TILT 1.0
#define ERC_DEFAULT_TILT 0.0
+#define ERASER_MODE_DELETE 0
+#define ERASER_MODE_CUT 1
+#define ERASER_MODE_CLIP 2
+
namespace Inkscape {
namespace UI {
namespace Tools {
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 748c82717..6e1d085aa 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -18,14 +18,14 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
+#include <cmath>
#include "trace/potrace/inkscape-potrace.h"
#include <2geom/pathvector.h>
#include <gdk/gdkkeysyms.h>
#include <queue>
-#include <deque>
#include <glibmm/i18n.h>
#include "color.h"
@@ -36,7 +36,6 @@
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
#include "display/drawing-image.h"
-#include "display/drawing-item.h"
#include "display/drawing.h"
#include "display/sp-canvas.h"
#include "document.h"
@@ -47,23 +46,15 @@
#include "macros.h"
#include "message-context.h"
#include "message-stack.h"
-#include "preferences.h"
#include "rubberband.h"
#include "selection.h"
#include "ui/shape-editor.h"
-#include "sp-defs.h"
-#include "sp-item.h"
#include "splivarot.h"
#include "sp-namedview.h"
-#include "sp-object.h"
-#include "sp-path.h"
-#include "sp-rect.h"
#include "sp-root.h"
#include "svg/svg.h"
#include "trace/imagemap.h"
-#include "trace/trace.h"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
#include "verbs.h"
#include "pixmaps/cursor-paintbucket.xpm"
@@ -99,10 +90,10 @@ Glib::ustring ch_init[8] = {
const std::vector<Glib::ustring> FloodTool::channel_list( ch_init, ch_init+8 );
Glib::ustring gap_init[4] = {
- C_("Flood autogap", "None"),
- C_("Flood autogap", "Small"),
- C_("Flood autogap", "Medium"),
- C_("Flood autogap", "Large")
+ NC_("Flood autogap", "None"),
+ NC_("Flood autogap", "Small"),
+ NC_("Flood autogap", "Medium"),
+ NC_("Flood autogap", "Large")
};
const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 );
@@ -196,6 +187,21 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width
}
/**
+ * \brief Check whether two unsigned integers are close to each other
+ *
+ * \param[in] a The 1st unsigned int
+ * \param[in] b The 2nd unsigned int
+ * \param[in] d The threshold for comparison
+ *
+ * \return true if |a-b| <= d; false otherwise
+ */
+static bool compare_guint32(guint32 const a, guint32 const b, guint32 const d)
+{
+ const int difference = std::abs(static_cast<int>(a) - static_cast<int>(b));
+ return difference <= d;
+}
+
+/**
* Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation.
* @param check The pixel in the pixel buffer to check.
* @param orig The original selected pixel to use as the fill target color.
@@ -206,7 +212,6 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width
*/
static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixel, guint32 dtc, int threshold, PaintBucketChannels method)
{
- int diff = 0;
float hsl_check[3] = {0,0,0}, hsl_orig[3] = {0,0,0};
guint32 ac = 0, rc = 0, gc = 0, bc = 0;
@@ -232,27 +237,35 @@ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixe
switch (method) {
case FLOOD_CHANNELS_ALPHA:
- return abs(static_cast<int>(ac) - ao) <= threshold;
+ return compare_guint32(ac, ao, threshold);
case FLOOD_CHANNELS_R:
- return abs(static_cast<int>(ac ? unpremul_alpha(rc, ac) : 0) - (ao ? unpremul_alpha(ro, ao) : 0)) <= threshold;
+ return compare_guint32(ac ? unpremul_alpha(rc, ac) : 0,
+ ao ? unpremul_alpha(ro, ao) : 0,
+ threshold);
case FLOOD_CHANNELS_G:
- return abs(static_cast<int>(ac ? unpremul_alpha(gc, ac) : 0) - (ao ? unpremul_alpha(go, ao) : 0)) <= threshold;
+ return compare_guint32(ac ? unpremul_alpha(gc, ac) : 0,
+ ao ? unpremul_alpha(go, ao) : 0,
+ threshold);
case FLOOD_CHANNELS_B:
- return abs(static_cast<int>(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold;
+ return compare_guint32(ac ? unpremul_alpha(bc, ac) : 0,
+ ao ? unpremul_alpha(bo, ao) : 0,
+ threshold);
case FLOOD_CHANNELS_RGB:
- guint32 amc, rmc, bmc, gmc;
- //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255;
- //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255;
- amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha
- rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255;
- gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255;
- bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255;
-
- diff += abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0));
- diff += abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0));
- diff += abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - (amop ? unpremul_alpha(bmop, amop) : 0));
- return ((diff / 3) <= ((threshold * 3) / 4));
-
+ {
+ guint32 amc, rmc, bmc, gmc;
+ //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255;
+ //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255;
+ amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha
+ rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255;
+ gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255;
+ bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255;
+
+ int diff = 0; // The total difference between each of the 3 color components
+ diff += std::abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(rmop, amop) : 0));
+ diff += std::abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(gmop, amop) : 0));
+ diff += std::abs(static_cast<int>(amc ? unpremul_alpha(bmc, amc) : 0) - static_cast<int>(amop ? unpremul_alpha(bmop, amop) : 0));
+ return ((diff / 3) <= ((threshold * 3) / 4));
+ }
case FLOOD_CHANNELS_H:
return ((int)(fabs(hsl_check[0] - hsl_orig[0]) * 100.0) <= threshold);
case FLOOD_CHANNELS_S:
@@ -456,7 +469,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",
SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() );
selection->add(reprobj);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ selection->pathUnion(true);
} else {
desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE,
ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index c98ecb686..4af70a816 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -17,43 +17,29 @@
#define DRAW_VERBOSE
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "live_effects/lpe-bendpath.h"
#include "live_effects/lpe-patternalongpath.h"
#include "live_effects/lpe-simplify.h"
#include "display/canvas-bpath.h"
-#include "xml/repr.h"
#include "svg/svg.h"
-#include <glibmm/i18n.h>
#include "display/curve.h"
-#include "desktop.h"
#include "desktop-style.h"
-#include "document.h"
#include "ui/draw-anchor.h"
#include "macros.h"
#include "message-stack.h"
#include "ui/tools/pen-tool.h"
#include "ui/tools/lpe-tool.h"
-#include "preferences.h"
-#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
-#include "sp-path.h"
-#include "sp-use.h"
#include "sp-item-group.h"
-#include "sp-namedview.h"
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
-#include "util/units.h"
// clipboard support
#include "ui/clipboard.h"
-#include "ui/tools/freehand-base.h"
-
-#include <gdk/gdkkeysyms.h>
using Inkscape::DocumentUndo;
@@ -226,6 +212,10 @@ static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath,
Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
static_cast<LPEPatternAlongPath*>(lpe)->pattern.set_new_value(newpath,true);
+ double scale_doc = 1 / dc->desktop->doc()->getDocumentScale()[0];
+ Inkscape::SVGOStringStream os;
+ os << scale_doc;
+ lpe->getRepr()->setAttribute("prop_scale", os.str().c_str());
}
static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
@@ -236,38 +226,14 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points
Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
static_cast<LPEPowerStroke*>(lpe)->offset_points.param_set_and_write_new_value(points);
- // find out stroke width (TODO: is there an easier way??)
- SPDesktop *desktop = dc->desktop;
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
- Inkscape::GC::release(repr);
-
- char const* tool = SP_IS_PEN_CONTEXT(dc) ? "/tools/freehand/pen" : "/tools/freehand/pencil";
-
- // apply the tool's current style
- sp_desktop_apply_style_tool(desktop, repr, tool, false);
-
- double stroke_width = 1.0;
- char const *style_str = NULL;
- style_str = repr->attribute("style");
- if (style_str) {
- SPStyle style(SP_ACTIVE_DOCUMENT);
- style.mergeString(style_str);
- stroke_width = style.stroke_width.computed;
- }
-
- std::ostringstream s;
- s.imbue(std::locale::classic());
- s << points[0][Geom::X] << "," << stroke_width / 2.;
-
// write powerstroke parameters:
lpe->getRepr()->setAttribute("start_linecap_type", "zerowidth");
lpe->getRepr()->setAttribute("end_linecap_type", "zerowidth");
- lpe->getRepr()->setAttribute("cusp_linecap_type", "round");
lpe->getRepr()->setAttribute("sort_points", "true");
lpe->getRepr()->setAttribute("interpolator_type", "CubicBezierJohan");
lpe->getRepr()->setAttribute("interpolator_beta", "0.2");
- lpe->getRepr()->setAttribute("offset_points", s.str().c_str());
+ lpe->getRepr()->setAttribute("miter_limit", "4");
+ lpe->getRepr()->setAttribute("linejoin_type", "extrp_arc");
}
static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *item)
@@ -307,12 +273,42 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem
enum shapeType { NONE, TRIANGLE_IN, TRIANGLE_OUT, ELLIPSE, CLIPBOARD, BEND_CLIPBOARD, LAST_APPLIED };
static shapeType previous_shape_type = NONE;
-static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
+static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve, bool is_bend)
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item && SP_IS_LPE_ITEM(item)) {
+ //Store the clipboard path to apply in the future without the use of clipboard
+ static Geom::PathVector previous_shape_pathv;
+ static SPItem *bend_item;
+ shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
+ if (previous_shape_type == NONE) {
+ previous_shape_type = shape;
+ }
+ if(shape == LAST_APPLIED){
+
+ shape = previous_shape_type;
+ if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
+ shape = LAST_APPLIED;
+ }
+ }
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ if (is_bend &&
+ (shape == BEND_CLIPBOARD || (shape == LAST_APPLIED && previous_shape_type != CLIPBOARD)) &&
+ cm->paste(SP_ACTIVE_DESKTOP,true))
+ {
+ bend_item = dc->selection->singleItem();
+ if(!bend_item || (!SP_IS_SHAPE(bend_item) && !SP_IS_GROUP(bend_item))){
+ previous_shape_type = NONE;
+ return;
+ }
+ } else if(is_bend) {
+ return;
+ }
+ if (!is_bend && previous_shape_type == BEND_CLIPBOARD && shape == BEND_CLIPBOARD) {
+ return;
+ }
bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0);
if(simplify){
double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
@@ -334,27 +330,16 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
curve = sp_shape->getCurve();
}
- //Store the clipboard path to apply in the future without the use of clipboard
- static Geom::PathVector previous_shape_pathv;
-
- shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
bool shape_applied = false;
SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS);
const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
- static SPItem *bend_item;
+ const char *stroke_width = sp_repr_css_property(css_item, "stroke-width", "0");
+ double swidth;
+ sp_svg_number_read_d(stroke_width, &swidth);
#define SHAPE_LENGTH 10
#define SHAPE_HEIGHT 10
-
- if(shape == LAST_APPLIED){
-
- shape = previous_shape_type;
- if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
- shape = LAST_APPLIED;
- }
- }
-
switch (shape) {
case NONE:
// don't apply any shape
@@ -363,7 +348,8 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
{
// "triangle in"
std::vector<Geom::Point> points(1);
- points[0] = Geom::Point(0., SHAPE_HEIGHT/2);
+ points[0] = Geom::Point(0., swidth/2);
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
@@ -374,7 +360,9 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
// "triangle out"
guint curve_length = curve->get_segment_count();
std::vector<Geom::Point> points(1);
- points[0] = Geom::Point((double)curve_length, SHAPE_HEIGHT/2);
+ points[0] = Geom::Point(0, swidth/2);
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
+ points[0][Geom::X] = (double)curve_length;
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
@@ -401,7 +389,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
{
// take shape from clipboard;
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){
+ if(cm->paste(SP_ACTIVE_DESKTOP,true)){
SPItem * pasted_clipboard = dc->selection->singleItem();
if(pasted_clipboard){
Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr();
@@ -429,21 +417,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
}
case BEND_CLIPBOARD:
{
- Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){
- gchar const *svgd = item->getRepr()->attribute("d");
- bend_item = dc->selection->singleItem();
- if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
- bend_item->moveTo(item,false);
- bend_item->transform.setTranslation(Geom::Point());
- spdc_apply_bend_shape(svgd, dc, bend_item);
- dc->selection->add(SP_OBJECT(bend_item));
-
- shape = BEND_CLIPBOARD;
- } else {
- bend_item = NULL;
- shape = NONE;
- }
+ gchar const *svgd = item->getRepr()->attribute("d");
+ if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
+ bend_item->moveTo(item,false);
+ bend_item->transform.setTranslation(Geom::Point());
+ spdc_apply_bend_shape(svgd, dc, bend_item);
+ dc->selection->add(SP_OBJECT(bend_item));
+
+ shape = BEND_CLIPBOARD;
} else {
bend_item = NULL;
shape = NONE;
@@ -455,7 +436,6 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if(previous_shape_type == CLIPBOARD){
if(previous_shape_pathv.size() != 0){
spdc_paste_curve_as_freehand_shape(previous_shape_pathv, dc, item);
-
shape_applied = true;
shape = CLIPBOARD;
} else{
@@ -465,7 +445,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if(bend_item != NULL && bend_item->getRepr() != NULL){
gchar const *svgd = item->getRepr()->attribute("d");
dc->selection->add(SP_OBJECT(bend_item));
- sp_selection_duplicate(dc->desktop);
+ dc->selection->duplicate();
dc->selection->remove(SP_OBJECT(bend_item));
bend_item = dc->selection->singleItem();
if(bend_item){
@@ -672,7 +652,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
}
// Step A - test, whether we ended on green anchor
- if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) {
+ if ( (forceclosed &&
+ (!dc->sa || (dc->sa && dc->sa->curve->is_empty()))) ||
+ ( dc->green_anchor && dc->green_anchor->active))
+ {
// We hit green anchor, closing Green-Blue-Red
dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
c->closepath_current();
@@ -754,7 +737,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
e->unref();
}
-
+ if (forceclosed)
+ {
+ dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
+ c->closepath_current();
+ }
spdc_flush_white(dc, c);
c->unref();
@@ -812,16 +799,16 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
if (!dc->white_item) {
// Attach repr
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
-
- spdc_check_for_and_apply_waiting_LPE(dc, item, c);
- if(previous_shape_type != BEND_CLIPBOARD){
- dc->selection->set(repr);
- }
+ //Bend needs the transforms applied after, Other effects best before
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c, true);
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c, false);
+ dc->selection->set(repr);
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}
@@ -926,7 +913,8 @@ static void spdc_free_colors(FreehandBase *dc)
}
void spdc_create_single_dot(ToolBase *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")
+ || !strcmp(tool, "/tools/calligraphic") );
Glib::ustring tool_path = tool;
SPDesktop *desktop = ec->desktop;
@@ -950,7 +938,8 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
// unset stroke and set fill color to former stroke color
gchar * str;
- str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);
+ str = strcmp(tool, "/tools/calligraphic") ? g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8)
+ : g_strdup_printf("fill:#%06x;stroke:#%06x;", sp_desktop_get_color_tool(desktop, tool, true) >> 8, sp_desktop_get_color_tool(desktop, tool, false) >> 8);
repr->setAttribute("style", str);
g_free(str);
@@ -961,6 +950,8 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
Geom::Affine const i2d (item->i2dt_affine ());
Geom::Point pp = pt * i2d.inverse();
double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0);
+ if (!strcmp(tool, "/tools/calligraphic"))
+ rad = 0.1 * prefs->getDouble(tool_path + "/width", 3.0) / desktop->current_zoom();
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,
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index a3e7b42f9..3ee4cd7d0 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -76,8 +76,10 @@ public:
GSList *white_curves;
GSList *white_anchors;
- //ALternative curve to use on continuing exisiting curve in case of bspline or spirolive
- //because usigh anchor curves give memory and random bugs, - and obscure code- in some plataform reported by su_v in mac
+ // Alternative curve to use on continuing the exisiting curve in case of
+ // bspline or spirolive, because using anchor curves gives random memory
+ // bugs as reported by su_v when running this code on macOS (as well as
+ // making the code hard to understand).
SPCurve *overwrite_curve;
// Start anchor
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 9d8101cc4..750596808 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -13,7 +13,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
@@ -31,17 +31,10 @@
#include "ui/tools/gradient-tool.h"
#include "gradient-chemistry.h"
#include <glibmm/i18n.h>
-#include "preferences.h"
#include "gradient-drag.h"
-#include "gradient-chemistry.h"
-#include "xml/repr.h"
-#include "sp-item.h"
#include "display/sp-ctrlline.h"
-#include "sp-linear-gradient.h"
-#include "sp-radial-gradient.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
-#include "svg/svg-color.h"
#include "snap.h"
#include "sp-namedview.h"
#include "rubberband.h"
@@ -86,6 +79,9 @@ GradientTool::~GradientTool() {
delete this->subselcon;
}
+// This must match GrPointType enum sp-gradient.h
+// We should move this to a shared header (can't simply move to gradient.h since that would require
+// including <glibmm/i18n.h> which messes up "N_" in extensions... argh!).
const gchar *gr_handle_descr [] = {
N_("Linear gradient <b>start</b>"), //POINT_LG_BEGIN
N_("Linear gradient <b>end</b>"),
@@ -95,7 +91,10 @@ const gchar *gr_handle_descr [] = {
N_("Radial gradient <b>radius</b>"),
N_("Radial gradient <b>focus</b>"), // POINT_RG_FOCUS
N_("Radial gradient <b>mid stop</b>"),
- N_("Radial gradient <b>mid stop</b>")
+ N_("Radial gradient <b>mid stop</b>"),
+ N_("Mesh gradient <b>corner</b>"),
+ N_("Mesh gradient <b>handle</b>"),
+ N_("Mesh gradient <b>tensor</b>")
};
void GradientTool::selection_changed(Inkscape::Selection*) {
@@ -106,7 +105,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
if (selection == NULL) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty())
return;
@@ -492,10 +491,10 @@ bool GradientTool::root_handler(GdkEvent* event) {
if (over_line) {
// we take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time);
+ sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time);
} else {
- std::vector<SPItem*> items=selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i) {
+ auto items= selection->items();
+ for (auto i = items.begin();i!=items.end();++i) {
SPItem *item = *i;
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -838,6 +837,16 @@ bool GradientTool::root_handler(GdkEvent* event) {
ret = TRUE;
break;
+ case GDK_KEY_i:
+ case GDK_KEY_I:
+ if (MOD__SHIFT_ONLY(event)) {
+ // Shift+I - insert stops (alternate keybinding for keyboards
+ // that don't have the Insert key)
+ sp_gradient_context_add_stops_between_selected_stops (this);
+ ret = TRUE;
+ }
+ break;
+
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
@@ -878,6 +887,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
return ret;
}
+// Creates a new linear or radial gradient.
static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
@@ -897,7 +907,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
@@ -907,8 +917,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> itemlist = selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();++i) {
+ auto itemlist = selection->items();
+ for (auto i = itemlist.begin();i!=itemlist.end();++i) {
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -931,7 +941,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
ec->_grdrag->local_change = true;
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
- ec->_grdrag->grabKnot (selection->itemList()[0],
+ ec->_grdrag->grabKnot (selection->items().front(),
type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
-1, // ignore number (though it is always 1)
fill_or_stroke, 99999, 99999, etime);
@@ -940,7 +950,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 9bbc1ac20..29e4c9e74 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -15,19 +15,16 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <2geom/sbasis-geometric.h>
-#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
-#include "macros.h"
#include "pixmaps/cursor-crosshairs.xpm"
#include <gtk/gtk.h>
#include "desktop.h"
#include "message-context.h"
-#include "preferences.h"
#include "ui/shape-editor.h"
#include "selection.h"
@@ -396,8 +393,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup();
gchar *arc_length;
double lengthval;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_PATH(*i)) {
path = SP_PATH(*i);
curve = path->getCurve();
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 5900a2359..f3185649b 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -11,11 +11,10 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm.h>
-#include <gdk/gdkkeysyms.h>
#include <boost/none_t.hpp>
#include "util/units.h"
#include "display/curve.h"
@@ -23,7 +22,6 @@
#include "display/sp-ctrlline.h"
#include "display/sp-ctrlcurve.h"
#include "display/sp-canvas.h"
-#include "display/sp-canvas-item.h"
#include "display/sp-canvas-util.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
@@ -31,34 +29,20 @@
#include "ui/tools/freehand-base.h"
#include <2geom/line.h>
#include <2geom/path-intersection.h>
-#include <2geom/pathvector.h>
-#include <2geom/crossing.h>
-#include <2geom/angle.h>
-#include <2geom/transforms.h>
#include "ui/dialog/knot-properties.h"
#include "sp-namedview.h"
-#include "sp-shape.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-defs.h"
-#include "sp-item.h"
#include "sp-root.h"
-#include "macros.h"
#include "svg/stringstream.h"
#include "rubberband.h"
#include "path-chemistry.h"
#include "desktop.h"
-#include "document.h"
#include "document-undo.h"
-#include "viewbox.h"
-#include "snap.h"
-#include "knot.h"
#include "text-editing.h"
#include "pixmaps/cursor-measure.xpm"
-#include "preferences.h"
#include "inkscape.h"
-#include "enums.h"
-#include "knot-enums.h"
#include "desktop-style.h"
#include "verbs.h"
#include <glibmm/i18n.h>
@@ -346,13 +330,13 @@ MeasureTool::MeasureTool()
end_p = readMeasurePoint(false);
dimension_offset = 35;
// create the knots
- this->knot_start = new SPKnot(desktop, N_("Measure start, <b>Shift+Click</b> for position dialog"));
+ this->knot_start = new SPKnot(desktop, _("Measure start, <b>Shift+Click</b> for position dialog"));
this->knot_start->setMode(SP_KNOT_MODE_XOR);
this->knot_start->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f);
this->knot_start->setShape(SP_KNOT_SHAPE_CIRCLE);
this->knot_start->updateCtrl();
- this->knot_end = new SPKnot(desktop, N_("Measure end, <b>Shift+Click</b> for position dialog"));
+ this->knot_end = new SPKnot(desktop, _("Measure end, <b>Shift+Click</b> for position dialog"));
this->knot_end->setMode(SP_KNOT_MODE_XOR);
this->knot_end->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f);
@@ -394,6 +378,10 @@ MeasureTool::~MeasureTool()
sp_canvas_item_destroy(measure_tmp_items[idx]);
}
measure_tmp_items.clear();
+ for (size_t idx = 0; idx < measure_item.size(); ++idx) {
+ sp_canvas_item_destroy(measure_item[idx]);
+ }
+ measure_item.clear();
for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) {
sp_canvas_item_destroy(measure_phantom_items[idx]);
}
@@ -565,7 +553,6 @@ bool MeasureTool::root_handler(GdkEvent* event)
explicit_base = boost::none;
explicit_base_tmp = boost::none;
last_end = boost::none;
- start_p = desktop->w2d(button_w);
if (event->button.button == 1 && !this->space_panning) {
// save drag origin
@@ -608,6 +595,12 @@ bool MeasureTool::root_handler(GdkEvent* event)
snap_manager.preSnap(scp);
snap_manager.unSetup();
}
+ Geom::Point const motion_w(event->motion.x, event->motion.y);
+ if(event->motion.state & GDK_SHIFT_MASK) {
+ showInfoBox(motion_w, true);
+ } else {
+ showInfoBox(motion_w, false);
+ }
} else {
ret = TRUE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1128,6 +1121,108 @@ void MeasureTool::setMeasureCanvasControlLine(Geom::Point start, Geom::Point end
}
}
+void MeasureTool::showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize)
+{
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
+ desktop,
+ pos,
+ measure_str);
+ sp_canvastext_set_fontsize(canvas_tooltip, fontsize);
+ canvas_tooltip->rgba = 0xffffffff;
+ canvas_tooltip->outline = false;
+ canvas_tooltip->background = true;
+ canvas_tooltip->anchor_position = TEXT_ANCHOR_LEFT;
+ canvas_tooltip->rgba_background = 0x00000099;
+ measure_item.push_back(SP_CANVAS_ITEM(canvas_tooltip));
+ sp_canvas_item_show(SP_CANVAS_ITEM(canvas_tooltip));
+}
+
+void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit();
+ for (size_t idx = 0; idx < measure_item.size(); ++idx) {
+ sp_canvas_item_destroy(measure_item[idx]);
+ }
+ measure_item.clear();
+
+ SPItem *newover = desktop->getItemAtPoint(cursor, into_groups);
+ if (newover) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0);
+ double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0;
+ int precision = prefs->getInt("/tools/measure/precision", 2);
+ Glib::ustring unit_name = prefs->getString("/tools/measure/unit");
+ if (!unit_name.compare("")) {
+ unit_name = "px";
+ }
+ Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse();
+ if(newover != over){
+ over = newover;
+ Preferences *prefs = Preferences::get();
+ int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
+ SPItem::BBoxType bbox_type = !prefs_bbox ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
+ Geom::OptRect bbox = over->bounds(bbox_type);
+ if (bbox) {
+
+ item_width = Inkscape::Util::Quantity::convert((*bbox).width() * scale, unit->abbr, unit_name);
+ item_height = Inkscape::Util::Quantity::convert((*bbox).height() * scale, unit->abbr, unit_name);
+ item_x = Inkscape::Util::Quantity::convert((*bbox).left(), unit->abbr, unit_name);
+ Geom::Point y_point(0,Inkscape::Util::Quantity::convert((*bbox).bottom() * scale, unit->abbr, "px"));
+ y_point *= desktop->doc2dt();
+ item_y = Inkscape::Util::Quantity::convert(y_point[Geom::Y] * scale, "px", unit_name);
+ if (SP_IS_SHAPE(over)) {
+ Geom::PathVector shape = SP_SHAPE(over)->getCurve()->get_pathvector();
+ item_length = Geom::length(paths_to_pw(shape));
+ item_length = Inkscape::Util::Quantity::convert(item_length * scale, unit->abbr, unit_name);
+ }
+ }
+ }
+ gchar *measure_str = NULL;
+ std::stringstream precision_str;
+ precision_str.imbue(std::locale::classic());
+ double origin = Inkscape::Util::Quantity::convert(14, "px", unit->abbr);
+ Geom::Point rel_position = Geom::Point(origin, origin);
+ Geom::Point pos = desktop->w2d(cursor);
+ double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr);
+ if (SP_IS_SHAPE(over)) {
+ precision_str << _("Length") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+ } else if (SP_IS_GROUP(over)) {
+ measure_str = _("Shift to measure into group");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+ }
+
+ precision_str << "Y: %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << "X: %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_x, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << _("Height") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_height, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << _("Width") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_width, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ g_free(measure_str);
+ }
+}
+
void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, Inkscape::XML::Node *measure_repr)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
diff --git a/src/ui/tools/measure-tool.h b/src/ui/tools/measure-tool.h
index 14fc9f81a..42122dca1 100644
--- a/src/ui/tools/measure-tool.h
+++ b/src/ui/tools/measure-tool.h
@@ -54,6 +54,8 @@ public:
virtual void setMarker(bool isStart);
virtual const std::string& getPrefsPath();
Geom::Point readMeasurePoint(bool is_start);
+ void showInfoBox(Geom::Point cursor, bool into_groups);
+ void showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize);
void writeMeasurePoint(Geom::Point point, bool is_start);
void setGuide(Geom::Point origin, double angle, const char *label);
void setPoint(Geom::Point origin, Inkscape::XML::Node *measure_repr);
@@ -77,6 +79,13 @@ private:
Geom::Point end_p;
std::vector<SPCanvasItem *> measure_tmp_items;
std::vector<SPCanvasItem *> measure_phantom_items;
+ std::vector<SPCanvasItem *> measure_item;
+ double item_width;
+ double item_height;
+ double item_x;
+ double item_y;
+ double item_length;
+ SPItem *over;
sigc::connection _knot_start_moved_connection;
sigc::connection _knot_start_ungrabbed_connection;
sigc::connection _knot_start_click_connection;
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 47927667c..ac43b6c9d 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
//#define DEBUG_MESH
@@ -33,12 +33,15 @@
#include "macros.h"
#include "message-context.h"
#include "message-stack.h"
-#include "preferences.h"
#include "rubberband.h"
#include "selection.h"
#include "snap.h"
#include "sp-namedview.h"
#include "verbs.h"
+#include "sp-text.h"
+#include "sp-defs.h"
+#include "style.h"
+#include "ui/control-manager.h"
// Gradient specific
#include "gradient-drag.h"
@@ -48,8 +51,9 @@
// Mesh specific
#include "ui/tools/mesh-tool.h"
-#include "sp-mesh.h"
+#include "sp-mesh-gradient.h"
#include "display/sp-ctrlcurve.h"
+#include "display/curve.h"
using Inkscape::DocumentUndo;
@@ -57,7 +61,7 @@ namespace Inkscape {
namespace UI {
namespace Tools {
-static void sp_mesh_end_drag(MeshTool &rc);
+static void sp_mesh_new_default(MeshTool &rc);
const std::string& MeshTool::getPrefsPath() {
return MeshTool::prefsPath;
@@ -71,6 +75,9 @@ MeshTool::MeshTool()
: ToolBase(cursor_gradient_xpm, 4, 4)
, cursor_addnode(false)
, node_added(false)
+ , show_handles(true)
+ , edit_fill(true)
+ , edit_stroke(true)
// TODO: Why are these connections stored as pointers?
, selcon(NULL)
, subselcon(NULL)
@@ -89,7 +96,19 @@ MeshTool::~MeshTool() {
delete this->subselcon;
}
+// This must match GrPointType enum sp-gradient.h
+// We should move this to a shared header (can't simply move to gradient.h since that would require
+// including <glibmm/i18n.h> which messes up "N_" in extensions... argh!).
const gchar *ms_handle_descr [] = {
+ N_("Linear gradient <b>start</b>"), //POINT_LG_BEGIN
+ N_("Linear gradient <b>end</b>"),
+ N_("Linear gradient <b>mid stop</b>"),
+ N_("Radial gradient <b>center</b>"),
+ N_("Radial gradient <b>radius</b>"),
+ N_("Radial gradient <b>radius</b>"),
+ N_("Radial gradient <b>focus</b>"), // POINT_RG_FOCUS
+ N_("Radial gradient <b>mid stop</b>"),
+ N_("Radial gradient <b>mid stop</b>"),
N_("Mesh gradient <b>corner</b>"),
N_("Mesh gradient <b>handle</b>"),
N_("Mesh gradient <b>tensor</b>")
@@ -103,7 +122,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty()) {
return;
@@ -162,9 +181,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
// if (style && (style->fill.isPaintserver())) {
// SPPaintServer *server = item->style->getFillPaintServer();
- // if ( SP_IS_MESH(server) ) {
+ // if ( SP_IS_MESHGRADIENT(server) ) {
- // SPMesh *mg = SP_MESH(server);
+ // SPMeshGradient *mg = SP_MESHGRADIENT(server);
// guint rows = 0;//mg->array.patches.size();
// for ( guint i = 0; i < rows; ++i ) {
@@ -237,7 +256,25 @@ void MeshTool::setup() {
)
));
+ sp_event_context_read(this, "show_handles");
+ sp_event_context_read(this, "edit_fill");
+ sp_event_context_read(this, "edit_stroke");
+
this->selection_changed(selection);
+
+}
+
+void MeshTool::set(const Inkscape::Preferences::Entry& value) {
+ Glib::ustring entry_name = value.getEntryName();
+ if (entry_name == "show_handles") {
+ this->show_handles = value.getBool(true);
+ } else if (entry_name == "edit_fill") {
+ this->edit_fill = value.getBool(true);
+ } else if (entry_name == "edit_stroke") {
+ this->edit_stroke = value.getBool(true);
+ } else {
+ ToolBase::set(value);
+ }
}
void
@@ -263,28 +300,39 @@ sp_mesh_context_select_prev (ToolBase *event_context)
}
/**
-Returns true if mouse cursor over mesh edge.
+Returns vector of control lines mouse is over. Returns only first if 'first' is true.
*/
-static bool
-sp_mesh_context_is_over_line (MeshTool *rc, SPItem *item, Geom::Point event_p)
+static std::vector<SPCtrlCurve *>
+sp_mesh_context_over_line (MeshTool *rc, Geom::Point event_p, bool first = true)
{
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
//Translate mouse point into proper coord system
rc->mousepoint_doc = desktop->w2d(event_p);
- SPCtrlCurve *curve = SP_CTRLCURVE(item);
- Geom::BezierCurveN<3> b( curve->p0, curve->p1, curve->p2, curve->p3 );
- Geom::Coord coord = b.nearestTime( rc->mousepoint_doc ); // Coord == double
- Geom::Point nearest = b( coord );
+ double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance;
+
+ GrDrag *drag = rc->_grdrag;
- double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
+ std::vector<SPCtrlCurve *> selected;
- double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance;
+ for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) {
+ if (!SP_IS_CTRLCURVE(*l)) continue;
- bool close = (dist_screen < tolerance);
+ SPCtrlCurve *curve = SP_CTRLCURVE(*l);
+ Geom::BezierCurveN<3> b( curve->p0, curve->p1, curve->p2, curve->p3 );
+ Geom::Coord coord = b.nearestTime( rc->mousepoint_doc ); // Coord == double
+ Geom::Point nearest = b( coord );
- return close;
+ double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
+ if (dist_screen < tolerance) {
+ selected.push_back(curve);
+ if (first) {
+ break;
+ }
+ }
+ }
+ return selected;
}
@@ -327,14 +375,15 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- std::map<SPMesh*, std::vector<guint> > points;
- std::map<SPMesh*, SPItem*> items;
-
+ std::map<SPMeshGradient*, std::vector<guint> > points;
+ std::map<SPMeshGradient*, SPItem*> items;
+ std::map<SPMeshGradient*, Inkscape::PaintTarget> fill_or_stroke;
+
// Get list of selected draggers for each mesh.
- // For all selected draggers
+ // For all selected draggers (a dragger may include draggerables from different meshes).
for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) {
GrDragger *dragger = *i;
- // For all draggables of dragger
+ // For all draggables of dragger (a draggable corresponds to a unique mesh).
for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) {
GrDraggable *d = *j;
@@ -342,17 +391,18 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
if( d->point_type != POINT_MG_CORNER ) continue;
// Find the gradient
- SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) );
+ SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) );
// Collect points together for same gradient
points[gradient].push_back( d->point_i );
items[gradient] = d->item;
+ fill_or_stroke[gradient] = d->fill_or_stroke ? Inkscape::FOR_FILL: Inkscape::FOR_STROKE;
}
}
// Loop over meshes.
- for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
- SPMesh *mg = SP_MESH( iter->first );
+ for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
+ SPMeshGradient *mg = SP_MESHGRADIENT( iter->first );
if( iter->second.size() > 0 ) {
guint noperation = 0;
switch (operation) {
@@ -382,6 +432,11 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
noperation += mg->array.color_pick( iter->second, items[iter->first] );
break;
+ case MG_CORNER_INSERT:
+ // std::cout << "INSERT" << std::endl;
+ noperation += mg->array.insert( iter->second );
+ break;
+
default:
std::cout << "sp_mesh_corner_operation: unknown operation" << std::endl;
}
@@ -395,22 +450,31 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
case MG_CORNER_SIDE_TOGGLE:
DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Toggled mesh path type."));
+ drag->local_change = true; // Don't create new draggers.
break;
case MG_CORNER_SIDE_ARC:
DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Approximated arc for mesh side."));
+ drag->local_change = true; // Don't create new draggers.
break;
case MG_CORNER_TENSOR_TOGGLE:
DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Toggled mesh tensors."));
+ drag->local_change = true; // Don't create new draggers.
break;
case MG_CORNER_COLOR_SMOOTH:
DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Smoothed mesh corner color."));
+ drag->local_change = true; // Don't create new draggers.
break;
case MG_CORNER_COLOR_PICK:
DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Picked mesh corner color."));
+ drag->local_change = true; // Don't create new draggers.
+ break;
+
+ case MG_CORNER_INSERT:
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Inserted new row or column."));
break;
default:
@@ -419,13 +483,76 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
}
}
}
- drag->updateDraggers();
+
+ // Not needed. Update is done via gr_drag_sel_modified().
+ // drag->updateDraggers();
}
/**
+ * Scale mesh to just fit into bbox of selected items.
+ */
+void
+sp_mesh_context_fit_mesh_in_bbox (MeshTool *rc)
+{
+
+#ifdef DEBUG_MESH
+ std::cout << "sp_mesh_context_fit_mesh_in_bbox: entrance: Entrance"<< std::endl;
+#endif
+
+ SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
+
+ Inkscape::Selection *selection = desktop->getSelection();
+ if (selection == NULL) {
+ return;
+ }
+
+ bool changed = false;
+ auto itemlist = selection->items();
+ for (auto i=itemlist.begin(); i!=itemlist.end(); ++i) {
+
+ SPItem *item = *i;
+ SPStyle *style = item->style;
+
+ if (style) {
+
+ if (style->fill.isPaintserver()) {
+ SPPaintServer *server = item->style->getFillPaintServer();
+ if ( SP_IS_MESHGRADIENT(server) ) {
+
+ Geom::OptRect item_bbox = item->geometricBounds();
+ SPMeshGradient *gradient = SP_MESHGRADIENT(server);
+ if (gradient->array.fill_box( item_bbox )) {
+ changed = true;
+ }
+ }
+ }
+
+ if (style->stroke.isPaintserver()) {
+ SPPaintServer *server = item->style->getStrokePaintServer();
+ if ( SP_IS_MESHGRADIENT(server) ) {
+
+ Geom::OptRect item_bbox = item->visualBounds();
+ SPMeshGradient *gradient = SP_MESHGRADIENT(server);
+ if (gradient->array.fill_box( item_bbox )) {
+ changed = true;
+ }
+ }
+ }
+
+ }
+ }
+ if (changed) {
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
+ _("Fit mesh inside bounding box."));
+ }
+}
+
+
+/**
Handles all keyboard and mouse input for meshs.
+Note: node/handle events are take care of elsewhere.
*/
bool MeshTool::root_handler(GdkEvent* event) {
static bool dragging;
@@ -450,43 +577,42 @@ bool MeshTool::root_handler(GdkEvent* event) {
// Double click:
// If over a mesh line, divide mesh row/column
- // If not over a line, create new gradients for selected objects.
+ // If not over a line and no mesh, create new mesh for top selected object.
if ( event->button.button == 1 ) {
- // Are we over a mesh line?
- bool over_line = false;
- SPCtrlCurve *line = NULL;
- if (! drag->lines.empty()) {
- for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) {
- line = (SPCtrlCurve*) (*l);
- over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
- }
- }
+ // Are we over a mesh line?
+ std::vector<SPCtrlCurve *> over_line =
+ sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y));
- if (over_line) {
+ if (!over_line.empty()) {
// We take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time);
+ sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time);
} else {
// Create a new gradient with default coordinates.
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
- SPItem *item = *i;
- SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
- Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
-#ifdef DEBUG_MESH
- std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl;
-#endif
- SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode);
-
- SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode);
- sp_gradient_reset_to_userspace(priv, item);
+ // Check if object already has mesh... if it does,
+ // don't create new mesh with click-drag.
+ bool has_mesh = false;
+ if (!selection->isEmpty()) {
+ SPStyle *style = selection->items().front()->style;
+ if (style) {
+ Inkscape::PaintTarget fill_or_stroke =
+ (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ?
+ Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
+ SPPaintServer *server =
+ (fill_or_stroke == Inkscape::FOR_FILL) ?
+ style->getFillPaintServer():
+ style->getStrokePaintServer();
+ if (server && SP_IS_MESHGRADIENT(server))
+ has_mesh = true;
+ }
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
- _("Create default mesh"));
+ if (!has_mesh) {
+ sp_mesh_new_default(*this);
+ }
}
ret = TRUE;
@@ -498,10 +624,36 @@ bool MeshTool::root_handler(GdkEvent* event) {
#ifdef DEBUG_MESH
std::cout << "sp_mesh_context_root_handler: GDK_BUTTON_PRESS" << std::endl;
#endif
+
// Button down
- // If Shift key down: do rubber band selection
- // Else set origin for drag. A drag creates a new gradient if one does not exist
+ // If mesh already exists, do rubber band selection.
+ // Else set origin for drag which will create a new gradient.
if ( event->button.button == 1 && !this->space_panning ) {
+
+ // Are we over a mesh line?
+ std::vector<SPCtrlCurve *> over_line =
+ sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y), false);
+
+ if (!over_line.empty()) {
+ for (std::vector<SPCtrlCurve *>::const_iterator it = over_line.begin();
+ it != over_line.end(); ++it ) {
+ SPItem *item = (*it)->item;
+ Inkscape::PaintTarget fill_or_stroke =
+ (*it)->is_fill ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
+ GrDragger* dragger0 = drag->getDraggerFor(item, POINT_MG_CORNER, (*it)->corner0, fill_or_stroke);
+ GrDragger* dragger1 = drag->getDraggerFor(item, POINT_MG_CORNER, (*it)->corner1, fill_or_stroke);
+ bool add = (event->button.state & GDK_SHIFT_MASK);
+ bool toggle = (event->button.state & GDK_CONTROL_MASK);
+ if ( !add && !toggle ) {
+ drag->deselectAll();
+ }
+ drag->setSelected( dragger0, true, !toggle );
+ drag->setSelected( dragger1, true, !toggle );
+ }
+ ret = true;
+ break; // To avoid putting the following code in an else block.
+ }
+
Geom::Point button_w(event->button.x, event->button.y);
// save drag origin
@@ -512,25 +664,43 @@ bool MeshTool::root_handler(GdkEvent* event) {
dragging = true;
Geom::Point button_dt = desktop->w2d(button_w);
- if (event->button.state & GDK_SHIFT_MASK) {
- Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
- } else {
- // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to
- // enable Ctrl+doubleclick of exactly the selected item(s)
- if (!(event->button.state & GDK_CONTROL_MASK)) {
- this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
+ // Check if object already has mesh... if it does,
+ // don't create new mesh with click-drag.
+ bool has_mesh = false;
+ if (!selection->isEmpty()) {
+ SPStyle *style = selection->items().front()->style;
+ if (style) {
+ Inkscape::PaintTarget fill_or_stroke =
+ (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ?
+ Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
+ SPPaintServer *server =
+ (fill_or_stroke == Inkscape::FOR_FILL) ?
+ style->getFillPaintServer():
+ style->getStrokePaintServer();
+ if (server && SP_IS_MESHGRADIENT(server))
+ has_mesh = true;
}
+ }
- if (!selection->isEmpty()) {
- SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop);
- m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
- m.unSetup();
- }
+ if (has_mesh) {
+ Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
+ }
- this->origin = button_dt;
+ // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to
+ // enable Ctrl+doubleclick of exactly the selected item(s)
+ if (!(event->button.state & GDK_CONTROL_MASK)) {
+ this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
}
+ if (!selection->isEmpty()) {
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop);
+ m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.unSetup();
+ }
+
+ this->origin = button_dt;
+
ret = TRUE;
}
break;
@@ -591,19 +761,14 @@ bool MeshTool::root_handler(GdkEvent* event) {
}
// Change cursor shape if over line
- bool over_line = false;
+ std::vector<SPCtrlCurve *> over_line =
+ sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y));
- if (!drag->lines.empty()) {
- for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; ++l) {
- over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y));
- }
- }
-
- if (this->cursor_addnode && !over_line) {
+ if (this->cursor_addnode && over_line.empty()) {
this->cursor_shape = cursor_gradient_xpm;
this->sp_event_context_update_cursor();
this->cursor_addnode = false;
- } else if (!this->cursor_addnode && over_line) {
+ } else if (!this->cursor_addnode && !over_line.empty()) {
this->cursor_shape = cursor_gradient_add_xpm;
this->sp_event_context_update_cursor();
this->cursor_addnode = true;
@@ -620,24 +785,15 @@ bool MeshTool::root_handler(GdkEvent* event) {
this->xp = this->yp = 0;
if ( event->button.button == 1 && !this->space_panning ) {
- // Check if over line
- bool over_line = false;
- SPCtrlLine *line = NULL;
- if (!drag->lines.empty()) {
- for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) {
- line = (SPCtrlLine*)(*l);
- over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
-
- if (over_line) {
- break;
- }
- }
- }
+ // Check if over line
+ std::vector<SPCtrlCurve *> over_line =
+ sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y));
if ( (event->button.state & GDK_CONTROL_MASK) && (event->button.state & GDK_MOD1_MASK ) ) {
- if (over_line && line) {
- sp_mesh_context_split_near_point(this, line->item, this->mousepoint_doc, 0);
+ if (!over_line.empty()) {
+ sp_mesh_context_split_near_point(this, over_line[0]->item,
+ this->mousepoint_doc, 0);
ret = TRUE;
}
} else {
@@ -650,22 +806,47 @@ bool MeshTool::root_handler(GdkEvent* event) {
}
if (!this->within_tolerance) {
- // we've been dragging, either create a new gradient
- // or rubberband-select if we have rubberband
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
-
- if (r->is_started() && !this->within_tolerance) {
- // this was a rubberband drag
- if (r->getMode() == RUBBERBAND_MODE_RECT) {
- Geom::OptRect const b = r->getRectangle();
- drag->selectRect(*b);
+
+ // Check if object already has mesh... if it does,
+ // don't create new mesh with click-drag.
+ bool has_mesh = false;
+ if (!selection->isEmpty()) {
+ SPStyle *style = selection->items().front()->style;
+ if (style) {
+ Inkscape::PaintTarget fill_or_stroke =
+ (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ?
+ Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
+ SPPaintServer *server =
+ (fill_or_stroke == Inkscape::FOR_FILL) ?
+ style->getFillPaintServer():
+ style->getStrokePaintServer();
+ if (server && SP_IS_MESHGRADIENT(server))
+ has_mesh = true;
}
+ }
+
+ if (!has_mesh) {
+ sp_mesh_new_default(*this);
} else {
- // Create a new mesh gradient
- sp_mesh_end_drag(*this);
+
+ // we've been dragging, either create a new gradient
+ // or rubberband-select if we have rubberband
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
+
+ if (r->is_started() && !this->within_tolerance) {
+ // this was a rubberband drag
+ if (r->getMode() == RUBBERBAND_MODE_RECT) {
+ Geom::OptRect const b = r->getRectangle();
+ if (!(event->button.state & GDK_SHIFT_MASK)) {
+ drag->deselectAll();
+ }
+ drag->selectRect(*b);
+ }
+ }
}
+
} else if (this->item_to_select) {
- if (over_line && line) {
+ if (!over_line.empty()) {
// Clicked on an existing mesh line, don't change selection. This stops
// possible change in selection during a double click with overlapping objects
} else {
@@ -673,15 +854,21 @@ bool MeshTool::root_handler(GdkEvent* event) {
if (event->button.state & GDK_SHIFT_MASK) {
selection->toggle(this->item_to_select);
} else {
+ drag->deselectAll();
selection->set(this->item_to_select);
}
}
} else {
- // click in an empty space; do the same as Esc
- if (!drag->selected.empty()) {
- drag->deselectAll();
+ if (!over_line.empty()) {
+ // Clicked on an existing mesh line, don't change selection. This stops
+ // possible change in selection during a double click with overlapping objects
} else {
- selection->clear();
+ // click in an empty space; do the same as Esc
+ if (!drag->selected.empty()) {
+ drag->deselectAll();
+ } else {
+ selection->clear();
+ }
}
}
@@ -709,10 +896,11 @@ bool MeshTool::root_handler(GdkEvent* event) {
case GDK_KEY_Shift_R:
case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine)
case GDK_KEY_Meta_R:
- sp_event_show_modifier_tip (this->defaultMessageContext(), event,
- _("FIXME<b>Ctrl</b>: snap mesh angle"),
- _("FIXME<b>Shift</b>: draw mesh around the starting point"),
- NULL);
+
+ // sp_event_show_modifier_tip (this->defaultMessageContext(), event,
+ // _("FIXME<b>Ctrl</b>: snap mesh angle"),
+ // _("FIXME<b>Shift</b>: draw mesh around the starting point"),
+ // NULL);
break;
case GDK_KEY_A:
@@ -830,25 +1018,33 @@ bool MeshTool::root_handler(GdkEvent* event) {
}
break;
+ // Mesh Operations --------------------------------------------
+
case GDK_KEY_Insert:
case GDK_KEY_KP_Insert:
// with any modifiers:
- //sp_gradient_context_add_stops_between_selected_stops (rc);
- std::cout << "Inserting stops between selected stops not implemented yet" << std::endl;
+ sp_mesh_context_corner_operation ( this, MG_CORNER_INSERT );
ret = TRUE;
break;
+ case GDK_KEY_i:
+ case GDK_KEY_I:
+ if (MOD__SHIFT_ONLY(event)) {
+ // Shift+I - insert corners (alternate keybinding for keyboards
+ // that don't have the Insert key)
+ sp_mesh_context_corner_operation ( this, MG_CORNER_INSERT );
+ ret = TRUE;
+ }
+ break;
+
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
if ( !drag->selected.empty() ) {
- std::cout << "Deleting mesh stops not implemented yet" << std::endl;
ret = TRUE;
}
break;
- // Mesh Operations --------------------------------------------
-
case GDK_KEY_b: // Toggle mesh side between lineto and curveto.
case GDK_KEY_B:
if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) {
@@ -926,7 +1122,8 @@ bool MeshTool::root_handler(GdkEvent* event) {
return ret;
}
-static void sp_mesh_end_drag(MeshTool &rc) {
+// Creates a new mesh gradient.
+static void sp_mesh_new_default(MeshTool &rc) {
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *document = desktop->getDocument();
@@ -935,44 +1132,65 @@ static void sp_mesh_end_drag(MeshTool &rc) {
if (!selection->isEmpty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- int type = SP_GRADIENT_TYPE_MESH;
- Inkscape::PaintTarget fill_or_stroke = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
-
- SPGradient *vector;
- if (ec->item_to_select) {
- // pick color from the object where drag started
- vector = sp_gradient_vector_for_object(document, desktop, ec->item_to_select, fill_or_stroke);
+ Inkscape::PaintTarget fill_or_stroke =
+ (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ?
+ Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
+
+ // Ensure mesh is immediately editable.
+ // Editing both fill and stroke at same time doesn't work well so avoid.
+ if (fill_or_stroke == Inkscape::FOR_FILL) {
+ prefs->setBool("/tools/mesh/edit_fill", true );
+ prefs->setBool("/tools/mesh/edit_stroke", false);
} else {
- // Starting from empty space:
- // Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
- sort(items.begin(),items.end(),sp_item_repr_compare_position);
- // take topmost
- vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
+ prefs->setBool("/tools/mesh/edit_fill", false);
+ prefs->setBool("/tools/mesh/edit_stroke", true );
}
- // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
+// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ Inkscape::XML::Document *xml_doc = document->getReprDoc();
+ SPDefs *defs = document->getDefs();
+
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
- sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke);
+ // Create mesh element
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:meshgradient");
- // We don't need to do anything. Mesh is already sized appropriately.
-
- (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ // privates are garbage-collectable
+ repr->setAttribute("inkscape:collect", "always");
+
+ // Attach to document
+ defs->getRepr()->appendChild(repr);
+ Inkscape::GC::release(repr);
+
+ // Get corresponding object
+ SPMeshGradient *mg = static_cast<SPMeshGradient *>(document->getObjectByRepr(repr));
+ mg->array.create(mg, *i, (fill_or_stroke == Inkscape::FOR_FILL) ?
+ (*i)->geometricBounds() : (*i)->visualBounds());
+
+ bool isText = SP_IS_TEXT(*i);
+ sp_style_set_property_url (*i, ((fill_or_stroke == Inkscape::FOR_FILL) ? "fill":"stroke"),
+ mg, isText);
+
+ (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG|SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
+
+ if (css) {
+ sp_repr_css_attr_unref(css);
+ css = 0;
}
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, _("Create mesh"));
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
@@ -982,7 +1200,6 @@ static void sp_mesh_end_drag(MeshTool &rc) {
}
}
-
}
}
}
diff --git a/src/ui/tools/mesh-tool.h b/src/ui/tools/mesh-tool.h
index 91b35b3af..1f012dc53 100644
--- a/src/ui/tools/mesh-tool.h
+++ b/src/ui/tools/mesh-tool.h
@@ -31,34 +31,40 @@ namespace Tools {
class MeshTool : public ToolBase {
public:
- MeshTool();
- virtual ~MeshTool();
+ MeshTool();
+ virtual ~MeshTool();
Geom::Point origin;
- bool cursor_addnode;
-
- bool node_added;
-
Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords
sigc::connection *selcon;
sigc::connection *subselcon;
- static const std::string prefsPath;
+ static const std::string prefsPath;
- virtual void setup();
- virtual bool root_handler(GdkEvent* event);
+ virtual void setup();
+ virtual void set(const Inkscape::Preferences::Entry& val);
+ virtual bool root_handler(GdkEvent* event);
- virtual const std::string& getPrefsPath();
+ virtual const std::string& getPrefsPath();
private:
- void selection_changed(Inkscape::Selection* sel);
+ void selection_changed(Inkscape::Selection* sel);
+
+ bool cursor_addnode;
+ bool node_added;
+ bool show_handles;
+ bool edit_fill;
+ bool edit_stroke;
+
+
};
void sp_mesh_context_select_next(ToolBase *event_context);
void sp_mesh_context_select_prev(ToolBase *event_context);
void sp_mesh_context_corner_operation(MeshTool *event_context, MeshCornerOperation operation );
+void sp_mesh_context_fit_mesh_in_bbox(MeshTool *event_context);
}
}
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 23aaf6bb1..0c948c91c 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -24,25 +24,21 @@
#include "message-context.h"
#include "selection.h"
#include "ui/shape-editor.h" // temporary!
-#include "live_effects/effect.h"
-#include "display/curve.h"
#include "snap.h"
#include "sp-namedview.h"
#include "sp-clippath.h"
#include "sp-item-group.h"
#include "sp-mask.h"
-#include "sp-object-group.h"
-#include "sp-path.h"
#include "sp-text.h"
#include "ui/control-manager.h"
#include "ui/tools/node-tool.h"
+#include "ui/tools-switch.h"
+#include "ui/tools/tool-base.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
-#include "ui/tool/manipulator.h"
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/path-manipulator.h"
#include "ui/tool/selector.h"
-#include "ui/tool/shape-record.h"
#include "pixmaps/cursor-node.xpm"
#include "pixmaps/cursor-node-d.xpm"
@@ -215,7 +211,7 @@ void NodeTool::setup() {
this->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(
sigc::mem_fun(this, &NodeTool::handleControlUiStyleChange)
);
-
+ this->helperpath_tmpitem = NULL;
this->_selected_nodes = new Inkscape::UI::ControlPointSelection(this->desktop, this->_transform_handle_group);
data.node_data.selection = this->_selected_nodes;
@@ -243,14 +239,12 @@ void NodeTool::setup() {
)))
);
- this->helperpath_tmpitem = NULL;
this->cursor_drag = false;
this->show_transform_handles = true;
this->single_node_transform_handles = false;
this->flash_tempitem = NULL;
this->flashed_item = NULL;
this->_last_over = NULL;
- this->helperpath_tmpitem = NULL;
// read prefs before adding items to selection to prevent momentarily showing the outline
sp_event_context_read(this, "show_handles");
@@ -277,31 +271,34 @@ void NodeTool::setup() {
}
this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive
- this->update_helperpath();
+ sp_update_helperpath();
}
// show helper paths of the applied LPE, if any
-void NodeTool::update_helperpath () {
- Inkscape::Selection *selection = this->desktop->getSelection();
-
- if (this->helperpath_tmpitem) {
- this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem);
- this->helperpath_tmpitem = NULL;
+void sp_update_helperpath() {
+ SPDesktop * desktop = SP_ACTIVE_DESKTOP;
+ if (!desktop || !tools_isactive(desktop, TOOLS_NODES)) {
+ return;
+ }
+ Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context);
+ Inkscape::Selection *selection = desktop->getSelection();
+ if (nt->helperpath_tmpitem) {
+ desktop->remove_temporary_canvasitem(nt->helperpath_tmpitem);
+ nt->helperpath_tmpitem = NULL;
}
if (SP_IS_LPE_ITEM(selection->singleItem())) {
Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE();
if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) {
- Inkscape::UI::ControlPointSelection::Set &selectionNodes = _selected_nodes->allPoints();
+
+ Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes;
std::vector<Geom::Point> selectedNodesPositions;
- for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) {
- if ((*i)->selected()) {
- Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i);
- selectedNodesPositions.push_back(n->position());
- }
+ for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) {
+ Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i);
+ selectedNodesPositions.push_back(n->position());
}
lpe->setSelectedNodePoints(selectedNodesPositions);
- lpe->setCurrentZoom(this->desktop->current_zoom());
+ lpe->setCurrentZoom(desktop->current_zoom());
SPCurve *c = new SPCurve();
SPCurve *cc = new SPCurve();
std::vector<Geom::PathVector> cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem()));
@@ -311,11 +308,11 @@ void NodeTool::update_helperpath () {
cc->reset();
}
if (!c->is_empty()) {
- SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c);
+ SPCanvasItem *helperpath = sp_canvas_bpath_new(desktop->getTempGroup(), c, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath), 0x0000ff9A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_affine_absolute(helperpath, selection->singleItem()->i2dt_affine());
- this->helperpath_tmpitem = this->desktop->add_temporary_canvasitem(helperpath, 0);
+ nt->helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0);
}
c->unref();
cc->unref();
@@ -378,8 +375,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape
r.role = role;
s.insert(r);
} else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) {
- for (SPObject *c = obj->children; c; c = c->next) {
- gather_items(nt, base, c, role, s);
+ for (auto& c: obj->children) {
+ gather_items(nt, base, &c, role, s);
}
} else if (SP_IS_ITEM(obj)) {
SPItem *item = static_cast<SPItem*>(obj);
@@ -407,8 +404,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
std::set<ShapeRecord> shapes;
- std::vector<SPItem*> items=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= sel->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *obj = *i;
if (SP_IS_ITEM(obj)) {
@@ -443,8 +440,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
}
}
+ std::vector<SPItem *> vec(sel->items().begin(), sel->items().end());
_previous_selection = _current_selection;
- _current_selection = sel->itemList();
+ _current_selection = vec;
this->_multipath->setItems(shapes);
this->update_tip(NULL);
@@ -473,13 +471,11 @@ bool NodeTool::root_handler(GdkEvent* event) {
if (this->_selected_nodes->event(this, event)) {
return true;
}
-
switch (event->type)
{
case GDK_MOTION_NOTIFY: {
- this->update_helperpath();
+ sp_update_helperpath();
combine_motion_events(desktop->canvas, event->motion, 0);
- this->update_helperpath();
SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button),
FALSE, TRUE);
@@ -532,7 +528,7 @@ bool NodeTool::root_handler(GdkEvent* event) {
}
c->transform(over_item->i2dt_affine());
- SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c);
+ SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash),
//prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0,
@@ -634,7 +630,6 @@ bool NodeTool::root_handler(GdkEvent* event) {
void NodeTool::update_tip(GdkEvent *event) {
using namespace Inkscape::UI;
-
if (event && (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)) {
unsigned new_state = state_after_event(event);
diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h
index 8342d66a6..983ba6cee 100644
--- a/src/ui/tools/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -49,14 +49,14 @@ public:
Inkscape::UI::ControlPointSelection* _selected_nodes;
Inkscape::UI::MultiPathManipulator* _multipath;
-
+ Inkscape::Display::TemporaryItem *helperpath_tmpitem;
+
bool edit_clipping_paths;
bool edit_masks;
static const std::string prefsPath;
virtual void setup();
- virtual void update_helperpath();
virtual void set(const Inkscape::Preferences::Entry& val);
virtual bool root_handler(GdkEvent* event);
@@ -68,7 +68,7 @@ private:
sigc::connection _sizeUpdatedConn;
SPItem *flashed_item;
- Inkscape::Display::TemporaryItem *helperpath_tmpitem;
+
Inkscape::Display::TemporaryItem *flash_tempitem;
Inkscape::UI::Selector* _selector;
Inkscape::UI::PathSharedData* _path_data;
@@ -96,8 +96,9 @@ private:
void update_tip(GdkEvent *event);
void handleControlUiStyleChange();
};
-
+ void sp_update_helperpath();
}
+
}
}
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 18af8e105..caf6faec2 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -32,8 +32,6 @@
#include "ui/draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
-#include "preferences.h"
-#include "sp-path.h"
#include "display/sp-canvas.h"
#include "display/curve.h"
#include "pixmaps/cursor-pen.xpm"
@@ -46,7 +44,6 @@
#include "ui/tools-switch.h"
#include "ui/control-manager.h"
// we include the necessary files for BSpline & Spiro
-#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
@@ -54,25 +51,16 @@
#include "live_effects/lpe-spiro.h"
-#include <typeinfo>
-#include <2geom/pathvector.h>
-#include <2geom/affine.h>
#include <2geom/curves.h>
#include "helper/geom-nodetype.h"
-#include "helper/geom-curves.h"
// For handling un-continuous paths:
-#include "message-stack.h"
#include "inkscape.h"
-#include "desktop.h"
#include "live_effects/spiro.h"
#define INKSCAPE_LPE_BSPLINE_C
#include "live_effects/lpe-bspline.h"
-#include <2geom/nearest-time.h>
-
-#include "live_effects/effect.h"
using Inkscape::ControlManager;
@@ -379,7 +367,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
//with this we avoid creating a new point over the existing one
if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){
- if( anchor && anchor == this->sa && this->green_curve->is_empty()){
+ if( anchor && anchor == this->sa && this->green_curve->is_unset()){
//remove the following line to avoid having one node on top of another
_finishSegment(event_dt, bevent.state);
_finish(true);
@@ -877,7 +865,7 @@ void PenTool::_redrawAll() {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
@@ -889,7 +877,7 @@ void PenTool::_redrawAll() {
this->red_curve->reset();
this->red_curve->moveto(this->p[0]);
this->red_curve->curveto(this->p[1], this->p[2], this->p[3]);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
// handles
// hide the handlers in bspline and spiro modes
@@ -931,7 +919,7 @@ void PenTool::_lastpointMove(gdouble x, gdouble y) {
return;
// green
- if (!this->green_curve->is_empty()) {
+ if (!this->green_curve->is_unset()) {
this->green_curve->last_point_additive_move( Geom::Point(x,y) );
} else {
// start anchor too
@@ -959,7 +947,7 @@ void PenTool::_lastpointToCurve() {
this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3.)*(this->red_curve->last_segment()->finalPoint() - this->red_curve->last_segment()->initialPoint());
//modificate the last segment of the green curve so it creates the type of node we need
if (this->spiro||this->bspline) {
- if (!this->green_curve->is_empty()) {
+ if (!this->green_curve->is_unset()) {
Geom::Point A(0,0);
Geom::Point B(0,0);
Geom::Point C(0,0);
@@ -998,7 +986,7 @@ void PenTool::_lastpointToCurve() {
}
}
//if the last node is an union with another curve
- if (this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()) {
+ if (this->green_curve->is_unset() && this->sa && !this->sa->curve->is_unset()) {
this->_bsplineSpiroStartAnchor(false);
}
}
@@ -1014,7 +1002,7 @@ void PenTool::_lastpointToLine() {
// modify the last segment of the green curve so the type of node we want is created.
if(this->spiro || this->bspline){
- if(!this->green_curve->is_empty()){
+ if(!this->green_curve->is_unset()){
Geom::Point A(0,0);
Geom::Point B(0,0);
Geom::Point C(0,0);
@@ -1045,7 +1033,7 @@ void PenTool::_lastpointToLine() {
}
}
// if the last node is an union with another curve
- if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){
+ if(this->green_curve->is_unset() && this->sa && !this->sa->curve->is_unset()){
this->_bsplineSpiroStartAnchor(true);
}
}
@@ -1224,7 +1212,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
// All this is needed to stop the last control
// point dispeating and stop making an n-1 shape.
Geom::Point const p(0, 0);
- if(this->red_curve->is_empty()) {
+ if(this->red_curve->is_unset()) {
this->red_curve->moveto(p);
}
this->_finishSegment(p, 0);
@@ -1245,7 +1233,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(this->desktop);
+ this->desktop->selection->toGuides();
ret = true;
}
break;
@@ -1263,10 +1251,10 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
void PenTool::_resetColors() {
// Red
this->red_curve->reset();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true);
// Blue
this->blue_curve->reset();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL, true);
// Green
while (this->green_bpaths) {
sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
@@ -1289,7 +1277,7 @@ void PenTool::_setInitialPoint(Geom::Point const p) {
this->p[0] = p;
this->p[1] = p;
this->npoints = 2;
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true);
this->desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
@@ -1355,7 +1343,7 @@ void PenTool::_bsplineSpiroColor()
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
@@ -1376,7 +1364,7 @@ void PenTool::_bsplineSpiro(bool shift)
void PenTool::_bsplineSpiroOn()
{
- if(!this->red_curve->is_empty()){
+ if(!this->red_curve->is_unset()){
using Geom::X;
using Geom::Y;
this->npoints = 5;
@@ -1389,7 +1377,7 @@ void PenTool::_bsplineSpiroOn()
void PenTool::_bsplineSpiroOff()
{
- if(!this->red_curve->is_empty()){
+ if(!this->red_curve->is_unset()){
this->npoints = 5;
this->p[0] = this->red_curve->first_segment()->initialPoint();
this->p[3] = this->red_curve->first_segment()->finalPoint();
@@ -1399,7 +1387,7 @@ void PenTool::_bsplineSpiroOff()
void PenTool::_bsplineSpiroStartAnchor(bool shift)
{
- if(this->sa->curve->is_empty()){
+ if(this->sa->curve->is_unset()){
return;
}
@@ -1509,18 +1497,18 @@ void PenTool::_bsplineSpiroMotion(bool shift){
}
using Geom::X;
using Geom::Y;
- if(this->red_curve->is_empty()) return;
+ if(this->red_curve->is_unset()) return;
this->npoints = 5;
SPCurve *tmp_curve = new SPCurve();
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
- if(this->green_curve->is_empty() && !this->sa){
+ if(this->green_curve->is_unset() && !this->sa){
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP,this->p[1][Y] + HANDLE_CUBIC_GAP);
if(shift){
this->p[2] = this->p[3];
}
- }else if(!this->green_curve->is_empty()){
+ }else if(!this->green_curve->is_unset()){
tmp_curve = this->green_curve->copy();
}else{
tmp_curve = this->overwrite_curve->copy();
@@ -1528,7 +1516,7 @@ void PenTool::_bsplineSpiroMotion(bool shift){
tmp_curve = tmp_curve ->create_reverse();
}
- if(!tmp_curve ->is_empty()){
+ if(!tmp_curve ->is_unset()){
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if(cubic){
if(this->bspline){
@@ -1560,7 +1548,7 @@ void PenTool::_bsplineSpiroMotion(bool shift){
}
}
- if(this->anchor_statusbar && !this->red_curve->is_empty()){
+ if(this->anchor_statusbar && !this->red_curve->is_unset()){
if(shift){
this->_bsplineSpiroEndAnchorOff();
}else{
@@ -1693,19 +1681,19 @@ void PenTool::_bsplineSpiroBuild()
//We create the base curve
SPCurve *curve = new SPCurve();
//If we continuate the existing curve we add it at the start
- if(this->sa && !this->sa->curve->is_empty()){
+ if(this->sa && !this->sa->curve->is_unset()){
curve = this->overwrite_curve->copy();
if (this->sa->start) {
curve = curve->create_reverse();
}
}
- if (!this->green_curve->is_empty()){
+ if (!this->green_curve->is_unset()){
curve->append_continuous(this->green_curve, 0.0625);
}
//and the red one
- if (!this->red_curve->is_empty()){
+ if (!this->red_curve->is_unset()){
this->red_curve->reset();
this->red_curve->moveto(this->p[0]);
if(this->anchor_statusbar && !this->sa && !(this->green_anchor && this->green_anchor->active)){
@@ -1713,11 +1701,11 @@ void PenTool::_bsplineSpiroBuild()
}else{
this->red_curve->curveto(this->p[1],this->p[2],this->p[3]);
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
curve->append_continuous(this->red_curve, 0.0625);
}
- if(!curve->is_empty()){
+ if(!curve->is_unset()){
// close the curve if the final points of the curve are close enough
if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){
curve->closepath_current();
@@ -1734,7 +1722,7 @@ void PenTool::_bsplineSpiroBuild()
LivePathEffect::sp_spiro_do_effect(curve);
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_show(this->blue_bpath);
curve->unref();
@@ -1790,7 +1778,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta
}
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
if (statusbar) {
gchar *message = is_curve ?
@@ -1830,7 +1818,7 @@ void PenTool::_setCtrl(Geom::Point const p, guint const state) {
this->red_curve->reset();
this->red_curve->moveto(this->p[0]);
this->red_curve->curveto(this->p[1], this->p[2], this->p[3]);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
}
SP_CTRL(this->c0)->moveto(this->p[2]);
this->cl0 ->setCoords(this->p[3], this->p[2]);
@@ -1856,13 +1844,13 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
++num_clicks;
- if (!this->red_curve->is_empty()) {
+ if (!this->red_curve->is_unset()) {
this->_bsplineSpiro(state & GDK_SHIFT_MASK);
this->green_curve->append_continuous(this->red_curve, 0.0625);
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true);
curve->unref();
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
@@ -1881,8 +1869,8 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
bool PenTool::_undoLastPoint() {
bool ret = false;
- if ( this->green_curve->is_empty() || (this->green_curve->last_segment() == NULL) ) {
- if (!this->red_curve->is_empty()) {
+ if ( this->green_curve->is_unset() || (this->green_curve->last_segment() == NULL) ) {
+ if (!this->red_curve->is_unset()) {
this->_cancel ();
ret = true;
} else {
@@ -1899,7 +1887,7 @@ bool PenTool::_undoLastPoint() {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// Get last segment
- if ( this->green_curve->is_empty() ) {
+ if ( this->green_curve->is_unset() ) {
g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty");
return false;
}
@@ -2031,7 +2019,7 @@ int PenTool::nextParaxialDirection(Geom::Point const &pt, Geom::Point const &ori
// (on first mouse release), in which case num_clicks immediately becomes 1.
// if (this->num_clicks == 0) {
- if (this->green_curve->is_empty()) {
+ if (this->green_curve->is_unset()) {
// first mouse click
double dist_h = fabs(pt[Geom::X] - origin[Geom::X]);
double dist_v = fabs(pt[Geom::Y] - origin[Geom::Y]);
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index b029ca613..ec2874823 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -27,7 +27,6 @@
#include "message-stack.h"
#include "message-context.h"
#include "sp-path.h"
-#include "preferences.h"
#include "snap.h"
#include "pixmaps/cursor-pencil.xpm"
#include <2geom/sbasis-to-bezier.h>
@@ -36,13 +35,9 @@
#include <glibmm/i18n.h>
#include "context-fns.h"
#include "sp-namedview.h"
-#include "xml/repr.h"
-#include "document.h"
#include "desktop-style.h"
-#include "macros.h"
#include "display/sp-canvas.h"
#include "display/curve.h"
-#include "livarot/Path.h"
#include "ui/tool/event-utils.h"
namespace Inkscape {
@@ -492,7 +487,7 @@ bool PencilTool::_handleKeyPress(GdkEventKey const &event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (Inkscape::UI::held_only_shift(event)) {
- sp_selection_to_guides(this->desktop);
+ this->desktop->selection->toGuides();
ret = true;
}
break;
@@ -593,8 +588,8 @@ void PencilTool::_setEndpoint(Geom::Point const &p) {
* Still not sure, how it will make most sense.
*/
void PencilTool::_finishEndpoint() {
- if ( ( this->red_curve->is_empty() )
- || ( *(this->red_curve->first_point()) == *(this->red_curve->second_point()) ) )
+ if (this->red_curve->is_unset() ||
+ this->red_curve->first_point() == this->red_curve->second_point())
{
this->red_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
@@ -852,7 +847,7 @@ void PencilTool::_fitAndSplit() {
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true);
curve->unref();
this->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color();
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 844965c4d..272531945 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -14,8 +14,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include <cstring>
#include <string>
@@ -29,16 +27,13 @@
#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-rect.xpm"
#include "ui/tools/rect-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
#include "verbs.h"
@@ -299,7 +294,7 @@ bool RectTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 905e38f2b..bae1793ed 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <cstring>
#include <string>
@@ -40,14 +40,12 @@
#include "desktop.h"
#include "sp-root.h"
-#include "preferences.h"
#include "ui/tools-switch.h"
#include "message-stack.h"
#include "selection-describer.h"
#include "seltrans.h"
#include "box3d.h"
#include "display/sp-canvas.h"
-#include "display/sp-canvas-item.h"
#include "display/drawing-item.h"
using Inkscape::DocumentUndo;
@@ -65,7 +63,7 @@ static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so t
static gint drag_escaped = 0; // if non-zero, drag was canceled by esc
const std::string& SelectTool::getPrefsPath() {
- return SelectTool::prefsPath;
+ return SelectTool::prefsPath;
}
const std::string SelectTool::prefsPath = "/tools/select";
@@ -111,7 +109,6 @@ SelectTool::SelectTool()
//static gint tolerance = 0;
//static bool within_tolerance = false;
static bool is_cycling = false;
-static bool moved_while_cycling = false;
SelectTool::~SelectTool() {
@@ -129,20 +126,12 @@ SelectTool::~SelectTool() {
this->_describer = NULL;
if (CursorSelectDragging) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(CursorSelectDragging);
-#else
- gdk_cursor_unref (CursorSelectDragging);
-#endif
CursorSelectDragging = NULL;
}
if (CursorSelectMouseover) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(CursorSelectMouseover);
-#else
- gdk_cursor_unref (CursorSelectMouseover);
-#endif
CursorSelectMouseover = NULL;
}
}
@@ -153,7 +142,7 @@ void SelectTool::setup() {
this->_describer = new Inkscape::SelectionDescriber(
desktop->selection,
desktop->messageStack(),
- _("Click selection to toggle scale/rotation handles"),
+ _("Click selection to toggle scale/rotation handles (or Shift+s)"),
_("No objects selected. Click, Shift+click, Alt+scroll mouse on top of objects, or drag around objects to select.")
);
@@ -297,7 +286,7 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
} else {
GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
- this->dragging = TRUE;
+ this->dragging = TRUE;
this->moved = FALSE;
gdk_window_set_cursor(window, CursorSelectDragging);
@@ -347,11 +336,11 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
break;
}
case GDK_LEAVE_NOTIFY:
- if (!desktop->isWaitingCursor() && !this->dragging) {
+ if (!desktop->isWaitingCursor() && !this->dragging) {
GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, this->cursor);
- }
+ }
break;
case GDK_KEY_PRESS:
@@ -379,61 +368,75 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = ToolBase::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
}
return ret;
}
void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) {
- if (this->cycling_cur_item == this->cycling_items.end()) {
+ if ( this->cycling_items.empty() )
return;
- }
Inkscape::DrawingItem *arenaitem;
- SPItem *item = *cycling_cur_item;
- g_assert(item != NULL);
- // Deactivate current item
- if (std::find(cycling_items_selected_before.begin(), cycling_items_selected_before.end(), item) == cycling_items_selected_before.end() && selection->includes(item)) {
- selection->remove(item);
+ if(cycling_cur_item) {
+ arenaitem = cycling_cur_item->get_arenaitem(desktop->dkey);
+ arenaitem->setOpacity(0.3);
}
- arenaitem = item->get_arenaitem(desktop->dkey);
- arenaitem->setOpacity(0.3);
-
// Find next item and activate it
- std::vector<SPItem *>::iterator next = this->cycling_cur_item;
+
+
+ std::vector<SPItem *>::iterator next = cycling_items.end();
+
if (scroll_event->direction == GDK_SCROLL_UP) {
- ++next;
- if (next == this->cycling_items.end() && this->cycling_wrap) {
- next = this->cycling_items.begin();
+ if (! cycling_cur_item) {
+ next = cycling_items.begin();
+ } else {
+ next = std::find( cycling_items.begin(), cycling_items.end(), cycling_cur_item );
+ g_assert (next != cycling_items.end());
+ next++;
+ if (next == cycling_items.end())
+ if ( cycling_wrap )
+ next = cycling_items.begin();
+ else
+ next--;
}
- } else {
- if(next == this->cycling_items.begin()) {
- next = this->cycling_items.end();
+ } else {
+ if (! cycling_cur_item) {
+ next = cycling_items.end();
+ next--;
+ } else {
+ next = std::find( cycling_items.begin(), cycling_items.end(), cycling_cur_item );
+ g_assert (next != cycling_items.end());
+ if (next == cycling_items.begin()){
+ if ( cycling_wrap ) {
+ next = cycling_items.end();
+ next--;
+ }
+ } else {
+ next--;
+ }
}
- --next;
}
- if (next!=this->cycling_items.end()) {
- this->cycling_cur_item = next;
- item = *next;
- g_assert(item != NULL);
- }
+ this->cycling_cur_item = *next;
+ g_assert(next != cycling_items.end());
+ g_assert(cycling_cur_item != NULL);
- arenaitem = item->get_arenaitem(desktop->dkey);
+ arenaitem = cycling_cur_item->get_arenaitem(desktop->dkey);
arenaitem->setOpacity(1.0);
if (shift_pressed) {
- selection->add(item);
+ selection->add(cycling_cur_item);
} else {
- selection->set(item);
+ selection->set(cycling_cur_item);
}
}
void SelectTool::sp_select_context_reset_opacities() {
- for (std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l ) {
+ for (std::vector<SPItem *>::const_iterator l = this->cycling_items_cmp.begin(); l != this->cycling_items_cmp.end(); ++l ) {
SPItem *item = *l;
if (item) {
Inkscape::DrawingItem *arenaitem = item->get_arenaitem(desktop->dkey);
@@ -443,10 +446,8 @@ void SelectTool::sp_select_context_reset_opacities() {
}
}
- this->cycling_items.clear();
- this->cycling_items_selected_before.clear();
- this->cycling_cur_item = this->cycling_items.end();
this->cycling_items_cmp.clear();
+ this->cycling_cur_item = NULL;
}
bool SelectTool::root_handler(GdkEvent* event) {
@@ -466,7 +467,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
if (!selection->isEmpty()) {
- SPItem *clicked_item = selection->itemList()[0];
+ SPItem *clicked_item = selection->items().front();
if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
desktop->setCurrentLayer(clicked_item);
@@ -533,11 +534,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_MOTION_NOTIFY:
{
- if (is_cycling) {
- moved_while_cycling = true;
- }
-
- tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
if ((event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) {
Geom::Point const motion_pt(event->motion.x, event->motion.y);
@@ -703,7 +700,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (r->is_started() && !within_tolerance) {
// this was a rubberband drag
- std::vector<SPItem*> items;
+ std::vector<SPItem*> items;
if (r->getMode() == RUBBERBAND_MODE_RECT) {
Geom::OptRect const b = r->getRectangle();
@@ -796,107 +793,67 @@ bool SelectTool::root_handler(GdkEvent* event) {
break;
case GDK_SCROLL: {
- GdkEventScroll *scroll_event = (GdkEventScroll*) event;
-
- if (scroll_event->state & GDK_MOD1_MASK) { // alt modified pressed
- if (moved_while_cycling) {
- moved_while_cycling = false;
- this->sp_select_context_reset_opacities();
- }
-
- is_cycling = true;
-
- bool shift_pressed = scroll_event->state & GDK_SHIFT_MASK;
-
- /* Rebuild list of items underneath the mouse pointer */
- Geom::Point p = desktop->d2w(desktop->point());
- SPItem *item = desktop->getItemAtPoint(p, true, NULL);
-
- // Save pointer to current cycle-item so that we can find it again later, in the freshly built list
- SPItem *tmp_cur_item = this->cycling_cur_item!=this->cycling_items.end() ? (*(this->cycling_cur_item)) : NULL;
- this->cycling_items.clear();
- this->cycling_cur_item = this->cycling_items.end();
- while(item != NULL) {
- this->cycling_items.push_back(item);
- item = desktop->getItemAtPoint(p, true, item);
- }
-
- /* Compare current item list with item list during previous scroll ... */
- bool item_lists_differ = this->cycling_items != this->cycling_items_cmp;
- /* If list of items under mouse pointer hasn't changed ... */
- if (!item_lists_differ) {
- // ... find current item in the freshly built list and continue cycling ...
- // TODO: This wouldn't be necessary if cycling_cur_item pointed to an element of cycling_items_cmp instead
- this->cycling_cur_item = std::find(this->cycling_items.begin(), this->cycling_items.end(), tmp_cur_item);
- g_assert(this->cycling_cur_item != this->cycling_items.end() || this->cycling_items.empty());
- } else {
- // ... otherwise reset opacities for outdated items ...
- Inkscape::DrawingItem *arenaitem;
-
- for (std::vector<SPItem *>::const_iterator l = this->cycling_items_cmp.begin(); l != this->cycling_items_cmp.end(); ++l) {
- SPItem *item = *l;
- if (item) {
- arenaitem = item->get_arenaitem(desktop->dkey);
- arenaitem->setOpacity(1.0);
- //if (!shift_pressed && !g_list_find(this->cycling_items_selected_before, item) && selection->includes(item))
- if (std::find(this->cycling_items_selected_before.begin(),this->cycling_items_selected_before.end(), item)==this->cycling_items_selected_before.end() && selection->includes(item)) {
- selection->remove(item);
- }
- }
- }
+ GdkEventScroll *scroll_event = (GdkEventScroll*) event;
- // ... clear the lists ...
+ if ( ! (scroll_event->state & GDK_MOD1_MASK)) // do nothing specific if alt was not pressed
+ break;
- this->cycling_items_cmp.clear();
- this->cycling_items_selected_before.clear();
- this->cycling_cur_item = this->cycling_items.end();
+ bool shift_pressed = scroll_event->state & GDK_SHIFT_MASK;
+ is_cycling = true;
- // ... and rebuild them with the new items.
- this->cycling_items_cmp = (this->cycling_items);
+ /* Rebuild list of items underneath the mouse pointer */
+ Geom::Point p = desktop->d2w(desktop->point());
+ SPItem *item = desktop->getItemAtPoint(p, true, NULL);
+ this->cycling_items.clear();
- for(std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l) {
- SPItem *item =*l;
- if (item) {
- arenaitem = item->get_arenaitem(desktop->dkey);
- arenaitem->setOpacity(0.3);
+ SPItem *tmp = NULL;
+ while(item != NULL) {
+ this->cycling_items.push_back(item);
+ item = desktop->getItemAtPoint(p, true, item);
+ if (selection->includes(item)) tmp = item;
+ }
- if (selection->includes(item)) {
- // already selected items are stored separately, too
- this->cycling_items_selected_before.push_back(item);
- }
- } else {
- g_assert_not_reached();
- }
+ /* Compare current item list with item list during previous scroll ... */
+ bool item_lists_differ = this->cycling_items != this->cycling_items_cmp;
+
+ if(item_lists_differ) {
+ this->sp_select_context_reset_opacities();
+ for (std::vector<SPItem *>::const_iterator l = this->cycling_items_cmp.begin(); l != this->cycling_items_cmp.end(); ++l)
+ selection->remove(*l); // deselects the previous content of the cycling loop
+ this->cycling_items_cmp = (this->cycling_items);
+
+ // set opacities in new stack
+ for(std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l) {
+ SPItem *item =*l;
+ if (item) {
+ Inkscape::DrawingItem *arenaitem = item->get_arenaitem(desktop->dkey);
+ arenaitem->setOpacity(0.3);
}
-
- // set the current item to the bottommost one so that the cycling step below re-starts at the top
- this->cycling_cur_item = this->cycling_items.end();
- this->cycling_cur_item--;
}
+ }
+ if(!cycling_cur_item) cycling_cur_item = tmp;
- this->cycling_wrap = prefs->getBool("/options/selection/cycleWrap", true);
+ this->cycling_wrap = prefs->getBool("/options/selection/cycleWrap", true);
- // Cycle through the items underneath the mouse pointer, one-by-one
- this->sp_select_context_cycle_through_items(selection, scroll_event, shift_pressed);
+ // Cycle through the items underneath the mouse pointer, one-by-one
+ this->sp_select_context_cycle_through_items(selection, scroll_event, shift_pressed);
- ret = TRUE;
+ ret = TRUE;
- GtkWindow *w =GTK_WINDOW(gtk_widget_get_toplevel( GTK_WIDGET(desktop->canvas) ));
- if (w)
- {
- gtk_window_present(w);
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- }
+ GtkWindow *w =GTK_WINDOW(gtk_widget_get_toplevel( GTK_WIDGET(desktop->canvas) ));
+ if (w) {
+ gtk_window_present(w);
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
}
break;
}
case GDK_KEY_PRESS: // keybindings for select context
- {
- {
- guint keyval = get_group0_keyval(&event->key);
-
+ {
+ {
+ guint keyval = get_group0_keyval(&event->key);
+
bool alt = ( MOD__ALT(event)
|| (keyval == GDK_KEY_Alt_L)
|| (keyval == GDK_KEY_Alt_R)
@@ -924,7 +881,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
// if Alt and nonempty selection, show moving cursor ("move selected"):
if (alt && !selection->isEmpty() && !desktop->isWaitingCursor()) {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
+ GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (desktop->getCanvas()));
gdk_window_set_cursor(window, CursorSelectDragging);
}
@@ -945,15 +902,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), mul*-10, 0); // shift
+ desktop->getSelection()->moveScreen(mul*-10, 0); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), mul*-1, 0); // no shift
+ desktop->getSelection()->moveScreen(mul*-1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), mul*-10*nudge, 0); // shift
+ desktop->getSelection()->move(mul*-10*nudge, 0); // shift
} else {
- sp_selection_move(desktop->getSelection(), mul*-nudge, 0); // no shift
+ desktop->getSelection()->move(mul*-nudge, 0); // no shift
}
}
@@ -968,15 +925,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*10); // shift
+ desktop->getSelection()->moveScreen(0, mul*10); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*1); // no shift
+ desktop->getSelection()->moveScreen(0, mul*1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), 0, mul*10*nudge); // shift
+ desktop->getSelection()->move(0, mul*10*nudge); // shift
} else {
- sp_selection_move(desktop->getSelection(), 0, mul*nudge); // no shift
+ desktop->getSelection()->move(0, mul*nudge); // no shift
}
}
@@ -991,15 +948,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), mul*10, 0); // shift
+ desktop->getSelection()->moveScreen(mul*10, 0); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), mul*1, 0); // no shift
+ desktop->getSelection()->moveScreen(mul*1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), mul*10*nudge, 0); // shift
+ desktop->getSelection()->move(mul*10*nudge, 0); // shift
} else {
- sp_selection_move(desktop->getSelection(), mul*nudge, 0); // no shift
+ desktop->getSelection()->move(mul*nudge, 0); // no shift
}
}
@@ -1014,15 +971,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*-10); // shift
+ desktop->getSelection()->moveScreen(0, mul*-10); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*-1); // no shift
+ desktop->getSelection()->moveScreen(0, mul*-1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), 0, mul*-10*nudge); // shift
+ desktop->getSelection()->move(0, mul*-10*nudge); // shift
} else {
- sp_selection_move(desktop->getSelection(), 0, mul*-nudge); // no shift
+ desktop->getSelection()->move(0, mul*-nudge); // no shift
}
}
@@ -1066,11 +1023,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketleft:
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_rotate_screen(selection, mul*1);
+ selection->rotateScreen(mul*1);
} else if (MOD__CTRL(event)) {
- sp_selection_rotate(selection, 90);
+ selection->rotate(90);
} else if (snaps) {
- sp_selection_rotate(selection, 180.0/snaps);
+ selection->rotate(180.0/snaps);
}
ret = TRUE;
@@ -1079,46 +1036,16 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketright:
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_rotate_screen(selection, -1*mul);
+ selection->rotateScreen(-1*mul);
} else if (MOD__CTRL(event)) {
- sp_selection_rotate(selection, -90);
+ selection->rotate(-90);
} else if (snaps) {
- sp_selection_rotate(selection, -180.0/snaps);
+ selection->rotate(-180.0/snaps);
}
ret = TRUE;
break;
-
- case GDK_KEY_less:
- case GDK_KEY_comma:
- if (MOD__ALT(event)) {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_scale_screen(selection, -2*mul);
- } else if (MOD__CTRL(event)) {
- sp_selection_scale_times(selection, 0.5);
- } else {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_scale(selection, -offset*mul);
- }
-
- ret = TRUE;
- break;
-
- case GDK_KEY_greater:
- case GDK_KEY_period:
- if (MOD__ALT(event)) {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_scale_screen(selection, 2*mul);
- } else if (MOD__CTRL(event)) {
- sp_selection_scale_times(selection, 2);
- } else {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_scale(selection, offset*mul);
- }
-
- ret = TRUE;
- break;
-
+
case GDK_KEY_Return:
if (MOD__CTRL_ONLY(event)) {
if (selection->singleItem()) {
@@ -1157,7 +1084,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
@@ -1166,7 +1093,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
break;
}
break;
- }
+ }
case GDK_KEY_RELEASE: {
guint keyval = get_group0_keyval(&event->key);
if (key_is_a_modifier (keyval)) {
@@ -1207,7 +1134,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = ToolBase::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h
index af183b1ca..420374661 100644
--- a/src/ui/tools/select-tool.h
+++ b/src/ui/tools/select-tool.h
@@ -42,8 +42,7 @@ public:
std::vector<SPItem *> cycling_items;
std::vector<SPItem *> cycling_items_cmp;
- std::vector<SPItem *> cycling_items_selected_before;
- std::vector<SPItem *>::iterator cycling_cur_item;
+ SPItem *cycling_cur_item;
bool cycling_wrap;
SPItem *item;
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 833fef18d..0ba08853e 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -14,8 +14,6 @@
* Released under GNU GPL
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include <cstring>
#include <string>
@@ -28,16 +26,13 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-spiral.xpm"
#include "ui/tools/spiral-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
#include "verbs.h"
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 9adaf3879..ad006627c 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -13,21 +13,19 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
* Jabiertxo Arraiza <jabier.arraiza@marker.es>
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <numeric>
#include "ui/dialog/dialog-manager.h"
#include "svg/svg.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -37,10 +35,7 @@
#include "message-context.h"
#include "pixmaps/cursor-spray.xpm"
-#include <boost/optional.hpp>
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
#include "splivarot.h"
@@ -57,17 +52,12 @@
#include "svg/svg-color.h"
#include "sp-text.h"
-#include "sp-root.h"
#include "sp-flowtext.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "display/curve.h"
#include "livarot/Shape.h"
#include <2geom/circle.h>
-#include <2geom/transforms.h>
-#include "preferences.h"
-#include "style.h"
#include "box3d.h"
#include "sp-item-transform.h"
#include "filter-chemistry.h"
@@ -76,9 +66,6 @@
#include "helper/action.h"
#include "verbs.h"
-#include <iostream>
-
-#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -196,6 +183,7 @@ SprayTool::SprayTool()
}
SprayTool::~SprayTool() {
+ object_set.clear();
this->enableGrDrag(false);
this->style_set_connection.disconnect();
@@ -210,7 +198,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -591,7 +579,7 @@ static bool fit_item(SPDesktop *desktop,
if (selection->isEmpty()) {
return false;
}
- std::vector<SPItem*> const items_selected(selection->itemList());
+ std::vector<SPItem*> const items_selected(selection->items().begin(), selection->items().end());
std::vector<SPItem*> items_down_erased;
for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) {
SPItem *item_down = *i;
@@ -862,7 +850,7 @@ static bool fit_item(SPDesktop *desktop,
}
static bool sp_spray_recursive(SPDesktop *desktop,
- Inkscape::Selection *selection,
+ Inkscape::ObjectSet *set,
SPItem *item,
Geom::Point p,
Geom::Point /*vector*/,
@@ -907,7 +895,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
if (box) {
// convert 3D boxes to ordinary groups before spraying their shapes
item = box3d_convert_to_group(box);
- selection->add(item);
+ set->add(item);
}
}
@@ -996,23 +984,11 @@ static bool sp_spray_recursive(SPDesktop *desktop,
}
#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
} else if (mode == SPRAY_MODE_SINGLE_PATH) {
+ long setSize = boost::distance(set->items());
+ SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object
+ SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union
+ SPItem *item_copied = nullptr; // Projected object
- SPItem *parent_item = NULL; // Initial object
- SPItem *item_copied = NULL; // Projected object
- SPItem *unionResult = NULL; // Previous union
-
- int i=1;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end(); ++it){
- SPItem *item1 = *it;
- if (i == 1) {
- parent_item = item1;
- }
- if (i == 2) {
- unionResult = item1;
- }
- i++;
- }
if (parent_item) {
SPDocument *doc = parent_item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
@@ -1045,13 +1021,13 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
// Union and duplication
- selection->clear();
- selection->add(item_copied);
+ set->clear();
+ set->add(item_copied);
if (unionResult) { // No need to add the very first item (initialized with NULL).
- selection->add(unionResult);
+ set->add(unionResult);
}
- sp_selected_path_union_skip_undo(selection, selection->desktop());
- selection->add(parent_item);
+ set->pathUnion(true);
+ set->add(parent_item);
Inkscape::GC::release(copy);
did = true;
}
@@ -1146,9 +1122,8 @@ static bool sp_spray_recursive(SPDesktop *desktop,
static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
SPDesktop *desktop = tc->desktop;
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
+ Inkscape::ObjectSet *set = tc->objectSet();
+ if (set->isEmpty()) {
return false;
}
@@ -1170,7 +1145,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
double move_standard_deviation = get_move_standard_deviation(tc);
{
- std::vector<SPItem*> const items(selection->itemList());
+ std::vector<SPItem*> const items(set->items().begin(), set->items().end());
for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
@@ -1182,7 +1157,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
SPItem *item = *i;
g_assert(item != NULL);
if (sp_spray_recursive(desktop
- , selection
+ , set
, item
, p, vector
, tc->mode
@@ -1276,6 +1251,11 @@ bool SprayTool::root_handler(GdkEvent* event) {
this->is_dilating = true;
this->has_dilated = false;
+ object_set = *desktop->getSelection();
+ if (mode == SPRAY_MODE_SINGLE_PATH) {
+ desktop->getSelection()->clear();
+ }
+
if(this->is_dilating && event->button.button == 1 && !this->space_panning) {
sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event));
}
@@ -1299,7 +1279,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
@@ -1384,6 +1364,8 @@ bool SprayTool::root_handler(GdkEvent* event) {
SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
break;
case SPRAY_MODE_SINGLE_PATH:
+ objectSet()->pathUnion(true);
+ desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end());
DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
break;
diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h
index c81110b37..d5504d565 100644
--- a/src/ui/tools/spray-tool.h
+++ b/src/ui/tools/spray-tool.h
@@ -13,6 +13,7 @@
* Vincent MONTAGNE
* Pierre BARBRY-BLOT
* Jabiertxo ARRAIZA
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
@@ -120,8 +121,14 @@ public:
virtual const std::string& getPrefsPath();
-
void update_cursor(bool /*with_shift*/);
+
+ ObjectSet* objectSet() {
+ return &object_set;
+ }
+
+private:
+ ObjectSet object_set;
};
}
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index 9190ae57b..ddee08189 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <cstring>
@@ -31,14 +31,11 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-star.xpm"
#include <glibmm/i18n.h>
-#include "preferences.h"
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 1888551cf..649bbb045 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -14,7 +14,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/clipboard.h>
@@ -23,7 +23,6 @@
#include <display/sp-ctrlquadr.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
-#include <sstream>
#include "context-fns.h"
@@ -36,7 +35,6 @@
#include "message-stack.h"
#include "pixmaps/cursor-text-insert.xpm"
#include "pixmaps/cursor-text.xpm"
-#include "preferences.h"
#include "rubberband.h"
#include "selection-chemistry.h"
#include "selection.h"
@@ -50,8 +48,8 @@
#include "ui/control-manager.h"
#include "verbs.h"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
-#include <gtk/gtk.h>
+#include "xml/attribute-record.h"
+#include "xml/sp-css-attr.h"
using Inkscape::ControlManager;
using Inkscape::DocumentUndo;
@@ -1361,6 +1359,59 @@ SPCSSAttr *sp_text_get_style_at_cursor(ToolBase const *ec)
return NULL;
}
+static bool css_attrs_are_equal(SPCSSAttr const *first, SPCSSAttr const *second)
+{
+ Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attrs = first->attributeList();
+ for ( ; attrs ; attrs++) {
+ gchar const *other_attr = second->attribute(g_quark_to_string(attrs->key));
+ if (other_attr == NULL || strcmp(attrs->value, other_attr))
+ return false;
+ }
+ attrs = second->attributeList();
+ for ( ; attrs ; attrs++) {
+ gchar const *other_attr = first->attribute(g_quark_to_string(attrs->key));
+ if (other_attr == NULL || strcmp(attrs->value, other_attr))
+ return false;
+ }
+ return true;
+}
+
+std::vector<SPCSSAttr*> sp_text_get_selected_style(ToolBase const *ec, unsigned *k, int *b, std::vector<unsigned> *positions)
+{
+ std::vector<SPCSSAttr*> vec;
+ SPCSSAttr *css, *css_new;
+ TextTool *tc = SP_TEXT_CONTEXT(ec);
+ Inkscape::Text::Layout::iterator i = std::min(tc->text_sel_start, tc->text_sel_end);
+ SPObject const *obj = sp_te_object_at_position(tc->text, i);
+ if (obj) {
+ css = take_style_from_item(const_cast<SPObject*>(obj));
+ }
+ vec.push_back(css);
+ positions->push_back(0);
+ i.nextCharacter();
+ *k = 1;
+ *b = 1;
+ while (i != std::max(tc->text_sel_start, tc->text_sel_end))
+ {
+ obj = sp_te_object_at_position(tc->text, i);
+ if (obj) {
+ css_new = take_style_from_item(const_cast<SPObject*>(obj));
+ }
+ if(!css_attrs_are_equal(css, css_new))
+ {
+ vec.push_back(css_new);
+ css = sp_repr_css_attr_new();
+ sp_repr_css_merge(css, css_new);
+ positions->push_back(*k);
+ (*b)++;
+ }
+ i.nextCharacter();
+ (*k)++;
+ }
+ positions->push_back(*k);
+ return vec;
+}
+
/**
Deletes the currently selected characters. Returns false if there is no
text selection currently.
@@ -1446,7 +1497,6 @@ bool TextTool::_styleSet(SPCSSAttr const *css)
_("Set text style"));
sp_text_context_update_cursor(this);
sp_text_context_update_text_selection(this);
-
return true;
}
diff --git a/src/ui/tools/text-tool.h b/src/ui/tools/text-tool.h
index 289ee180d..f2e6fea1a 100644
--- a/src/ui/tools/text-tool.h
+++ b/src/ui/tools/text-tool.h
@@ -94,6 +94,7 @@ private:
bool sp_text_paste_inline(ToolBase *ec);
Glib::ustring sp_text_get_selected_text(ToolBase const *ec);
SPCSSAttr *sp_text_get_style_at_cursor(ToolBase const *ec);
+std::vector<SPCSSAttr*> sp_text_get_selected_style(ToolBase const *ec, unsigned *k, int *b, std::vector<unsigned> *positions);
bool sp_text_delete_selection(ToolBase *ec);
void sp_text_context_place_cursor (TextTool *tc, SPObject *text, Inkscape::Text::Layout::iterator where);
void sp_text_context_place_cursor_at (TextTool *tc, SPObject *text, Geom::Point const p);
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 36fe26e76..3d755eadc 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -15,23 +15,28 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "widgets/desktop-widget.h"
#include "shortcuts.h"
#include "file.h"
+
+#include "ui/interface.h"
+#include "ui/event-debug.h"
+#include "ui/tool/control-point.h"
+#include "ui/shape-editor.h"
#include "ui/tools/tool-base.h"
+#include "ui/tools-switch.h"
+#include "ui/tools/lpe-tool.h"
-#include <string.h>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
#include <glibmm/i18n.h>
-#include <cstring>
-#include <string>
#include "display/sp-canvas.h"
+#include "display/sp-canvas-group.h"
+#include "display/canvas-rotate.h"
#include "xml/node-event-vector.h"
#include "sp-cursor.h"
#include "desktop.h"
@@ -40,21 +45,12 @@
#include "desktop-style.h"
#include "sp-namedview.h"
#include "selection.h"
-#include "ui/interface.h"
#include "macros.h"
-#include "ui/tools-switch.h"
-#include "preferences.h"
#include "message-context.h"
#include "gradient-drag.h"
-#include "attributes.h"
#include "rubberband.h"
#include "selcue.h"
-#include "ui/tools/lpe-tool.h"
-#include "ui/tool/control-point.h"
-#include "ui/shape-editor.h"
#include "sp-guide.h"
-#include "color.h"
-#include "knot.h"
#include "knot-ptr.h"
// globals for temporary switching to selector by space
@@ -118,11 +114,7 @@ ToolBase::~ToolBase() {
}
if (this->cursor != NULL) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
this->cursor = NULL;
}
@@ -149,16 +141,10 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
GdkDisplay *display = gdk_display_get_default();
GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type);
-#if WITH_GTKMM_3_0
if (cursor) {
gdk_window_set_cursor (gtk_widget_get_window (w), cursor);
g_object_unref (cursor);
}
-#else
- gdk_window_set_cursor (gtk_widget_get_window (w), cursor);
- gdk_cursor_unref (cursor);
-#endif
-
}
/**
@@ -188,11 +174,7 @@ void ToolBase::sp_event_context_update_cursor() {
);
if (pixbuf != NULL) {
if (this->cursor) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
}
this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y);
g_object_unref(pixbuf);
@@ -202,11 +184,7 @@ void ToolBase::sp_event_context_update_cursor() {
if (pixbuf) {
if (this->cursor) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
}
this->cursor = gdk_cursor_new_from_pixbuf(display,
pixbuf, this->hot_x, this->hot_y);
@@ -349,6 +327,8 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration,
}
bool ToolBase::root_handler(GdkEvent* event) {
+
+ // ui_dump_event (event, "ToolBase::root_handler");
static Geom::Point button_w;
static unsigned int panning = 0;
static unsigned int panning_cursor = 0;
@@ -400,7 +380,22 @@ bool ToolBase::root_handler(GdkEvent* event) {
break;
case 2:
- if (event->button.state & GDK_SHIFT_MASK) {
+ if (event->button.state & GDK_CONTROL_MASK) {
+ // On screen canvas rotation preview
+
+ // Grab background before doing anything else
+ sp_canvas_rotate_start (SP_CANVAS_ROTATE(desktop->canvas_rotate),
+ desktop->canvas->_backing_store);
+ sp_canvas_item_ungrab (desktop->acetate, event->button.time);
+ sp_canvas_item_show (desktop->canvas_rotate);
+ sp_canvas_item_grab (desktop->canvas_rotate,
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL, event->button.time );
+ // sp_canvas_item_hide (desktop->drawing);
+
+ } else if (event->button.state & GDK_SHIFT_MASK) {
zoom_rb = 2;
} else {
// When starting panning, make sure there are no snap events pending because these might disable the panning again
@@ -410,9 +405,9 @@ bool ToolBase::root_handler(GdkEvent* event) {
panning = 2;
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK, NULL,
- event->button.time - 1);
+ GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK,
+ NULL, event->button.time - 1);
}
@@ -491,7 +486,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
Geom::Point const motion_w(event->motion.x, event->motion.y);
Geom::Point const moved_w(motion_w - button_w);
- this->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
+ this->desktop->scroll_relative(moved_w, true); // we're still scrolling, do not redraw
ret = TRUE;
}
} else if (zoom_rb) {
@@ -522,6 +517,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
break;
case GDK_BUTTON_RELEASE:
+
xp = yp = 0;
if (panning_cursor == 1) {
@@ -562,7 +558,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
Geom::Point const motion_w(event->button.x, event->button.y);
Geom::Point const moved_w(motion_w - button_w);
- this->desktop->scroll_world(moved_w);
+ this->desktop->scroll_relative(moved_w);
desktop->updateNow();
ret = TRUE;
} else if (zoom_rb == event->button.button) {
@@ -639,7 +635,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
- this->desktop->scroll_world(i, 0);
+ this->desktop->scroll_relative(Geom::Point(i, 0));
ret = TRUE;
}
break;
@@ -652,7 +648,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
- this->desktop->scroll_world(0, i);
+ this->desktop->scroll_relative(Geom::Point(0, i));
ret = TRUE;
}
break;
@@ -665,7 +661,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
- this->desktop->scroll_world(-i, 0);
+ this->desktop->scroll_relative(Geom::Point(-i, 0));
ret = TRUE;
}
break;
@@ -678,7 +674,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
acceleration, desktop->getCanvas()));
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
- this->desktop->scroll_world(0, -i);
+ this->desktop->scroll_relative(Geom::Point(0, -i));
ret = TRUE;
}
break;
@@ -772,34 +768,60 @@ bool ToolBase::root_handler(GdkEvent* event) {
case GDK_SCROLL: {
bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
+ bool shift = (event->scroll.state & GDK_SHIFT_MASK);
bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
int const wheel_scroll = prefs->getIntLimited(
"/options/wheelscroll/value", 40, 0, 1000);
-#if GTK_CHECK_VERSION(3,0,0)
// Size of smooth-scrolls (only used in GTK+ 3)
gdouble delta_x = 0;
gdouble delta_y = 0;
-#endif
- /* shift + wheel, pan left--right */
- if (event->scroll.state & GDK_SHIFT_MASK) {
+ if (ctrl & shift) {
+ /* ctrl + shift, rotate */
+
+ double rotate_inc = prefs->getDoubleLimited(
+ "/options/rotateincrement/value", 15, 1, 90, "°" );
+ rotate_inc *= M_PI/180.0;
+
switch (event->scroll.direction) {
case GDK_SCROLL_UP:
- desktop->scroll_world(wheel_scroll, 0);
+ // Do nothing
break;
case GDK_SCROLL_DOWN:
- desktop->scroll_world(-wheel_scroll, 0);
+ rotate_inc = -rotate_inc;
+ break;
+
+ default:
+ rotate_inc = 0.0;
+ break;
+ }
+
+ if (rotate_inc != 0.0) {
+ Geom::Point const scroll_dt = desktop->point();
+ desktop->rotate_relative_keep_point(scroll_dt, rotate_inc);
+ }
+
+ } else if (event->scroll.state & GDK_SHIFT_MASK) {
+ /* shift + wheel, pan left--right */
+
+ switch (event->scroll.direction) {
+ case GDK_SCROLL_UP:
+ desktop->scroll_relative(Geom::Point(wheel_scroll, 0));
+ break;
+
+ case GDK_SCROLL_DOWN:
+ desktop->scroll_relative(Geom::Point(-wheel_scroll, 0));
break;
default:
break;
}
- /* ctrl + wheel, zoom in--out */
} else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
+ /* ctrl + wheel, zoom in--out */
double rel_zoom;
double const zoom_inc = prefs->getDoubleLimited(
"/options/zoomincrement/value", M_SQRT2, 1.01, 10);
@@ -827,27 +849,25 @@ bool ToolBase::root_handler(GdkEvent* event) {
} else {
switch (event->scroll.direction) {
case GDK_SCROLL_UP:
- desktop->scroll_world(0, wheel_scroll);
+ desktop->scroll_relative(Geom::Point(0, wheel_scroll));
break;
case GDK_SCROLL_DOWN:
- desktop->scroll_world(0, -wheel_scroll);
+ desktop->scroll_relative(Geom::Point(0, -wheel_scroll));
break;
case GDK_SCROLL_LEFT:
- desktop->scroll_world(wheel_scroll, 0);
+ desktop->scroll_relative(Geom::Point(wheel_scroll, 0));
break;
case GDK_SCROLL_RIGHT:
- desktop->scroll_world(-wheel_scroll, 0);
+ desktop->scroll_relative(Geom::Point(-wheel_scroll, 0));
break;
-#if GTK_CHECK_VERSION(3,0,0)
case GDK_SCROLL_SMOOTH:
gdk_event_get_scroll_deltas(event, &delta_x, &delta_y);
- desktop->scroll_world(delta_x, delta_y);
+ desktop->scroll_relative(Geom::Point(delta_x, delta_y));
break;
-#endif
}
}
break;
@@ -1081,9 +1101,8 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
item = sp_event_context_find_item (desktop,
Geom::Point(event->button.x, event->button.y), FALSE, FALSE);
- /* fixme: This is not what I want but works for now (Lauris) */
- if (event->type == GDK_KEY_PRESS) {
- item = desktop->getSelection()->singleItem();
+ if (event->type == GDK_KEY_PRESS && !desktop->getSelection()->isEmpty()) {
+ item = desktop->getSelection()->items().front();
}
ContextMenu* CM = new ContextMenu(desktop, item);
@@ -1157,8 +1176,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p,
SPItem *item = 0;
if (select_under) {
- SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(
- desktop->selection->itemList(), p);
+ auto tmp = desktop->selection->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(vec, p);
item = desktop->getItemAtPoint(p, into_groups, selected_at_point);
if (item == NULL) { // we may have reached bottom, flip over to the top
item = desktop->getItemAtPoint(p, into_groups, NULL);
@@ -1189,47 +1209,6 @@ sp_event_context_get_shape_editor(ToolBase *ec) {
return ec->shape_editor;
}
-void event_context_print_event_info(GdkEvent *event, bool print_return) {
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- g_print("GDK_BUTTON_PRESS");
- break;
- case GDK_2BUTTON_PRESS:
- g_print("GDK_2BUTTON_PRESS");
- break;
- case GDK_3BUTTON_PRESS:
- g_print("GDK_3BUTTON_PRESS");
- break;
-
- case GDK_MOTION_NOTIFY:
- g_print("GDK_MOTION_NOTIFY");
- break;
- case GDK_ENTER_NOTIFY:
- g_print("GDK_ENTER_NOTIFY");
- break;
-
- case GDK_LEAVE_NOTIFY:
- g_print("GDK_LEAVE_NOTIFY");
- break;
- case GDK_BUTTON_RELEASE:
- g_print("GDK_BUTTON_RELEASE");
- break;
-
- case GDK_KEY_PRESS:
- g_print("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key));
- break;
- case GDK_KEY_RELEASE:
- g_print("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key));
- break;
- default:
- //g_print ("even type not recognized");
- break;
- }
-
- if (print_return) {
- g_print("\n");
- }
-}
/**
* Analyses the current event, calculates the mouse speed, turns snapping off (temporarily) if the
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index 58eb6f88e..3d22fc66f 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -176,6 +176,7 @@ public:
ShapeEditor* shape_editor;
bool space_panning;
+ bool rotating_mode;
DelayedSnapEvent *_delayed_snap_event;
bool _dse_callback_in_process;
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 39a7a3f0b..ff5d623c2 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -11,8 +11,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -21,7 +19,6 @@
#include "svg/svg.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -48,34 +45,27 @@
#include "pixmaps/cursor-push.xpm"
#include "pixmaps/cursor-roughen.xpm"
#include "pixmaps/cursor-color.xpm"
-#include <boost/optional.hpp>
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
-#include "color.h"
-#include "svg/svg-color.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "path-chemistry.h"
-#include "sp-gradient.h"
#include "sp-stop.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
+#include "sp-mesh-gradient.h"
+#include "sp-mesh-array.h"
#include "gradient-chemistry.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "display/curve.h"
#include "livarot/Shape.h"
-#include <2geom/transforms.h>
#include <2geom/circle.h>
-#include "preferences.h"
#include "style.h"
#include "box3d.h"
#include "sp-item-transform.h"
@@ -153,7 +143,7 @@ void TweakTool::update_cursor (bool with_shift) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -385,9 +375,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
GSList *children = NULL;
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) {
- children = g_slist_prepend(children, child);
+ for (auto& child: item->children) {
+ if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) {
+ children = g_slist_prepend(children, &child);
}
}
@@ -773,112 +763,132 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
p *= (gradient->gradientTransform).inverse();
// now p is in gradient's original coordinates
- double pos = 0;
- double r = 0;
-
SPLinearGradient *lg = dynamic_cast<SPLinearGradient *>(gradient);
- if (lg) {
- Geom::Point p1(lg->x1.computed, lg->y1.computed);
- Geom::Point p2(lg->x2.computed, lg->y2.computed);
- Geom::Point pdiff(p2 - p1);
- double vl = Geom::L2(pdiff);
+ SPRadialGradient *rg = dynamic_cast<SPRadialGradient *>(gradient);
+ if (lg || rg) {
- // This is the matrix which moves and rotates the gradient line
- // so it's oriented along the X axis:
- Geom::Affine norm = Geom::Affine(Geom::Translate(-p1)) * Geom::Affine(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X])));
+ double pos = 0;
+ double r = 0;
- // Transform the mouse point by it to find out its projection onto the gradient line:
- Geom::Point pnorm = p * norm;
+ if (lg) {
+ Geom::Point p1(lg->x1.computed, lg->y1.computed);
+ Geom::Point p2(lg->x2.computed, lg->y2.computed);
+ Geom::Point pdiff(p2 - p1);
+ double vl = Geom::L2(pdiff);
- // Scale its X coordinate to match the length of the gradient line:
- pos = pnorm[Geom::X] / vl;
- // Calculate radius in lenfth-of-gradient-line units
- r = radius / vl;
+ // This is the matrix which moves and rotates the gradient line
+ // so it's oriented along the X axis:
+ Geom::Affine norm = Geom::Affine(Geom::Translate(-p1)) *
+ Geom::Affine(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X])));
- } else {
- SPRadialGradient *rg = dynamic_cast<SPRadialGradient *>(gradient);
+ // Transform the mouse point by it to find out its projection onto the gradient line:
+ Geom::Point pnorm = p * norm;
+
+ // Scale its X coordinate to match the length of the gradient line:
+ pos = pnorm[Geom::X] / vl;
+ // Calculate radius in lenfth-of-gradient-line units
+ r = radius / vl;
+
+ }
if (rg) {
Geom::Point c (rg->cx.computed, rg->cy.computed);
pos = Geom::L2(p - c) / rg->r.computed;
r = radius / rg->r.computed;
}
- }
- // Normalize pos to 0..1, taking into accound gradient spread:
- double pos_e = pos;
- if (gradient->getSpread() == SP_GRADIENT_SPREAD_PAD) {
- if (pos > 1) {
- pos_e = 1;
- }
- if (pos < 0) {
- pos_e = 0;
- }
- } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REPEAT) {
- if (pos > 1 || pos < 0) {
- pos_e = pos - floor(pos);
- }
- } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REFLECT) {
- if (pos > 1 || pos < 0) {
- bool odd = ((int)(floor(pos)) % 2 == 1);
- pos_e = pos - floor(pos);
- if (odd) {
- pos_e = 1 - pos_e;
+ // Normalize pos to 0..1, taking into accound gradient spread:
+ double pos_e = pos;
+ if (gradient->getSpread() == SP_GRADIENT_SPREAD_PAD) {
+ if (pos > 1) {
+ pos_e = 1;
+ }
+ if (pos < 0) {
+ pos_e = 0;
+ }
+ } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REPEAT) {
+ if (pos > 1 || pos < 0) {
+ pos_e = pos - floor(pos);
+ }
+ } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REFLECT) {
+ if (pos > 1 || pos < 0) {
+ bool odd = ((int)(floor(pos)) % 2 == 1);
+ pos_e = pos - floor(pos);
+ if (odd) {
+ pos_e = 1 - pos_e;
+ }
}
}
- }
- SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false);
+ SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false);
- double offset_l = 0;
- double offset_h = 0;
- SPObject *child_prev = NULL;
- for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- SPStop *stop = dynamic_cast<SPStop *>(child);
- if (!stop) {
- continue;
- }
+ double offset_l = 0;
+ double offset_h = 0;
+ SPObject *child_prev = NULL;
+ for (auto& child: vector->children) {
+ SPStop *stop = dynamic_cast<SPStop *>(&child);
+ if (!stop) {
+ continue;
+ }
- offset_h = stop->offset;
-
- if (child_prev) {
- SPStop *prevStop = dynamic_cast<SPStop *>(child_prev);
- g_assert(prevStop != NULL);
-
- if (offset_h - offset_l > r && pos_e >= offset_l && pos_e <= offset_h) {
- // the summit falls in this interstop, and the radius is small,
- // so it only affects the ends of this interstop;
- // distribute the force between the two endstops so that they
- // get all the painting even if they are not touched by the brush
- tweak_color (mode, stop->specified_color.v.c, rgb_goal,
- force * (pos_e - offset_l) / (offset_h - offset_l),
- do_h, do_s, do_l);
- tweak_color(mode, prevStop->specified_color.v.c, rgb_goal,
- force * (offset_h - pos_e) / (offset_h - offset_l),
- do_h, do_s, do_l);
- stop->updateRepr();
- child_prev->updateRepr();
- break;
- } else {
- // wide brush, may affect more than 2 stops,
- // paint each stop by the force from the profile curve
- if (offset_l <= pos_e && offset_l > pos_e - r) {
+ offset_h = stop->offset;
+
+ if (child_prev) {
+ SPStop *prevStop = dynamic_cast<SPStop *>(child_prev);
+ g_assert(prevStop != NULL);
+
+ if (offset_h - offset_l > r && pos_e >= offset_l && pos_e <= offset_h) {
+ // the summit falls in this interstop, and the radius is small,
+ // so it only affects the ends of this interstop;
+ // distribute the force between the two endstops so that they
+ // get all the painting even if they are not touched by the brush
+ tweak_color (mode, stop->specified_color.v.c, rgb_goal,
+ force * (pos_e - offset_l) / (offset_h - offset_l),
+ do_h, do_s, do_l);
tweak_color(mode, prevStop->specified_color.v.c, rgb_goal,
- force * tweak_profile (fabs (pos_e - offset_l), r),
+ force * (offset_h - pos_e) / (offset_h - offset_l),
do_h, do_s, do_l);
+ stop->updateRepr();
child_prev->updateRepr();
+ break;
+ } else {
+ // wide brush, may affect more than 2 stops,
+ // paint each stop by the force from the profile curve
+ if (offset_l <= pos_e && offset_l > pos_e - r) {
+ tweak_color(mode, prevStop->specified_color.v.c, rgb_goal,
+ force * tweak_profile (fabs (pos_e - offset_l), r),
+ do_h, do_s, do_l);
+ child_prev->updateRepr();
+ }
+
+ if (offset_h >= pos_e && offset_h < pos_e + r) {
+ tweak_color (mode, stop->specified_color.v.c, rgb_goal,
+ force * tweak_profile (fabs (pos_e - offset_h), r),
+ do_h, do_s, do_l);
+ stop->updateRepr();
+ }
}
+ }
- if (offset_h >= pos_e && offset_h < pos_e + r) {
+ offset_l = offset_h;
+ child_prev = &child;
+ }
+ } else {
+ // Mesh
+ SPMeshGradient *mg = dynamic_cast<SPMeshGradient *>(gradient);
+ if (mg) {
+ SPMeshGradient *mg_array = dynamic_cast<SPMeshGradient *>(mg->getArray());
+ SPMeshNodeArray *array = &(mg_array->array);
+ // Every third node is a corner node
+ for( unsigned i=0; i < array->nodes.size(); i+=3 ) {
+ for( unsigned j=0; j < array->nodes[i].size(); j+=3 ) {
+ SPStop *stop = array->nodes[i][j]->stop;
+ double distance = Geom::L2(Geom::Point(p - array->nodes[i][j]->p));
tweak_color (mode, stop->specified_color.v.c, rgb_goal,
- force * tweak_profile (fabs (pos_e - offset_h), r),
- do_h, do_s, do_l);
+ force * tweak_profile (distance, radius), do_h, do_s, do_l);
stop->updateRepr();
}
}
}
-
- offset_l = offset_h;
- child_prev = child;
}
}
@@ -894,8 +904,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
bool did = false;
if (dynamic_cast<SPGroup *>(item)) {
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: item->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
if (sp_tweak_color_recursive (mode, childItem, item_at_point,
fill_goal, do_fill,
@@ -951,9 +961,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
Geom::Affine i2dt = item->i2dt_affine ();
if (style->filter.set && style->getFilter()) {
//cycle through filter primitives
- SPObject *primitive_obj = style->getFilter()->children;
- while (primitive_obj) {
- SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj);
+ for (auto& primitive_obj: style->getFilter()->children) {
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj);
if (primitive) {
//if primitive is gaussianblur
SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive);
@@ -962,7 +971,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
blur_now += num * i2dt.descrim(); // sum all blurs in the filter
}
}
- primitive_obj = primitive_obj->next;
}
}
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y];
@@ -1076,8 +1084,9 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point
double move_force = get_move_force(tc);
double color_force = MIN(sqrt(path_force)/20.0, 1);
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+// auto items= selection->items();
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ for(auto i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
if (is_color_mode (tc->mode)) {
@@ -1185,7 +1194,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak."));
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index 13e097c18..d40d2e969 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -21,7 +21,6 @@
#include "desktop.h"
#include "pixmaps/cursor-zoom.xpm"
#include "pixmaps/cursor-zoom-out.xpm"
-#include "preferences.h"
#include "selection-chemistry.h"
#include "ui/tools/zoom-tool.h"
@@ -104,12 +103,14 @@ bool ZoomTool::root_handler(GdkEvent* event) {
desktop->zoom_relative_keep_point(button_dt, zoom_rel);
ret = true;
}
-
- sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
- GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
- NULL, event->button.time);
- this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
+ NULL, event->button.time);
+
+ this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
break;
}
@@ -157,10 +158,10 @@ bool ZoomTool::root_handler(GdkEvent* event) {
Inkscape::Rubberband::get(desktop)->stop();
- if (this->grabbed) {
- sp_canvas_item_ungrab(this->grabbed, event->button.time);
- this->grabbed = NULL;
- }
+ if (this->grabbed) {
+ sp_canvas_item_ungrab(this->grabbed, event->button.time);
+ this->grabbed = NULL;
+ }
xp = yp = 0;
escaped = false;
diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp
index 036659661..c263eaded 100644
--- a/src/ui/uxmanager.cpp
+++ b/src/ui/uxmanager.cpp
@@ -10,30 +10,18 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "widgets/desktop-widget.h"
-#include <algorithm>
#include "uxmanager.h"
#include "desktop.h"
#include "util/ege-tags.h"
#include "widgets/toolbox.h"
-#include "preferences.h"
-#include "gdkmm/screen.h"
-
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#endif // GDK_WINDOWING_X11
using std::vector;
-
-gchar const* KDE_WINDOW_MANAGER_NAME = "KWin";
-gchar const* UNKOWN_WINDOW_MANAGER_NAME = "unknown";
-
-
class TrackItem
{
public:
@@ -100,11 +88,9 @@ public:
virtual gint getDefaultTask( SPDesktop *desktop );
virtual void setTask(SPDesktop* dt, gint val);
- virtual bool isFloatWindowProblem() const;
virtual bool isWidescreen() const;
private:
- bool _floatwindowIssues;
bool _widescreen;
};
@@ -126,7 +112,6 @@ UXManager::~UXManager()
}
UXManagerImpl::UXManagerImpl() :
- _floatwindowIssues(false),
_widescreen(false)
{
ege::TagSet tags;
@@ -135,19 +120,6 @@ UXManagerImpl::UXManagerImpl() :
tags.addTag(ege::Tag("General"));
tags.addTag(ege::Tag("Icons"));
-#if defined(GDK_WINDOWING_X11)
- char const* wmName = gdk_x11_screen_get_window_manager_name( gdk_screen_get_default() );
- //g_message("Window manager is [%s]", wmName);
-
- //if (g_ascii_strcasecmp( wmName, UNKOWN_WINDOW_MANAGER_NAME ) == 0) {
- if (g_ascii_strcasecmp( wmName, KDE_WINDOW_MANAGER_NAME ) == 0) {
- _floatwindowIssues = true;
- }
-#elif defined(GDK_WINDOWING_WIN32)
- _floatwindowIssues = true;
-#endif // GDK_WINDOWING_WIN32
-
-
Glib::RefPtr<Gdk::Screen> defaultScreen = Gdk::Screen::get_default();
if (defaultScreen) {
int width = defaultScreen->get_width();
@@ -163,11 +135,6 @@ UXManagerImpl::~UXManagerImpl()
{
}
-bool UXManagerImpl::isFloatWindowProblem() const
-{
- return _floatwindowIssues;
-}
-
bool UXManagerImpl::isWidescreen() const
{
return _widescreen;
diff --git a/src/ui/uxmanager.h b/src/ui/uxmanager.h
index 711703192..f91bde25e 100644
--- a/src/ui/uxmanager.h
+++ b/src/ui/uxmanager.h
@@ -35,7 +35,6 @@ public:
virtual gint getDefaultTask( SPDesktop *desktop ) = 0;
virtual void setTask( SPDesktop* dt, gint val ) = 0;
- virtual bool isFloatWindowProblem() const = 0;
virtual bool isWidescreen() const = 0;
protected:
diff --git a/src/ui/view/Makefile_insert b/src/ui/view/Makefile_insert
deleted file mode 100644
index b3ab598d4..000000000
--- a/src/ui/view/Makefile_insert
+++ /dev/null
@@ -1,9 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/view/edit-widget-interface.h \
- ui/view/view.h \
- ui/view/view.cpp \
- ui/view/view-widget.cpp \
- ui/view/view-widget.h
-
diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h
index fcba0c6da..c93b1f0ee 100644
--- a/src/ui/view/edit-widget-interface.h
+++ b/src/ui/view/edit-widget-interface.h
@@ -128,6 +128,9 @@ struct EditWidgetInterface
/// The zoom display will get the keyboard focus.
virtual void letZoomGrabFocus() = 0;
+ /// Temporarily block signals and update rotation display
+ virtual void updateRotation() = 0;
+
/// In auxiliary toolbox, set focus to widget having specific id
virtual void setToolboxFocusTo (const gchar *) = 0;
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
deleted file mode 100644
index eb98e6872..000000000
--- a/src/ui/widget/Makefile_insert
+++ /dev/null
@@ -1,110 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/widget/anchor-selector.h \
- ui/widget/anchor-selector.cpp \
- ui/widget/attr-widget.h \
- ui/widget/button.h \
- ui/widget/button.cpp \
- ui/widget/color-entry.cpp \
- ui/widget/color-entry.h \
- ui/widget/color-icc-selector.cpp \
- ui/widget/color-icc-selector.h \
- ui/widget/color-notebook.cpp \
- ui/widget/color-notebook.h \
- ui/widget/color-wheel-selector.cpp \
- ui/widget/color-wheel-selector.h \
- ui/widget/color-picker.cpp \
- ui/widget/color-picker.h \
- ui/widget/color-preview.cpp \
- ui/widget/color-preview.h \
- ui/widget/color-slider.cpp \
- ui/widget/color-slider.h \
- ui/widget/color-scales.cpp \
- ui/widget/color-scales.h \
- ui/widget/combo-enums.h \
- ui/widget/dock.h \
- ui/widget/dock.cpp \
- ui/widget/dock-item.h \
- ui/widget/dock-item.cpp \
- ui/widget/entity-entry.cpp \
- ui/widget/entity-entry.h \
- ui/widget/entry.cpp \
- ui/widget/entry.h \
- ui/widget/filter-effect-chooser.h \
- ui/widget/filter-effect-chooser.cpp \
- ui/widget/font-variants.h \
- ui/widget/font-variants.cpp \
- ui/widget/gimpspinscale.c \
- ui/widget/gimpspinscale.h \
- ui/widget/gimpcolorwheel.c \
- ui/widget/gimpcolorwheel.h \
- ui/widget/frame.cpp \
- ui/widget/frame.h \
- ui/widget/imageicon.cpp \
- ui/widget/imageicon.h \
- ui/widget/imagetoggler.cpp \
- ui/widget/imagetoggler.h \
- ui/widget/labelled.cpp \
- ui/widget/labelled.h \
- ui/widget/layer-selector.cpp \
- ui/widget/layer-selector.h \
- ui/widget/licensor.cpp \
- ui/widget/licensor.h \
- ui/widget/notebook-page.cpp \
- ui/widget/notebook-page.h \
- ui/widget/object-composite-settings.cpp \
- ui/widget/object-composite-settings.h \
- ui/widget/page-sizer.cpp \
- ui/widget/page-sizer.h \
- ui/widget/panel.cpp \
- ui/widget/panel.h \
- ui/widget/point.cpp \
- ui/widget/point.h \
- ui/widget/preferences-widget.cpp \
- ui/widget/preferences-widget.h \
- ui/widget/random.cpp \
- ui/widget/random.h \
- ui/widget/registered-widget.cpp \
- ui/widget/registered-widget.h \
- ui/widget/registered-enums.h \
- ui/widget/registry.cpp \
- ui/widget/registry.h \
- ui/widget/rendering-options.cpp \
- ui/widget/rendering-options.h \
- ui/widget/rotateable.h \
- ui/widget/rotateable.cpp \
- ui/widget/scalar-unit.cpp \
- ui/widget/scalar-unit.h \
- ui/widget/scalar.cpp \
- ui/widget/scalar.h \
- ui/widget/selected-style.h \
- ui/widget/selected-style.cpp \
- ui/widget/spinbutton.h \
- ui/widget/spinbutton.cpp \
- ui/widget/spin-scale.h \
- ui/widget/spin-scale.cpp \
- ui/widget/spin-slider.h \
- ui/widget/spin-slider.cpp \
- ui/widget/style-subject.h \
- ui/widget/style-subject.cpp \
- ui/widget/style-swatch.h \
- ui/widget/style-swatch.cpp \
- ui/widget/text.cpp \
- ui/widget/text.h \
- ui/widget/tolerance-slider.cpp \
- ui/widget/tolerance-slider.h \
- ui/widget/unit-menu.cpp \
- ui/widget/unit-menu.h \
- ui/widget/unit-tracker.h \
- ui/widget/unit-tracker.cpp \
- ui/widget/clipmaskicon.cpp \
- ui/widget/clipmaskicon.h \
- ui/widget/highlight-picker.cpp \
- ui/widget/highlight-picker.h \
- ui/widget/layertypeicon.cpp \
- ui/widget/layertypeicon.h \
- ui/widget/insertordericon.cpp \
- ui/widget/insertordericon.h \
- ui/widget/addtoicon.cpp \
- ui/widget/addtoicon.h
diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp
index 10294125d..70516ed00 100644
--- a/src/ui/widget/addtoicon.cpp
+++ b/src/ui/widget/addtoicon.cpp
@@ -9,7 +9,7 @@
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "ui/widget/addtoicon.h"
@@ -19,9 +19,7 @@
#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
-#include "preferences.h"
#include "layertypeicon.h"
-#include "addtoicon.h"
namespace Inkscape {
namespace UI {
@@ -51,8 +49,6 @@ AddToIcon::AddToIcon() :
set_pixbuf();
}
-
-#if WITH_GTKMM_3_0
void AddToIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -82,47 +78,16 @@ void AddToIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void AddToIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void AddToIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void AddToIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
set_pixbuf();
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool AddToIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h
index a8d900d1f..3b2228754 100644
--- a/src/ui/widget/addtoicon.h
+++ b/src/ui/widget/addtoicon.h
@@ -31,8 +31,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -46,18 +44,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp
index df00b786a..087e7375e 100644
--- a/src/ui/widget/anchor-selector.cpp
+++ b/src/ui/widget/anchor-selector.cpp
@@ -8,7 +8,6 @@
*/
#include "ui/widget/anchor-selector.h"
-#include <iostream>
#include "widgets/icon.h"
#include "ui/icon-names.h"
@@ -28,11 +27,7 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b
AnchorSelector::AnchorSelector()
: Gtk::Alignment(0.5, 0, 0, 0),
-#if WITH_GTKMM_3_0
_container()
-#else
- _container(3, 3, true)
-#endif
{
setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]);
setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]);
@@ -44,20 +39,14 @@ AnchorSelector::AnchorSelector()
setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]);
setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]);
-#if WITH_GTKMM_3_0
_container.set_row_homogeneous();
_container.set_column_homogeneous(true);
-#endif
for(int i = 0; i < 9; ++i) {
_buttons[i].signal_clicked().connect(
sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i));
-#if WITH_GTKMM_3_0
_container.attach(_buttons[i], i % 3, i / 3, 1, 1);
-#else
- _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL);
-#endif
}
_selection = 4;
_buttons[4].set_active();
diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h
index 0a702d296..96331fae3 100644
--- a/src/ui/widget/anchor-selector.h
+++ b/src/ui/widget/anchor-selector.h
@@ -16,12 +16,7 @@
#include <gtkmm/alignment.h>
#include <gtkmm/togglebutton.h>
-
-#if WITH_GTKMM_3_0
- #include <gtkmm/grid.h>
-#else
- #include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
namespace Inkscape {
namespace UI {
@@ -32,12 +27,7 @@ class AnchorSelector : public Gtk::Alignment
private:
Gtk::ToggleButton _buttons[9];
int _selection;
-
-#if WITH_GTKMM_3_0
Gtk::Grid _container;
-#else
- Gtk::Table _container;
-#endif
sigc::signal<void> _selectionChanged;
diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp
index 421f1df1e..a1e3eaf82 100644
--- a/src/ui/widget/clipmaskicon.cpp
+++ b/src/ui/widget/clipmaskicon.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "ui/widget/clipmaskicon.h"
@@ -27,13 +27,13 @@ namespace Widget {
ClipMaskIcon::ClipMaskIcon() :
Glib::ObjectBase(typeid(ClipMaskIcon)),
Gtk::CellRendererPixbuf(),
- _pixClipName(INKSCAPE_ICON("path-intersection")),
- _pixInverseName(INKSCAPE_ICON("path-difference")),
- _pixMaskName(INKSCAPE_ICON("mask-intersection")),
+ _pixClipName(INKSCAPE_ICON("path-cut")),
+ _pixMaskName(INKSCAPE_ICON("path-difference")),
+ _pixBothName(INKSCAPE_ICON("bitmap-trace")),
_property_active(*this, "active", 0),
_property_pixbuf_clip(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)),
- _property_pixbuf_inverse(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)),
- _property_pixbuf_mask(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0))
+ _property_pixbuf_mask(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0)),
+ _property_pixbuf_both(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0))
{
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
@@ -43,28 +43,26 @@ ClipMaskIcon::ClipMaskIcon() :
if (!icon_theme->has_icon(_pixClipName)) {
Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixClipName.data()), Inkscape::ICON_SIZE_DECORATION );
}
- if (!icon_theme->has_icon(_pixInverseName)) {
- Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixInverseName.data()), Inkscape::ICON_SIZE_DECORATION );
- }
if (!icon_theme->has_icon(_pixMaskName)) {
Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixMaskName.data()), Inkscape::ICON_SIZE_DECORATION );
}
+ if (!icon_theme->has_icon(_pixBothName)) {
+ Inkscape::queueIconPrerender( INKSCAPE_ICON(_pixBothName.data()), Inkscape::ICON_SIZE_DECORATION );
+ }
if (icon_theme->has_icon(_pixClipName)) {
_property_pixbuf_clip = icon_theme->load_icon(_pixClipName, phys, (Gtk::IconLookupFlags)0);
}
- if (icon_theme->has_icon(_pixInverseName)) {
- _property_pixbuf_inverse = icon_theme->load_icon(_pixInverseName, phys, (Gtk::IconLookupFlags)0);
- }
if (icon_theme->has_icon(_pixMaskName)) {
_property_pixbuf_mask = icon_theme->load_icon(_pixMaskName, phys, (Gtk::IconLookupFlags)0);
}
+ if (icon_theme->has_icon(_pixBothName)) {
+ _property_pixbuf_both = icon_theme->load_icon(_pixBothName, phys, (Gtk::IconLookupFlags)0);
+ }
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
}
-
-#if WITH_GTKMM_3_0
void ClipMaskIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -94,39 +92,12 @@ void ClipMaskIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void ClipMaskIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-
-#if WITH_GTKMM_3_0
void ClipMaskIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
switch (_property_active.get_value())
{
@@ -137,17 +108,13 @@ void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
property_pixbuf() = _property_pixbuf_mask;
break;
case 3:
- property_pixbuf() = _property_pixbuf_inverse;
+ property_pixbuf() = _property_pixbuf_both;
break;
default:
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
break;
}
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool ClipMaskIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/clipmaskicon.h b/src/ui/widget/clipmaskicon.h
index eca852a83..deb4554df 100644
--- a/src/ui/widget/clipmaskicon.h
+++ b/src/ui/widget/clipmaskicon.h
@@ -32,7 +32,6 @@ public:
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -46,18 +45,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
@@ -71,13 +58,13 @@ private:
int phys;
Glib::ustring _pixClipName;
- Glib::ustring _pixInverseName;
Glib::ustring _pixMaskName;
+ Glib::ustring _pixBothName;
Glib::Property<int> _property_active;
Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_clip;
- Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_inverse;
Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_mask;
+ Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_both;
};
diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp
index b422892fe..616e9afa8 100644
--- a/src/ui/widget/color-icc-selector.cpp
+++ b/src/ui/widget/color-icc-selector.cpp
@@ -2,14 +2,10 @@
#include "config.h"
#endif
-#include <math.h>
#include <gtkmm/adjustment.h>
#include <glibmm/i18n.h>
-#include <gtk/gtk.h>
-#include <map>
#include <set>
-#include <vector>
#include "ui/dialog-events.h"
#include "ui/widget/color-icc-selector.h"
@@ -87,7 +83,6 @@ GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs)
void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height,
bool hexpand = false, bool centered = false, guint xpadding = XPAD, guint ypadding = YPAD)
{
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(child, xpadding);
gtk_widget_set_margin_end(child, xpadding);
@@ -106,14 +101,6 @@ void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint
gtk_widget_set_valign(child, GTK_ALIGN_CENTER);
}
gtk_grid_attach(GTK_GRID(parent), child, left, top, width, height);
-#else
- GtkAttachOptions xoptions =
- centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL;
- GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL;
-
- gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding,
- ypadding);
-#endif
}
} // namespace
@@ -431,12 +418,7 @@ void ColorICCSelector::init()
_impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str());
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5);
-#endif
-
gtk_widget_show(_impl->_compUI[i]._label);
gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE);
@@ -495,12 +477,7 @@ void ColorICCSelector::init()
// Label
_impl->_label = gtk_label_new_with_mnemonic(_("_A:"));
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5);
-#endif
-
gtk_widget_show(_impl->_label);
attachToGridOrTable(t, _impl->_label, 0, row, 1, 1);
@@ -633,9 +610,10 @@ void ColorICCSelectorImpl::_switchToProfile(gchar const *name)
#endif // DEBUG_LCMS
tmp.set(SP_RGBA32_U_COMPOSE(pre[0], pre[1], pre[2], 0xff));
}
+
+ dirty = true;
}
}
- dirty = true;
}
}
else {
@@ -726,11 +704,7 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const & /*name*/) {}
void ColorICCSelector::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_colorChanged();
}
diff --git a/src/ui/widget/color-icc-selector.h b/src/ui/widget/color-icc-selector.h
index 1bcb0a540..aaa8372b8 100644
--- a/src/ui/widget/color-icc-selector.h
+++ b/src/ui/widget/color-icc-selector.h
@@ -6,11 +6,7 @@
#endif
#include <gtkmm/widget.h>
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -24,11 +20,7 @@ namespace Widget {
class ColorICCSelectorImpl;
class ColorICCSelector
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *MODE_NAME;
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp
index 6d7ada734..33e22b59d 100644
--- a/src/ui/widget/color-notebook.cpp
+++ b/src/ui/widget/color-notebook.cpp
@@ -20,10 +20,6 @@
#endif
#include "widgets/icon.h"
-#include <cstring>
-#include <string>
-#include <cstdlib>
-#include <cstddef>
#include <glibmm/i18n.h>
#include <gtkmm/label.h>
#include <gtkmm/notebook.h>
@@ -56,13 +52,8 @@ namespace Widget {
ColorNotebook::ColorNotebook(SelectedColor &color)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(2, 3, false)
-#endif
, _selected_color(color)
-
{
Page *page;
@@ -110,12 +101,8 @@ void ColorNotebook::_initUI()
notebook->set_show_tabs(false);
_book = GTK_WIDGET(notebook->gobj());
-#if GTK_CHECK_VERSION(3, 0, 0)
_buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE);
-#else
- _buttonbox = gtk_hbox_new(TRUE, 2);
-#endif
gtk_widget_show(_buttonbox);
_buttons = new GtkWidget *[_available_pages.size()];
@@ -126,7 +113,6 @@ void ColorNotebook::_initUI()
sp_set_font_size_smaller(_buttonbox);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_buttonbox, XPAD);
gtk_widget_set_margin_end(_buttonbox, XPAD);
@@ -139,14 +125,9 @@ void ColorNotebook::_initUI()
gtk_widget_set_hexpand(_buttonbox, TRUE);
gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER);
attach(*Glib::wrap(_buttonbox), 0, row, 2, 1);
-#else
- attach(*Glib::wrap(_buttonbox), 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, static_cast<Gtk::AttachOptions>(0),
- XPAD, YPAD);
-#endif
row++;
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_book, XPAD * 2);
gtk_widget_set_margin_end(_book, XPAD * 2);
@@ -159,20 +140,13 @@ void ColorNotebook::_initUI()
gtk_widget_set_hexpand(_book, TRUE);
gtk_widget_set_vexpand(_book, TRUE);
attach(*notebook, 0, row, 2, 1);
-#else
- attach(*notebook, 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD);
-#endif
// restore the last active page
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_setCurrentPage(prefs->getInt("/colorselector/page", 0));
row++;
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
-#else
- GtkWidget *rgbabox = gtk_hbox_new(FALSE, 0);
-#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/* Create color management icons */
@@ -210,11 +184,7 @@ void ColorNotebook::_initUI()
/* Create RGBA entry and color preview */
_rgbal = gtk_label_new_with_mnemonic(_("RGBA_:"));
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_rgbal, GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5);
-#endif
gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2);
ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color));
@@ -230,7 +200,6 @@ void ColorNotebook::_initUI()
gtk_widget_hide(GTK_WIDGET(_box_toomuchink));
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(rgbabox, XPAD);
gtk_widget_set_margin_end(rgbabox, XPAD);
@@ -241,9 +210,6 @@ void ColorNotebook::_initUI()
gtk_widget_set_margin_top(rgbabox, YPAD);
gtk_widget_set_margin_bottom(rgbabox, YPAD);
attach(*Glib::wrap(rgbabox), 0, row, 2, 1);
-#else
- attach(*Glib::wrap(rgbabox), 0, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK, XPAD, YPAD);
-#endif
#ifdef SPCS_PREVIEW
_p = sp_color_preview_new(0xffffffff);
diff --git a/src/ui/widget/color-notebook.h b/src/ui/widget/color-notebook.h
index d28028c72..0948e3d46 100644
--- a/src/ui/widget/color-notebook.h
+++ b/src/ui/widget/color-notebook.h
@@ -19,12 +19,7 @@
#endif
#include <boost/ptr_container/ptr_vector.hpp>
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
-#include <gtk/gtk.h>
#include <glib.h>
#include "color.h"
@@ -35,11 +30,7 @@ namespace UI {
namespace Widget {
class ColorNotebook
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
ColorNotebook(SelectedColor &color);
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index a66fbfc9c..5a62c3c98 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -59,13 +59,8 @@ void ColorPicker::setupDialog(const Glib::ustring &title)
_color_selector = Gtk::manage(new ColorNotebook(_selected_color));
-#if WITH_GTKMM_3_0
_colorSelectorDialog.get_content_area()->pack_start (
*_color_selector, true, true, 0);
-#else
- _colorSelectorDialog.get_vbox()->pack_start (
- *_color_selector, true, true, 0);
-#endif
_color_selector->show();
}
diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp
index 62c7cca1d..c9b6e56d2 100644
--- a/src/ui/widget/color-preview.cpp
+++ b/src/ui/widget/color-preview.cpp
@@ -34,7 +34,6 @@ ColorPreview::on_size_allocate (Gtk::Allocation &all)
queue_draw();
}
-#if WITH_GTKMM_3_0
void
ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
{
@@ -58,31 +57,6 @@ ColorPreview::get_preferred_width_for_height_vfunc(int /* height */, int& minimu
{
minimum_width = natural_width = SPCP_DEFAULT_WIDTH;
}
-#else
-void
-ColorPreview::on_size_request (Gtk::Requisition *req)
-{
- req->width = SPCP_DEFAULT_WIDTH;
- req->height = SPCP_DEFAULT_HEIGHT;
-}
-
-bool
-ColorPreview::on_expose_event (GdkEventExpose *event)
-{
- bool result = true;
-
- if (get_is_drawable())
- {
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- result = on_draw(cr);
- }
-
- return result;
-}
-#endif
void
ColorPreview::setRgba32 (guint32 rgba)
diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h
index caddfb9a2..1276cf42b 100644
--- a/src/ui/widget/color-preview.h
+++ b/src/ui/widget/color-preview.h
@@ -33,16 +33,10 @@ public:
protected:
virtual void on_size_allocate (Gtk::Allocation &all);
-#if WITH_GTKMM_3_0
virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const;
virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const;
virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const;
virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const;
-#else
- virtual void on_size_request (Gtk::Requisition *req);
- virtual bool on_expose_event(GdkEventExpose *event);
-#endif
-
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
guint32 _rgba;
diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp
index 48a2693bc..4023d227c 100644
--- a/src/ui/widget/color-scales.cpp
+++ b/src/ui/widget/color-scales.cpp
@@ -3,15 +3,12 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <math.h>
#include <gtkmm/adjustment.h>
#include <glibmm/i18n.h>
-#include <gtk/gtk.h>
-#include "svg/svg-icc-color.h"
#include "ui/dialog-events.h"
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
@@ -46,15 +43,12 @@ static const gchar *sp_color_scales_hue_map();
const gchar *ColorScales::SUBMODE_NAMES[] = { N_("None"), N_("RGB"), N_("HSL"), N_("CMYK") };
ColorScales::ColorScales(SelectedColor &color, SPColorScalesMode mode)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(5, 3, false)
-#endif
, _color(color)
, _rangeLimit(255.0)
, _updating(FALSE)
, _dragging(FALSE)
+ , _mode(SP_COLOR_SCALES_MODE_NONE)
{
for (gint i = 0; i < 5; i++) {
_l[i] = 0;
@@ -93,15 +87,9 @@ void ColorScales::_initUI(SPColorScalesMode mode)
/* Label */
_l[i] = gtk_label_new("");
-#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign(_l[i], GTK_ALIGN_END);
-#else
- gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5);
-#endif
-
gtk_widget_show(_l[i]);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_l[i], XPAD);
gtk_widget_set_margin_end(_l[i], XPAD);
@@ -112,9 +100,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_widget_set_margin_top(_l[i], YPAD);
gtk_widget_set_margin_bottom(_l[i], YPAD);
gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _l[i], 0, 1, i, i + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
-#endif
/* Adjustment */
_a[i] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0));
@@ -122,7 +107,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
_s[i] = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_a[i], true)));
_s[i]->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
_s[i]->set_margin_start(XPAD);
_s[i]->set_margin_end(XPAD);
@@ -134,10 +118,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
_s[i]->set_margin_bottom(YPAD);
_s[i]->set_hexpand(true);
gtk_grid_attach(GTK_GRID(t), _s[i]->gobj(), 1, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _s[i]->gobj(), 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- GTK_FILL, XPAD, YPAD);
-#endif
/* Spinbutton */
_b[i] = gtk_spin_button_new(GTK_ADJUSTMENT(_a[i]), 1.0, 0);
@@ -145,7 +125,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_label_set_mnemonic_widget(GTK_LABEL(_l[i]), _b[i]);
gtk_widget_show(_b[i]);
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
gtk_widget_set_margin_start(_b[i], XPAD);
gtk_widget_set_margin_end(_b[i], XPAD);
@@ -158,9 +137,6 @@ void ColorScales::_initUI(SPColorScalesMode mode)
gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER);
gtk_widget_set_valign(_b[i], GTK_ALIGN_CENTER);
gtk_grid_attach(GTK_GRID(t), _b[i], 2, i, 1, 1);
-#else
- gtk_table_attach(GTK_TABLE(t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
-#endif
/* Attach channel value to adjustment */
g_object_set_data(G_OBJECT(_a[i]), "channel", GINT_TO_POINTER(i));
@@ -272,7 +248,6 @@ void ColorScales::_setRangeLimit(gdouble upper)
_rangeLimit = upper;
for (gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) {
gtk_adjustment_set_upper(_a[i], upper);
- gtk_adjustment_changed(_a[i]);
}
}
@@ -286,11 +261,7 @@ void ColorScales::_onColorChanged()
void ColorScales::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_updateDisplay();
}
diff --git a/src/ui/widget/color-scales.h b/src/ui/widget/color-scales.h
index aeacfbcc1..1e86d762d 100644
--- a/src/ui/widget/color-scales.h
+++ b/src/ui/widget/color-scales.h
@@ -5,11 +5,7 @@
#include <config.h>
#endif
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -27,11 +23,7 @@ typedef enum {
} SPColorScalesMode;
class ColorScales
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *SUBMODE_NAMES[];
diff --git a/src/ui/widget/color-slider.cpp b/src/ui/widget/color-slider.cpp
index 0c9586a67..2e665dbec 100644
--- a/src/ui/widget/color-slider.cpp
+++ b/src/ui/widget/color-slider.cpp
@@ -12,19 +12,13 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <gdkmm/cursor.h>
-#include <gdkmm/screen.h>
#include <gdkmm/general.h>
#include <gtkmm/adjustment.h>
-#if WITH_GTKMM_3_0
#include <gtkmm/stylecontext.h>
-#else
-#include <gtkmm/style.h>
-#endif
-#include <gtk/gtk.h>
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
@@ -43,14 +37,8 @@ namespace Inkscape {
namespace UI {
namespace Widget {
-#if GTK_CHECK_VERSION(3, 0, 0)
ColorSlider::ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment)
: _dragging(false)
-#else
-ColorSlider::ColorSlider(Gtk::Adjustment *adjustment)
- : _dragging(false)
- , _adjustment(NULL)
-#endif
, _value(0.0)
, _oldvalue(0.0)
, _mapsize(0)
@@ -83,12 +71,7 @@ ColorSlider::~ColorSlider()
if (_adjustment) {
_adjustment_changed_connection.disconnect();
_adjustment_value_changed_connection.disconnect();
-#if GTK_CHECK_VERSION(3, 0, 0)
_adjustment.reset();
-#else
- _adjustment->unreference();
- _adjustment = NULL;
-#endif
}
}
@@ -109,26 +92,15 @@ void ColorSlider::on_realize()
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gdk_screen_get_system_visual(gdk_screen_get_default());
-#if !GTK_CHECK_VERSION(3, 0, 0)
- attributes.colormap = gdk_screen_get_system_colormap(gdk_screen_get_default());
-#endif
attributes.event_mask = get_events();
attributes.event_mask |= (Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK |
Gdk::POINTER_MOTION_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK);
-#if GTK_CHECK_VERSION(3, 0, 0)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
-#else
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-#endif
_gdk_window = Gdk::Window::create(get_parent_window(), &attributes, attributes_mask);
set_window(_gdk_window);
_gdk_window->set_user_data(gobj());
-
-#if !GTK_CHECK_VERSION(3, 0, 0)
- style_attach();
-#endif
}
}
@@ -149,8 +121,6 @@ void ColorSlider::on_size_allocate(Gtk::Allocation &allocation)
}
}
-#if GTK_CHECK_VERSION(3, 0, 0)
-
void ColorSlider::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
{
Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
@@ -177,38 +147,12 @@ void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int &minim
get_preferred_height(minimum_height, natural_height);
}
-#else
-
-void ColorSlider::on_size_request(Gtk::Requisition *requisition)
-{
- GtkStyle *style = gtk_widget_get_style(gobj());
- requisition->width = SLIDER_WIDTH + style->xthickness * 2;
- requisition->height = SLIDER_HEIGHT + style->ythickness * 2;
-}
-
-bool ColorSlider::on_expose_event(GdkEventExpose *event)
-{
- bool result = false;
-
- if (get_is_drawable()) {
- Cairo::RefPtr<Cairo::Context> cr = _gdk_window->create_cairo_context();
- result = on_draw(cr);
- }
- return result;
-}
-
-#endif
-
bool ColorSlider::on_button_press_event(GdkEventButton *event)
{
if (event->button == 1) {
Gtk::Allocation allocation = get_allocation();
gint cx, cw;
-#if GTK_CHECK_VERSION(3, 0, 0)
cx = get_style_context()->get_padding(get_state_flags()).get_left();
-#else
- cx = get_style()->get_xthickness();
-#endif
cw = allocation.get_width() - 2 * cx;
signal_grabbed.emit();
_dragging = true;
@@ -216,15 +160,9 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event)
ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0));
signal_dragged.emit();
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_device_grab(
gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)), _gdk_window->gobj(), GDK_OWNERSHIP_NONE, FALSE,
static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, event->time);
-#else
- gdk_pointer_grab(get_window()->gobj(), FALSE,
- static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL,
- event->time);
-#endif
}
return false;
@@ -233,13 +171,8 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event)
bool ColorSlider::on_button_release_event(GdkEventButton *event)
{
if (event->button == 1) {
-
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_device_ungrab(gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)),
gdk_event_get_time(reinterpret_cast<GdkEvent *>(event)));
-#else
- get_window()->pointer_ungrab(event->time);
-#endif
_dragging = false;
signal_released.emit();
@@ -256,11 +189,7 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event)
if (_dragging) {
gint cx, cw;
Gtk::Allocation allocation = get_allocation();
-#if GTK_CHECK_VERSION(3, 0, 0)
cx = get_style_context()->get_padding(get_state_flags()).get_left();
-#else
- cx = get_style()->get_xthickness();
-#endif
cw = allocation.get_width() - 2 * cx;
ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0));
signal_dragged.emit();
@@ -269,19 +198,10 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event)
return false;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
void ColorSlider::setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment)
{
-#else
-void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment)
-{
-#endif
if (!adjustment) {
-#if GTK_CHECK_VERSION(3, 0, 0)
_adjustment = Gtk::Adjustment::create(0.0, 0.0, 1.0, 0.01, 0.0, 0.0);
-#else
- _adjustment = Gtk::manage(new Gtk::Adjustment(0.0, 0.0, 1.0, 0.01, 0.0, 0.0));
-#endif
}
else {
adjustment->set_page_increment(0.0);
@@ -292,9 +212,6 @@ void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment)
if (_adjustment) {
_adjustment_changed_connection.disconnect();
_adjustment_value_changed_connection.disconnect();
-#if !GTK_CHECK_VERSION(3, 0, 0)
- _adjustment->unreference();
-#endif
}
_adjustment = adjustment;
@@ -315,18 +232,11 @@ void ColorSlider::_onAdjustmentValueChanged()
{
if (_value != ColorScales::getScaled(_adjustment->gobj())) {
gint cx, cy, cw, ch;
-#if GTK_CHECK_VERSION(3, 0, 0)
- Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
- Gtk::Allocation allocation = get_allocation();
- Gtk::Border padding = style_context->get_padding(get_state_flags());
+ auto style_context = get_style_context();
+ auto allocation = get_allocation();
+ auto padding = style_context->get_padding(get_state_flags());
cx = padding.get_left();
cy = padding.get_top();
-#else
- Glib::RefPtr<Gtk::Style> style = get_style();
- Gtk::Allocation allocation = get_allocation();
- cx = style->get_xthickness();
- cy = style->get_ythickness();
-#endif
cw = allocation.get_width() - 2 * cx;
ch = allocation.get_height() - 2 * cy;
if ((gint)(ColorScales::getScaled(_adjustment->gobj()) * cw) != (gint)(_value * cw)) {
@@ -390,40 +300,22 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
{
gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false);
- Gtk::Allocation allocation = get_allocation();
-
-#if GTK_CHECK_VERSION(3, 0, 0)
- Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
-#else
- Glib::RefPtr<Gdk::Window> window = get_window();
- Glib::RefPtr<Gtk::Style> style = get_style();
-#endif
+ auto allocation = get_allocation();
+ auto style_context = get_style_context();
// Draw shadow
if (colorsOnTop) {
-#if GTK_CHECK_VERSION(3, 0, 0)
style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height());
-#else
- gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
- "colorslider", 0, 0, allocation.get_width(), allocation.get_height());
-#endif
}
/* Paintable part of color gradient area */
Gdk::Rectangle carea;
-
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Border padding;
padding = style_context->get_padding(get_state_flags());
carea.set_x(padding.get_left());
carea.set_y(padding.get_top());
- ;
-#else
- carea.set_x(style->get_xthickness());
- carea.set_y(style->get_ythickness());
-#endif
carea.set_width(allocation.get_width() - 2 * carea.get_x());
carea.set_height(allocation.get_height() - 2 * carea.get_y());
@@ -491,12 +383,7 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
/* Draw shadow */
if (!colorsOnTop) {
-#if GTK_CHECK_VERSION(3, 0, 0)
style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height());
-#else
- gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(),
- "colorslider", 0, 0, allocation.get_width(), allocation.get_height());
-#endif
}
/* Draw arrow */
diff --git a/src/ui/widget/color-slider.h b/src/ui/widget/color-slider.h
index 253f3123c..9be6c356a 100644
--- a/src/ui/widget/color-slider.h
+++ b/src/ui/widget/color-slider.h
@@ -24,18 +24,10 @@ namespace Widget {
*/
class ColorSlider : public Gtk::Widget {
public:
-#if GTK_CHECK_VERSION(3, 0, 0)
ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment);
-#else
- ColorSlider(Gtk::Adjustment *adjustment);
-#endif
~ColorSlider();
-#if GTK_CHECK_VERSION(3, 0, 0)
void setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment);
-#else
- void setAdjustment(Gtk::Adjustment *adjustment);
-#endif
void setColors(guint32 start, guint32 mid, guint32 end);
@@ -56,16 +48,10 @@ protected:
bool on_button_release_event(GdkEventButton *event);
bool on_motion_notify_event(GdkEventMotion *event);
bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
-
-#if GTK_CHECK_VERSION(3, 0, 0)
void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const;
void get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const;
void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const;
void get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const;
-#else
- void on_size_request(Gtk::Requisition *requisition);
- bool on_expose_event(GdkEventExpose *event);
-#endif
private:
void _onAdjustmentChanged();
@@ -73,11 +59,7 @@ private:
bool _dragging;
-#if GTK_CHECK_VERSION(3, 0, 0)
Glib::RefPtr<Gtk::Adjustment> _adjustment;
-#else
- Gtk::Adjustment *_adjustment;
-#endif
sigc::connection _adjustment_changed_connection;
sigc::connection _adjustment_value_changed_connection;
diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp
index 22c616325..4f011c6c3 100644
--- a/src/ui/widget/color-wheel-selector.cpp
+++ b/src/ui/widget/color-wheel-selector.cpp
@@ -1,21 +1,17 @@
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include "color-wheel-selector.h"
-#include <math.h>
-#include <gtk/gtk.h>
#include <glibmm/i18n.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/label.h>
#include <gtkmm/spinbutton.h>
-#include "svg/svg-icc-color.h"
#include "ui/dialog-events.h"
-#include "ui/selected-color.h"
#include "ui/widget/color-scales.h"
#include "ui/widget/color-slider.h"
-#include "ui/widget/gimpcolorwheel.h"
+#include "widgets/gimp/gimpcolorwheel.h"
namespace Inkscape {
namespace UI {
@@ -29,16 +25,9 @@ namespace Widget {
const gchar *ColorWheelSelector::MODE_NAME = N_("Wheel");
ColorWheelSelector::ColorWheelSelector(SelectedColor &color)
-#if GTK_CHECK_VERSION(3, 0, 0)
: Gtk::Grid()
-#else
- : Gtk::Table(5, 3, false)
-#endif
, _color(color)
, _updating(false)
-#if !GTK_CHECK_VERSION(3, 0, 0)
- , _alpha_adjustment(NULL)
-#endif
, _wheel(0)
, _slider(0)
{
@@ -50,9 +39,6 @@ ColorWheelSelector::ColorWheelSelector(SelectedColor &color)
ColorWheelSelector::~ColorWheelSelector()
{
_wheel = 0;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- delete _alpha_adjustment;
-#endif
_color_changed_connection.disconnect();
_color_dragged_connection.disconnect();
@@ -66,16 +52,11 @@ void ColorWheelSelector::_initUI()
_wheel = gimp_color_wheel_new();
gtk_widget_show(_wheel);
-#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_set_halign(_wheel, GTK_ALIGN_FILL);
gtk_widget_set_valign(_wheel, GTK_ALIGN_FILL);
gtk_widget_set_hexpand(_wheel, TRUE);
gtk_widget_set_vexpand(_wheel, TRUE);
gtk_grid_attach(GTK_GRID(gobj()), _wheel, 0, row, 3, 1);
-#else
- gtk_table_attach(GTK_TABLE(gobj()), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
-#endif
row++;
@@ -84,7 +65,6 @@ void ColorWheelSelector::_initUI()
label->set_alignment(1.0, 0.5);
label->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
label->set_margin_start(XPAD);
label->set_margin_end(XPAD);
@@ -97,22 +77,15 @@ void ColorWheelSelector::_initUI()
label->set_halign(Gtk::ALIGN_FILL);
label->set_valign(Gtk::ALIGN_FILL);
attach(*label, 0, row, 1, 1);
-#else
- attach(*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::FILL, XPAD, YPAD);
-#endif
-/* Adjustment */
-#if GTK_CHECK_VERSION(3, 0, 0)
+ /* Adjustment */
_alpha_adjustment = Gtk::Adjustment::create(0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
-#else
- _alpha_adjustment = new Gtk::Adjustment(0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
-#endif
+
/* Slider */
_slider = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(_alpha_adjustment));
_slider->set_tooltip_text(_("Alpha (opacity)"));
_slider->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
_slider->set_margin_start(XPAD);
_slider->set_margin_end(XPAD);
@@ -126,25 +99,17 @@ void ColorWheelSelector::_initUI()
_slider->set_halign(Gtk::ALIGN_FILL);
_slider->set_valign(Gtk::ALIGN_FILL);
attach(*_slider, 1, row, 1, 1);
-#else
- attach(*_slider, 1, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::FILL, XPAD, YPAD);
-#endif
_slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5),
SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 1.0));
-/* Spinbutton */
-#if GTK_CHECK_VERSION(3, 0, 0)
- Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0));
-#else
- Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(*_alpha_adjustment, 1.0, 0));
-#endif
+ /* Spinbutton */
+ auto spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0));
spin_button->set_tooltip_text(_("Alpha (opacity)"));
sp_dialog_defocus_on_enter(GTK_WIDGET(spin_button->gobj()));
label->set_mnemonic_widget(*spin_button);
spin_button->show();
-#if GTK_CHECK_VERSION(3, 0, 0)
#if GTK_CHECK_VERSION(3, 12, 0)
spin_button->set_margin_start(XPAD);
spin_button->set_margin_end(XPAD);
@@ -157,9 +122,6 @@ void ColorWheelSelector::_initUI()
spin_button->set_halign(Gtk::ALIGN_CENTER);
spin_button->set_valign(Gtk::ALIGN_CENTER);
attach(*spin_button, 2, row, 1, 1);
-#else
- attach(*spin_button, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, XPAD, YPAD);
-#endif
/* Signals */
_alpha_adjustment->signal_value_changed().connect(sigc::mem_fun(this, &ColorWheelSelector::_adjustmentChanged));
@@ -172,11 +134,7 @@ void ColorWheelSelector::_initUI()
void ColorWheelSelector::on_show()
{
-#if GTK_CHECK_VERSION(3, 0, 0)
Gtk::Grid::on_show();
-#else
- Gtk::Table::on_show();
-#endif
_updateDisplay();
}
diff --git a/src/ui/widget/color-wheel-selector.h b/src/ui/widget/color-wheel-selector.h
index 5711d417c..ee7bd9b83 100644
--- a/src/ui/widget/color-wheel-selector.h
+++ b/src/ui/widget/color-wheel-selector.h
@@ -16,11 +16,7 @@
#include <config.h>
#endif
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/selected-color.h"
@@ -33,11 +29,7 @@ namespace Widget {
class ColorSlider;
class ColorWheelSelector
-#if GTK_CHECK_VERSION(3, 0, 0)
: public Gtk::Grid
-#else
- : public Gtk::Table
-#endif
{
public:
static const gchar *MODE_NAME;
@@ -61,11 +53,7 @@ protected:
SelectedColor &_color;
bool _updating;
-#if GTK_CHECK_VERSION(3, 0, 0)
Glib::RefPtr<Gtk::Adjustment> _alpha_adjustment;
-#else
- Gtk::Adjustment *_alpha_adjustment;
-#endif
GtkWidget *_wheel;
Inkscape::UI::Widget::ColorSlider *_slider;
diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h
index 4678ab83b..e7524ac71 100644
--- a/src/ui/widget/combo-enums.h
+++ b/src/ui/widget/combo-enums.h
@@ -16,7 +16,6 @@
#include <gtkmm/liststore.h>
#include "attr-widget.h"
#include "util/enums.h"
-
#include <glibmm/i18n.h>
namespace Inkscape {
@@ -190,9 +189,11 @@ public:
const Util::EnumDataConverter<E>& c,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
- bool mnemonic = true)
- : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
- { }
+ bool mnemonic = true,
+ bool sorted = true)
+ : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
+ {
+ }
ComboBoxEnum<E>* getCombobox() {
return static_cast< ComboBoxEnum<E>* > (_widget);
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp
index 8d960ddc3..d124854ae 100644
--- a/src/ui/widget/dock-item.cpp
+++ b/src/ui/widget/dock-item.cpp
@@ -9,15 +9,12 @@
#include "ui/widget/dock.h"
-#include "dock-item.h"
#include "desktop.h"
#include "inkscape.h"
-#include "preferences.h"
#include "ui/icon-names.h"
#include "widgets/icon.h"
#include <gtkmm/icontheme.h>
-#include <gtkmm/stockitem.h>
#include <glibmm/exceptionhandler.h>
namespace Inkscape {
@@ -49,22 +46,11 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l
if (!iconTheme->has_icon(icon_name)) {
Inkscape::queueIconPrerender( INKSCAPE_ICON(icon_name.data()), Inkscape::ICON_SIZE_MENU );
}
- // Icon might be in the icon theme, or might be a stock item. Check the proper source:
if ( iconTheme->has_icon(icon_name) ) {
int width = 0;
int height = 0;
Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height);
_icon_pixbuf = iconTheme->load_icon(icon_name, width);
- } else {
- Gtk::StockItem item;
- Gtk::StockID stockId(icon_name);
- if ( Gtk::StockItem::lookup(stockId, item) ) {
-#if WITH_GTKMM_3_0
- _icon_pixbuf = _dock.getWidget().render_icon_pixbuf( stockId, Gtk::ICON_SIZE_MENU );
-#else
- _icon_pixbuf = _dock.getWidget().render_icon( stockId, Gtk::ICON_SIZE_MENU );
-#endif
- }
}
}
@@ -175,12 +161,8 @@ DockItem::set_size_request(int width, int height)
void DockItem::size_request(Gtk::Requisition& requisition)
{
-#if WITH_GTKMM_3_0
Gtk::Requisition req_natural;
getWidget().get_preferred_size(req_natural, requisition);
-#else
- requisition = getWidget().size_request();
-#endif
}
void
@@ -433,6 +415,8 @@ void
DockItem::_onStateChanged(State /*prev_state*/, State new_state)
{
_window = getWindow();
+ if(_window)
+ _window->set_type_hint(Gdk::WINDOW_TYPE_HINT_NORMAL);
if (new_state == FLOATING_STATE && _window) {
_window->signal_hide().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onHideWindow));
diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h
index 25a69d94c..2df45b207 100644
--- a/src/ui/widget/dock-item.h
+++ b/src/ui/widget/dock-item.h
@@ -19,11 +19,7 @@
#include <gtkmm/frame.h>
#include <gtkmm/window.h>
-#if WITH_EXT_GDL
#include <gdl/gdl.h>
-#else
-#include "libgdl/gdl.h"
-#endif
namespace Gtk {
class HButtonBox;
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index fda647182..b2dec401f 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -65,7 +65,6 @@ Dock::Dock(Gtk::Orientation orientation)
static_cast<GtkOrientation>(orientation));
#endif
-#if WITH_GTKMM_3_0
switch(orientation) {
case Gtk::ORIENTATION_VERTICAL:
_dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
@@ -75,17 +74,6 @@ Dock::Dock(Gtk::Orientation orientation)
}
_paned = Gtk::manage(new Gtk::Paned(orientation));
-#else
- switch (orientation) {
- case Gtk::ORIENTATION_VERTICAL:
- _dock_box = Gtk::manage(new Gtk::HBox());
- _paned = Gtk::manage(new Gtk::VPaned());
- break;
- case Gtk::ORIENTATION_HORIZONTAL:
- _dock_box = Gtk::manage(new Gtk::VBox());
- _paned = Gtk::manage(new Gtk::HPaned());
- }
-#endif
_scrolled_window->add(*_dock_box);
_scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -268,7 +256,7 @@ void Dock::_onLayoutChanged()
_paned->get_child1()->set_size_request(-1, -1);
_scrolled_window->set_size_request(_default_empty_width);
}
- getParentPaned()->set_position(INT_MAX);
+ getParentPaned()->set_position(10000);
} else {
// unset any forced size requests
diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp
index a8de2f384..381f0a2e1 100644
--- a/src/ui/widget/entity-entry.cpp
+++ b/src/ui/widget/entity-entry.cpp
@@ -14,14 +14,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/entry.h>
#include "inkscape.h"
-#include "sp-object.h"
#include "rdf.h"
#include "ui/widget/registry.h"
#include "sp-root.h"
diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp
index 64d28119a..b1dd9ae8e 100644
--- a/src/ui/widget/entry.cpp
+++ b/src/ui/widget/entry.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "entry.h"
diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp
index 242a99073..eace494ed 100644
--- a/src/ui/widget/filter-effect-chooser.cpp
+++ b/src/ui/widget/filter-effect-chooser.cpp
@@ -10,12 +10,8 @@
*/
#include "filter-effect-chooser.h"
-#include <glibmm/i18n.h>
-
-#include "desktop.h"
#include "document.h"
-#include "inkscape.h"
namespace Inkscape {
namespace UI {
@@ -55,10 +51,6 @@ sigc::signal<void>& SimpleFilterModifier::signal_blend_blur_changed()
const Glib::ustring SimpleFilterModifier::get_blend_mode()
{
- if (!(_flags & BLEND)) {
- return "normal";
- }
-
const Util::EnumData<Inkscape::Filters::FilterBlendMode> *d = _blend.get_active_data();
if (d) {
return _blend.get_active_data()->key;
diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp
new file mode 100644
index 000000000..ed57c803a
--- /dev/null
+++ b/src/ui/widget/font-button.cpp
@@ -0,0 +1,61 @@
+/*
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "font-button.h"
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/fontbutton.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip,
+ Glib::ustring const &suffix,
+ Glib::ustring const &icon,
+ bool mnemonic)
+ : Labelled(label, tooltip, new Gtk::FontButton("Sans 10"), suffix, icon, mnemonic)
+{
+}
+
+Glib::ustring FontButton::getValue() const
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_widget)->get_font_name();
+}
+
+
+void FontButton::setValue (Glib::ustring fontspec)
+{
+ g_assert(_widget != NULL);
+ static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec);
+}
+
+Glib::SignalProxy0<void> FontButton::signal_font_value_changed()
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_widget)->signal_font_set();
+}
+
+
+} // namespace Widget
+} // 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/font-button.h b/src/ui/widget/font-button.h
new file mode 100644
index 000000000..98c3db440
--- /dev/null
+++ b/src/ui/widget/font-button.h
@@ -0,0 +1,62 @@
+/*
+ *
+ * Copyright (C) 2007 Author
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+
+#include "labelled.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * A labelled font button for entering font values
+ */
+class FontButton : public Labelled
+{
+public:
+ /**
+ * Construct a FontButton Widget.
+ *
+ * @param label Label.
+ * @param suffix Suffix, placed after the widget (defaults to "").
+ * @param icon Icon filename, placed before the label (defaults to "").
+ * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to false).
+ */
+ FontButton( Glib::ustring const &label,
+ Glib::ustring const &tooltip,
+ Glib::ustring const &suffix = "",
+ Glib::ustring const &icon = "",
+ bool mnemonic = true);
+
+ Glib::ustring getValue() const;
+ void setValue (Glib::ustring fontspec);
+ /**
+ * Signal raised when the font button's value changes.
+ */
+ Glib::SignalProxy0<void> signal_font_value_changed();
+};
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_RANDOM_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp
index 62598dead..6753bbc7a 100644
--- a/src/ui/widget/font-variants.cpp
+++ b/src/ui/widget/font-variants.cpp
@@ -8,26 +8,18 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm.h>
#include <glibmm/i18n.h>
#include <libnrtype/font-instance.h>
-#include <iostream>
#include "font-variants.h"
// For updating from selection
#include "desktop.h"
-#include "selection.h"
-#include "style.h"
#include "sp-text.h"
-#include "sp-tspan.h"
-#include "sp-tref.h"
-#include "sp-textpath.h"
-#include "sp-item-group.h"
-#include "xml/repr.h"
namespace Inkscape {
namespace UI {
@@ -239,9 +231,13 @@ namespace Widget {
// Add tooltips
_feature_entry.set_tooltip_text( _("Feature settings in CSS form. No sanity checking is performed."));
+ _feature_list.set_justify( Gtk::JUSTIFY_LEFT );
+ _feature_list.set_line_wrap( true );
+
// Add to frame
_feature_vbox.add( _feature_entry );
_feature_vbox.add( _feature_label );
+ _feature_vbox.add( _feature_list );
_feature_frame.add( _feature_vbox );
add( _feature_frame );
@@ -540,30 +536,35 @@ namespace Widget {
// Make list of tables not handled above... eventually add Gtk::Label with
// this info.
- // std::map<Glib::ustring,int> table_copy = res->openTypeTables;
- // if( (it = table_copy.find("liga")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("clig")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("dlig")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("hlig")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("calt")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("subs")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("sups")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("smcp")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("c2sc")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("pcap")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("unic")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("titl")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("lnum")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("onum")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("pnum")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("tnum")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("frac")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("afrc")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("ordn")) != table_copy.end() ) table_copy.erase( it );
- // if( (it = table_copy.find("zero")) != table_copy.end() ) table_copy.erase( it );
- // for(it = table_copy.begin(); it != table_copy.end(); ++it) {
- // std::cout << "Other: " << it->first << " Occurances: " << it->second << std::endl;
- // }
+ std::map<Glib::ustring,int> table_copy = res->openTypeTables;
+ if( (it = table_copy.find("liga")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("clig")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("dlig")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("hlig")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("calt")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("subs")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("sups")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("smcp")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("c2sc")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("pcap")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("unic")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("titl")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("lnum")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("onum")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("pnum")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("tnum")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("frac")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("afrc")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("ordn")) != table_copy.end() ) table_copy.erase( it );
+ if( (it = table_copy.find("zero")) != table_copy.end() ) table_copy.erase( it );
+ std::string ott_list = "OpenType tables not included above: ";
+ for(it = table_copy.begin(); it != table_copy.end(); ++it) {
+ // std::cout << "Other: " << it->first << " Occurances: " << it->second << std::endl;
+ ott_list += it->first;
+ ott_list += ", ";
+ }
+
+ _feature_list.set_text( ott_list.c_str() );
} else {
std::cerr << "FontVariants::update(): Couldn't find font_instance for: "
@@ -637,7 +638,7 @@ namespace Widget {
} else if( _caps_all_small.get_active() ) {
css_string = "all-small-caps";
caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL;
- } else if( _caps_all_petite.get_active() ) {
+ } else if( _caps_petite.get_active() ) {
css_string = "petite";
caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE;
} else if( _caps_all_petite.get_active() ) {
diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h
index d4329feff..507e5fb91 100644
--- a/src/ui/widget/font-variants.h
+++ b/src/ui/widget/font-variants.h
@@ -86,7 +86,8 @@ protected:
Gtk::VBox _feature_vbox;
Gtk::Entry _feature_entry;
Gtk::Label _feature_label;
-
+ Gtk::Label _feature_list;
+
private:
void ligatures_init();
void ligatures_callback();
diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp
index eaa4336bb..6593d9c7c 100644
--- a/src/ui/widget/frame.cpp
+++ b/src/ui/widget/frame.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "frame.h"
@@ -21,26 +21,20 @@ namespace UI {
namespace Widget {
Frame::Frame(Glib::ustring const &label_text /*= ""*/, gboolean label_bold /*= TRUE*/ )
- : _label(label_text, 1.0, 0.5, TRUE),
- _alignment()
+ : _label(label_text, 1.0, 0.5, TRUE)
{
set_shadow_type(Gtk::SHADOW_NONE);
- //Put an indented GtkAlignment inside the frame.
- //Further children should be children of this GtkAlignment:
- Gtk::Frame::add(_alignment);
- set_padding(4, 0, 8, 0);
-
set_label_widget(_label);
set_label(label_text, label_bold);
-
- show_all_children();
}
void
Frame::add(Widget& widget)
{
- _alignment.add(widget);
+ Gtk::Frame::add(widget);
+ set_padding(4, 0, 8, 0);
+ show_all_children();
}
void
@@ -56,7 +50,21 @@ Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/
void
Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right)
{
- _alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right);
+ auto child = get_child();
+
+ if(child)
+ {
+ child->set_margin_top(padding_top);
+ child->set_margin_bottom(padding_bottom);
+
+#if GTK_CHECK_VERSION(3,12,0)
+ child->set_margin_start(padding_left);
+ child->set_margin_end(padding_right);
+#else
+ child->set_margin_left(padding_left);
+ child->set_margin_right(padding_right);
+#endif
+ }
}
Gtk::Label const *
diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h
index a04666651..24dd716e6 100644
--- a/src/ui/widget/frame.h
+++ b/src/ui/widget/frame.h
@@ -10,7 +10,6 @@
#ifndef INKSCAPE_UI_WIDGET_FRAME_H
#define INKSCAPE_UI_WIDGET_FRAME_H
-#include <gtkmm/alignment.h>
#include <gtkmm/frame.h>
#include <gtkmm/label.h>
@@ -55,8 +54,6 @@ public:
protected:
Gtk::Label _label;
- Gtk::Alignment _alignment;
-
};
} // namespace Widget
diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c
deleted file mode 100644
index d54486505..000000000
--- a/src/ui/widget/gimpcolorwheel.c
+++ /dev/null
@@ -1,1604 +0,0 @@
-/* HSV color selector for GTK+
- *
- * Copyright (C) 1999 The Free Software Foundation
- *
- * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
- * Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
- * Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
- * Michael Natterer <mitch@gimp.org> (ported back to GIMP)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * This widget was adopted by Inkscape by Alex Valavanis <valavanisalex@gmail.com>
- * on 2013-01-08. Last merges with GIMP code were applied using the following
- * commits from the GIMP git repository at
- * http://git.gnome.org/browse/gimp/tree/modules/gimpcolorwheel.c
- *
- * Gtk+ 2 code merge: commit 632c5 (2013-01-06)
- * Gtk+ 3 code merge: commit bcfc6, gtk3-port branch (2013-01-06)
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include "gimpcolorwheel.h"
-#include <math.h>
-
-
-/* Default ring fraction */
-#define DEFAULT_FRACTION 0.1
-
-/* Default width/height */
-#define DEFAULT_SIZE 100
-
-/* Default ring width */
-#define DEFAULT_RING_WIDTH 10
-
-
-/* Dragging modes */
-typedef enum
-{
- DRAG_NONE,
- DRAG_H,
- DRAG_SV
-} DragMode;
-
-/* Private part of the GimpColorWheel structure */
-typedef struct
-{
- /* Color value */
- gdouble h;
- gdouble s;
- gdouble v;
-
- /* ring_width is this fraction of size */
- gdouble ring_fraction;
-
- /* Size and ring width */
- gint size;
- gint ring_width;
-
- /* Window for capturing events */
- GdkWindow *window;
-
- /* Dragging mode */
- DragMode mode;
-
- guint focus_on_ring : 1;
-} GimpColorWheelPrivate;
-
-enum
-{
- CHANGED,
- MOVE,
- LAST_SIGNAL
-};
-
-static void gimp_color_wheel_map (GtkWidget *widget);
-static void gimp_color_wheel_unmap (GtkWidget *widget);
-static void gimp_color_wheel_realize (GtkWidget *widget);
-static void gimp_color_wheel_unrealize (GtkWidget *widget);
-static void gimp_color_wheel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean gimp_color_wheel_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_color_wheel_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_color_wheel_motion (GtkWidget *widget,
- GdkEventMotion *event);
-#if GTK_CHECK_VERSION(3,0,0)
-static gboolean gimp_color_wheel_draw (GtkWidget *widget,
- cairo_t *cr);
-static void gimp_color_wheel_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static void gimp_color_wheel_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height);
-#else
-static gboolean gimp_color_wheel_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void gimp_color_wheel_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-#endif
-
-static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget,
- GdkEventGrabBroken *event);
-static gboolean gimp_color_wheel_focus (GtkWidget *widget,
- GtkDirectionType direction);
-static void gimp_color_wheel_move (GimpColorWheel *wheel,
- GtkDirectionType dir);
-
-
-static guint wheel_signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE (GimpColorWheel, gimp_color_wheel, GTK_TYPE_WIDGET)
-
-#define parent_class gimp_color_wheel_parent_class
-
-
-static void
-gimp_color_wheel_class_init (GimpColorWheelClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
- GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class);
- GtkBindingSet *binding_set;
-
- widget_class->map = gimp_color_wheel_map;
- widget_class->unmap = gimp_color_wheel_unmap;
- widget_class->realize = gimp_color_wheel_realize;
- widget_class->unrealize = gimp_color_wheel_unrealize;
- widget_class->size_allocate = gimp_color_wheel_size_allocate;
- widget_class->button_press_event = gimp_color_wheel_button_press;
- widget_class->button_release_event = gimp_color_wheel_button_release;
- widget_class->motion_notify_event = gimp_color_wheel_motion;
-
-#if GTK_CHECK_VERSION(3,0,0)
- widget_class->get_preferred_width = gimp_color_wheel_get_preferred_width;
- widget_class->get_preferred_height = gimp_color_wheel_get_preferred_height;
- widget_class->draw = gimp_color_wheel_draw;
-#else
- widget_class->size_request = gimp_color_wheel_size_request;
- widget_class->expose_event = gimp_color_wheel_expose;
-#endif
-
- widget_class->focus = gimp_color_wheel_focus;
- widget_class->grab_broken_event = gimp_color_wheel_grab_broken;
-
- wheel_class->move = gimp_color_wheel_move;
-
- wheel_signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GimpColorWheelClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- wheel_signals[MOVE] =
- g_signal_new ("move",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GimpColorWheelClass, move),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- GTK_TYPE_DIRECTION_TYPE);
-
- binding_set = gtk_binding_set_by_class (class);
-
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_UP);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_UP);
-
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_DOWN);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_DOWN);
-
-
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_RIGHT);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_RIGHT);
-
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_LEFT);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0,
- "move", 1,
- G_TYPE_ENUM, GTK_DIR_LEFT);
-
- g_type_class_add_private (object_class, sizeof (GimpColorWheelPrivate));
-}
-
-static void
-gimp_color_wheel_init (GimpColorWheel *wheel)
-{
- GimpColorWheelPrivate *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (wheel, GIMP_TYPE_COLOR_WHEEL,
- GimpColorWheelPrivate);
-
- wheel->priv = priv;
-
- gtk_widget_set_has_window (GTK_WIDGET (wheel), FALSE);
- gtk_widget_set_can_focus (GTK_WIDGET (wheel), TRUE);
-
- priv->ring_fraction = DEFAULT_FRACTION;
- priv->size = DEFAULT_SIZE;
- priv->ring_width = DEFAULT_RING_WIDTH;
-}
-
-static void
-gimp_color_wheel_map (GtkWidget *widget)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
-
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-
- gdk_window_show (priv->window);
-}
-
-static void
-gimp_color_wheel_unmap (GtkWidget *widget)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
-
- gdk_window_hide (priv->window);
-
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-}
-
-static void
-gimp_color_wheel_realize (GtkWidget *widget)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- GtkAllocation allocation;
- GdkWindowAttr attr;
- gint attr_mask;
- GdkWindow *parent_window;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- gtk_widget_set_realized (widget, TRUE);
-
- attr.window_type = GDK_WINDOW_CHILD;
- attr.x = allocation.x;
- attr.y = allocation.y;
- attr.width = allocation.width;
- attr.height = allocation.height;
- attr.wclass = GDK_INPUT_ONLY;
- attr.event_mask = (gtk_widget_get_events (widget) |
- GDK_KEY_PRESS_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
-
- attr_mask = GDK_WA_X | GDK_WA_Y;
-
- parent_window = gtk_widget_get_parent_window (widget);
-
- gtk_widget_set_window (widget, parent_window);
- g_object_ref (parent_window);
-
- priv->window = gdk_window_new (parent_window, &attr, attr_mask);
- gdk_window_set_user_data (priv->window, wheel);
-
-#if !GTK_CHECK_VERSION(3,0,0)
- gtk_widget_style_attach (widget);
-#endif
-}
-
-static void
-gimp_color_wheel_unrealize (GtkWidget *widget)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
-
- gdk_window_set_user_data (priv->window, NULL);
- gdk_window_destroy (priv->window);
- priv->window = NULL;
-
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-static void
-gimp_color_wheel_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- *minimum_width = *natural_width = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
-}
-
-static void
-gimp_color_wheel_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- *minimum_height = *natural_height = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
-}
-#else
-static void
-gimp_color_wheel_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- requisition->width = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
- requisition->height = DEFAULT_SIZE + 2 * (focus_width + focus_pad);
-}
-#endif
-
-static void
-gimp_color_wheel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_set_allocation (widget, allocation);
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
- priv->size = MIN (allocation->width - 2 * (focus_width + focus_pad),
- allocation->height - 2 * (focus_width + focus_pad));
-
- priv->ring_width = priv->size * priv->ring_fraction;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (priv->window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-}
-
-
-/* Utility functions */
-
-#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
-
-/* Converts from HSV to RGB */
-static void
-hsv_to_rgb (gdouble *h,
- gdouble *s,
- gdouble *v)
-{
- gdouble hue, saturation, value;
- gdouble f, p, q, t;
-
- if (*s == 0.0)
- {
- *h = *v;
- *s = *v;
- *v = *v; /* heh */
- }
- else
- {
- hue = *h * 6.0;
- saturation = *s;
- value = *v;
-
- if (hue == 6.0)
- hue = 0.0;
-
- f = hue - (int) hue;
- p = value * (1.0 - saturation);
- q = value * (1.0 - saturation * f);
- t = value * (1.0 - saturation * (1.0 - f));
-
- switch ((int) hue)
- {
- case 0:
- *h = value;
- *s = t;
- *v = p;
- break;
-
- case 1:
- *h = q;
- *s = value;
- *v = p;
- break;
-
- case 2:
- *h = p;
- *s = value;
- *v = t;
- break;
-
- case 3:
- *h = p;
- *s = q;
- *v = value;
- break;
-
- case 4:
- *h = t;
- *s = p;
- *v = value;
- break;
-
- case 5:
- *h = value;
- *s = p;
- *v = q;
- break;
-
- default:
- g_assert_not_reached ();
- }
- }
-}
-
-/* Computes the vertices of the saturation/value triangle */
-static void
-compute_triangle (GimpColorWheel *wheel,
- gint *hx,
- gint *hy,
- gint *sx,
- gint *sy,
- gint *vx,
- gint *vy)
-{
- GimpColorWheelPrivate *priv = wheel->priv;
- GtkAllocation allocation;
- gdouble center_x;
- gdouble center_y;
- gdouble inner, outer;
- gdouble angle;
-
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
-
- center_x = allocation.width / 2.0;
- center_y = allocation.height / 2.0;
-
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
- angle = priv->h * 2.0 * G_PI;
-
- *hx = floor (center_x + cos (angle) * inner + 0.5);
- *hy = floor (center_y - sin (angle) * inner + 0.5);
- *sx = floor (center_x + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
- *sy = floor (center_y - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
- *vx = floor (center_x + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
- *vy = floor (center_y - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
-}
-
-/* Computes whether a point is inside the hue ring */
-static gboolean
-is_in_ring (GimpColorWheel *wheel,
- gdouble x,
- gdouble y)
-{
- GimpColorWheelPrivate *priv = wheel->priv;
- GtkAllocation allocation;
- gdouble dx, dy, dist;
- gdouble center_x;
- gdouble center_y;
- gdouble inner, outer;
-
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
-
- center_x = allocation.width / 2.0;
- center_y = allocation.height / 2.0;
-
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
-
- dx = x - center_x;
- dy = center_y - y;
- dist = dx * dx + dy * dy;
-
- return (dist >= inner * inner && dist <= outer * outer);
-}
-
-/* Computes a saturation/value pair based on the mouse coordinates */
-static void
-compute_sv (GimpColorWheel *wheel,
- gdouble x,
- gdouble y,
- gdouble *s,
- gdouble *v)
-{
- GtkAllocation allocation;
- gint ihx, ihy, isx, isy, ivx, ivy;
- gdouble hx, hy, sx, sy, vx, vy;
- gdouble center_x;
- gdouble center_y;
-
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
-
- compute_triangle (wheel, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
-
- center_x = allocation.width / 2.0;
- center_y = allocation.height / 2.0;
-
- hx = ihx - center_x;
- hy = center_y - ihy;
- sx = isx - center_x;
- sy = center_y - isy;
- vx = ivx - center_x;
- vy = center_y - ivy;
- x -= center_x;
- y = center_y - y;
-
- if (vx * (x - sx) + vy * (y - sy) < 0.0)
- {
- *s = 1.0;
- *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy))
- / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy)));
-
- if (*v < 0.0)
- *v = 0.0;
- else if (*v > 1.0)
- *v = 1.0;
- }
- else if (hx * (x - sx) + hy * (y - sy) < 0.0)
- {
- *s = 0.0;
- *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy))
- / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy)));
-
- if (*v < 0.0)
- *v = 0.0;
- else if (*v > 1.0)
- *v = 1.0;
- }
- else if (sx * (x - hx) + sy * (y - hy) < 0.0)
- {
- *v = 1.0;
- *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) /
- ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy)));
-
- if (*s < 0.0)
- *s = 0.0;
- else if (*s > 1.0)
- *s = 1.0;
- }
- else
- {
- *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx))
- / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx)));
-
- if (*v<= 0.0)
- {
- *v = 0.0;
- *s = 0.0;
- }
- else
- {
- if (*v > 1.0)
- *v = 1.0;
-
- if (fabs (hy - vy) < fabs (hx - vx))
- *s = (x - sx - *v * (vx - sx)) / (*v * (hx - vx));
- else
- *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy));
-
- if (*s < 0.0)
- *s = 0.0;
- else if (*s > 1.0)
- *s = 1.0;
- }
- }
-}
-
-/* Computes whether a point is inside the saturation/value triangle */
-static gboolean
-is_in_triangle (GimpColorWheel *wheel,
- gdouble x,
- gdouble y)
-{
- gint hx, hy, sx, sy, vx, vy;
- gdouble det, s, v;
-
- compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
-
- det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx);
-
- s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det;
- v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det;
-
- return (s >= 0.0 && v >= 0.0 && s + v <= 1.0);
-}
-
-/* Computes a value based on the mouse coordinates */
-static double
-compute_v (GimpColorWheel *wheel,
- gdouble x,
- gdouble y)
-{
- GtkAllocation allocation;
- gdouble center_x;
- gdouble center_y;
- gdouble dx, dy;
- gdouble angle;
-
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
-
- center_x = allocation.width / 2.0;
- center_y = allocation.height / 2.0;
-
- dx = x - center_x;
- dy = center_y - y;
-
- angle = atan2 (dy, dx);
- if (angle < 0.0)
- angle += 2.0 * G_PI;
-
- return angle / (2.0 * G_PI);
-}
-
-static void
-set_cross_grab (GimpColorWheel *wheel,
- guint32 time)
-{
- GimpColorWheelPrivate *priv = wheel->priv;
- GdkCursor *cursor;
-
- cursor =
- gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (wheel)),
- GDK_CROSSHAIR);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gdk_device_grab (gtk_get_current_event_device(),
- priv->window,
- GDK_OWNERSHIP_NONE,
- FALSE,
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_RELEASE_MASK,
- cursor, time);
- g_object_unref (cursor);
-#else
- gdk_pointer_grab (priv->window, FALSE,
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_RELEASE_MASK,
- NULL, cursor, time);
- gdk_cursor_unref (cursor);
-#endif
-}
-
-static gboolean gimp_color_wheel_grab_broken(GtkWidget *widget, GdkEventGrabBroken *event)
-{
- (void)event;
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
-
- priv->mode = DRAG_NONE;
-
- return TRUE;
-}
-
-static gboolean
-gimp_color_wheel_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gdouble x, y;
-
- if (priv->mode != DRAG_NONE || event->button != 1)
- return FALSE;
-
- x = event->x;
- y = event->y;
-
- if (is_in_ring (wheel, x, y))
- {
- priv->mode = DRAG_H;
- set_cross_grab (wheel, event->time);
-
- gimp_color_wheel_set_color (wheel,
- compute_v (wheel, x, y),
- priv->s,
- priv->v);
-
- gtk_widget_grab_focus (widget);
- priv->focus_on_ring = TRUE;
-
- return TRUE;
- }
-
- if (is_in_triangle (wheel, x, y))
- {
- gdouble s, v;
-
- priv->mode = DRAG_SV;
- set_cross_grab (wheel, event->time);
-
- compute_sv (wheel, x, y, &s, &v);
- gimp_color_wheel_set_color (wheel, priv->h, s, v);
-
- gtk_widget_grab_focus (widget);
- priv->focus_on_ring = FALSE;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-gimp_color_wheel_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- DragMode mode;
- gdouble x, y;
-
- if (priv->mode == DRAG_NONE || event->button != 1)
- return FALSE;
-
- /* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
- * can see that this is the final color state.
- */
-
- mode = priv->mode;
- priv->mode = DRAG_NONE;
-
- x = event->x;
- y = event->y;
-
- if (mode == DRAG_H)
- {
- gimp_color_wheel_set_color (wheel,
- compute_v (wheel, x, y), priv->s, priv->v);
- }
- else if (mode == DRAG_SV)
- {
- gdouble s, v;
-
- compute_sv (wheel, x, y, &s, &v);
- gimp_color_wheel_set_color (wheel, priv->h, s, v);
- }
- else
- g_assert_not_reached ();
-
-#if GTK_CHECK_VERSION(3,0,0)
- gdk_device_ungrab (gtk_get_current_event_device(),
- event->time);
-#else
- gdk_display_pointer_ungrab (gdk_window_get_display (event->window),
- event->time);
-#endif
-
- return TRUE;
-}
-
-static gboolean
-gimp_color_wheel_motion (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gdouble x, y;
-
- if (priv->mode == DRAG_NONE)
- return FALSE;
-
- gdk_event_request_motions (event);
- x = event->x;
- y = event->y;
-
- if (priv->mode == DRAG_H)
- {
- gimp_color_wheel_set_color (wheel,
- compute_v (wheel, x, y), priv->s, priv->v);
- return TRUE;
- }
- else if (priv->mode == DRAG_SV)
- {
- gdouble s, v;
-
- compute_sv (wheel, x, y, &s, &v);
- gimp_color_wheel_set_color (wheel, priv->h, s, v);
- return TRUE;
- }
-
- g_assert_not_reached ();
-
- return FALSE;
-}
-
-
-/* Redrawing */
-
-/* Paints the hue ring */
-static void
-paint_ring (GimpColorWheel *wheel,
- cairo_t *cr)
-{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget *widget = GTK_WIDGET (wheel);
-#else
- GtkAllocation allocation;
-#endif
- GimpColorWheelPrivate *priv = wheel->priv;
- gint width, height;
- gint xx, yy;
- gdouble dx, dy, dist;
- gdouble center_x;
- gdouble center_y;
- gdouble inner, outer;
- guint32 *buf, *p;
- gdouble angle;
- gdouble hue;
- gdouble r, g, b;
- cairo_surface_t *source;
- cairo_t *source_cr;
- gint stride;
-
-#if GTK_CHECK_VERSION(3,0,0)
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
-#else
- gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation);
- width = allocation.width;
- height = allocation.height;
-#endif
-
- center_x = width / 2.0;
- center_y = height / 2.0;
-
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
-
- /* Create an image initialized with the ring colors */
-
- stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
- buf = g_new (guint32, height * stride / 4);
-
- for (yy = 0; yy < height; yy++)
- {
- p = buf + yy * width;
- dy = -(yy - center_y);
-
- for (xx = 0; xx < width; xx++)
- {
- dx = xx - center_x;
-
- dist = dx * dx + dy * dy;
- if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1)))
- {
- *p++ = 0;
- continue;
- }
-
- angle = atan2 (dy, dx);
- if (angle < 0.0)
- angle += 2.0 * G_PI;
-
- hue = angle / (2.0 * G_PI);
-
- r = hue;
- g = 1.0;
- b = 1.0;
- hsv_to_rgb (&r, &g, &b);
-
- *p++ = (((int)floor (r * 255 + 0.5) << 16) |
- ((int)floor (g * 255 + 0.5) << 8) |
- (int)floor (b * 255 + 0.5));
- }
- }
-
- source = cairo_image_surface_create_for_data ((unsigned char *)buf,
- CAIRO_FORMAT_RGB24,
- width, height, stride);
-
- /* Now draw the value marker onto the source image, so that it
- * will get properly clipped at the edges of the ring
- */
- source_cr = cairo_create (source);
-
- r = priv->h;
- g = 1.0;
- b = 1.0;
- hsv_to_rgb (&r, &g, &b);
-
- if (INTENSITY (r, g, b) > 0.5)
- cairo_set_source_rgb (source_cr, 0.0, 0.0, 0.0);
- else
- cairo_set_source_rgb (source_cr, 1.0, 1.0, 1.0);
-
- cairo_move_to (source_cr, center_x, center_y);
- cairo_line_to (source_cr,
- center_x + cos (priv->h * 2.0 * G_PI) * priv->size / 2,
- center_y - sin (priv->h * 2.0 * G_PI) * priv->size / 2);
- cairo_stroke (source_cr);
- cairo_destroy (source_cr);
-
- /* Draw the ring using the source image */
-
- cairo_save (cr);
-
- cairo_set_source_surface (cr, source, 0, 0);
- cairo_surface_destroy (source);
-
- cairo_set_line_width (cr, priv->ring_width);
- cairo_new_path (cr);
- cairo_arc (cr,
- center_x, center_y,
- priv->size / 2.0 - priv->ring_width / 2.0,
- 0, 2 * G_PI);
- cairo_stroke (cr);
-
- cairo_restore (cr);
-
- g_free (buf);
-}
-
-/* Converts an HSV triplet to an integer RGB triplet */
-static void
-get_color (gdouble h,
- gdouble s,
- gdouble v,
- gint *r,
- gint *g,
- gint *b)
-{
- hsv_to_rgb (&h, &s, &v);
-
- *r = floor (h * 255 + 0.5);
- *g = floor (s * 255 + 0.5);
- *b = floor (v * 255 + 0.5);
-}
-
-#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t))
-
-#define LERP(a, b, v1, v2, i) (((v2) - (v1) != 0) \
- ? ((a) + ((b) - (a)) * ((i) - (v1)) / ((v2) - (v1))) \
- : (a))
-
-/* Number of pixels we extend out from the edges when creating
- * color source to avoid artifacts
- */
-#define PAD 3
-
-/* Paints the HSV triangle */
-static void
-paint_triangle (GimpColorWheel *wheel,
- cairo_t *cr,
- gboolean draw_focus)
-{
- GtkWidget *widget = GTK_WIDGET (wheel);
- GimpColorWheelPrivate *priv = wheel->priv;
- gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
- gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
- gint x2, y2, r2, g2, b2; /* Second vertex */
- gint x3, y3, r3, g3, b3; /* Third vertex */
- gint t;
- guint32 *buf, *p, c;
- gint xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */
- gint xx, yy;
- gint x_interp, y_interp;
- gint x_start, x_end;
- cairo_surface_t *source;
- gdouble r, g, b;
- gint stride;
- gint width, height;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *context;
-
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
-#else
- gchar *detail;
-
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
- width = allocation.width;
- height = allocation.height;
-#endif
-
- /* Compute triangle's vertices */
-
- compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
-
- x1 = hx;
- y1 = hy;
- get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1);
-
- x2 = sx;
- y2 = sy;
- get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2);
-
- x3 = vx;
- y3 = vy;
- get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3);
-
- if (y2 > y3)
- {
- SWAP (x2, x3, t);
- SWAP (y2, y3, t);
- SWAP (r2, r3, t);
- SWAP (g2, g3, t);
- SWAP (b2, b3, t);
- }
-
- if (y1 > y3)
- {
- SWAP (x1, x3, t);
- SWAP (y1, y3, t);
- SWAP (r1, r3, t);
- SWAP (g1, g3, t);
- SWAP (b1, b3, t);
- }
-
- if (y1 > y2)
- {
- SWAP (x1, x2, t);
- SWAP (y1, y2, t);
- SWAP (r1, r2, t);
- SWAP (g1, g2, t);
- SWAP (b1, b2, t);
- }
-
- /* Shade the triangle */
-
- stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
- buf = g_new (guint32, height * stride / 4);
-
- for (yy = 0; yy < height; yy++)
- {
- p = buf + yy * width;
-
- if (yy >= y1 - PAD && yy < y3 + PAD)
- {
- y_interp = CLAMP (yy, y1, y3);
-
- if (y_interp < y2)
- {
- xl = LERP (x1, x2, y1, y2, y_interp);
-
- rl = LERP (r1, r2, y1, y2, y_interp);
- gl = LERP (g1, g2, y1, y2, y_interp);
- bl = LERP (b1, b2, y1, y2, y_interp);
- }
- else
- {
- xl = LERP (x2, x3, y2, y3, y_interp);
-
- rl = LERP (r2, r3, y2, y3, y_interp);
- gl = LERP (g2, g3, y2, y3, y_interp);
- bl = LERP (b2, b3, y2, y3, y_interp);
- }
-
- xr = LERP (x1, x3, y1, y3, y_interp);
-
- rr = LERP (r1, r3, y1, y3, y_interp);
- gr = LERP (g1, g3, y1, y3, y_interp);
- br = LERP (b1, b3, y1, y3, y_interp);
-
- if (xl > xr)
- {
- SWAP (xl, xr, t);
- SWAP (rl, rr, t);
- SWAP (gl, gr, t);
- SWAP (bl, br, t);
- }
-
- x_start = MAX (xl - PAD, 0);
- x_end = MIN (xr + PAD, width);
- x_start = MIN (x_start, x_end);
-
- c = (rl << 16) | (gl << 8) | bl;
-
- for (xx = 0; xx < x_start; xx++)
- *p++ = c;
-
- for (; xx < x_end; xx++)
- {
- x_interp = CLAMP (xx, xl, xr);
-
- *p++ = ((LERP (rl, rr, xl, xr, x_interp) << 16) |
- (LERP (gl, gr, xl, xr, x_interp) << 8) |
- LERP (bl, br, xl, xr, x_interp));
- }
-
- c = (rr << 16) | (gr << 8) | br;
-
- for (; xx < width; xx++)
- *p++ = c;
- }
- }
-
- source = cairo_image_surface_create_for_data ((unsigned char *)buf,
- CAIRO_FORMAT_RGB24,
- width, height, stride);
-
- /* Draw a triangle with the image as a source */
-
- cairo_set_source_surface (cr, source, 0, 0);
- cairo_surface_destroy (source);
-
- cairo_move_to (cr, x1, y1);
- cairo_line_to (cr, x2, y2);
- cairo_line_to (cr, x3, y3);
- cairo_close_path (cr);
- cairo_fill (cr);
-
- g_free (buf);
-
- /* Draw value marker */
-
- xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
- yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
-
- r = priv->h;
- g = priv->s;
- b = priv->v;
- hsv_to_rgb (&r, &g, &b);
-
-#if GTK_CHECK_VERSION(3,0,0)
- context = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (context);
-#endif
-
- if (INTENSITY (r, g, b) > 0.5)
- {
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_add_class (context, "light-area-focus");
-#else
- detail = "colorwheel_light";
-#endif
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- }
- else
- {
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_add_class (context, "dark-area-focus");
-#else
- detail = "colorwheel_dark";
-#endif
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- }
-
-#define RADIUS 4
-#define FOCUS_RADIUS 6
-
- cairo_new_path (cr);
- cairo_arc (cr, xx, yy, RADIUS, 0, 2 * G_PI);
- cairo_stroke (cr);
-
- /* Draw focus outline */
-
- if (draw_focus && ! priv->focus_on_ring)
- {
- gint focus_width;
- gint focus_pad;
-
- gtk_widget_style_get (widget,
- "focus-line-width", &focus_width,
- "focus-padding", &focus_pad,
- NULL);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_render_focus (context, cr,
- xx - FOCUS_RADIUS - focus_width - focus_pad,
- yy - FOCUS_RADIUS - focus_width - focus_pad,
- 2 * (FOCUS_RADIUS + focus_width + focus_pad),
- 2 * (FOCUS_RADIUS + focus_width + focus_pad));
-#else
- gtk_widget_get_allocation (widget, &allocation);
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- NULL, widget, detail,
- allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad,
- allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad,
- 2 * (FOCUS_RADIUS + focus_width + focus_pad),
- 2 * (FOCUS_RADIUS + focus_width + focus_pad));
-#endif
- }
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_restore (context);
-#endif
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-static gboolean
-gimp_color_wheel_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gboolean draw_focus;
-
- draw_focus = gtk_widget_has_visible_focus (widget);
-
- paint_ring (wheel, cr);
- paint_triangle (wheel, cr, draw_focus);
-
- if (draw_focus && priv->focus_on_ring)
- {
- GtkStyleContext *context = gtk_widget_get_style_context (widget);
-
- gtk_render_focus (context, cr, 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
- }
-
- return FALSE;
-}
-#else
-static gint
-gimp_color_wheel_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
-
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
- gboolean draw_focus;
- GtkAllocation allocation;
-
- if (! (event->window == gtk_widget_get_window (widget) &&
- gtk_widget_is_drawable (widget)))
- return FALSE;
-
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- gtk_widget_get_allocation (widget, &allocation);
- cairo_translate (cr, allocation.x, allocation.y);
-
- draw_focus = gtk_widget_has_focus (widget);
-
- paint_ring (wheel, cr);
- paint_triangle (wheel, cr, draw_focus);
-
- cairo_destroy (cr);
-
- if (draw_focus && priv->focus_on_ring)
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- &event->area, widget, NULL,
- allocation.x,
- allocation.y,
- allocation.width,
- allocation.height);
-
- return FALSE;
-}
-#endif
-
-static gboolean
-gimp_color_wheel_focus (GtkWidget *widget,
- GtkDirectionType dir)
-{
- GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget);
- GimpColorWheelPrivate *priv = wheel->priv;
-
- if (!gtk_widget_has_focus (widget))
- {
- if (dir == GTK_DIR_TAB_BACKWARD)
- priv->focus_on_ring = FALSE;
- else
- priv->focus_on_ring = TRUE;
-
- gtk_widget_grab_focus (widget);
- return TRUE;
- }
-
- switch (dir)
- {
- case GTK_DIR_UP:
- if (priv->focus_on_ring)
- return FALSE;
- else
- priv->focus_on_ring = TRUE;
- break;
-
- case GTK_DIR_DOWN:
- if (priv->focus_on_ring)
- priv->focus_on_ring = FALSE;
- else
- return FALSE;
- break;
-
- case GTK_DIR_LEFT:
- case GTK_DIR_TAB_BACKWARD:
- if (priv->focus_on_ring)
- return FALSE;
- else
- priv->focus_on_ring = TRUE;
- break;
-
- case GTK_DIR_RIGHT:
- case GTK_DIR_TAB_FORWARD:
- if (priv->focus_on_ring)
- priv->focus_on_ring = FALSE;
- else
- return FALSE;
- break;
- }
-
- gtk_widget_queue_draw (widget);
-
- return TRUE;
-}
-
-/**
- * gimp_color_wheel_new:
- *
- * Creates a new HSV color selector.
- *
- * Return value: A newly-created HSV color selector.
- *
- * Since: 2.14
- */
-GtkWidget*
-gimp_color_wheel_new (void)
-{
- return g_object_new (GIMP_TYPE_COLOR_WHEEL, NULL);
-}
-
-/**
- * gimp_color_wheel_set_color:
- * @hsv: An HSV color selector
- * @h: Hue
- * @s: Saturation
- * @v: Value
- *
- * Sets the current color in an HSV color selector.
- * Color component values must be in the [0.0, 1.0] range.
- *
- * Since: 2.14
- */
-void
-gimp_color_wheel_set_color (GimpColorWheel *wheel,
- gdouble h,
- gdouble s,
- gdouble v)
-{
- GimpColorWheelPrivate *priv;
-
- g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel));
- g_return_if_fail (h >= 0.0 && h <= 1.0);
- g_return_if_fail (s >= 0.0 && s <= 1.0);
- g_return_if_fail (v >= 0.0 && v <= 1.0);
-
- priv = wheel->priv;
-
- if(h == 0.0 && s == 0.0) {
- h = priv->h;
- }
-
- priv->h = h;
- priv->s = s;
- priv->v = v;
-
- g_signal_emit (wheel, wheel_signals[CHANGED], 0);
-
- gtk_widget_queue_draw (GTK_WIDGET (wheel));
-}
-
-/**
- * gimp_color_wheel_get_color:
- * @hsv: An HSV color selector
- * @h: (out): Return value for the hue
- * @s: (out): Return value for the saturation
- * @v: (out): Return value for the value
- *
- * Queries the current color in an HSV color selector.
- * Returned values will be in the [0.0, 1.0] range.
- *
- * Since: 2.14
- */
-void
-gimp_color_wheel_get_color (GimpColorWheel *wheel,
- gdouble *h,
- gdouble *s,
- gdouble *v)
-{
- GimpColorWheelPrivate *priv;
-
- g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel));
-
- priv = wheel->priv;
-
- if (h) *h = priv->h;
- if (s) *s = priv->s;
- if (v) *v = priv->v;
-}
-
-/**
- * gimp_color_wheel_set_ring_fraction:
- * @ring: A wheel color selector
- * @fraction: Ring fraction
- *
- * Sets the ring fraction of a wheel color selector.
- *
- * Since: GIMP 2.10
- */
-void
-gimp_color_wheel_set_ring_fraction (GimpColorWheel *hsv,
- gdouble fraction)
-{
- GimpColorWheelPrivate *priv;
-
- g_return_if_fail (GIMP_IS_COLOR_WHEEL (hsv));
-
- priv = hsv->priv;
-
- priv->ring_fraction = CLAMP (fraction, 0.01, 0.99);
-
- gtk_widget_queue_draw (GTK_WIDGET (hsv));
-}
-
-/**
- * gimp_color_wheel_get_ring_fraction:
- * @ring: A wheel color selector
- *
- * Returns value: The ring fraction of the wheel color selector.
- *
- * Since: GIMP 2.10
- */
-gdouble
-gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel)
-{
- GimpColorWheelPrivate *priv;
-
- g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), DEFAULT_FRACTION);
-
- priv = wheel->priv;
-
- return priv->ring_fraction;
-}
-
-/**
- * gimp_color_wheel_is_adjusting:
- * @hsv: A #GimpColorWheel
- *
- * An HSV color selector can be said to be adjusting if multiple rapid
- * changes are being made to its value, for example, when the user is
- * adjusting the value with the mouse. This function queries whether
- * the HSV color selector is being adjusted or not.
- *
- * Return value: %TRUE if clients can ignore changes to the color value,
- * since they may be transitory, or %FALSE if they should consider
- * the color value status to be final.
- *
- * Since: 2.14
- */
-gboolean
-gimp_color_wheel_is_adjusting (GimpColorWheel *wheel)
-{
- GimpColorWheelPrivate *priv;
-
- g_return_val_if_fail (GIMP_IS_COLOR_WHEEL (wheel), FALSE);
-
- priv = wheel->priv;
-
- return priv->mode != DRAG_NONE;
-}
-
-static void
-gimp_color_wheel_move (GimpColorWheel *wheel,
- GtkDirectionType dir)
-{
- GimpColorWheelPrivate *priv = wheel->priv;
- gdouble hue, sat, val;
- gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
- gint x, y; /* position in triangle */
-
- hue = priv->h;
- sat = priv->s;
- val = priv->v;
-
- compute_triangle (wheel, &hx, &hy, &sx, &sy, &vx, &vy);
-
- x = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
- y = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
-
-#define HUE_DELTA 0.002
- switch (dir)
- {
- case GTK_DIR_UP:
- if (priv->focus_on_ring)
- hue += HUE_DELTA;
- else
- {
- y -= 1;
- compute_sv (wheel, x, y, &sat, &val);
- }
- break;
-
- case GTK_DIR_DOWN:
- if (priv->focus_on_ring)
- hue -= HUE_DELTA;
- else
- {
- y += 1;
- compute_sv (wheel, x, y, &sat, &val);
- }
- break;
-
- case GTK_DIR_LEFT:
- if (priv->focus_on_ring)
- hue += HUE_DELTA;
- else
- {
- x -= 1;
- compute_sv (wheel, x, y, &sat, &val);
- }
- break;
-
- case GTK_DIR_RIGHT:
- if (priv->focus_on_ring)
- hue -= HUE_DELTA
- ;
- else
- {
- x += 1;
- compute_sv (wheel, x, y, &sat, &val);
- }
- break;
-
- default:
- /* we don't care about the tab directions */
- break;
- }
-
- /* Wrap */
- if (hue < 0.0)
- hue = 1.0;
- else if (hue > 1.0)
- hue = 0.0;
-
- gimp_color_wheel_set_color (wheel, hue, sat, val);
-}
diff --git a/src/ui/widget/gimpcolorwheel.h b/src/ui/widget/gimpcolorwheel.h
deleted file mode 100644
index 016fb593f..000000000
--- a/src/ui/widget/gimpcolorwheel.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* HSV color selector for GTK+
- *
- * Copyright (C) 1999 The Free Software Foundation
- *
- * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
- * Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
- * Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GIMP_COLOR_WHEEL_H__
-#define __GIMP_COLOR_WHEEL_H__
-
-G_BEGIN_DECLS
-
-#define GIMP_TYPE_COLOR_WHEEL (gimp_color_wheel_get_type ())
-#define GIMP_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheel))
-#define GIMP_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
-#define GIMP_IS_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_WHEEL))
-#define GIMP_IS_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_WHEEL))
-#define GIMP_COLOR_WHEEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
-
-
-typedef struct _GimpColorWheel GimpColorWheel;
-typedef struct _GimpColorWheelClass GimpColorWheelClass;
-
-struct _GimpColorWheel
-{
- GtkWidget parent_instance;
-
- /* Private data */
- gpointer priv;
-};
-
-struct _GimpColorWheelClass
-{
- GtkWidgetClass parent_class;
-
- /* Notification signals */
- void (* changed) (GimpColorWheel *wheel);
-
- /* Keybindings */
- void (* move) (GimpColorWheel *wheel,
- GtkDirectionType type);
-
- /* Padding for future expansion */
- void (*_gimp_reserved1) (void);
- void (*_gimp_reserved2) (void);
- void (*_gimp_reserved3) (void);
- void (*_gimp_reserved4) (void);
-};
-
-
-GType gimp_color_wheel_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_color_wheel_new (void);
-
-void gimp_color_wheel_set_color (GimpColorWheel *wheel,
- double h,
- double s,
- double v);
-void gimp_color_wheel_get_color (GimpColorWheel *wheel,
- gdouble *h,
- gdouble *s,
- gdouble *v);
-
-void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
- gdouble fraction);
-gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
-
-gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
-
-G_END_DECLS
-
-#endif /* __GIMP_COLOR_WHEEL_H__ */
diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c
deleted file mode 100644
index d99646a64..000000000
--- a/src/ui/widget/gimpspinscale.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/* GIMP - The GNU Image Manipulation Program
- * Copyright (C) 1995 Spencer Kimball and Peter Mattis
- *
- * gimpspinscale.c
- * Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
- * 2012 Øyvind Kolås <pippin@gimp.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
-
-#include "gimpspinscale.h"
-
-
-enum
-{
- PROP_0,
- PROP_LABEL,
- PROP_FOCUS_WIDGET
-};
-
-typedef enum
-{
- TARGET_NUMBER,
- TARGET_UPPER,
- TARGET_LOWER
-#if WITH_GTKMM_3_0
- ,TARGET_NONE
-#endif
-} SpinScaleTarget;
-
-typedef enum
-{
- APPEARANCE_FULL = 1, /* Full size suitable for tablets */
- APPEARANCE_COMPACT, /* Compact, suitable for desktops with mouse control */
-} SpinScaleAppearance;
-
-typedef struct _GimpSpinScalePrivate GimpSpinScalePrivate;
-
-struct _GimpSpinScalePrivate
-{
- gchar *label;
-
- gboolean scale_limits_set;
- gdouble scale_lower;
- gdouble scale_upper;
- gdouble gamma;
-
- PangoLayout *layout;
- gboolean changing_value;
- gboolean relative_change;
- gdouble start_x;
- gdouble start_value;
-
- GtkWidget* focusWidget;
- gboolean transferFocus;
- SpinScaleAppearance appearanceMode;
-};
-
-#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
- GIMP_TYPE_SPIN_SCALE, \
- GimpSpinScalePrivate))
-
-
-static void gimp_spin_scale_dispose (GObject *object);
-static void gimp_spin_scale_finalize (GObject *object);
-static void gimp_spin_scale_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_spin_scale_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gimp_spin_scale_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-
-#if WITH_GTKMM_3_0
-static void gimp_spin_scale_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static void gimp_spin_scale_get_preferred_height (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width);
-static gboolean gimp_spin_scale_draw (GtkWidget *widget,
- cairo_t *cr);
-#else
-static void gimp_spin_scale_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-
-static gboolean gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event);
-#endif
-
-static gboolean gimp_spin_scale_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_spin_scale_button_release (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gimp_spin_scale_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static gboolean gimp_spin_scale_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event);
-static gboolean gimp_spin_scale_keypress( GtkWidget *widget,
- GdkEventKey *event);
-
-static void gimp_spin_scale_defocus( GtkSpinButton *spin_button );
-
-static void gimp_spin_scale_value_changed (GtkSpinButton *spin_button);
-
-
-G_DEFINE_TYPE (GimpSpinScale, gimp_spin_scale, GTK_TYPE_SPIN_BUTTON);
-
-#define parent_class gimp_spin_scale_parent_class
-
-
-static void
-gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass);
-
- object_class->dispose = gimp_spin_scale_dispose;
- object_class->finalize = gimp_spin_scale_finalize;
- object_class->set_property = gimp_spin_scale_set_property;
- object_class->get_property = gimp_spin_scale_get_property;
-
- widget_class->style_set = gimp_spin_scale_style_set;
-#if WITH_GTKMM_3_0
- widget_class->get_preferred_width = gimp_spin_scale_get_preferred_width;
- widget_class->get_preferred_height = gimp_spin_scale_get_preferred_height;
- widget_class->draw = gimp_spin_scale_draw;
-#else
- widget_class->size_request = gimp_spin_scale_size_request;
- widget_class->expose_event = gimp_spin_scale_expose;
-#endif
- widget_class->button_press_event = gimp_spin_scale_button_press;
- widget_class->button_release_event = gimp_spin_scale_button_release;
- widget_class->motion_notify_event = gimp_spin_scale_motion_notify;
- widget_class->leave_notify_event = gimp_spin_scale_leave_notify;
- widget_class->key_press_event = gimp_spin_scale_keypress;
-
- spin_button_class->value_changed = gimp_spin_scale_value_changed;
-
- g_object_class_install_property (object_class, PROP_LABEL,
- g_param_spec_string ("label", NULL, NULL,
- NULL,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (klass, sizeof (GimpSpinScalePrivate));
-}
-
-static void
-gimp_spin_scale_init (GimpSpinScale *scale)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- gtk_widget_add_events (GTK_WIDGET (scale),
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_LEAVE_NOTIFY_MASK);
-
- gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE);
-
- private->gamma = 1.0;
- private->focusWidget = NULL;
- private->transferFocus = FALSE;
- private->appearanceMode = APPEARANCE_COMPACT;
-}
-
-static void
-gimp_spin_scale_dispose (GObject *object)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-gimp_spin_scale_finalize (GObject *object)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
-
- if (private->label)
- {
- g_free (private->label);
- private->label = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gimp_spin_scale_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
- GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
-
- switch (property_id)
- {
- case PROP_LABEL:
- gimp_spin_scale_set_label (scale, g_value_get_string (value));
- break;
-
- case PROP_FOCUS_WIDGET:
- {
- /* TODO unhook prior */
- private->focusWidget = GTK_WIDGET (g_value_get_pointer (value));
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gimp_spin_scale_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (object);
- GimpSpinScale *scale = GIMP_SPIN_SCALE (object);
-
- switch (property_id)
- {
- case PROP_LABEL:
- g_value_set_string (value, gimp_spin_scale_get_label (scale));
- break;
-
- case PROP_FOCUS_WIDGET:
- g_value_set_pointer (value, private->focusWidget);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-void
-gimp_spin_scale_set_focuswidget( GtkWidget *scale, GtkWidget* widget )
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- /* TODO unhook prior */
-
- private->focusWidget = widget;
-}
-
-void
-gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- if ( strcmp("full", appearance) == 0 ) {
- private->appearanceMode = APPEARANCE_FULL;
- } else if ( strcmp("compact", appearance) == 0 ) {
- private->appearanceMode = APPEARANCE_COMPACT;
- }
-}
-
-#if GTK_CHECK_VERSION(3,0,0)
-static void
-gimp_spin_scale_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
- minimum_width,
- natural_width);
-
- metrics = pango_context_get_metrics (context,
- pango_context_get_font_description (context),
- pango_context_get_language (context));
-
- if (private->label)
- {
- gint char_width;
- gint digit_width;
- gint char_pixels;
-
- char_width = pango_font_metrics_get_approximate_char_width (metrics);
- digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
- char_pixels = PANGO_PIXELS (MAX (char_width, digit_width));
-
- /* ~3 chars for the ellipse */
- *minimum_width += char_pixels * 3;
- *natural_width += char_pixels * 3;
- }
-
- pango_font_metrics_unref (metrics);
-}
-
-static void
-gimp_spin_scale_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
- //gint height;
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget,
- minimum_height,
- natural_height);
-
- metrics = pango_context_get_metrics (context,
- pango_context_get_font_description (context),
- pango_context_get_language (context));
-
- //height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- // pango_font_metrics_get_descent (metrics));
-
- *minimum_height += 1;
- *natural_height += 1;
-
- pango_font_metrics_unref (metrics);
-}
-#else
-static void
-gimp_spin_scale_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics;
- gint height;
-
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
-
- metrics = pango_context_get_metrics (context, style->font_desc,
- pango_context_get_language (context));
-
- height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
-
- if (private->appearanceMode == APPEARANCE_COMPACT) {
- requisition->height += 1;
- } else {
- requisition->height += height;
- }
-
- if (private->label)
- {
- gint char_width;
- gint digit_width;
- gint char_pixels;
-
- char_width = pango_font_metrics_get_approximate_char_width (metrics);
- digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
- char_pixels = PANGO_PIXELS (MAX (char_width, digit_width));
-
- /* ~3 chars for the ellipses */
- requisition->width += char_pixels * 3;
- }
-
- pango_font_metrics_unref (metrics);
-}
-#endif
-
-static void
-gimp_spin_scale_style_set (GtkWidget *widget,
- GtkStyle *prev_style)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-}
-
-
-static gboolean
-#if GTK_CHECK_VERSION(3,0,0)
- gimp_spin_scale_draw (GtkWidget *widget,
- cairo_t *cr)
-#else
- gimp_spin_scale_expose (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStyleContext *style = gtk_widget_get_style_context(widget);
- GtkAllocation allocation;
- GdkRGBA color;
-
- cairo_save (cr);
- GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- cairo_restore (cr);
-
- gtk_widget_get_allocation (widget, &allocation);
-#else
- GtkStyle *style = gtk_widget_get_style (widget);
- cairo_t *cr;
- gint w;
-
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- w = gdk_window_get_width (event->window);
-#endif
-
- cairo_set_line_width (cr, 1.0);
-
-#if GTK_CHECK_VERSION(3,0,0)
- if (private->label)
- {
- GdkRectangle text_area;
- gint minimum_width;
- gint natural_width;
-#else
- if (private->label &&
- gtk_widget_is_drawable (widget) &&
- event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
- {
- GtkRequisition requisition;
- GtkAllocation allocation;
-#endif
- PangoRectangle logical;
- gint layout_offset_x;
- gint layout_offset_y;
-#if GTK_CHECK_VERSION(3,0,0)
- GtkStateFlags state;
- GdkRGBA text_color;
- GdkRGBA bar_text_color;
-#else
- GtkStateType state;
- GdkColor text_color;
- GdkColor bar_text_color;
- gint window_width;
- gint window_height;
-#endif
- gdouble progress_fraction;
- gint progress_x;
- gint progress_y;
- gint progress_width;
- gint progress_height;
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
- &minimum_width,
- &natural_width);
-#else
- GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition);
- gtk_widget_get_allocation (widget, &allocation);
-#endif
-
- if (! private->layout)
- {
- private->layout = gtk_widget_create_pango_layout (widget,
- private->label);
- pango_layout_set_ellipsize (private->layout, PANGO_ELLIPSIZE_END);
- }
-
- pango_layout_set_width (private->layout,
- PANGO_SCALE *
-#if GTK_CHECK_VERSION(3,0,0)
- (allocation.width - minimum_width));
-#else
- (allocation.width - requisition.width));
-#endif
- pango_layout_get_pixel_extents (private->layout, NULL, &logical);
-
- gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-#if GTK_CHECK_VERSION(3,0,0)
- layout_offset_x = text_area.x + text_area.width - logical.width - 4;
-#else
- layout_offset_x = w - logical.width - 4;
-#endif
- else
- layout_offset_x = 4;
-
- layout_offset_x -= logical.x;
-
-#if GTK_CHECK_VERSION(3,0,0)
- state = gtk_widget_get_state_flags (widget);
-
- gtk_style_context_get_color (style, state, &text_color);
-
- gtk_style_context_save (style);
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR);
- gtk_style_context_get_color (style, state, &bar_text_color);
- gtk_style_context_restore (style);
-#else
- state = GTK_STATE_SELECTED;
- if (! gtk_widget_get_sensitive (widget))
- state = GTK_STATE_INSENSITIVE;
- text_color = style->text[gtk_widget_get_state (widget)];
- bar_text_color = style->fg[state];
-
- window_width = gdk_window_get_width (event->window);
- window_height = gdk_window_get_height (event->window);
-#endif
-
- progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget));
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- {
- progress_fraction = 1.0 - progress_fraction;
-
-#if GTK_CHECK_VERSION(3,0,0)
- progress_x = text_area.width * progress_fraction;
-#else
- progress_x = window_width * progress_fraction;
-#endif
- progress_y = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- progress_width = text_area.width - progress_x;
- progress_height = text_area.height;
-#else
- progress_width = window_width - progress_x;
- progress_height = window_height;
-#endif
- }
- else
- {
- progress_x = 0;
- progress_y = 0;
-#if GTK_CHECK_VERSION(3,0,0)
- progress_width = text_area.width * progress_fraction;
- progress_height = text_area.height;
-#else
- progress_width = window_width * progress_fraction;
- progress_height = window_height;
-#endif
- }
-
- cairo_save (cr);
-
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_rectangle (cr, 0, 0, text_area.width, text_area.height);
-#else
- cairo_rectangle (cr, 0, 0, window_width, window_height);
-#endif
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &text_color);
-#else
- cairo_move_to (cr, layout_offset_x, layout_offset_y-3);
- gdk_cairo_set_source_color (cr, &text_color);
-#endif
- pango_cairo_show_layout (cr, private->layout);
- cairo_restore (cr);
-
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
-
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
- gdk_cairo_set_source_rgba (cr, &bar_text_color);
-#else
- cairo_move_to (cr, layout_offset_x, layout_offset_y-3);
- gdk_cairo_set_source_color (cr, &bar_text_color);
-#endif
- pango_cairo_show_layout (cr, private->layout);
- }
-
-#if !GTK_CHECK_VERSION(3,0,0)
- cairo_destroy (cr);
-#endif
-
- return FALSE;
-}
-
-#if WITH_GTKMM_3_0
-/* Returns TRUE if a translation should be done */
-static gboolean
-gtk_widget_get_translation_to_window (GtkWidget *widget,
- GdkWindow *window,
- int *x,
- int *y)
-{
- GdkWindow *w, *widget_window;
-
- if (!gtk_widget_get_has_window (widget))
- {
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- *x = -allocation.x;
- *y = -allocation.y;
- }
- else
- {
- *x = 0;
- *y = 0;
- }
-
- widget_window = gtk_widget_get_window (widget);
-
- for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
- {
- int wx, wy;
- gdk_window_get_position (w, &wx, &wy);
- *x += wx;
- *y += wy;
- }
-
- if (w == NULL)
- {
- *x = 0;
- *y = 0;
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-gimp_spin_scale_event_to_widget_coords (GtkWidget *widget,
- GdkWindow *window,
- gdouble event_x,
- gdouble event_y,
- gint *widget_x,
- gint *widget_y)
-{
- gint tx, ty;
-
- if (gtk_widget_get_translation_to_window (widget, window, &tx, &ty))
- {
- event_x += tx;
- event_y += ty;
- }
-
- *widget_x = event_x;
- *widget_y = event_y;
-}
-#endif
-
-static SpinScaleTarget
-gimp_spin_scale_get_target (GtkWidget *widget,
- gdouble x,
- gdouble y)
-{
- GtkAllocation allocation;
- PangoRectangle logical;
- gint layout_x;
- gint layout_y;
-
- gtk_widget_get_allocation (widget, &allocation);
- gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y);
- pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)),
- NULL, &logical);
-
-#if WITH_GTKMM_3_0
- GdkRectangle text_area;
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
-
- if (x >= text_area.x && x < text_area.width &&
- y >= text_area.y && y < text_area.height)
- {
- x -= text_area.x;
- y -= text_area.y;
-
- if (x > layout_x && x < layout_x + logical.width &&
- y > layout_y && y < layout_y + logical.height)
- {
- return TARGET_NUMBER;
- }
- else if (y > text_area.height / 2)
- {
- return TARGET_LOWER;
- }
-
- return TARGET_UPPER;
- }
-
- return TARGET_NONE;
-#else
- if (x > layout_x && x < layout_x + logical.width &&
- y > layout_y && y < layout_y + logical.height)
- {
- return TARGET_NUMBER;
- }
-
- else if (y > allocation.height / 2)
- {
- return TARGET_LOWER;
- }
- return TARGET_UPPER;
-#endif
-}
-
-static void
-gimp_spin_scale_get_limits (GimpSpinScale *scale,
- gdouble *lower,
- gdouble *upper)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (scale);
-
- if (private->scale_limits_set)
- {
- *lower = private->scale_lower;
- *upper = private->scale_upper;
- }
- else
- {
- GtkSpinButton *spin_button = GTK_SPIN_BUTTON (scale);
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
-
- *lower = gtk_adjustment_get_lower (adjustment);
- *upper = gtk_adjustment_get_upper (adjustment);
- }
-}
-
-static void
-gimp_spin_scale_change_value (GtkWidget *widget,
- gdouble x)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
- gdouble lower;
- gdouble upper;
- gdouble value;
-#if WITH_GTKMM_3_0
-#else
-#endif
-#if WITH_GTKMM_3_0
- GdkRectangle text_area;
- gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
-#else
- GdkWindow *text_window = gtk_entry_get_text_window (GTK_ENTRY (widget));
- gint width;
-
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
-
- width = gdk_window_get_width (text_window);
-#endif
-
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-#if WITH_GTKMM_3_0
- x = text_area.width - x;
-#else
- x = width - x;
-#endif
-
-
- if (private->relative_change)
- {
- gdouble diff;
- gdouble step;
-
-
-#if WITH_GTKMM_3_0
- step = (upper - lower) / text_area.width / 10.0;
-#else
- step = (upper - lower) / width / 10.0;
-#endif
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-
-#if WITH_GTKMM_3_0
- diff = x - (text_area.width - private->start_x);
-#else
- diff = x - (width - private->start_x);
-#endif
- else
- diff = x - private->start_x;
-
- value = (private->start_value + diff * step);
- }
- else
- {
- gdouble fraction;
-
-
-#if WITH_GTKMM_3_0
- fraction = x / (gdouble) text_area.width;
-#else
- fraction = x / (gdouble) width;
-#endif
- if (fraction > 0.0)
- fraction = pow (fraction, private->gamma);
-
- value = fraction * (upper - lower) + lower;
- }
-
- gtk_adjustment_set_value (adjustment, value);
-}
-
-static gboolean
-gimp_spin_scale_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- private->changing_value = FALSE;
- private->relative_change = FALSE;
-
-#if WITH_GTKMM_3_0
- gint x, y;
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
- switch (gimp_spin_scale_get_target (widget, x, y))
- {
- case TARGET_UPPER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- gimp_spin_scale_change_value (widget, x);
-
- return TRUE;
-
- case TARGET_LOWER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- private->relative_change = TRUE;
- private->start_x = x;
- private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
-
- return TRUE;
-
- default:
- break;
- }
-#else
- if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
- {
- switch (gimp_spin_scale_get_target (widget, event->x, event->y))
- {
- case TARGET_UPPER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- gimp_spin_scale_change_value (widget, event->x);
-
- return TRUE;
-
- case TARGET_LOWER:
- private->changing_value = TRUE;
-
- gtk_widget_grab_focus (widget);
-
- private->relative_change = TRUE;
- private->start_x = event->x;
- private->start_value = gtk_adjustment_get_value (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)));
-
- return TRUE;
-
- default:
- break;
- }
- }
-#endif
-
- return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
-}
-
-static gboolean
-gimp_spin_scale_button_release (GtkWidget *widget,
- GdkEventButton *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-#if WITH_GTKMM_3_0
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-#endif
-
- if (private->changing_value)
- {
- private->changing_value = FALSE;
-#if WITH_GTKMM_3_0
- gimp_spin_scale_change_value (widget, x);
-#else
- gimp_spin_scale_change_value (widget, event->x);
-#endif
- return TRUE;
- }
-
- return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
-}
-
-static gboolean
-gimp_spin_scale_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-
- gdk_event_request_motions (event);
-
-#if WITH_GTKMM_3_0
- gint x, y;
-
- gimp_spin_scale_event_to_widget_coords (widget, event->window,
- event->x, event->y,
- &x, &y);
-#endif
-
- if (private->changing_value)
- {
-#if WITH_GTKMM_3_0
- gimp_spin_scale_change_value (widget, x);
-#else
- gimp_spin_scale_change_value (widget, event->x);
-#endif
-
- return TRUE;
- }
-
- GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
-
- if (! (event->state &
- (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))
-#if WITH_GTKMM_3_0
-#else
- && event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))
-#endif
- )
- {
- GdkDisplay *display = gtk_widget_get_display (widget);
- GdkCursor *cursor = NULL;
-
-#if WITH_GTKMM_3_0
- switch (gimp_spin_scale_get_target (widget, x, y))
-#else
- switch (gimp_spin_scale_get_target (widget, event->x, event->y))
-#endif
- {
- case TARGET_NUMBER:
- cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
- break;
-
- case TARGET_UPPER:
- cursor = gdk_cursor_new_for_display (display, GDK_SB_UP_ARROW);
- break;
-
- case TARGET_LOWER:
- cursor = gdk_cursor_new_for_display (display, GDK_SB_H_DOUBLE_ARROW);
- break;
-
- default:
- break;
- }
-
-
-#if WITH_GTKMM_3_0
- if (cursor)
- {
- gdk_window_set_cursor (event->window, cursor);
- g_object_unref (cursor);
- }
-#else
- gdk_window_set_cursor (event->window, cursor);
- gdk_cursor_unref (cursor);
-#endif
- }
-
- return FALSE;
-}
-
-static gboolean
-gimp_spin_scale_leave_notify (GtkWidget *widget,
- GdkEventCrossing *event)
-{
- gdk_window_set_cursor (event->window, NULL);
-
- return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
-}
-
-gboolean gimp_spin_scale_keypress( GtkWidget *widget, GdkEventKey *event)
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (widget);
- guint key = 0;
- gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display( gdk_display_get_default() ),
- event->hardware_keycode, (GdkModifierType)event->state,
- 0, &key, 0, 0, 0 );
-
- switch ( key ) {
-
- case GDK_KEY_Escape:
- case GDK_KEY_Return:
- case GDK_KEY_KP_Enter:
- {
- private->transferFocus = TRUE;
- gimp_spin_scale_defocus( GTK_SPIN_BUTTON(widget) );
- }
- break;
-
- }
-
- return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
-}
-
-static void
-gimp_spin_scale_defocus( GtkSpinButton *spin_button )
-{
- GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
-
- if ( private->transferFocus ) {
- if ( private->focusWidget ) {
- gtk_widget_grab_focus( private->focusWidget );
- }
- }
-}
-
-static void
-gimp_spin_scale_value_changed (GtkSpinButton *spin_button)
-{
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
- GimpSpinScalePrivate *private = GET_PRIVATE (spin_button);
- gdouble lower;
- gdouble upper;
- gdouble value;
-
- gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (spin_button), &lower, &upper);
-
- value = CLAMP (gtk_adjustment_get_value (adjustment), lower, upper);
-
- gtk_entry_set_progress_fraction (GTK_ENTRY (spin_button),
- pow ((value - lower) / (upper - lower),
- 1.0 / private->gamma));
-
- // TODO - Allow scrollwheel to change value then return focus,
- // but clicks/keypress should keep focus in the control
- //if ( gtk_widget_has_focus( GTK_WIDGET(spin_button) ) ) {
- // gimp_spin_scale_defocus( spin_button );
- //}
-}
-
-
-/* public functions */
-
-GtkWidget *
-gimp_spin_scale_new (GtkAdjustment *adjustment,
- const gchar *label,
- gint digits)
-{
- g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
-
- return g_object_new (GIMP_TYPE_SPIN_SCALE,
- "adjustment", adjustment,
- "label", label,
- "digits", digits,
- NULL);
-}
-
-void
-gimp_spin_scale_set_label (GimpSpinScale *scale,
- const gchar *label)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- if (label == private->label)
- return;
-
- g_free (private->label);
- private->label = g_strdup (label);
-
- if (private->layout)
- {
- g_object_unref (private->layout);
- private->layout = NULL;
- }
-
- gtk_widget_queue_resize (GTK_WIDGET (scale));
-
- g_object_notify (G_OBJECT (scale), "label");
-}
-
-const gchar *
-gimp_spin_scale_get_label (GimpSpinScale *scale)
-{
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), NULL);
-
- return GET_PRIVATE (scale)->label;
-}
-
-void
-gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
- gdouble lower,
- gdouble upper)
-{
- GimpSpinScalePrivate *private;
- GtkSpinButton *spin_button;
- GtkAdjustment *adjustment;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
- spin_button = GTK_SPIN_BUTTON (scale);
- adjustment = gtk_spin_button_get_adjustment (spin_button);
-
- g_return_if_fail (lower >= gtk_adjustment_get_lower (adjustment));
- g_return_if_fail (upper <= gtk_adjustment_get_upper (adjustment));
-
- private->scale_limits_set = TRUE;
- private->scale_lower = lower;
- private->scale_upper = upper;
- private->gamma = 1.0;
-
- gimp_spin_scale_value_changed (spin_button);
-}
-
-void
-gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- private->scale_limits_set = FALSE;
- private->scale_lower = 0.0;
- private->scale_upper = 0.0;
-
- gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
-}
-
-gboolean
-gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
- gdouble *lower,
- gdouble *upper)
-{
- GimpSpinScalePrivate *private;
-
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), FALSE);
-
- private = GET_PRIVATE (scale);
-
- if (lower)
- *lower = private->scale_lower;
-
- if (upper)
- *upper = private->scale_upper;
-
- return private->scale_limits_set;
-}
-
-void
-gimp_spin_scale_set_gamma (GimpSpinScale *scale,
- gdouble gamma)
-{
- GimpSpinScalePrivate *private;
-
- g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
-
- private = GET_PRIVATE (scale);
-
- private->gamma = gamma;
-
- gimp_spin_scale_value_changed (GTK_SPIN_BUTTON (scale));
-}
-
-gdouble
-gimp_spin_scale_get_gamma (GimpSpinScale *scale)
-{
- g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
-
- return GET_PRIVATE(scale)->gamma;
-}
diff --git a/src/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h
deleted file mode 100644
index b42a0faf8..000000000
--- a/src/ui/widget/gimpspinscale.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* GIMP - The GNU Image Manipulation Program
- * Copyright (C) 1995 Spencer Kimball and Peter Mattis
- *
- * gimpspinscale.h
- * Copyright (C) 2010 Michael Natterer <mitch@gimp.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GIMP_SPIN_SCALE_H__
-#define __GIMP_SPIN_SCALE_H__
-
-#ifndef WITH_GIMP
-#include <gtk/gtk.h>
-#endif
-
-G_BEGIN_DECLS
-
-#define GIMP_TYPE_SPIN_SCALE (gimp_spin_scale_get_type ())
-#define GIMP_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScale))
-#define GIMP_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
-#define GIMP_IS_SPIN_SCALE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SPIN_SCALE))
-#define GIMP_IS_SPIN_SCALE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SPIN_SCALE))
-#define GIMP_SPIN_SCALE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SPIN_SCALE, GimpSpinScaleClass))
-
-
-typedef struct _GimpSpinScale GimpSpinScale;
-typedef struct _GimpSpinScaleClass GimpSpinScaleClass;
-
-struct _GimpSpinScale
-{
- GtkSpinButton parent_instance;
-};
-
-struct _GimpSpinScaleClass
-{
- GtkSpinButtonClass parent_class;
-};
-
-
-GType gimp_spin_scale_get_type (void) G_GNUC_CONST;
-
-GtkWidget * gimp_spin_scale_new (GtkAdjustment *adjustment,
- const gchar *label,
- gint digits);
-
-void gimp_spin_scale_set_label (GimpSpinScale *scale,
- const gchar *label);
-const gchar * gimp_spin_scale_get_label (GimpSpinScale *scale);
-
-void gimp_spin_scale_set_scale_limits (GimpSpinScale *scale,
- gdouble lower,
- gdouble upper);
-void gimp_spin_scale_unset_scale_limits (GimpSpinScale *scale);
-gboolean gimp_spin_scale_get_scale_limits (GimpSpinScale *scale,
- gdouble *lower,
- gdouble *upper);
-
-void gimp_spin_scale_set_gamma (GimpSpinScale *scale,
- gdouble gamma);
-gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale);
-
-void gimp_spin_scale_set_focuswidget (GtkWidget *scale,
- GtkWidget *widget);
-
-void gimp_spin_scale_set_appearance (GtkWidget *scale,
- const gchar *appearance);
-
-G_END_DECLS
-
-#endif /* __GIMP_SPIN_SCALE_H__ */
diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp
index 09999b52d..561c1332a 100644
--- a/src/ui/widget/highlight-picker.cpp
+++ b/src/ui/widget/highlight-picker.cpp
@@ -14,9 +14,6 @@
#include "highlight-picker.h"
#include "widgets/icon.h"
-#include "widgets/toolbox.h"
-#include "ui/icon-names.h"
-#include <glibmm/i18n.h>
namespace Inkscape {
namespace UI {
@@ -35,8 +32,6 @@ HighlightPicker::~HighlightPicker()
{
}
-
-#if WITH_GTKMM_3_0
void HighlightPicker::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -66,39 +61,12 @@ void HighlightPicker::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void HighlightPicker::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = 10;//+= (*width) >> 1;
- }
- if ( height ) {
- *height = 20; //cell_area ? cell_area->get_height() / 2 : 50; //+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void HighlightPicker::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
GdkRectangle carea;
@@ -140,11 +108,7 @@ void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
convert_pixbuf_argb32_to_normal(pixbuf);
property_pixbuf() = Glib::wrap(pixbuf);
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool HighlightPicker::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/highlight-picker.h b/src/ui/widget/highlight-picker.h
index c5fe4c02c..c459b0dcd 100644
--- a/src/ui/widget/highlight-picker.h
+++ b/src/ui/widget/highlight-picker.h
@@ -29,8 +29,6 @@ public:
Glib::PropertyProxy<guint32> property_active() { return _property_active.get_proxy(); }
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -44,18 +42,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp
index df261b69a..8e7df7a68 100644
--- a/src/ui/widget/imageicon.cpp
+++ b/src/ui/widget/imageicon.cpp
@@ -11,17 +11,12 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
-
-
#include "imageicon.h"
-#include <sys/stat.h>
#include "svg-view-widget.h"
#include "document.h"
#include "inkscape.h"
-#include <glibmm/convert.h>
#include <glibmm/fileutils.h>
-
+#include <glibmm/convert.h>
namespace Inkscape
{
diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp
index 29907f4c9..987cc67bb 100644
--- a/src/ui/widget/imagetoggler.cpp
+++ b/src/ui/widget/imagetoggler.cpp
@@ -53,8 +53,6 @@ ImageToggler::ImageToggler( char const* on, char const* off) :
property_pixbuf() = _property_pixbuf_off.get_value();
}
-
-#if WITH_GTKMM_3_0
void ImageToggler::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -84,46 +82,15 @@ void ImageToggler::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void ImageToggler::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width += (*width) >> 1;
- }
- if ( height ) {
- *height += (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void ImageToggler::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void ImageToggler::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off;
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool
diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h
index 7b02fa4dc..d4f27cf11 100644
--- a/src/ui/widget/imagetoggler.h
+++ b/src/ui/widget/imagetoggler.h
@@ -36,8 +36,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -51,18 +49,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp
index 9aec7d135..7ed1ed2e2 100644
--- a/src/ui/widget/insertordericon.cpp
+++ b/src/ui/widget/insertordericon.cpp
@@ -52,7 +52,6 @@ InsertOrderIcon::InsertOrderIcon() :
}
-#if WITH_GTKMM_3_0
void InsertOrderIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -82,39 +81,12 @@ void InsertOrderIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void InsertOrderIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width = phys;//+= (*width) >> 1;
- }
- if ( height ) {
- *height =phys;//+= (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void InsertOrderIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
switch (_property_active.get_value())
{
@@ -128,11 +100,7 @@ void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0);
break;
}
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool InsertOrderIcon::activate_vfunc(GdkEvent* /*event*/,
diff --git a/src/ui/widget/insertordericon.h b/src/ui/widget/insertordericon.h
index bf8ac4fa7..43188fa5b 100644
--- a/src/ui/widget/insertordericon.h
+++ b/src/ui/widget/insertordericon.h
@@ -33,7 +33,6 @@ public:
protected:
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -47,18 +46,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index 1a9ce617f..4432a6e09 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -11,7 +11,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <cstring>
@@ -19,15 +19,15 @@
#include "ui/dialog/layer-properties.h"
#include <glibmm/i18n.h>
+#include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include "desktop.h"
#include "document.h"
#include "document-undo.h"
#include "layer-manager.h"
-#include "sp-item.h"
#include "ui/icon-names.h"
-#include "ui/widget/layer-selector.h"
#include "util/filter-list.h"
#include "util/reverse-list.h"
#include "verbs.h"
@@ -348,27 +348,17 @@ void LayerSelector::_buildSiblingEntries(
unsigned depth, SPObject &parent,
Inkscape::Util::List<SPObject &> hierarchy
) {
- using Inkscape::Util::List;
using Inkscape::Util::rest;
- using Inkscape::Util::reverse_list_in_place;
- using Inkscape::Util::filter_list;
- Inkscape::Util::List<SPObject &> siblings(
- reverse_list_in_place(
- filter_list<SPObject::SiblingIterator>(
- is_layer(_desktop), parent.firstChild(), NULL
- )
- )
- );
+ auto siblings = parent.children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed;
SPObject *layer( hierarchy ? &*hierarchy : NULL );
- while (siblings) {
- _buildEntry(depth, *siblings);
- if ( &*siblings == layer ) {
+ for (auto& sib: siblings) {
+ _buildEntry(depth, sib);
+ if ( &sib == layer ) {
_buildSiblingEntries(depth+1, *layer, rest(hierarchy));
}
- ++siblings;
}
}
diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp
index 672c607e5..df85f271a 100644
--- a/src/ui/widget/layertypeicon.cpp
+++ b/src/ui/widget/layertypeicon.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "ui/widget/layertypeicon.h"
@@ -18,7 +18,6 @@
#include "widgets/icon.h"
#include "widgets/toolbox.h"
#include "ui/icon-names.h"
-#include "layertypeicon.h"
namespace Inkscape {
namespace UI {
@@ -64,8 +63,6 @@ LayerTypeIcon::LayerTypeIcon() :
property_pixbuf() = _property_pixbuf_path.get_value();
}
-
-#if WITH_GTKMM_3_0
void LayerTypeIcon::get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const
@@ -95,46 +92,15 @@ void LayerTypeIcon::get_preferred_width_vfunc(Gtk::Widget& widget,
nat_w += (nat_w) >> 1;
}
}
-#else
-void LayerTypeIcon::get_size_vfunc(Gtk::Widget& widget,
- const Gdk::Rectangle* cell_area,
- int* x_offset,
- int* y_offset,
- int* width,
- int* height ) const
-{
- Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
-
- if ( width ) {
- *width += (*width) >> 1;
- }
- if ( height ) {
- *height += (*height) >> 1;
- }
-}
-#endif
-#if WITH_GTKMM_3_0
void LayerTypeIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags )
-#else
-void LayerTypeIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags )
-#endif
{
property_pixbuf() = _property_active.get_value() == 1 ? _property_pixbuf_group : (_property_active.get_value() == 2 ? _property_pixbuf_layer : _property_pixbuf_path);
-#if WITH_GTKMM_3_0
Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags );
-#else
- Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
-#endif
}
bool
diff --git a/src/ui/widget/layertypeicon.h b/src/ui/widget/layertypeicon.h
index 6c71ce361..f12029c12 100644
--- a/src/ui/widget/layertypeicon.h
+++ b/src/ui/widget/layertypeicon.h
@@ -35,8 +35,6 @@ public:
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off();
protected:
-
-#if WITH_GTKMM_3_0
virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
@@ -50,18 +48,6 @@ protected:
virtual void get_preferred_height_vfunc(Gtk::Widget& widget,
int& min_h,
int& nat_h) const;
-#else
- virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags );
-
- virtual void get_size_vfunc( Gtk::Widget &widget,
- Gdk::Rectangle const *cell_area,
- int *x_offset, int *y_offset, int *width, int *height ) const;
-#endif
virtual bool activate_vfunc(GdkEvent *event,
Gtk::Widget &widget,
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp
index d21e848f2..1e9ee361d 100644
--- a/src/ui/widget/licensor.cpp
+++ b/src/ui/widget/licensor.cpp
@@ -13,12 +13,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "licensor.h"
#include <gtkmm/entry.h>
+#include <gtkmm/radiobutton.h>
#include "ui/widget/entity-entry.h"
#include "ui/widget/registry.h"
@@ -27,7 +28,6 @@
#include "document-undo.h"
#include "document-private.h"
#include "verbs.h"
-#include <gtkmm/radiobutton.h>
namespace Inkscape {
@@ -134,18 +134,10 @@ void Licensor::update (SPDocument *doc)
for (i=0; rdf_licenses[i].name; i++)
if (license == &rdf_licenses[i])
break;
-#if WITH_GTKMM_3_0
static_cast<LicenseItem*>(get_children()[i+1])->set_active();
-#else
- static_cast<LicenseItem*>(children()[i+1].get_widget())->set_active();
-#endif
}
else {
-#if WITH_GTKMM_3_0
static_cast<LicenseItem*>(get_children()[0])->set_active();
-#else
- static_cast<LicenseItem*>(children()[0].get_widget())->set_active();
-#endif
}
/* update the URI */
diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp
index 2f03ed23b..6d8ff1d75 100644
--- a/src/ui/widget/notebook-page.cpp
+++ b/src/ui/widget/notebook-page.cpp
@@ -11,31 +11,19 @@
#include "notebook-page.h"
-#if WITH_GTKMM_3_0
# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
namespace Inkscape {
namespace UI {
namespace Widget {
NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding)
-#if WITH_GTKMM_3_0
:_table(Gtk::manage(new Gtk::Grid()))
-#else
- :_table(Gtk::manage(new Gtk::Table(n_rows, n_columns)))
-#endif
{
set_border_width(2);
-#if WITH_GTKMM_3_0
_table->set_row_spacing(2);
_table->set_column_spacing(2);
-#else
- _table->set_spacings(2);
-#endif
pack_start(*_table, expand, fill, padding);
}
diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h
index c11de1b5b..6eb23907c 100644
--- a/src/ui/widget/notebook-page.h
+++ b/src/ui/widget/notebook-page.h
@@ -17,11 +17,7 @@
#include <gtkmm/box.h>
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
@@ -42,19 +38,10 @@ public:
*/
NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0);
-#if WITH_GTKMM_3_0
Gtk::Grid& table() { return *_table; }
-#else
- Gtk::Table& table() { return *_table; }
-#endif
protected:
-
-#if WITH_GTKMM_3_0
Gtk::Grid *_table;
-#else
- Gtk::Table *_table;
-#endif
};
} // namespace Widget
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 8acf083d0..1727660c8 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -14,8 +14,6 @@
#include "ui/widget/object-composite-settings.h"
-#include <glibmm/i18n.h>
-
#include "desktop.h"
#include "desktop-style.h"
@@ -23,17 +21,12 @@
#include "document-undo.h"
#include "filter-chemistry.h"
#include "inkscape.h"
-#include "selection.h"
#include "style.h"
-#include "sp-item.h"
#include "svg/css-ostringstream.h"
#include "verbs.h"
-#include "xml/repr.h"
#include "widgets/icon.h"
-#include "ui/icon-names.h"
#include "display/sp-canvas.h"
#include "ui/widget/style-subject.h"
-#include "ui/widget/gimpspinscale.h"
namespace Inkscape {
namespace UI {
@@ -125,7 +118,7 @@ ObjectCompositeSettings::_blendBlurValueChanged()
const Glib::ustring blendmode = _fe_cb.get_blend_mode();
//apply created filter to every selected item
- std::vector<SPObject*> sel=_subject->list();
+ std::vector<SPObject*> sel = _subject->list();
for (std::vector<SPObject*>::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) {
if (!SP_IS_ITEM(*i)) {
continue;
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 19ab1a280..081300b9e 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -18,35 +18,18 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "page-sizer.h"
-#include <cmath>
-#include <string>
-#include <string.h>
-#include <sstream>
-#include <vector>
-
#include <glibmm/i18n.h>
-#include <2geom/transforms.h>
-
-#include "document.h"
-#include "desktop.h"
#include "helper/action.h"
-#include "helper/action-context.h"
-#include "util/units.h"
-#include "inkscape.h"
-#include "sp-namedview.h"
#include "sp-root.h"
#include "ui/widget/button.h"
-#include "ui/widget/scalar-unit.h"
#include "verbs.h"
-#include "xml/node.h"
-#include "xml/repr.h"
using std::pair;
using Inkscape::Util::unit_table;
@@ -353,7 +336,6 @@ PageSizer::PageSizer(Registry & _wr)
_customDimTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_customDimTable.set_row_spacing(4);
_customDimTable.set_column_spacing(4);
@@ -372,15 +354,6 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageMarginExpander.set_hexpand();
_fitPageMarginExpander.set_vexpand();
_customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1);
-#else
- _customDimTable.resize(3, 2);
- _customDimTable.set_row_spacings(4);
- _customDimTable.set_col_spacings(4);
- _customDimTable.attach(_dimensionWidth, 0,1, 0,1);
- _customDimTable.attach(_dimensionUnits, 1,2, 0,1);
- _customDimTable.attach(_dimensionHeight, 0,1, 1,2);
- _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3);
-#endif
_dimTabOrderGList = NULL;
_dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj());
@@ -398,7 +371,6 @@ PageSizer::PageSizer(Registry & _wr)
//## Set up margin settings
_marginTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_marginTable.set_row_spacing(4);
_marginTable.set_column_spacing(4);
@@ -421,16 +393,6 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageButtonAlign.set_hexpand();
_fitPageButtonAlign.set_vexpand();
_marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1);
-#else
- _marginTable.set_border_width(4);
- _marginTable.set_row_spacings(4);
- _marginTable.set_col_spacings(4);
- _marginTable.attach(_marginTopAlign, 0,2, 0,1);
- _marginTable.attach(_marginLeftAlign, 0,1, 1,2);
- _marginTable.attach(_marginRightAlign, 1,2, 1,2);
- _marginTable.attach(_marginBottomAlign, 0,2, 2,3);
- _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4);
-#endif
_marginTopAlign.set(0.5, 0.5, 0.0, 1.0);
_marginTopAlign.add(_marginTop);
@@ -444,7 +406,7 @@ PageSizer::PageSizer(Registry & _wr)
_fitPageButtonAlign.set(0.5, 0.5, 0.0, 1.0);
_fitPageButtonAlign.add(_fitPageButton);
_fitPageButton.set_use_underline();
- _fitPageButton.set_label(_("_Resize page to drawing or selection"));
+ _fitPageButton.set_label(_("_Resize page to drawing or selection (Ctrl+Shift+R)"));
_fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection"));
_scaleFrame.set_label(_("Scale"));
@@ -453,7 +415,6 @@ PageSizer::PageSizer(Registry & _wr)
_scaleTable.set_border_width(4);
-#if WITH_GTKMM_3_0
_scaleTable.set_row_spacing(4);
_scaleTable.set_column_spacing(4);
@@ -465,16 +426,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxExpander.set_hexpand();
_viewboxExpander.set_vexpand();
_scaleTable.attach(_viewboxExpander, 0, 2, 2, 1);
-#else
- _scaleTable.resize(3, 2);
- _scaleTable.set_row_spacings(4);
- _scaleTable.set_col_spacings(4);
- _scaleTable.attach(_scaleX, 0,1, 0,1);
- _scaleTable.attach(_scaleY, 1,2, 0,1);
- _scaleTable.attach(_scaleLabel, 2,3, 0,1);
- _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL);
- _scaleTable.attach(_viewboxExpander, 0,3, 2,3);
-#endif
_scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly."));
_scaleWarning.set_line_wrap( true );
@@ -483,7 +434,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxExpander.set_label(_("_Viewbox..."));
_viewboxExpander.add(_viewboxTable);
-#if WITH_GTKMM_3_0
_viewboxTable.set_row_spacing(2);
_viewboxTable.set_column_spacing(2);
@@ -503,16 +453,6 @@ PageSizer::PageSizer(Registry & _wr)
_viewboxH.set_vexpand();
_viewboxTable.attach(_viewboxH, 1, 1, 1, 1);
-#else
- _viewboxTable.set_border_width(4);
- _viewboxTable.set_row_spacings(2);
- _viewboxTable.set_col_spacings(2);
- _viewboxTable.attach(_viewboxX, 0,1, 0,1);
- _viewboxTable.attach(_viewboxY, 1,2, 0,1);
- _viewboxTable.attach(_viewboxW, 0,1, 1,2);
- _viewboxTable.attach(_viewboxH, 1,2, 1,2);
-#endif
-
_wr.setUpdating (true);
updateScaleUI();
_wr.setUpdating (false);
diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h
index 0eea28e61..f1966f848 100644
--- a/src/ui/widget/page-sizer.h
+++ b/src/ui/widget/page-sizer.h
@@ -23,15 +23,9 @@
#include <gtkmm/alignment.h>
#include <gtkmm/expander.h>
#include <gtkmm/frame.h>
+#include <gtkmm/grid.h>
#include <gtkmm/liststore.h>
#include <gtkmm/scrolledwindow.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
-
#include <gtkmm/radiobutton.h>
namespace Inkscape {
@@ -222,12 +216,7 @@ protected:
//### Custom size frame
Gtk::Frame _customFrame;
-
-#if WITH_GTKMM_3_0
Gtk::Grid _customDimTable;
-#else
- Gtk::Table _customDimTable;
-#endif
RegisteredUnitMenu _dimensionUnits;
RegisteredScalarUnit _dimensionWidth;
@@ -237,12 +226,7 @@ protected:
//### Fit Page options
Gtk::Expander _fitPageMarginExpander;
-#if WITH_GTKMM_3_0
Gtk::Grid _marginTable;
-#else
- Gtk::Table _marginTable;
-#endif
-
Gtk::Alignment _marginTopAlign;
Gtk::Alignment _marginLeftAlign;
Gtk::Alignment _marginRightAlign;
@@ -257,11 +241,7 @@ protected:
// Document scale
Gtk::Frame _scaleFrame;
-#if WITH_GTKMM_3_0
Gtk::Grid _scaleTable;
-#else
- Gtk::Table _scaleTable;
-#endif
Gtk::Label _scaleLabel;
Gtk::Label _scaleWarning;
@@ -271,11 +251,7 @@ protected:
// Viewbox
Gtk::Expander _viewboxExpander;
-#if WITH_GTKMM_3_0
Gtk::Grid _viewboxTable;
-#else
- Gtk::Table _viewboxTable;
-#endif
RegisteredScalar _viewboxX;
RegisteredScalar _viewboxY;
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index ab13577d7..dff92594b 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -12,20 +12,17 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/dialog.h> // for Gtk::RESPONSE_*
#include <gtkmm/menu.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/radiobutton.h>
+#include <gtkmm/checkmenuitem.h>
#include <gtkmm/radiomenuitem.h>
#include <gtkmm/separatormenuitem.h>
#include <glibmm/i18n.h>
-#include <gtk/gtk.h>
-
#include "panel.h"
#include "icon-size.h"
#include "preferences.h"
@@ -68,15 +65,13 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path,
_label(label),
_apply_label(apply_label),
_verb_num(verb_num),
- _temp_arrow(Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT),
+ _temp_arrow(),
_menu(0),
_action_area(0),
_fillable(0)
{
set_name( "InkscapePanel" );
-#if WITH_GTKMM_3_0
set_orientation( Gtk::ORIENTATION_VERTICAL );
-#endif
_init();
}
@@ -273,11 +268,9 @@ void Panel::_init()
_top_bar.pack_end(_menu_popper, false, false);
gint width = 0;
gint height = 0;
-
- if ( gtk_icon_size_lookup( Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_DECORATION), &width, &height ) ) {
- _temp_arrow.set_size_request(width, height);
- }
-
+ gtk_image_set_from_icon_name(_temp_arrow.gobj(),
+ "pan-start-symbolic",
+ Inkscape::getRegisteredIconSize(Inkscape::ICON_SIZE_SMALL_TOOLBAR));
_menu_popper.add(_temp_arrow);
_menu_popper.signal_button_press_event().connect_notify(sigc::mem_fun(*this, &Panel::_popper));
}
@@ -582,14 +575,7 @@ void Panel::_apply()
Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id, bool pack_start)
{
- Gtk::Button *button = new Gtk::Button(button_text);
- _addResponseButton(button, response_id, pack_start);
- return button;
-}
-
-Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id, bool pack_start)
-{
- Gtk::Button *button = new Gtk::Button(stock_id);
+ Gtk::Button *button = new Gtk::Button(button_text, true);
_addResponseButton(button, response_id, pack_start);
return button;
}
@@ -598,13 +584,9 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_s
{
// Create a button box for the response buttons if it's the first button to be added
if (!_action_area) {
-#if WITH_GTKMM_3_0
_action_area = new Gtk::ButtonBox();
_action_area->set_layout(Gtk::BUTTONBOX_END);
_action_area->set_spacing(6);
-#else
- _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
-#endif
_action_area->set_border_width(4);
pack_end(*_action_area, Gtk::PACK_SHRINK, 0);
}
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 7b2836fe8..b5498498d 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -18,9 +18,9 @@
#endif
#include <gtkmm/box.h>
-#include <gtkmm/arrow.h>
#include <gtkmm/button.h>
#include <gtkmm/eventbox.h>
+#include <gtkmm/image.h>
#include <gtkmm/label.h>
#include "enums.h"
#include <vector>
@@ -31,13 +31,7 @@ class SPDocument;
namespace Gtk {
class CheckMenuItem;
-
-#if WITH_GTKMM_3_0
class ButtonBox;
-#else
- class HButtonBox;
-#endif
-
class MenuItem;
}
@@ -64,12 +58,7 @@ namespace Widget {
* @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications.
* @see UI::Dialog::DialogManager manages the dialogs within inkscape.
*/
-#if WITH_GTKMM_3_0
class Panel : public Gtk::Box {
-#else
-class Panel : public Gtk::VBox {
-#endif
-
public:
static void prep();
@@ -112,10 +101,10 @@ public:
/* Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE
* signals on click. */
Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id, bool pack_start=false);
- Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id, bool pack_start=false);
void setDefaultResponse(int response_id);
void setResponseSensitive(int response_id, bool setting);
+ /* Return signals. Signals emited by PanelDialog. */
virtual sigc::signal<void, SPDesktop *, SPDocument *> &signalDocumentReplaced();
virtual sigc::signal<void, SPDesktop *> &signalActivateDesktop();
virtual sigc::signal<void, SPDesktop *> &signalDeactiveDesktop();
@@ -168,16 +157,11 @@ private:
Gtk::VBox _right_bar;
Gtk::VBox _contents;
Gtk::Label _tab_title;
- Gtk::Arrow _temp_arrow;
+ Gtk::Image _temp_arrow;
Gtk::EventBox _menu_popper;
Gtk::Button _close_button;
Gtk::Menu *_menu;
-
-#if WITH_GTKMM_3_0
- Gtk::ButtonBox *_action_area; //< stores response buttons
-#else
- Gtk::HButtonBox *_action_area; //< stores response buttons
-#endif
+ Gtk::ButtonBox *_action_area; //< stores response buttons
std::vector<Gtk::Widget *> _non_horizontal;
std::vector<Gtk::Widget *> _non_vertical;
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
index 6aa6196bb..6b31b1856 100644
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
@@ -12,14 +12,11 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "ui/widget/point.h"
-#include "ui/widget/labelled.h"
-#include "ui/widget/scalar.h"
-#include <gtkmm/box.h>
namespace Inkscape {
namespace UI {
@@ -53,11 +50,7 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 17078df8f..71bfd8473 100644
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
@@ -82,11 +82,7 @@ public:
*/
Point( Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index d56506d62..b2cebcaa6 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -11,14 +11,13 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/box.h>
#include <gtkmm/frame.h>
#include <gtkmm/alignment.h>
#include <gtkmm/scale.h>
-#include <gtkmm/stock.h>
#include <gtkmm/table.h>
#include "preferences.h"
@@ -26,20 +25,16 @@
#include "verbs.h"
#include "selcue.h"
#include "io/sys.h"
-#include <iostream>
#include "desktop.h"
-#include "enums.h"
#include "inkscape.h"
#include "message-stack.h"
#include "style.h"
-#include "selection.h"
#include "selection-chemistry.h"
#include "ui/dialog/filedialog.h"
-#include "xml/repr.h"
-#include <glibmm/convert.h>
#include <glibmm/i18n.h>
+#include <glibmm/convert.h>
#ifdef WIN32
#include <windows.h>
@@ -55,14 +50,9 @@ DialogPage::DialogPage()
{
set_border_width(12);
-#if WITH_GTKMM_3_0
set_orientation(Gtk::ORIENTATION_VERTICAL);
set_column_spacing(12);
set_row_spacing(6);
-#else
- set_col_spacings(12);
- set_row_spacings(6);
-#endif
}
/**
@@ -101,12 +91,7 @@ void DialogPage::add_line(bool indent,
// be indented if desired
Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment());
w_alignment->add(*hb);
-
-#if WITH_GTKMM_3_0
w_alignment->set_valign(Gtk::ALIGN_CENTER);
-#else
- guint row = property_n_rows();
-#endif
// Add a label in the first column if provided
if (label != "")
@@ -122,17 +107,12 @@ void DialogPage::add_line(bool indent,
if (indent)
label_alignment->set_padding(0, 0, 12, 0);
-#if WITH_GTKMM_3_0
label_alignment->set_valign(Gtk::ALIGN_CENTER);
add(*label_alignment);
attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1);
-#else
- attach(*label_alignment, 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
-#endif
}
// Now add the widget to the bottom of the dialog
-#if WITH_GTKMM_3_0
if (label == "")
{
if (indent)
@@ -145,17 +125,6 @@ void DialogPage::add_line(bool indent,
g_value_set_int(&width, 2);
gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width);
}
-#else
- // The widget should span two columns if there is no label
- int w_col_span = 1;
- if (label == "")
- w_col_span = 2;
-
- attach(*w_alignment, 2 - w_col_span, 2, row, row + 1,
- Gtk::FILL | Gtk::EXPAND,
- Gtk::AttachOptions(),
- 0, 0);
-#endif
// Add a label on the right of the widget if desired
if (suffix != "")
@@ -174,18 +143,8 @@ void DialogPage::add_group_header(Glib::ustring name)
Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true));
label_widget->set_use_markup(true);
-
-#if WITH_GTKMM_3_0
label_widget->set_valign(Gtk::ALIGN_CENTER);
add(*label_widget);
-// if (row != 1)
- // set_row_spacing(row - 1, 18);
-#else
- int row = property_n_rows();
- attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
- if (row != 1)
- set_row_spacing(row - 1, 18);
-#endif
}
}
@@ -427,24 +386,6 @@ ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int maj
}
}
-#if !WITH_GTKMM_3_0
-bool
-ZoomCorrRuler::on_expose_event(GdkEventExpose *event) {
- bool result = false;
-
- if(get_is_drawable())
- {
- Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- result = on_draw(cr);
- }
-
- return result;
-}
-#endif
-
bool
ZoomCorrRuler::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
Glib::RefPtr<Gdk::Window> window = get_window();
@@ -548,11 +489,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
_ruler.set_size(ruler_width, ruler_height);
-#if WITH_GTKMM_3_0
_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- _slider = Gtk::manage(new Gtk::HScale());
-#endif
_slider->set_size_request(_ruler.width(), -1);
_slider->set_range (lower, upper);
@@ -579,21 +516,13 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
alignment1->add(_sb);
alignment2->add(_unit);
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = Gtk::manage(new Gtk::Grid());
+ auto table = Gtk::manage(new Gtk::Grid());
table->attach(*_slider, 0, 0, 1, 1);
alignment1->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment1, 1, 0, 1, 1);
table->attach(_ruler, 0, 1, 1, 1);
alignment2->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment2, 1, 1, 1, 1);
-#else
- Gtk::Table *table = Gtk::manage(new Gtk::Table());
- table->attach(*_slider, 0, 1, 0, 1);
- table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
- table->attach(_ruler, 0, 1, 1, 2);
- table->attach(*alignment2, 1, 2, 1, 2, static_cast<Gtk::AttachOptions>(0));
-#endif
pack_start(*table, Gtk::PACK_SHRINK);
}
@@ -640,11 +569,7 @@ PrefSlider::init(Glib::ustring const &prefs_path,
freeze = false;
-#if WITH_GTKMM_3_0
_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- _slider = Gtk::manage(new Gtk::HScale());
-#endif
_slider->set_range (lower, upper);
_slider->set_increments (step_increment, page_increment);
@@ -661,17 +586,11 @@ PrefSlider::init(Glib::ustring const &prefs_path,
Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
alignment1->add(_sb);
-#if WITH_GTKMM_3_0
- Gtk::Grid *table = Gtk::manage(new Gtk::Grid());
+ auto table = Gtk::manage(new Gtk::Grid());
_slider->set_hexpand();
table->attach(*_slider, 0, 0, 1, 1);
alignment1->set_halign(Gtk::ALIGN_CENTER);
table->attach(*alignment1, 1, 0, 1, 1);
-#else
- Gtk::Table *table = Gtk::manage(new Gtk::Table());
- table->attach(*_slider, 0, 1, 0, 1);
- table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
-#endif
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
@@ -788,8 +707,9 @@ void PrefEntryFileButtonHBox::init(Glib::ustring const &prefs_path,
relatedButton = new Gtk::Button();
Gtk::HBox* pixlabel = new Gtk::HBox(false, 3);
- Gtk::Image *im = new Gtk::Image(Gtk::StockID(Gtk::Stock::INDEX),
- Gtk::ICON_SIZE_BUTTON);
+ Gtk::Image *im = new Gtk::Image();
+ im->set_from_icon_name("applications-graphics",
+ Gtk::ICON_SIZE_BUTTON);
pixlabel->pack_start(*im);
Gtk::Label *l = new Gtk::Label();
l->set_markup_with_mnemonic(_("_Browse..."));
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index 1d2d77699..142793509 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -30,12 +30,7 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
-
-#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
-#else
-#include <gtkmm/table.h>
-#endif
#include "ui/widget/color-picker.h"
#include "ui/widget/unit-menu.h"
@@ -43,11 +38,7 @@
#include "ui/widget/scalar-unit.h"
namespace Gtk {
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
namespace Inkscape {
@@ -126,10 +117,6 @@ public:
static const double textpadding;
private:
-#if !WITH_GTKMM_3_0
- bool on_expose_event(GdkEventExpose *event);
-#endif
-
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval);
@@ -155,11 +142,7 @@ private:
Inkscape::UI::Widget::SpinButton _sb;
UnitMenu _unit;
-#if WITH_GTKMM_3_0
Gtk::Scale* _slider;
-#else
- Gtk::HScale* _slider;
-#endif
ZoomCorrRuler _ruler;
bool freeze; // used to block recursive updates of slider and spinbutton
};
@@ -178,11 +161,7 @@ private:
Glib::ustring _prefs_path;
Inkscape::UI::Widget::SpinButton _sb;
-#if WITH_GTKMM_3_0
Gtk::Scale* _slider;
-#else
- Gtk::HScale* _slider;
-#endif
bool freeze; // used to block recursive updates of slider and spinbutton
};
@@ -279,11 +258,7 @@ protected:
void on_changed();
};
-#if WITH_GTKMM_3_0
class DialogPage : public Gtk::Grid
-#else
-class DialogPage : public Gtk::Table
-#endif
{
public:
DialogPage();
diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp
index 0a646b6fb..ba3b025ba 100644
--- a/src/ui/widget/random.cpp
+++ b/src/ui/widget/random.cpp
@@ -10,7 +10,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
@@ -47,11 +47,7 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h
index dc2b457c2..d86ab6246 100644
--- a/src/ui/widget/random.h
+++ b/src/ui/widget/random.h
@@ -75,11 +75,7 @@ public:
*/
Random(Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h
index 9e1682c7d..1d5074836 100644
--- a/src/ui/widget/registered-enums.h
+++ b/src/ui/widget/registered-enums.h
@@ -33,11 +33,11 @@ public:
const Util::EnumDataConverter<E>& c,
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
- SPDocument *doc_in = NULL )
- : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
+ SPDocument *doc_in = NULL,
+ bool sorted = true )
+ : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
{
RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
-
_changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
}
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 298377af3..be677a434 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -14,33 +14,21 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "registered-widget.h"
-#include <gtkmm/radiobutton.h>
-#include "ui/widget/color-picker.h"
-#include "ui/widget/registry.h"
-#include "ui/widget/scalar-unit.h"
-#include "ui/widget/point.h"
-#include "ui/widget/random.h"
#include "widgets/spinbutton-events.h"
-#include "xml/repr.h"
#include "svg/svg-color.h"
#include "svg/stringstream.h"
#include "verbs.h"
-
-// for interruptability bug:
-#include "display/sp-canvas.h"
-
-#include "desktop.h"
-
-
#include "sp-root.h"
+#include <gtkmm/radiobutton.h>
+
namespace Inkscape {
namespace UI {
namespace Widget {
@@ -113,10 +101,8 @@ RegisteredToggleButton::~RegisteredToggleButton()
_toggled_connection.disconnect();
}
-RegisteredToggleButton::RegisteredToggleButton (const Glib::ustring& /*label*/, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in, char const *active_str, char const *inactive_str)
+RegisteredToggleButton::RegisteredToggleButton (const Glib::ustring& /*label*/, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in, char const *icon_active, char const *icon_inactive)
: RegisteredWidget<Gtk::ToggleButton>()
- , _active_str(active_str)
- , _inactive_str(inactive_str)
{
init_parent(key, wr, repr_in, doc_in);
setProgrammatically = false;
@@ -149,7 +135,7 @@ RegisteredToggleButton::on_toggled()
return;
_wr->setUpdating (true);
- write_to_xml(get_active() ? _active_str : _inactive_str);
+ write_to_xml(get_active() ? "true" : "false");
//The slave button is greyed out if the master button is untoggled
for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) {
(*i)->set_sensitive(get_active());
@@ -299,7 +285,6 @@ RegisteredScalar::on_value_changed()
setProgrammatically = false;
return;
}
-
if (_wr->isUpdating()) {
return;
}
@@ -333,8 +318,6 @@ 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));
}
@@ -350,16 +333,12 @@ RegisteredText::on_activate()
return;
}
_wr->setUpdating (true);
-
- Inkscape::SVGOStringStream os;
- os << getText();
-
+ Glib::ustring str(getText());
set_sensitive(false);
+ Inkscape::SVGOStringStream os;
+ os << str;
write_to_xml(os.str().c_str());
set_sensitive(true);
-
- setText(os.str().c_str());
-
_wr->setUpdating (false);
}
@@ -805,6 +784,47 @@ RegisteredRandom::on_value_changed()
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered FONT-BUTTON
+ */
+
+RegisteredFontButton::~RegisteredFontButton()
+{
+ _signal_font_set.disconnect();
+}
+
+RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<FontButton>(label, tip)
+{
+ init_parent(key, wr, repr_in, doc_in);
+ _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
+}
+
+void
+RegisteredFontButton::setValue (Glib::ustring fontspec)
+{
+ FontButton::setValue(fontspec);
+}
+
+void
+RegisteredFontButton::on_value_changed()
+{
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Inkscape::SVGOStringStream os;
+ os << getValue();
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index 9d2489712..f66d5cbf2 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -22,6 +22,7 @@
#include "ui/widget/text.h"
#include "ui/widget/random.h"
#include "ui/widget/unit-menu.h"
+#include "ui/widget/font-button.h"
#include "ui/widget/color-picker.h"
#include "inkscape.h"
@@ -77,6 +78,8 @@ protected:
RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
template< typename A, typename B, typename C, typename D, typename E , typename F>
RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
+ template< typename A, typename B, typename C, typename D, typename E , typename F, typename G>
+ RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); }
virtual ~RegisteredWidget() {};
@@ -132,7 +135,7 @@ private:
repr = NULL;
doc = NULL;
write_undo = false;
- event_type = -1;
+ event_type = 0; //SP_VERB_INVALID
}
};
@@ -166,7 +169,7 @@ protected:
class RegisteredToggleButton : public RegisteredWidget<Gtk::ToggleButton> {
public:
virtual ~RegisteredToggleButton();
- RegisteredToggleButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL, char const *active_str = "true", char const *inactive_str = "false");
+ RegisteredToggleButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL, char const *icon_active = "true", char const *icon_inactive = "false");
void setActive (bool);
@@ -183,7 +186,6 @@ public:
// if a callback checks it, it must reset it back to false
protected:
- char const *_active_str, *_inactive_str;
sigc::connection _toggled_connection;
void on_toggled();
};
@@ -419,6 +421,23 @@ protected:
void on_value_changed();
};
+class RegisteredFontButton : public RegisteredWidget<FontButton> {
+public:
+ virtual ~RegisteredFontButton();
+ RegisteredFontButton ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL);
+
+ void setValue (Glib::ustring fontspec);
+
+protected:
+ sigc::connection _signal_font_set;
+ void on_value_changed();
+};
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp
index 837387f7b..220731b7e 100644
--- a/src/ui/widget/rendering-options.cpp
+++ b/src/ui/widget/rendering-options.cpp
@@ -9,7 +9,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm.h>
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp
index 5e938dee6..0e290730d 100644
--- a/src/ui/widget/rotateable.cpp
+++ b/src/ui/widget/rotateable.cpp
@@ -8,12 +8,11 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <gtkmm/box.h>
#include <gtkmm/eventbox.h>
-#include <glibmm/i18n.h>
#include <2geom/point.h>
#include "ui/tools/tool-base.h"
#include "rotateable.h"
@@ -35,6 +34,7 @@ Rotateable::Rotateable():
signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click));
signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion));
signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release));
+ gtk_widget_add_events(GTK_WIDGET(gobj()), GDK_SCROLL_MASK);
signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll));
}
diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp
index fca8a7974..f8543a371 100644
--- a/src/ui/widget/scalar.cpp
+++ b/src/ui/widget/scalar.cpp
@@ -43,11 +43,7 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
}
Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits,
Glib::ustring const &suffix,
Glib::ustring const &icon,
@@ -126,10 +122,12 @@ void Scalar::setRange(double min, double max)
static_cast<SpinButton*>(_widget)->set_range(min, max);
}
-void Scalar::setValue(double value)
+void Scalar::setValue(double value, bool setProg)
{
g_assert(_widget != NULL);
- setProgrammatically = true; // callback is supposed to reset back, if it cares
+ if (setProg) {
+ setProgrammatically = true; // callback is supposed to reset back, if it cares
+ }
static_cast<SpinButton*>(_widget)->set_value(value);
}
@@ -141,11 +139,7 @@ void Scalar::update()
void Scalar::addSlider()
{
-#if WITH_GTKMM_3_0
- Gtk::Scale *scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment());
-#else
- Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() );
-#endif
+ auto scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment());
scale->set_draw_value(false);
add (*manage (scale));
}
diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h
index 86d7aee28..f186f46ac 100644
--- a/src/ui/widget/scalar.h
+++ b/src/ui/widget/scalar.h
@@ -73,11 +73,7 @@ public:
*/
Scalar(Glib::ustring const &label,
Glib::ustring const &tooltip,
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> &adjust,
-#else
- Gtk::Adjustment &adjust,
-#endif
unsigned digits = 0,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
@@ -139,7 +135,7 @@ public:
/**
* Sets the value of the spin button.
*/
- void setValue(double value);
+ void setValue(double value, bool setProg = true);
/**
* Manually forces an update of the spin button.
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index f7fd63f51..65d68195c 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -10,11 +10,10 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "selected-style.h"
-#include <gtkmm/separatormenuitem.h>
#include "widgets/spw-utilities.h"
#include "ui/widget/color-preview.h"
@@ -26,24 +25,19 @@
#include "sp-namedview.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
-#include "sp-mesh.h"
+#include "sp-mesh-gradient.h"
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
#include "ui/dialog/panel-dialog.h"
-#include "xml/repr.h"
-#include "document.h"
#include "document-undo.h"
#include "widgets/widget-sizes.h"
#include "widgets/spinbutton-events.h"
#include "widgets/gradient-image.h"
-#include "sp-gradient.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "ui/tools/tool-base.h"
#include "message-context.h"
-#include "verbs.h"
-#include "color.h"
#include <display/sp-canvas.h>
#include "pixmaps/cursor-adj-h.xpm"
#include "pixmaps/cursor-adj-s.xpm"
@@ -51,7 +45,8 @@
#include "pixmaps/cursor-adj-a.xpm"
#include "sp-cursor.h"
#include "gradient-chemistry.h"
-#include "util/units.h"
+
+#include <gtkmm/separatormenuitem.h>
using Inkscape::Util::unit_table;
@@ -123,11 +118,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
current_stroke_width(0),
_desktop (NULL),
-#if WITH_GTKMM_3_0
_table(),
-#else
- _table(2, 6),
-#endif
_fill_label (_("Fill:")),
_stroke_label (_("Stroke:")),
_opacity_label (_("O:")),
@@ -139,11 +130,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_stroke_flag_place (),
_opacity_place (),
-#if WITH_GTKMM_3_0
_opacity_adjustment(Gtk::Adjustment::create(100, 0.0, 100, 1.0, 10.0)),
-#else
- _opacity_adjustment (100, 0.0, 100, 1.0, 10.0),
-#endif
_opacity_sb (0.02, 0),
_stroke (),
@@ -166,13 +153,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_opacity_label.set_alignment(0.0, 0.5);
_opacity_label.set_padding(0, 0);
-#if WITH_GTKMM_3_0
_table.set_column_spacing(2);
_table.set_row_spacing(0);
-#else
- _table.set_col_spacings (2);
- _table.set_row_spacings (0);
-#endif
for (int i = SS_FILL; i <= SS_STROKE; i++) {
@@ -379,7 +361,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1);
_opacity_sb.set_sensitive (false);
-#if WITH_GTKMM_3_0
_table.attach(_fill_label, 0, 0, 1, 1);
_table.attach(_stroke_label, 0, 1, 1, 1);
@@ -388,26 +369,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_table.attach(_fill_place, 2, 0, 1, 1);
_table.attach(_stroke, 2, 1, 1, 1);
-#else
- _table.attach(_fill_label, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK);
- _table.attach(_stroke_label, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK);
-
- _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK);
- _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK);
-
- _table.attach(_fill_place, 2,3, 0,1);
- _table.attach(_stroke, 2,3, 1,2);
-#endif
_opacity_place.add(_opacity_label);
-#if WITH_GTKMM_3_0
_table.attach(_opacity_place, 4, 0, 1, 2);
_table.attach(_opacity_sb, 5, 0, 1, 2);
-#else
- _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK);
- _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
pack_start(_table, true, true, 2);
@@ -815,56 +781,7 @@ void SelectedStyle::on_stroke_paste() {
}
void SelectedStyle::on_fillstroke_swap() {
- SPCSSAttr *css = sp_repr_css_attr_new ();
-
- switch (_mode[SS_FILL]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "stroke", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "stroke");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_FILL]);
- sp_repr_css_set_property (css, "stroke", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
- case SS_PATTERN:
- sp_repr_css_set_property (css, "stroke", _paintserver_id[SS_FILL].c_str());
- break;
- }
-
- switch (_mode[SS_STROKE]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "fill", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "fill");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_STROKE]);
- sp_repr_css_set_property (css, "fill", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
- case SS_PATTERN:
- sp_repr_css_set_property (css, "fill", _paintserver_id[SS_STROKE].c_str());
- break;
- }
-
- sp_desktop_set_style (_desktop, css);
- sp_repr_css_attr_unref (css);
- DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
- _("Swap fill and stroke"));
+ _desktop->getSelection()->swapFillStroke();
}
void SelectedStyle::on_fill_edit() {
@@ -1044,9 +961,9 @@ SelectedStyle::update()
place->set_tooltip_text(__rgradient[i]);
_mode[i] = SS_RGRADIENT;
#ifdef WITH_MESH
- } else if (SP_IS_MESH(server)) {
- SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector);
+ } else if (SP_IS_MESHGRADIENT(server)) {
+ SPGradient *array = SP_GRADIENT(server)->getArray();
+ sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), array);
place->add(_gradient_box_m[i]);
place->set_tooltip_text(__mgradient[i]);
_mode[i] = SS_MGRADIENT;
@@ -1120,11 +1037,7 @@ SelectedStyle::update()
if (_opacity_blocked) break;
_opacity_blocked = true;
_opacity_sb.set_sensitive(true);
-#if WITH_GTKMM_3_0
_opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
-#else
- _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100);
-#endif
_opacity_blocked = false;
break;
}
@@ -1224,11 +1137,7 @@ void SelectedStyle::on_opacity_changed ()
_opacity_blocked = true;
SPCSSAttr *css = sp_repr_css_attr_new ();
Inkscape::CSSOStringStream os;
-#if WITH_GTKMM_3_0
os << CLAMP ((_opacity_adjustment->get_value() / 100), 0.0, 1.0);
-#else
- os << CLAMP ((_opacity_adjustment.get_value() / 100), 0.0, 1.0);
-#endif
sp_repr_css_set_property (css, "opacity", os.str().c_str());
// FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK
// sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop
@@ -1357,11 +1266,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
g_object_unref(pixbuf);
gdk_window_set_cursor(gtk_widget_get_window(w), cr);
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cr);
-#else
- gdk_cursor_unref(cr);
-#endif
cr = NULL;
cr_set = true;
}
@@ -1425,11 +1330,7 @@ RotateableSwatch::do_release(double by, guint modifier) {
GtkWidget *w = GTK_WIDGET(gobj());
gdk_window_set_cursor(gtk_widget_get_window(w), NULL);
if (cr) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cr);
-#else
- gdk_cursor_unref (cr);
-#endif
cr = NULL;
}
cr_set = false;
@@ -1479,13 +1380,8 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier*
{
double newval;
// by is -1..1
- if (by < 0) {
- // map negative 0..-1 to current..0
- newval = current * (1 + by);
- } else {
- // map positive 0..1 to current..4*current
- newval = current * (1 + by) * (1 + by);
- }
+ double max_f = 50; // maximum width is (current * max_f), minimum - zero
+ newval = current * (std::exp(std::log(max_f-1) * (by+1)) - 1) / (max_f-2);
SPCSSAttr *css = sp_repr_css_attr_new ();
if (final && newval < 1e-6) {
@@ -1493,6 +1389,7 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier*
// if it's not final, leave it a chance to increase again (which is not possible with "none")
sp_repr_css_set_property (css, "stroke", "none");
} else {
+ newval = Inkscape::Util::Quantity::convert(newval, parent->_sw_unit, "px");
Inkscape::CSSOStringStream os;
os << newval;
sp_repr_css_set_property (css, "stroke-width", os.str().c_str());
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index 804a6fef6..065d745f0 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -16,12 +16,7 @@
#endif
#include <gtkmm/box.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>
@@ -136,15 +131,12 @@ public:
guint _mode[2];
double current_stroke_width;
+ Inkscape::Util::Unit const *_sw_unit; // points to object in UnitTable, do not delete
protected:
SPDesktop *_desktop;
-#if WITH_GTKMM_3_0
Gtk::Grid _table;
-#else
- Gtk::Table _table;
-#endif
Gtk::Label _fill_label;
Gtk::Label _stroke_label;
@@ -157,11 +149,7 @@ protected:
Gtk::EventBox _stroke_flag_place;
Gtk::EventBox _opacity_place;
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment;
-#else
- Gtk::Adjustment _opacity_adjustment;
-#endif
Inkscape::UI::Widget::SpinButton _opacity_sb;
Gtk::Label _na[2];
@@ -284,8 +272,6 @@ protected:
void on_popup_preset(int i);
Gtk::MenuItem _popup_sw_remove;
- Inkscape::Util::Unit const *_sw_unit; /// points to object in UnitTable, do not delete
-
void *_drop[2];
bool _dropEnabled[2];
};
diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp
index bb08d67df..f74626d9b 100644
--- a/src/ui/widget/spin-scale.cpp
+++ b/src/ui/widget/spin-scale.cpp
@@ -8,11 +8,10 @@
#include "spin-scale.h"
-#include <gtkmm/adjustment.h>
#include <glibmm/i18n.h>
#include <glibmm/stringutils.h>
-#include "ui/widget/gimpspinscale.h"
+#include "widgets/gimp/gimpspinscale.h"
namespace Inkscape {
namespace UI {
@@ -22,13 +21,8 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper
double /*climb_rate*/, int digits, const SPAttributeEnum a, const char* tip_text)
: AttrWidget(a, value)
{
-#if WITH_GTKMM_3_0
_adjustment = Gtk::Adjustment::create(value, lower, upper, step_inc);
_spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits);
-#else
- _adjustment = new Gtk::Adjustment(value, lower, upper, step_inc);
- _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits);
-#endif
signal_value_changed().connect(signal_attr_changed().make_slot());
@@ -42,12 +36,10 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper
}
SpinScale::SpinScale(const char* label,
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj,
-#else
- Gtk::Adjustment *adj,
-#endif
- int digits, const SPAttributeEnum a, const char* tip_text)
+ Glib::RefPtr<Gtk::Adjustment> adj,
+ int digits,
+ const SPAttributeEnum a,
+ const char* tip_text)
: AttrWidget(a, 0.0),
_adjustment(adj)
@@ -111,19 +103,12 @@ void SpinScale::set_appearance(const gchar* appearance)
gimp_spin_scale_set_appearance(_spinscale, appearance);
}
-#if WITH_GTKMM_3_0
-const Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment() const
-#else
-const Gtk::Adjustment *SpinScale::get_adjustment() const
-#endif
+const decltype(SpinScale::_adjustment) SpinScale::get_adjustment() const
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
-Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment()
-#else
-Gtk::Adjustment *SpinScale::get_adjustment()
-#endif
+
+decltype(SpinScale::_adjustment) SpinScale::get_adjustment()
{
return _adjustment;
}
diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h
index 50e4fc953..d7030bed3 100644
--- a/src/ui/widget/spin-scale.h
+++ b/src/ui/widget/spin-scale.h
@@ -36,12 +36,8 @@ public:
int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
SpinScale(const char* label,
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj,
-#else
- Gtk::Adjustment *adj,
-#endif
- int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
+ Glib::RefPtr<Gtk::Adjustment> adj,
+ int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL);
virtual Glib::ustring get_as_attribute() const;
virtual void set_from_attribute(SPObject*);
@@ -52,23 +48,14 @@ public:
void set_value(const double);
void set_focuswidget(GtkWidget *widget);
void set_appearance(const gchar* appearance);
-
-#if WITH_GTKMM_3_0
- const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const;
- Glib::RefPtr<Gtk::Adjustment> get_adjustment();
-#else
- const Gtk::Adjustment *get_adjustment() const;
- Gtk::Adjustment *get_adjustment();
-#endif
private:
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _adjustment;
-#else
- Gtk::Adjustment *_adjustment;
-#endif
-
GtkWidget *_spinscale;
+
+public:
+ const decltype(_adjustment) get_adjustment() const;
+ decltype(_adjustment) get_adjustment();
};
diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp
index 9b361ae78..f17b9b26c 100644
--- a/src/ui/widget/spin-slider.cpp
+++ b/src/ui/widget/spin-slider.cpp
@@ -20,11 +20,7 @@ namespace Widget {
SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc,
double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text)
: AttrWidget(a, value),
-#if WITH_GTKMM_3_0
_adjustment(Gtk::Adjustment::create(value, lower, upper, step_inc)),
-#else
- _adjustment(value, lower, upper, step_inc),
-#endif
_scale(_adjustment), _spin(_adjustment, climb_rate, digits)
{
signal_value_changed().connect(signal_attr_changed().make_slot());
@@ -43,11 +39,7 @@ SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc
Glib::ustring SpinSlider::get_as_attribute() const
{
-#if WITH_GTKMM_3_0
- const double val = _adjustment->get_value();
-#else
- const double val = _adjustment.get_value();
-#endif
+ const auto val = _adjustment->get_value();
if(_spin.get_digits() == 0)
return Glib::Ascii::dtostr((int)val);
@@ -58,77 +50,43 @@ Glib::ustring SpinSlider::get_as_attribute() const
void SpinSlider::set_from_attribute(SPObject* o)
{
const gchar* val = attribute_value(o);
-#if WITH_GTKMM_3_0
if(val)
_adjustment->set_value(Glib::Ascii::strtod(val));
else
_adjustment->set_value(get_default()->as_double());
-#else
- if(val)
- _adjustment.set_value(Glib::Ascii::strtod(val));
- else
- _adjustment.set_value(get_default()->as_double());
-#endif
}
Glib::SignalProxy0<void> SpinSlider::signal_value_changed()
{
-#if WITH_GTKMM_3_0
return _adjustment->signal_value_changed();
-#else
- return _adjustment.signal_value_changed();
-#endif
}
double SpinSlider::get_value() const
{
-#if WITH_GTKMM_3_0
return _adjustment->get_value();
-#else
- return _adjustment.get_value();
-#endif
}
void SpinSlider::set_value(const double val)
{
-#if WITH_GTKMM_3_0
_adjustment->set_value(val);
-#else
- _adjustment.set_value(val);
-#endif
}
-#if WITH_GTKMM_3_0
-const Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment() const
-#else
-const Gtk::Adjustment& SpinSlider::get_adjustment() const
-#endif
+const decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() const
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
-Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment()
-#else
-Gtk::Adjustment& SpinSlider::get_adjustment()
-#endif
+
+decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment()
{
return _adjustment;
}
-#if WITH_GTKMM_3_0
const Gtk::Scale& SpinSlider::get_scale() const
-#else
-const Gtk::HScale& SpinSlider::get_scale() const
-#endif
{
return _scale;
}
-#if WITH_GTKMM_3_0
Gtk::Scale& SpinSlider::get_scale()
-#else
-Gtk::HScale& SpinSlider::get_scale()
-#endif
{
return _scale;
}
@@ -157,15 +115,9 @@ DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double
{
signal_value_changed().connect(signal_attr_changed().make_slot());
-#if WITH_GTKMM_3_0
_s1.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot());
_s2.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot());
_s1.get_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked));
-#else
- _s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
- _s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot());
- _s1.get_adjustment().signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked));
-#endif
_link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinSlider::link_toggled));
Gtk::VBox* vb = Gtk::manage(new Gtk::VBox);
@@ -202,13 +154,8 @@ void DualSpinSlider::set_from_attribute(SPObject* o)
_link.set_active(toks[1] == 0);
-#if WITH_GTKMM_3_0
_s1.get_adjustment()->set_value(v1);
_s2.get_adjustment()->set_value(v2);
-#else
- _s1.get_adjustment().set_value(v1);
- _s2.get_adjustment().set_value(v2);
-#endif
g_strfreev(toks);
}
diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h
index a5999f14f..5a29c1b67 100644
--- a/src/ui/widget/spin-slider.h
+++ b/src/ui/widget/spin-slider.h
@@ -42,17 +42,8 @@ public:
double get_value() const;
void set_value(const double);
-#if WITH_GTKMM_3_0
- const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const;
- Glib::RefPtr<Gtk::Adjustment> get_adjustment();
const Gtk::Scale& get_scale() const;
Gtk::Scale& get_scale();
-#else
- const Gtk::Adjustment& get_adjustment() const;
- Gtk::Adjustment& get_adjustment();
- const Gtk::HScale& get_scale() const;
- Gtk::HScale& get_scale();
-#endif
const Inkscape::UI::Widget::SpinButton& get_spin_button() const;
Inkscape::UI::Widget::SpinButton& get_spin_button();
@@ -60,14 +51,13 @@ public:
// Change the SpinSlider into a SpinButton with AttrWidget support)
void remove_scale();
private:
-#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _adjustment;
Gtk::Scale _scale;
-#else
- Gtk::Adjustment _adjustment;
- Gtk::HScale _scale;
-#endif
Inkscape::UI::Widget::SpinButton _spin;
+
+public:
+ const decltype(_adjustment) get_adjustment() const;
+ decltype(_adjustment) get_adjustment();
};
/**
diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp
index d7669d4e5..d1776e630 100644
--- a/src/ui/widget/spinbutton.cpp
+++ b/src/ui/widget/spinbutton.cpp
@@ -8,7 +8,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include "spinbutton.h"
diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h
index 30ffc7d77..ae571994b 100644
--- a/src/ui/widget/spinbutton.h
+++ b/src/ui/widget/spinbutton.h
@@ -36,11 +36,7 @@ public:
{
connect_signals();
};
-#if GTK_CHECK_VERSION(3,0,0)
explicit SpinButton(Glib::RefPtr<Gtk::Adjustment>& adjustment, double climb_rate = 0.0, guint digits = 0)
-#else
- explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0)
-#endif
: Gtk::SpinButton(adjustment, climb_rate, digits),
_unit_menu(NULL),
_unit_tracker(NULL),
diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp
index da3bbcd20..a779e6feb 100644
--- a/src/ui/widget/style-subject.cpp
+++ b/src/ui/widget/style-subject.cpp
@@ -8,7 +8,6 @@
#include "ui/widget/style-subject.h"
#include "desktop.h"
-#include "sp-object.h"
#include "xml/sp-css-attr.h"
#include "desktop-style.h"
@@ -55,11 +54,13 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const {
}
}
-std::vector<SPObject*> StyleSubject::Selection::list(){
+std::vector<SPObject*> StyleSubject::Selection::list() {
Inkscape::Selection *selection = _getSelection();
- if(selection)
- return selection->list();
- else return std::vector<SPObject*>();
+ if(selection) {
+ return std::vector<SPObject *>(selection->objects().begin(), selection->objects().end());
+ }
+
+ return std::vector<SPObject*>();
}
Geom::OptRect StyleSubject::Selection::getBounds(SPItem::BBoxType type) {
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index 188be705d..f8eac1c78 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -13,9 +13,6 @@
#include "style-swatch.h"
-#include <cstring>
-#include <string>
-
#include "widgets/spw-utilities.h"
#include "ui/widget/color-preview.h"
@@ -23,22 +20,15 @@
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "sp-pattern.h"
-#include "xml/repr.h"
#include "xml/sp-css-attr.h"
#include "widgets/widget-sizes.h"
#include "util/units.h"
#include "helper/action.h"
-#include "helper/action-context.h"
-#include "preferences.h"
#include "inkscape.h"
#include "verbs.h"
#include <glibmm/i18n.h>
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
enum {
SS_FILL,
@@ -117,11 +107,7 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_css(NULL),
_tool_obs(NULL),
_style_obs(NULL),
-#if WITH_GTKMM_3_0
_table(Gtk::manage(new Gtk::Grid())),
-#else
- _table(Gtk::manage(new Gtk::Table(2, 6))),
-#endif
_sw_unit(NULL)
{
set_name("StyleSwatch");
@@ -139,13 +125,8 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_opacity_value.set_alignment(0.0, 0.5);
_opacity_value.set_padding(0, 0);
-#if WITH_GTKMM_3_0
_table->set_column_spacing(2);
_table->set_row_spacing(0);
-#else
- _table->set_col_spacings(2);
- _table->set_row_spacings(0);
-#endif
_stroke.pack_start(_place[SS_STROKE]);
_stroke_width_place.add(_stroke_width);
@@ -153,19 +134,11 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip)
_opacity_place.add(_opacity_value);
-#if WITH_GTKMM_3_0
_table->attach(_label[SS_FILL], 0, 0, 1, 1);
_table->attach(_label[SS_STROKE], 0, 1, 1, 1);
_table->attach(_place[SS_FILL], 1, 0, 1, 1);
_table->attach(_stroke, 1, 1, 1, 1);
_table->attach(_opacity_place, 2, 0, 1, 2);
-#else
- _table->attach(_label[SS_FILL], 0,1, 0,1, Gtk::FILL, Gtk::SHRINK);
- _table->attach(_label[SS_STROKE], 0,1, 1,2, Gtk::FILL, Gtk::SHRINK);
- _table->attach(_place[SS_FILL], 1,2, 0,1);
- _table->attach(_stroke, 1,2, 1,2);
- _table->attach(_opacity_place, 2,3, 0,2, Gtk::SHRINK, Gtk::SHRINK);
-#endif
_swatch.add(*_table);
pack_start(_swatch, true, true, 0);
diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h
index 0016e0256..81a907d16 100644
--- a/src/ui/widget/style-swatch.h
+++ b/src/ui/widget/style-swatch.h
@@ -29,11 +29,7 @@ class SPStyle;
class SPCSSAttr;
namespace Gtk {
-#if WITH_GTKMM_3_0
class Grid;
-#else
-class Table;
-#endif
}
namespace Inkscape {
@@ -75,11 +71,7 @@ private:
Gtk::EventBox _swatch;
-#if WITH_GTKMM_3_0
Gtk::Grid *_table;
-#else
- Gtk::Table *_table;
-#endif
Gtk::Label _label[2];
Gtk::EventBox _place[2];
diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp
index ec58d5bb4..e6795b138 100644
--- a/src/ui/widget/text.cpp
+++ b/src/ui/widget/text.cpp
@@ -28,13 +28,13 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip,
{
}
-const char *Text::getText() const
+Glib::ustring const Text::getText() const
{
g_assert(_widget != NULL);
- return static_cast<Gtk::Entry*>(_widget)->get_text().c_str();
+ return static_cast<Gtk::Entry*>(_widget)->get_text();
}
-void Text::setText(const char* text)
+void Text::setText(Glib::ustring const text)
{
g_assert(_widget != NULL);
setProgrammatically = true; // callback is supposed to reset back, if it cares
diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h
index b90788940..593875b23 100644
--- a/src/ui/widget/text.h
+++ b/src/ui/widget/text.h
@@ -44,12 +44,12 @@ public:
/**
* Get the text in the entry.
*/
- const char* getText() const;
+ Glib::ustring const getText() const;
/**
* Sets the text of the text entry.
*/
- void setText(const char* text);
+ void setText(Glib::ustring const text);
void update();
diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp
index ced811c57..dea14585d 100644
--- a/src/ui/widget/tolerance-slider.cpp
+++ b/src/ui/widget/tolerance-slider.cpp
@@ -9,7 +9,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/adjustment.h>
@@ -76,12 +76,8 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la
// align the label with the checkbox text above by indenting 22 px.
_hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22);
-#if WITH_GTKMM_3_0
_hscale = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
_hscale->set_range(1.0, 51.0);
-#else
- _hscale = Gtk::manage (new Gtk::HScale (1.0, 51, 1.0));
-#endif
theLabel1->set_mnemonic_widget (*_hscale);
_hscale->set_draw_value (true);
@@ -121,11 +117,7 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la
void ToleranceSlider::setValue (double val)
{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = _hscale->get_adjustment();
-#else
- Gtk::Adjustment *adj = _hscale->get_adjustment();
-#endif
+ auto adj = _hscale->get_adjustment();
adj->set_lower (1.0);
adj->set_upper (51.0);
diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h
index 7ae8e4712..3d2548ebe 100644
--- a/src/ui/widget/tolerance-slider.h
+++ b/src/ui/widget/tolerance-slider.h
@@ -14,11 +14,7 @@
namespace Gtk {
class RadioButton;
-#if WITH_GTKMM_3_0
class Scale;
-#else
-class HScale;
-#endif
}
namespace Inkscape {
@@ -60,13 +56,7 @@ protected:
void on_toggled();
void update (double val);
Gtk::HBox *_hbox;
-
-#if WITH_GTKMM_3_0
Gtk::Scale *_hscale;
-#else
- Gtk::HScale *_hscale;
-#endif
-
Gtk::RadioButtonGroup _radio_button_group;
Gtk::RadioButton *_button1;
Gtk::RadioButton *_button2;