summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-12-16 05:41:25 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-12-16 05:41:25 +0000
commit7ec903c9898f872dbd9426ed7a62e1969fdb7be7 (patch)
treea306139e829118a83516af02279c9eafd3440eaa /src
parentHershey Text: whitespace; py: docstring, modeline; inx: fix attribute value (diff)
parentTranslations.Spanish translation update by Lucas Vieites. (diff)
downloadinkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.tar.gz
inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.zip
merge from trunk (r11955)
(bzr r11687.1.3)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/Makefile_insert231
-rw-r--r--src/Makefile.am16
-rw-r--r--src/Makefile_insert3
-rw-r--r--src/arc-context.cpp2
-rw-r--r--src/attribute-rel-util.cpp9
-rw-r--r--src/bind/dobinding.cpp2
-rw-r--r--src/bind/javabind.cpp28
-rw-r--r--src/box3d-side.cpp21
-rw-r--r--src/box3d.cpp38
-rw-r--r--src/color-profile.cpp6
-rw-r--r--src/color.cpp2
-rw-r--r--src/common-context.cpp4
-rw-r--r--src/conn-avoid-ref.cpp2
-rw-r--r--src/debug/timestamp.cpp1
-rw-r--r--src/desktop-events.cpp12
-rw-r--r--src/desktop-handles.cpp3
-rw-r--r--src/desktop-style.cpp6
-rw-r--r--src/desktop.cpp69
-rw-r--r--src/desktop.h5
-rw-r--r--src/device-manager.cpp13
-rw-r--r--src/dialogs/find.cpp48
-rw-r--r--src/dir-util.cpp1
-rw-r--r--src/display/Makefile_insert3
-rw-r--r--src/display/canvas-arena.cpp12
-rw-r--r--src/display/canvas-axonomgrid.cpp116
-rw-r--r--src/display/canvas-axonomgrid.h15
-rw-r--r--src/display/canvas-grid.cpp19
-rw-r--r--src/display/canvas-text.cpp4
-rw-r--r--src/display/curve.cpp2
-rw-r--r--src/display/drawing-context.h2
-rw-r--r--src/display/drawing-item.cpp27
-rw-r--r--src/display/drawing-shape.cpp2
-rw-r--r--src/display/drawing-text.cpp2
-rw-r--r--src/display/drawing.cpp34
-rw-r--r--src/display/guideline.cpp8
-rw-r--r--src/display/nr-filter-colormatrix.cpp77
-rw-r--r--src/display/nr-filter-colormatrix.h9
-rw-r--r--src/display/nr-filter-composite.cpp9
-rw-r--r--src/display/nr-filter-flood.cpp33
-rw-r--r--src/display/nr-filter-gaussian.cpp9
-rw-r--r--src/display/nr-filter-image.cpp134
-rw-r--r--src/display/nr-filter-image.h1
-rw-r--r--src/display/nr-filter-merge.cpp2
-rw-r--r--src/display/nr-filter-primitive.cpp28
-rw-r--r--src/display/nr-filter-skeleton.cpp3
-rw-r--r--src/display/nr-style.cpp8
-rw-r--r--src/display/nr-svgfonts.cpp67
-rw-r--r--src/display/sodipodi-ctrl.cpp8
-rw-r--r--src/display/sodipodi-ctrlrect.cpp11
-rw-r--r--src/display/sp-canvas.cpp10
-rw-r--r--src/display/sp-ctrlpoint.cpp4
-rw-r--r--src/display/sp-ctrlquadr.cpp4
-rw-r--r--src/document-subset.cpp2
-rw-r--r--src/document.cpp47
-rw-r--r--src/dom/prop-css.cpp2
-rw-r--r--src/dom/prop-css2.cpp2
-rw-r--r--src/dom/svgimpl.cpp2
-rw-r--r--src/dom/util/ziptool.cpp2
-rw-r--r--src/draw-context.cpp21
-rw-r--r--src/dropper-context.cpp107
-rw-r--r--src/dyna-draw-context.cpp2
-rw-r--r--src/ege-adjustment-action.cpp12
-rw-r--r--src/eraser-context.cpp2
-rw-r--r--src/event-context.cpp132
-rw-r--r--src/event-context.h1
-rw-r--r--src/extension/CMakeLists.txt4
-rw-r--r--src/extension/Makefile_insert1
-rw-r--r--src/extension/effect.h2
-rw-r--r--src/extension/implementation/implementation.h1
-rw-r--r--src/extension/init.cpp8
-rw-r--r--src/extension/input.cpp7
-rw-r--r--src/extension/input.h4
-rw-r--r--src/extension/internal/Makefile_insert21
-rw-r--r--src/extension/internal/cairo-png-out.cpp2
-rw-r--r--src/extension/internal/cairo-ps-out.cpp6
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp20
-rw-r--r--src/extension/internal/cairo-renderer.cpp28
-rw-r--r--src/extension/internal/cairo-renderer.h2
-rw-r--r--src/extension/internal/emf-win32-inout.cpp29
-rw-r--r--src/extension/internal/filter/color.h63
-rw-r--r--src/extension/internal/filter/paint.h51
-rw-r--r--src/extension/internal/latex-text-renderer.cpp7
-rw-r--r--src/extension/internal/latex-text-renderer.h4
-rw-r--r--src/extension/internal/odf.cpp2
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp8
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp16
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h4
-rw-r--r--src/extension/internal/svg.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp289
-rw-r--r--src/extension/internal/vsd-input.h54
-rw-r--r--src/extension/param/enum.cpp4
-rw-r--r--src/extension/param/float.cpp25
-rw-r--r--src/extension/param/int.cpp25
-rw-r--r--src/extension/param/radiobutton.cpp4
-rw-r--r--src/extension/prefdialog.cpp10
-rw-r--r--src/extension/system.cpp1
-rw-r--r--src/extract-uri.cpp2
-rw-r--r--src/file.cpp23
-rw-r--r--src/filter-chemistry.cpp2
-rw-r--r--src/flood-context.cpp37
-rw-r--r--src/gradient-chemistry.cpp108
-rw-r--r--src/gradient-chemistry.h6
-rw-r--r--src/gradient-context.cpp17
-rw-r--r--src/gradient-drag.cpp221
-rw-r--r--src/gradient-drag.h9
-rw-r--r--src/helper/Makefile_insert1
-rw-r--r--src/helper/gnome-utils.cpp2
-rw-r--r--src/helper/stock-items.cpp3
-rw-r--r--src/helper/units.cpp18
-rw-r--r--src/ink-action.cpp6
-rw-r--r--src/ink-comboboxentry-action.cpp2
-rw-r--r--src/inkscape.cpp30
-rw-r--r--src/inkview.cpp63
-rw-r--r--src/interface.cpp245
-rw-r--r--src/interface.h7
-rw-r--r--src/io/ftos.cpp4
-rw-r--r--src/io/sys.cpp34
-rw-r--r--src/io/sys.h2
-rw-r--r--src/knot-holder-entity.cpp16
-rw-r--r--src/knot-holder-entity.h4
-rw-r--r--src/layer-manager.cpp81
-rw-r--r--src/layer-manager.h1
-rw-r--r--src/libavoid/makepath.cpp2
-rw-r--r--src/libavoid/orthogonal.cpp4
-rw-r--r--src/libcola/connected_components.cpp2
-rw-r--r--src/libcola/shortest_paths.cpp4
-rw-r--r--src/libcola/straightener.cpp2
-rw-r--r--src/libcroco/cr-term.c4
-rw-r--r--src/libgdl/Makefile_insert4
-rw-r--r--src/libnrtype/FontFactory.cpp11
-rw-r--r--src/libnrtype/FontInstance.cpp7
-rw-r--r--src/libnrtype/Layout-TNG-Input.cpp6
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp6
-rw-r--r--src/libnrtype/Makefile_insert1
-rw-r--r--src/libvpsc/csolve_VPSC.h2
-rw-r--r--src/libvpsc/generate-constraints.cpp6
-rw-r--r--src/libvpsc/remove_rectangle_overlap.cpp1
-rw-r--r--src/livarot/Makefile_insert1
-rw-r--r--src/livarot/PathSimplify.cpp10
-rw-r--r--src/livarot/PathStroke.cpp4
-rw-r--r--src/livarot/ShapeMisc.cpp4
-rw-r--r--src/live_effects/effect.cpp6
-rw-r--r--src/live_effects/lpe-angle_bisector.cpp12
-rw-r--r--src/live_effects/lpe-boolops.cpp4
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp14
-rw-r--r--src/live_effects/lpe-dynastroke.cpp52
-rw-r--r--src/live_effects/lpe-gears.cpp3
-rw-r--r--src/live_effects/lpe-knot.cpp9
-rw-r--r--src/live_effects/lpe-lattice.cpp32
-rw-r--r--src/live_effects/lpe-line_segment.cpp2
-rw-r--r--src/live_effects/lpe-mirror_symmetry.cpp2
-rw-r--r--src/live_effects/lpe-parallel.cpp12
-rw-r--r--src/live_effects/lpe-path_length.cpp4
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp18
-rw-r--r--src/live_effects/lpe-perp_bisector.h4
-rw-r--r--src/live_effects/lpe-perspective_path.cpp4
-rw-r--r--src/live_effects/lpe-powerstroke.cpp187
-rw-r--r--src/live_effects/lpe-recursiveskeleton.cpp2
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp4
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp20
-rw-r--r--src/live_effects/lpe-test-doEffect-stack.cpp6
-rw-r--r--src/live_effects/lpe-text_label.cpp2
-rw-r--r--src/live_effects/parameter/parameter.cpp4
-rw-r--r--src/live_effects/parameter/point.cpp4
-rw-r--r--src/live_effects/parameter/powerstrokepointarray.cpp4
-rw-r--r--src/live_effects/parameter/vector.cpp4
-rw-r--r--src/live_effects/spiro.cpp8
-rw-r--r--src/main.cpp111
-rw-r--r--src/marker.cpp4
-rw-r--r--src/measure-context.cpp4
-rw-r--r--src/menus-skeleton.h6
-rw-r--r--src/mod360.cpp2
-rw-r--r--src/object-edit.cpp42
-rw-r--r--src/path-prefix.h4
-rw-r--r--src/pen-context.cpp10
-rw-r--r--src/pencil-context.cpp25
-rw-r--r--src/pixmaps/cursor-adj-a.xpm38
-rw-r--r--src/pixmaps/cursor-dropper-f.xpm38
-rw-r--r--src/pixmaps/cursor-dropper-s.xpm38
-rw-r--r--src/preferences-skeleton.h4
-rw-r--r--src/preferences.cpp11
-rw-r--r--src/preferences.h7
-rw-r--r--src/rect-context.cpp2
-rw-r--r--src/registrytool.cpp3
-rw-r--r--src/removeoverlap.cpp1
-rw-r--r--src/resource-manager.cpp4
-rw-r--r--src/satisfied-guide-cns.cpp11
-rw-r--r--src/select-context.cpp9
-rw-r--r--src/selection-chemistry.cpp217
-rw-r--r--src/selection-chemistry.h6
-rw-r--r--src/selection-describer.cpp13
-rw-r--r--src/selection.cpp34
-rw-r--r--src/selection.h6
-rw-r--r--src/seltrans.cpp34
-rw-r--r--src/shortcuts.cpp524
-rw-r--r--src/shortcuts.h16
-rw-r--r--src/snap-candidate.h8
-rw-r--r--src/snap.cpp9
-rw-r--r--src/snap.h2
-rw-r--r--src/sp-conn-end.cpp2
-rw-r--r--src/sp-gradient.cpp31
-rw-r--r--src/sp-image.cpp52
-rw-r--r--src/sp-item-group.cpp4
-rw-r--r--src/sp-item-notify-moveto.cpp1
-rw-r--r--src/sp-item-rm-unsatisfied-cns.cpp1
-rw-r--r--src/sp-item-transform.cpp1
-rw-r--r--src/sp-item-update-cns.cpp5
-rw-r--r--src/sp-item.cpp78
-rw-r--r--src/sp-lpe-item.cpp81
-rw-r--r--src/sp-lpe-item.h4
-rw-r--r--src/sp-mesh-array.cpp4
-rw-r--r--src/sp-metric.h2
-rw-r--r--src/sp-metrics.cpp4
-rw-r--r--src/sp-namedview.cpp4
-rw-r--r--src/sp-object-repr.cpp1
-rw-r--r--src/sp-object.cpp76
-rw-r--r--src/sp-object.h44
-rw-r--r--src/sp-offset.cpp2
-rw-r--r--src/sp-pattern.cpp57
-rw-r--r--src/sp-shape.cpp8
-rw-r--r--src/sp-symbol.cpp5
-rw-r--r--src/sp-use.cpp8
-rw-r--r--src/spiral-context.cpp2
-rw-r--r--src/splivarot.cpp4
-rw-r--r--src/spray-context.cpp40
-rw-r--r--src/star-context.cpp2
-rw-r--r--src/style.cpp6
-rw-r--r--src/svg/itos.cpp2
-rw-r--r--src/svg/round.cpp1
-rw-r--r--src/text-chemistry.cpp10
-rw-r--r--src/tools-switch.cpp2
-rw-r--r--src/trace/quantize.cpp16
-rw-r--r--src/trace/trace.h11
-rw-r--r--src/tweak-context.cpp40
-rw-r--r--src/ui/CMakeLists.txt9
-rw-r--r--src/ui/clipboard.cpp50
-rw-r--r--src/ui/clipboard.h2
-rw-r--r--src/ui/dialog/Makefile_insert2
-rw-r--r--src/ui/dialog/align-and-distribute.cpp27
-rw-r--r--src/ui/dialog/align-and-distribute.h2
-rw-r--r--src/ui/dialog/calligraphic-profile-rename.cpp39
-rw-r--r--src/ui/dialog/calligraphic-profile-rename.h8
-rw-r--r--src/ui/dialog/clonetiler.cpp67
-rw-r--r--src/ui/dialog/color-item.cpp25
-rw-r--r--src/ui/dialog/color-item.h4
-rw-r--r--src/ui/dialog/debug.cpp8
-rw-r--r--src/ui/dialog/dialog-manager.cpp3
-rw-r--r--src/ui/dialog/dialog.cpp4
-rw-r--r--src/ui/dialog/document-metadata.cpp112
-rw-r--r--src/ui/dialog/document-metadata.h21
-rw-r--r--src/ui/dialog/document-properties.cpp86
-rw-r--r--src/ui/dialog/export.cpp34
-rw-r--r--src/ui/dialog/export.h5
-rw-r--r--src/ui/dialog/filedialog.cpp3
-rw-r--r--src/ui/dialog/filedialog.h2
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp36
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.h3
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp72
-rw-r--r--src/ui/dialog/filedialogimpl-win32.h2
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp27
-rw-r--r--src/ui/dialog/fill-and-stroke.h6
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp255
-rw-r--r--src/ui/dialog/filter-effects-dialog.h7
-rw-r--r--src/ui/dialog/font-substitution.cpp4
-rw-r--r--src/ui/dialog/glyphs.cpp8
-rw-r--r--src/ui/dialog/guides.cpp70
-rw-r--r--src/ui/dialog/guides.h16
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp347
-rw-r--r--src/ui/dialog/inkscape-preferences.h62
-rw-r--r--src/ui/dialog/input.cpp484
-rw-r--r--src/ui/dialog/layer-properties.cpp199
-rw-r--r--src/ui/dialog/layer-properties.h60
-rw-r--r--src/ui/dialog/layers.cpp157
-rw-r--r--src/ui/dialog/layers.h11
-rw-r--r--src/ui/dialog/livepatheffect-add.cpp3
-rw-r--r--src/ui/dialog/object-attributes.cpp2
-rw-r--r--src/ui/dialog/object-properties.cpp48
-rw-r--r--src/ui/dialog/ocaldialogs.cpp14
-rw-r--r--src/ui/dialog/ocaldialogs.h2
-rw-r--r--src/ui/dialog/print.cpp2
-rw-r--r--src/ui/dialog/spellcheck.cpp22
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp15
-rw-r--r--src/ui/dialog/swatches.cpp88
-rw-r--r--src/ui/dialog/symbols.cpp610
-rw-r--r--src/ui/dialog/symbols.h115
-rw-r--r--src/ui/dialog/text-edit.cpp27
-rw-r--r--src/ui/dialog/tile.cpp4
-rw-r--r--src/ui/dialog/tracedialog.cpp167
-rw-r--r--src/ui/dialog/transformation.cpp10
-rw-r--r--src/ui/dialog/undo-history.cpp28
-rw-r--r--src/ui/previewable.h3
-rw-r--r--src/ui/previewfillable.h3
-rw-r--r--src/ui/previewholder.cpp53
-rw-r--r--src/ui/previewholder.h5
-rw-r--r--src/ui/tool/node-tool.cpp4
-rw-r--r--src/ui/tool/node.cpp2
-rw-r--r--src/ui/widget/Makefile_insert4
-rw-r--r--src/ui/widget/color-picker.cpp2
-rw-r--r--src/ui/widget/dock.cpp12
-rw-r--r--src/ui/widget/filter-effect-chooser.cpp15
-rw-r--r--src/ui/widget/filter-effect-chooser.h8
-rw-r--r--src/ui/widget/frame.cpp2
-rw-r--r--src/ui/widget/gimpspinscale.c1092
-rw-r--r--src/ui/widget/gimpspinscale.h76
-rw-r--r--src/ui/widget/layer-selector.cpp38
-rw-r--r--src/ui/widget/layer-selector.h5
-rw-r--r--src/ui/widget/licensor.cpp18
-rw-r--r--src/ui/widget/object-composite-settings.cpp58
-rw-r--r--src/ui/widget/object-composite-settings.h12
-rw-r--r--src/ui/widget/page-sizer.cpp4
-rw-r--r--src/ui/widget/panel.cpp114
-rw-r--r--src/ui/widget/panel.h6
-rw-r--r--src/ui/widget/preferences-widget.cpp15
-rw-r--r--src/ui/widget/rotateable.cpp31
-rw-r--r--src/ui/widget/rotateable.h3
-rw-r--r--src/ui/widget/selected-style.cpp194
-rw-r--r--src/ui/widget/selected-style.h12
-rw-r--r--src/ui/widget/spin-scale.cpp248
-rw-r--r--src/ui/widget/spin-scale.h117
-rw-r--r--src/ui/widget/spin-slider.cpp2
-rw-r--r--src/ui/widget/style-swatch.cpp7
-rw-r--r--src/ui/widget/unit-menu.cpp14
-rw-r--r--src/unclump.cpp19
-rw-r--r--src/util/expression-evaluator.cpp2
-rw-r--r--src/vanishing-point.cpp2
-rw-r--r--src/verbs.cpp137
-rw-r--r--src/verbs.h33
-rw-r--r--src/widgets/CMakeLists.txt2
-rw-r--r--src/widgets/Makefile_insert2
-rw-r--r--src/widgets/arc-toolbar.cpp10
-rw-r--r--src/widgets/box3d-toolbar.cpp4
-rw-r--r--src/widgets/button.cpp4
-rw-r--r--src/widgets/calligraphy-toolbar.cpp87
-rw-r--r--src/widgets/connector-toolbar.cpp16
-rw-r--r--src/widgets/desktop-widget.cpp233
-rw-r--r--src/widgets/eek-preview.cpp129
-rw-r--r--src/widgets/eek-preview.h11
-rw-r--r--src/widgets/erasor-toolbar.cpp4
-rw-r--r--src/widgets/font-selector.cpp23
-rw-r--r--src/widgets/gradient-image.cpp6
-rw-r--r--src/widgets/gradient-selector.cpp112
-rw-r--r--src/widgets/gradient-selector.h4
-rw-r--r--src/widgets/gradient-toolbar.cpp45
-rw-r--r--src/widgets/gradient-vector.cpp2
-rw-r--r--src/widgets/icon.cpp11
-rw-r--r--src/widgets/lpe-toolbar.cpp10
-rw-r--r--src/widgets/measure-toolbar.cpp4
-rw-r--r--src/widgets/node-toolbar.cpp8
-rw-r--r--src/widgets/paint-selector.cpp4
-rw-r--r--src/widgets/pencil-toolbar.cpp4
-rw-r--r--src/widgets/rect-toolbar.cpp4
-rw-r--r--src/widgets/ruler.cpp7
-rw-r--r--src/widgets/select-toolbar.cpp1
-rw-r--r--src/widgets/shrink-wrap-button.cpp2
-rw-r--r--src/widgets/sp-color-gtkselector.cpp155
-rw-r--r--src/widgets/sp-color-gtkselector.h55
-rw-r--r--src/widgets/sp-color-icc-selector.cpp96
-rw-r--r--src/widgets/sp-color-notebook.cpp73
-rw-r--r--src/widgets/sp-color-scales.cpp47
-rw-r--r--src/widgets/sp-color-slider.cpp20
-rw-r--r--src/widgets/sp-color-wheel-selector.cpp65
-rw-r--r--src/widgets/sp-xmlview-attr-list.cpp7
-rw-r--r--src/widgets/sp-xmlview-content.cpp10
-rw-r--r--src/widgets/sp-xmlview-tree.cpp175
-rw-r--r--src/widgets/sp-xmlview-tree.h11
-rw-r--r--src/widgets/spinbutton-events.cpp52
-rw-r--r--src/widgets/spiral-toolbar.cpp4
-rw-r--r--src/widgets/spw-utilities.cpp96
-rw-r--r--src/widgets/spw-utilities.h20
-rw-r--r--src/widgets/star-toolbar.cpp12
-rw-r--r--src/widgets/stroke-marker-selector.cpp5
-rw-r--r--src/widgets/stroke-style.cpp51
-rw-r--r--src/widgets/stroke-style.h13
-rw-r--r--src/widgets/text-toolbar.cpp18
-rw-r--r--src/widgets/toolbox.cpp22
-rw-r--r--src/widgets/widget-sizes.h6
-rw-r--r--src/xml/Makefile_insert3
-rw-r--r--src/xml/node-fns.cpp1
-rw-r--r--src/xml/quote.cpp1
-rw-r--r--src/xml/repr-css.cpp24
-rw-r--r--src/xml/repr-io.cpp8
-rw-r--r--src/xml/repr-sorting.cpp1
-rw-r--r--src/xml/repr-util.cpp2
-rw-r--r--src/xml/simple-node.cpp2
-rw-r--r--src/zoom-context.cpp16
385 files changed, 9887 insertions, 3326 deletions
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert
index e3b6fcdab..07e066df5 100644
--- a/src/2geom/Makefile_insert
+++ b/src/2geom/Makefile_insert
@@ -6,112 +6,129 @@
rm -f 2geom/lib2geom.a $(2geom_lib2geom_a_OBJECTS)
2geom_lib2geom_a_SOURCES = \
- 2geom/affine.h \
- 2geom/affine.cpp \
- 2geom/angle.h \
- 2geom/basic-intersection.cpp \
- 2geom/basic-intersection.h \
- 2geom/bezier-clipping.cpp \
- 2geom/bezier-curve.cpp \
- 2geom/bezier-curve.h \
- 2geom/bezier.h \
- 2geom/bezier-to-sbasis.h \
- 2geom/bezier-utils.cpp \
- 2geom/bezier-utils.h \
- 2geom/choose.h \
- 2geom/circle-circle.cpp \
- 2geom/circle.cpp \
- 2geom/circle.h \
- 2geom/circulator.h \
- 2geom/concepts.h \
- 2geom/conjugate_gradient.cpp \
- 2geom/conjugate_gradient.h \
- 2geom/convex-cover.cpp \
- 2geom/convex-cover.h \
- 2geom/coord.h \
- 2geom/crossing.cpp \
- 2geom/crossing.h \
+ 2geom/2geom.h \
+ 2geom/affine.cpp \
+ 2geom/affine.h \
+ 2geom/angle.h \
+ 2geom/basic-intersection.cpp \
+ 2geom/basic-intersection.h \
+ 2geom/bezier-clipping.cpp \
+ 2geom/bezier-curve.cpp \
+ 2geom/bezier-curve.h \
+ 2geom/bezier.h \
+ 2geom/bezier-to-sbasis.h \
+ 2geom/bezier-utils.cpp \
+ 2geom/bezier-utils.h \
+ 2geom/choose.h \
+ 2geom/circle-circle.cpp \
+ 2geom/circle.cpp \
+ 2geom/circle.h \
+ 2geom/circulator.h \
+ 2geom/CMakeLists.txt \
+ 2geom/concepts.h \
+ 2geom/conicsec.cpp \
+ 2geom/conicsec.h \
+ 2geom/conic_section_clipper_cr.h \
+ 2geom/conic_section_clipper.h \
+ 2geom/conic_section_clipper_impl.cpp \
+ 2geom/conic_section_clipper_impl.h \
+ 2geom/conjugate_gradient.cpp \
+ 2geom/conjugate_gradient.h \
+ 2geom/convex-cover.cpp \
+ 2geom/convex-cover.h \
+ 2geom/coord.h \
+ 2geom/crossing.cpp \
+ 2geom/crossing.h \
2geom/curve.cpp \
- 2geom/curve.h \
- 2geom/curves.h \
- 2geom/d2.h \
- 2geom/d2-sbasis.cpp \
- 2geom/d2-sbasis.h \
- 2geom/ellipse.cpp \
- 2geom/ellipse.h \
- 2geom/elliptical-arc.cpp \
- 2geom/elliptical-arc.h \
- 2geom/exception.h \
- 2geom/forward.h \
- 2geom/geom.cpp \
- 2geom/geom.h \
- 2geom/hvlinesegment.h \
- 2geom/interval.h \
- 2geom/isnan.h \
- 2geom/linear.h \
- 2geom/line.cpp \
- 2geom/line.h \
- 2geom/nearest-point.cpp \
- 2geom/nearest-point.h \
- 2geom/numeric/fitting-model.h \
- 2geom/numeric/fitting-tool.h \
- 2geom/numeric/linear_system.h \
- 2geom/numeric/matrix.cpp \
- 2geom/numeric/matrix.h \
- 2geom/numeric/vector.h \
- 2geom/ord.h \
- 2geom/path.cpp \
- 2geom/path.h \
- 2geom/path-intersection.cpp \
- 2geom/path-intersection.h \
- 2geom/pathvector.cpp \
- 2geom/pathvector.h \
- 2geom/piecewise.cpp \
- 2geom/piecewise.h \
- 2geom/point.cpp \
- 2geom/point.h \
- 2geom/point-l.h \
- 2geom/point-ops.h \
- 2geom/poly.cpp \
- 2geom/poly.h \
- 2geom/quadtree.cpp \
- 2geom/quadtree.h \
- 2geom/ray.h \
- 2geom/rect.cpp \
- 2geom/rect.h \
- 2geom/region.cpp \
- 2geom/region.h \
- 2geom/sbasis-2d.cpp \
- 2geom/sbasis-2d.h \
- 2geom/sbasis.cpp \
- 2geom/sbasis-curve.h \
- 2geom/sbasis-geometric.cpp \
- 2geom/sbasis-geometric.h \
- 2geom/sbasis.h \
- 2geom/sbasis-math.cpp \
- 2geom/sbasis-math.h \
- 2geom/sbasis-poly.cpp \
- 2geom/sbasis-poly.h \
- 2geom/sbasis-roots.cpp \
- 2geom/sbasis-to-bezier.cpp \
- 2geom/sbasis-to-bezier.h \
- 2geom/shape.cpp \
- 2geom/shape.h \
- 2geom/solve-bezier.cpp \
- 2geom/solve-bezier-one-d.cpp \
- 2geom/solve-bezier-parametric.cpp \
- 2geom/solver.h \
- 2geom/sturm.h \
- 2geom/svg-elliptical-arc.cpp \
- 2geom/svg-elliptical-arc.h \
- 2geom/svg-path.cpp \
- 2geom/svg-path.h \
- 2geom/svg-path-parser.cpp \
- 2geom/svg-path-parser.h \
- 2geom/sweep.cpp \
- 2geom/sweep.h \
- 2geom/transforms.cpp \
- 2geom/transforms.h \
- 2geom/utils.cpp \
- 2geom/utils.h
+ 2geom/curve.h \
+ 2geom/curves.h \
+ 2geom/d2.h \
+ 2geom/d2-sbasis.cpp \
+ 2geom/d2-sbasis.h \
+ 2geom/ellipse.cpp \
+ 2geom/ellipse.h \
+ 2geom/elliptical-arc.cpp \
+ 2geom/elliptical-arc.h \
+ 2geom/exception.h \
+ 2geom/forward.h \
+ 2geom/generic-interval.h \
+ 2geom/generic-rect.h \
+ 2geom/geom.cpp \
+ 2geom/geom.h \
+ 2geom/hvlinesegment.h \
+ 2geom/interval.h \
+ 2geom/int-interval.h \
+ 2geom/int-point.h \
+ 2geom/int-rect.h \
+ 2geom/linear.h \
+ 2geom/line.cpp \
+ 2geom/line.h \
+ 2geom/math-utils.h \
+ 2geom/nearest-point.cpp \
+ 2geom/nearest-point.h \
+ 2geom/ord.h \
+ 2geom/path.cpp \
+ 2geom/path.h \
+ 2geom/path-intersection.cpp \
+ 2geom/path-intersection.h \
+ 2geom/pathvector.cpp \
+ 2geom/pathvector.h \
+ 2geom/piecewise.cpp \
+ 2geom/piecewise.h \
+ 2geom/point.cpp \
+ 2geom/point.h \
+ 2geom/point-ops.h \
+ 2geom/poly.cpp \
+ 2geom/poly.h \
+ 2geom/quadtree.cpp \
+ 2geom/quadtree.h \
+ 2geom/ray.h \
+ 2geom/rect.cpp \
+ 2geom/rect.h \
+ 2geom/recursive-bezier-intersection.cpp \
+ 2geom/region.cpp \
+ 2geom/region.h \
+ 2geom/sbasis-2d.cpp \
+ 2geom/sbasis-2d.h \
+ 2geom/sbasis.cpp \
+ 2geom/sbasis-curve.h \
+ 2geom/sbasis-geometric.cpp \
+ 2geom/sbasis-geometric.h \
+ 2geom/sbasis.h \
+ 2geom/sbasis-math.cpp \
+ 2geom/sbasis-math.h \
+ 2geom/sbasis-poly.cpp \
+ 2geom/sbasis-poly.h \
+ 2geom/sbasis-roots.cpp \
+ 2geom/sbasis-to-bezier.cpp \
+ 2geom/sbasis-to-bezier.h \
+ 2geom/shape.cpp \
+ 2geom/shape.h \
+ 2geom/solve-bezier.cpp \
+ 2geom/solve-bezier-one-d.cpp \
+ 2geom/solve-bezier-parametric.cpp \
+ 2geom/solver.h \
+ 2geom/svg-elliptical-arc.cpp \
+ 2geom/svg-elliptical-arc.h \
+ 2geom/svg-path.cpp \
+ 2geom/svg-path.h \
+ 2geom/svg-path-parser.cpp \
+ 2geom/svg-path-parser.h \
+ 2geom/sweep.cpp \
+ 2geom/sweep.h \
+ 2geom/toposweep.cpp \
+ 2geom/toposweep.h \
+ 2geom/transforms.cpp \
+ 2geom/transforms.h \
+ 2geom/utils.cpp \
+ 2geom/utils.h \
+ 2geom/numeric/fitting-model.h \
+ 2geom/numeric/fitting-tool.h \
+ 2geom/numeric/linear_system.h \
+ 2geom/numeric/matrix.cpp \
+ 2geom/numeric/matrix.h \
+ 2geom/numeric/symmetric-matrix-fs.h \
+ 2geom/numeric/symmetric-matrix-fs-operation.h \
+ 2geom/numeric/symmetric-matrix-fs-trace.h \
+ 2geom/numeric/vector.h
diff --git a/src/Makefile.am b/src/Makefile.am
index c27af0800..46c655f9c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,9 +16,6 @@ bin_PROGRAMS = inkscape inkview
# Libraries which should be compiled by "make" but not installed.
# Use this only for libraries that are really standalone, rather than for
# source tree subdirectories.
-#if WITH_INKBOARD
-#libpedro = pedro/libpedro.a
-#endif
if !WITH_EXT_GDL
internal_GDL = libgdl/libgdl.a
@@ -35,7 +32,6 @@ noinst_LIBRARIES = \
libvpsc/libvpsc.a \
livarot/libvarot.a \
2geom/lib2geom.a \
- $(libpedro) \
libinkversion.a
all_libs = \
@@ -51,6 +47,7 @@ all_libs = \
$(PYTHON_LIBS) \
$(INKBOARD_LIBS) \
$(LIBWPG_LIBS) \
+ $(LIBVISIO_LIBS) \
$(DBUS_LIBS) \
$(GDL_LIBS) \
$(IMAGEMAGICK_LIBS)
@@ -74,6 +71,7 @@ INCLUDES = \
$(IMAGEMAGICK_CFLAGS) \
$(INKBOARD_CFLAGS) \
$(LIBWPG_CFLAGS) \
+ $(LIBVISIO_CFLAGS) \
$(DBUS_CFLAGS) \
$(GDL_CFLAGS) \
$(XFT_CFLAGS) \
@@ -107,11 +105,6 @@ win32ldflags = -lcomdlg32 -lmscms
mwindows = -mwindows
endif
-if INKJAR
-inkjar_dir = inkjar
-inkjar_libs = inkjar/libinkjar.a
-endif
-
# Include all partial makefiles from subdirectories
include Makefile_insert
include bind/Makefile_insert
@@ -154,7 +147,6 @@ EXTRA_DIST += \
$(top_srcdir)/Doxyfile \
sp-skeleton.cpp sp-skeleton.h \
util/makefile.in \
- application/makefile.in \
bind/makefile.in \
debug/makefile.in \
dialogs/makefile.in \
@@ -169,11 +161,8 @@ EXTRA_DIST += \
io/makefile.in \
io/crystalegg.xml \
io/doc2html.xsl \
- pedro/makefile.in \
- jabber_whiteboard/makefile.in \
libgdl/makefile.in \
libcroco/makefile.in \
- libnr/makefile.in \
libnrtype/makefile.in \
libavoid/makefile.in \
livarot/makefile.in \
@@ -197,7 +186,6 @@ EXTRA_DIST += \
helper/sp-marshal.list \
show-preview.bmp \
winconsole.cpp \
- $(jabber_whiteboard_SOURCES) \
$(CXXTEST_TEMPLATE)
# Extra files to remove when doing "make distclean"
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 36e05270a..2d557158b 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -40,7 +40,7 @@ ink_common_sources += \
dir-util.cpp dir-util.h \
document.cpp document.h document-private.h \
document-subset.cpp document-subset.h \
- document-undo.cpp \
+ document-undo.cpp document-undo.h \
doxygen-main.cpp \
draw-anchor.cpp draw-anchor.h \
draw-context.cpp draw-context.h \
@@ -61,7 +61,6 @@ ink_common_sources += \
filter-enums.cpp filter-enums.h \
fixes.cpp \
flood-context.cpp flood-context.h \
- forward.h \
gc-alloc.h \
gc-anchored.h gc-anchored.cpp \
gc-core.h \
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index 95ff05b37..9675df8e3 100644
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
@@ -159,7 +159,7 @@ static void sp_arc_context_dispose(GObject *object)
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer data)
+static void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer data)
{
SPArcContext *ac = SP_ARC_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(ac);
diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp
index cf94c0c1e..38327b413 100644
--- a/src/attribute-rel-util.cpp
+++ b/src/attribute-rel-util.cpp
@@ -76,7 +76,14 @@ void sp_attribute_clean_recursive(Node *repr, unsigned int flags) {
}
for(Node *child=repr->firstChild() ; child ; child = child->next()) {
- sp_attribute_clean_recursive( child, flags );
+
+ // Don't remove default css values if element is in <defs> or is a <symbol>
+ Glib::ustring element = child->name();
+ unsigned int flags_temp = flags;
+ if( element.compare( "svg:defs" ) == 0 || element.compare( "svg:symbol" ) == 0 ) {
+ flags_temp &= ~(SP_ATTR_CLEAN_DEFAULT_WARN|SP_ATTR_CLEAN_DEFAULT_REMOVE);
+ }
+ sp_attribute_clean_recursive( child, flags_temp );
}
}
diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp
index 6da754716..03b16a9dd 100644
--- a/src/bind/dobinding.cpp
+++ b/src/bind/dobinding.cpp
@@ -180,7 +180,7 @@ static NativeClass nc_DOMBase =
//########################################################################
-void JNICALL DOMImplementation_nCreateDocument
+static void JNICALL DOMImplementation_nCreateDocument
(JNIEnv *env, jobject obj)
{
DOMImplementationImpl domImpl;
diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp
index 0831ddf19..d2d01f0b3 100644
--- a/src/bind/javabind.cpp
+++ b/src/bind/javabind.cpp
@@ -111,7 +111,7 @@ String normalizePath(const String &str)
/**
* Convert a java string to a C++ string
*/
-String getString(JNIEnv *env, jstring jstr)
+static String getString(JNIEnv *env, jstring jstr)
{
const char *chars = env->GetStringUTFChars(jstr, JNI_FALSE);
String str = chars;
@@ -138,62 +138,62 @@ String getExceptionString(JNIEnv *env)
return buf;
}
-jint getObjInt(JNIEnv *env, jobject obj, const char *name)
+static jint getObjInt(JNIEnv *env, jobject obj, const char *name)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "I");
return env->GetIntField(obj, fid);
}
-void setObjInt(JNIEnv *env, jobject obj, const char *name, jint val)
+static void setObjInt(JNIEnv *env, jobject obj, const char *name, jint val)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "I");
env->SetIntField(obj, fid, val);
}
-jlong getObjLong(JNIEnv *env, jobject obj, const char *name)
+static jlong getObjLong(JNIEnv *env, jobject obj, const char *name)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "J");
return env->GetLongField(obj, fid);
}
-void setObjLong(JNIEnv *env, jobject obj, const char *name, jlong val)
+static void setObjLong(JNIEnv *env, jobject obj, const char *name, jlong val)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "J");
env->SetLongField(obj, fid, val);
}
-jfloat getObjFloat(JNIEnv *env, jobject obj, const char *name)
+static jfloat getObjFloat(JNIEnv *env, jobject obj, const char *name)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "F");
return env->GetFloatField(obj, fid);
}
-void setObjFloat(JNIEnv *env, jobject obj, const char *name, jfloat val)
+static void setObjFloat(JNIEnv *env, jobject obj, const char *name, jfloat val)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "F");
env->SetFloatField(obj, fid, val);
}
-jdouble getObjDouble(JNIEnv *env, jobject obj, const char *name)
+static jdouble getObjDouble(JNIEnv *env, jobject obj, const char *name)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "D");
return env->GetDoubleField(obj, fid);
}
-void setObjDouble(JNIEnv *env, jobject obj, const char *name, jdouble val)
+static void setObjDouble(JNIEnv *env, jobject obj, const char *name, jdouble val)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "D");
env->SetDoubleField(obj, fid, val);
}
-String getObjString(JNIEnv *env, jobject obj, const char *name)
+static String getObjString(JNIEnv *env, jobject obj, const char *name)
{
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "Ljava/lang/String;");
jstring jstr = (jstring)env->GetObjectField(obj, fid);
return getString(env, jstr);
}
-void setObjString(JNIEnv *env, jobject obj, const char *name, const String &val)
+static void setObjString(JNIEnv *env, jobject obj, const char *name, const String &val)
{
jstring jstr = env->NewStringUTF(val.c_str());
jfieldID fid = env->GetFieldID(env->GetObjectClass(obj), name, "Ljava/lang/String;");
@@ -725,7 +725,7 @@ static void populateClassPath(const String &javaroot,
* This is provided to scripts can grab the current copy or the
* repr tree. If anyone has a smarter way of doing this, please implement.
*/
-jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/)
+static jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/)
{
//JavaBinderyImpl *bind = (JavaBinderyImpl *)ptr;
String buf = sp_repr_save_buf((SP_ACTIVE_DOCUMENT)->rdoc);
@@ -737,7 +737,7 @@ jstring JNICALL documentGet(JNIEnv *env, jobject /*obj*/, jlong /*ptr*/)
* This is provided to scripts can load an XML tree into Inkscape.
* If anyone has a smarter way of doing this, please implement.
*/
-jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, jstring /*jstr*/)
+static jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, jstring /*jstr*/)
{
/*
JavaBinderyImpl *bind = (JavaBinderyImpl *)ptr;
@@ -752,7 +752,7 @@ jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, js
* redirect its logging stream here.
* For the main C++/Java bindings, see dobinding.cpp
*/
-void JNICALL logWrite(JNIEnv */*env*/, jobject /*obj*/, jlong ptr, jint ch)
+static void JNICALL logWrite(JNIEnv */*env*/, jobject /*obj*/, jlong ptr, jint ch)
{
JavaBinderyImpl *bind = reinterpret_cast<JavaBinderyImpl *>(ptr);
bind->log(ch);
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index 031b16a7c..42268ec83 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -65,8 +65,7 @@ static void box3d_side_class_init(Box3DSideClass *klass)
{
SPObjectClass *sp_object_class = reinterpret_cast<SPObjectClass *>(klass);
SPShapeClass *shape_class = reinterpret_cast<SPShapeClass *>(klass);
-
- parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE);
+ parent_class = SP_SHAPE_CLASS(g_type_class_ref (SP_TYPE_SHAPE));
sp_object_class->build = box3d_side_build;
sp_object_class->write = box3d_side_write;
@@ -86,8 +85,8 @@ box3d_side_init (Box3DSide * side)
static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr)
{
- if (((SPObjectClass *) parent_class)->build) {
- ((SPObjectClass *) parent_class)->build(object, document, repr);
+ if ((SP_OBJECT_CLASS(parent_class))->build) {
+ (SP_OBJECT_CLASS(parent_class))->build(object, document, repr);
}
object->readAttr( "inkscape:box3dsidetype" );
@@ -111,7 +110,7 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
static_cast<SPShape *>(object)->setShape();
/* Duplicate the path */
- SPCurve const *curve = ((SPShape *) object)->_curve;
+ SPCurve const *curve = (SP_SHAPE(object))->_curve;
//Nulls might be possible if this called iteratively
if ( !curve ) {
return NULL;
@@ -120,8 +119,8 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
repr->setAttribute("d", d);
g_free (d);
- if (((SPObjectClass *) (parent_class))->write)
- ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->write)
+ (SP_OBJECT_CLASS(parent_class))->write (object, xml_doc, repr, flags);
return repr;
}
@@ -154,8 +153,8 @@ box3d_side_set (SPObject *object, unsigned int key, const gchar *value)
}
break;
default:
- if (((SPObjectClass *) parent_class)->set)
- ((SPObjectClass *) parent_class)->set (object, key, value);
+ if ((SP_OBJECT_CLASS(parent_class))->set)
+ (SP_OBJECT_CLASS(parent_class))->set (object, key, value);
break;
}
}
@@ -173,8 +172,8 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags)
static_cast<SPShape *>(object)->setShape ();
}
- if (((SPObjectClass *) parent_class)->update)
- ((SPObjectClass *) parent_class)->update (object, ctx, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->update)
+ (SP_OBJECT_CLASS(parent_class))->update (object, ctx, flags);
}
/* Create a new Box3DSide and append it to the parent box */
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 23f934b64..0cb139458 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -82,13 +82,12 @@ box3d_get_type(void)
return type;
}
-static void
-box3d_class_init(SPBox3DClass *klass)
+static void box3d_class_init(SPBox3DClass *klass)
{
- SPObjectClass *sp_object_class = (SPObjectClass *) klass;
- SPItemClass *item_class = (SPItemClass *) klass;
+ SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass);
+ SPItemClass *item_class = SP_ITEM_CLASS(klass);
- parent_class = (SPGroupClass *) g_type_class_ref(SP_TYPE_GROUP);
+ parent_class = SP_GROUP_CLASS(g_type_class_ref(SP_TYPE_GROUP));
sp_object_class->build = box3d_build;
sp_object_class->release = box3d_release;
@@ -110,8 +109,8 @@ box3d_init(SPBox3D *box)
static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
- if (((SPObjectClass *) (parent_class))->build) {
- ((SPObjectClass *) (parent_class))->build(object, document, repr);
+ if ((SP_OBJECT_CLASS(parent_class))->build) {
+ (SP_OBJECT_CLASS(parent_class))->build(object, document, repr);
}
SPBox3D *box = SP_BOX3D (object);
@@ -140,7 +139,7 @@ static void box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::N
static void
box3d_release(SPObject *object)
{
- SPBox3D *box = (SPBox3D *) object;
+ SPBox3D *box = SP_BOX3D(object);
if (box->persp_href) {
g_free(box->persp_href);
@@ -173,8 +172,8 @@ box3d_release(SPObject *object)
*/
}
- if (((SPObjectClass *) parent_class)->release)
- ((SPObjectClass *) parent_class)->release(object);
+ if ((SP_OBJECT_CLASS(parent_class))->release)
+ (SP_OBJECT_CLASS(parent_class))->release(object);
}
static void
@@ -225,8 +224,8 @@ box3d_set(SPObject *object, unsigned int key, const gchar *value)
}
break;
default:
- if (((SPObjectClass *) (parent_class))->set) {
- ((SPObjectClass *) (parent_class))->set(object, key, value);
+ if ((SP_OBJECT_CLASS(parent_class))->set) {
+ (SP_OBJECT_CLASS(parent_class))->set(object, key, value);
}
break;
}
@@ -260,8 +259,8 @@ box3d_update(SPObject *object, SPCtx *ctx, guint flags)
}
// Invoke parent method
- if (((SPObjectClass *) (parent_class))->update)
- ((SPObjectClass *) (parent_class))->update(object, ctx, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->update)
+ (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags);
}
@@ -307,8 +306,8 @@ static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Docume
box->save_corner7 = box->orig_corner7;
}
- if (((SPObjectClass *) (parent_class))->write) {
- ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->write) {
+ (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags);
}
return repr;
@@ -366,7 +365,7 @@ box3d_set_transform(SPItem *item, Geom::Affine const &xform)
return Geom::identity();
}
-Proj::Pt3
+static Proj::Pt3
box3d_get_proj_corner (guint id, Proj::Pt3 const &c0, Proj::Pt3 const &c7) {
return Proj::Pt3 ((id & Box3D::X) ? c7[Proj::X] : c0[Proj::X],
(id & Box3D::Y) ? c7[Proj::Y] : c0[Proj::Y],
@@ -684,7 +683,7 @@ box3d_half_line_crosses_joining_line (Geom::Point const &A, Geom::Point const &B
{
inters = Geom::intersection(lineAB, lineCD);
}
- catch (Geom::InfiniteSolutions e)
+ catch (Geom::InfiniteSolutions& e)
{
// We're probably dealing with parallel lines, so they don't really cross
return false;
@@ -1078,6 +1077,8 @@ box3d_recompute_z_orders (SPBox3D *box) {
central_axis = Box3D::Z;
}
+ // FIXME: At present, this is not used. Why is it calculated?
+ /*
unsigned int central_corner = 3 ^ central_axis;
if (central_axis == Box3D::Z) {
central_corner = central_corner ^ Box3D::XYZ;
@@ -1085,6 +1086,7 @@ box3d_recompute_z_orders (SPBox3D *box) {
if (box3d_XY_axes_are_swapped(box)) {
central_corner = central_corner ^ Box3D::XYZ;
}
+ */
Geom::Point c1(box3d_get_corner_screen(box, 1, false));
Geom::Point c2(box3d_get_corner_screen(box, 2, false));
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index a1e9dd0f1..981d527f0 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -639,9 +639,9 @@ bool ColorProfile::GamutCheck(SPColor color)
cmsUInt8Number outofgamut = 0;
guchar check_color[4] = {
- SP_RGBA32_R_U(val),
- SP_RGBA32_G_U(val),
- SP_RGBA32_B_U(val),
+ static_cast<guchar>(SP_RGBA32_R_U(val)),
+ static_cast<guchar>(SP_RGBA32_G_U(val)),
+ static_cast<guchar>(SP_RGBA32_B_U(val)),
255};
cmsDoTransform(ColorProfile::getTransfGamutCheck(), &check_color, &outofgamut, 1);
diff --git a/src/color.cpp b/src/color.cpp
index 187a6ba6a..0a07d3f21 100644
--- a/src/color.cpp
+++ b/src/color.cpp
@@ -352,7 +352,7 @@ sp_color_rgb_to_hsl_floatv (float *hsl, float r, float g, float b)
}
}
-float
+static float
hue_2_rgb (float v1, float v2, float h)
{
if (h < 0) h += 6.0;
diff --git a/src/common-context.cpp b/src/common-context.cpp
index 9ced41a26..9d5dbb048 100644
--- a/src/common-context.cpp
+++ b/src/common-context.cpp
@@ -56,9 +56,9 @@ GType sp_common_context_get_type(void)
static void sp_common_context_class_init(SPCommonContextClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
- SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
+ SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass);
- common_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+ common_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass));
object_class->dispose = sp_common_context_dispose;
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index d6f02e875..c0882c526 100644
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
@@ -86,7 +86,7 @@ void SPAvoidRef::setAvoid(char const *value)
}
}
-void print_connection_points(std::map<int, ConnectionPoint>& cp)
+static void print_connection_points(std::map<int, ConnectionPoint>& cp)
{
std::map<int, ConnectionPoint>::iterator i;
for (i=cp.begin(); i!=cp.end(); ++i)
diff --git a/src/debug/timestamp.cpp b/src/debug/timestamp.cpp
index e100134c8..6de03a463 100644
--- a/src/debug/timestamp.cpp
+++ b/src/debug/timestamp.cpp
@@ -13,6 +13,7 @@
#include <glib.h>
#include <glibmm/ustring.h>
#include "debug/simple-event.h"
+#include "timestamp.h"
namespace Inkscape {
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 6b47bdad6..1cfe018ce 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -23,6 +23,7 @@
#include "ui/dialog/guides.h"
#include "desktop.h"
+#include "desktop-events.h"
#include "desktop-handles.h"
#include "dialogs/dialog-events.h"
#include "display/canvas-axonomgrid.h"
@@ -501,7 +502,16 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
guide_cursor = gdk_cursor_new (GDK_EXCHANGE);
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
#if GTK_CHECK_VERSION(3,0,0)
- g_object_unref(guide_cursor);
+ g_object_unref(guide_cursor);
+#else
+ gdk_cursor_unref(guide_cursor);
+#endif
+ } else {
+ GdkCursor *guide_cursor;
+ guide_cursor = gdk_cursor_new (GDK_HAND1);
+ gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
+#if GTK_CHECK_VERSION(3,0,0)
+ g_object_unref(guide_cursor);
#else
gdk_cursor_unref(guide_cursor);
#endif
diff --git a/src/desktop-handles.cpp b/src/desktop-handles.cpp
index d35df6454..f7ffbed70 100644
--- a/src/desktop-handles.cpp
+++ b/src/desktop-handles.cpp
@@ -13,6 +13,7 @@
#include "display/sp-canvas.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
+#include "desktop-handles.h"
SPEventContext *
sp_desktop_event_context (SPDesktop const * desktop)
@@ -43,7 +44,7 @@ sp_desktop_canvas (SPDesktop const * desktop)
{
g_return_val_if_fail (desktop != NULL, NULL);
- return ((SPCanvasItem *) desktop->main)->canvas;
+ return (SP_CANVAS_ITEM(desktop->main))->canvas;
}
SPCanvasItem *
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 74e15e3e2..410e71730 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -1117,7 +1117,7 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res)
/**
* Write to style_res the baseline numbers.
*/
-int
+static int
objects_query_baselines (GSList *objects, SPStyle *style_res)
{
bool different = false;
@@ -1273,7 +1273,7 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res)
}
}
-int
+static int
objects_query_fontspecification (GSList *objects, SPStyle *style_res)
{
bool different = false;
@@ -1335,7 +1335,7 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res)
}
}
-int
+static int
objects_query_blend (GSList *objects, SPStyle *style_res)
{
const int empty_prev = -2;
diff --git a/src/desktop.cpp b/src/desktop.cpp
index ca981a458..2f8f3e4b6 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -55,6 +55,7 @@
#include "document.h"
#include "event-log.h"
#include "helper/units.h"
+#include "interface.h"
#include "inkscape-private.h"
#include "layer-fns.h"
#include "layer-manager.h"
@@ -496,13 +497,51 @@ void SPDesktop::setCurrentLayer(SPObject *object) {
_layer_hierarchy->setBottom(object);
}
-void SPDesktop::toggleAllLayers(bool hide) {
+void SPDesktop::toggleHideAllLayers(bool hide) {
- for ( SPObject* obj = currentRoot(); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
+ for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
SP_ITEM(obj)->setHidden(hide);
}
}
+void SPDesktop::toggleLockAllLayers(bool lock) {
+
+ for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
+ SP_ITEM(obj)->setLocked(lock);
+ }
+}
+
+void SPDesktop::toggleLockOtherLayers(SPObject *object) {
+ g_return_if_fail(SP_IS_GROUP(object));
+ g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) );
+
+ bool othersLocked = false;
+ std::vector<SPObject*> layers;
+ for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) {
+ // Dont lock any ancestors, since that would in turn lock the layer as well
+ if (!obj->isAncestorOf(object)) {
+ layers.push_back(obj);
+ othersLocked |= !SP_ITEM(obj)->isLocked();
+ }
+ }
+ for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
+ if (!obj->isAncestorOf(object)) {
+ layers.push_back(obj);
+ othersLocked |= !SP_ITEM(obj)->isLocked();
+ }
+ }
+
+ SPItem *item = SP_ITEM(object);
+ if ( item->isLocked() ) {
+ item->setLocked(false);
+ }
+
+ for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) {
+ SP_ITEM(*it)->setLocked(othersLocked);
+ }
+}
+
+
void SPDesktop::toggleLayerSolo(SPObject *object) {
g_return_if_fail(SP_IS_GROUP(object));
g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) );
@@ -510,12 +549,17 @@ void SPDesktop::toggleLayerSolo(SPObject *object) {
bool othersShowing = false;
std::vector<SPObject*> layers;
for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) {
- layers.push_back(obj);
- othersShowing |= !SP_ITEM(obj)->isHidden();
+ // Don't hide ancestors, since that would in turn hide the layer as well
+ if (!obj->isAncestorOf(object)) {
+ layers.push_back(obj);
+ othersShowing |= !SP_ITEM(obj)->isHidden();
+ }
}
for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
- layers.push_back(obj);
- othersShowing |= !SP_ITEM(obj)->isHidden();
+ if (!obj->isAncestorOf(object)) {
+ layers.push_back(obj);
+ othersShowing |= !SP_ITEM(obj)->isHidden();
+ }
}
@@ -1309,6 +1353,17 @@ SPDesktop::toggleScrollbars()
_widget->toggleScrollbars();
}
+
+void SPDesktop::toggleToolbar(gchar const *toolbar_name)
+{
+ Glib::ustring pref_path = getLayoutPrefPath(this) + toolbar_name + "/state";
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean visible = prefs->getBool(pref_path, true);
+ prefs->setBool(pref_path, !visible);
+
+ layoutWidget();
+}
+
void
SPDesktop::layoutWidget()
{
@@ -1465,7 +1520,6 @@ void SPDesktop::toggleSnapGlobal()
namedview->setSnapGlobal(!v);
}
-
//----------------------------------------------------------------------
// Callback implementations. The virtual ones are connected by the view.
@@ -1849,6 +1903,7 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_CLONETILER, "/dialogs/clonetiler") );
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_ITEM, "/dialogs/object") );
mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SPELLCHECK, "/dialogs/spellcheck") );
+ mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SYMBOLS, "/dialogs/symbols") );
for (iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); iter++) {
int verbId = iter->first;
diff --git a/src/desktop.h b/src/desktop.h
index 919cd905e..529199692 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -280,7 +280,9 @@ public:
void setCurrentLayer(SPObject *object);
void toggleLayerSolo(SPObject *object);
- void toggleAllLayers(bool hidden);
+ void toggleHideAllLayers(bool hide);
+ void toggleLockAllLayers(bool lock);
+ void toggleLockOtherLayers(SPObject *object);
SPObject *layerForObject(SPObject *object);
bool isLayer(SPObject *object) const;
bool isWithinViewport(SPItem *item) const;
@@ -364,6 +366,7 @@ public:
void toggleSnapGlobal();
bool gridsEnabled() const { return grids_visible; };
void showGrids(bool show, bool dirty_document = true);
+ void toggleToolbar(gchar const *toolbar_name);
bool is_iconified();
bool is_maximized();
diff --git a/src/device-manager.cpp b/src/device-manager.cpp
index 059e1b52d..29efa2627 100644
--- a/src/device-manager.cpp
+++ b/src/device-manager.cpp
@@ -113,7 +113,7 @@ static std::map<Glib::ustring, Gdk::AxisUse> &getStringToAxis()
return mapping;
}
-std::map<Gdk::AxisUse, Glib::ustring> &getAxisToString()
+static std::map<Gdk::AxisUse, Glib::ustring> &getAxisToString()
{
static bool init = false;
static std::map<Gdk::AxisUse, Glib::ustring> mapping;
@@ -139,7 +139,7 @@ static std::map<Glib::ustring, Gdk::InputMode> &getStringToMode()
return mapping;
}
-std::map<Gdk::InputMode, Glib::ustring> &getModeToString()
+static std::map<Gdk::InputMode, Glib::ustring> &getModeToString()
{
static bool init = false;
static std::map<Gdk::InputMode, Glib::ustring> mapping;
@@ -173,14 +173,7 @@ public:
virtual bool hasCursor() const {return gdk_device_get_has_cursor (device);}
virtual gint getNumKeys() const {
-// Backward-compatibility: The GSEAL-compliant
-// gdk_device_get_n_keys function was only introduced
-// with GTK 2.24
-#if GTK_CHECK_VERSION(2, 24, 0)
- return gdk_device_get_n_keys (device);
-#else
- return device->num_keys;
-#endif // GTK_CHECK_VERSION
+ return gdk_device_get_n_keys (device);
}
virtual Glib::ustring getLink() const {return link;}
virtual void setLink( Glib::ustring const& link ) {this->link = link;}
diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp
index 41d7f3418..8acc96596 100644
--- a/src/dialogs/find.cpp
+++ b/src/dialogs/find.cpp
@@ -18,7 +18,7 @@
//TODO : delete this
GtkWidget * sp_find_dialog_old (void);
-void
+static void
//GtkWidget *
sp_find_dialog(){
// DialogFind::get().present();
@@ -102,7 +102,7 @@ static gboolean sp_find_dialog_delete(GObject *, GdkEvent *, gpointer /*data*/)
return FALSE; // which means, go ahead and destroy it
}
-void
+static void
sp_find_squeeze_window()
{
GtkRequisition r;
@@ -114,7 +114,7 @@ sp_find_squeeze_window()
gtk_window_resize ((GtkWindow *) dlg, r.width, r.height);
}
-bool
+static bool
item_id_match (SPItem *item, const gchar *id, bool exact)
{
if (item->getRepr() == NULL) {
@@ -138,7 +138,7 @@ item_id_match (SPItem *item, const gchar *id, bool exact)
}
}
-bool
+static bool
item_text_match (SPItem *item, const gchar *text, bool exact)
{
if (item->getRepr() == NULL) {
@@ -162,7 +162,7 @@ item_text_match (SPItem *item, const gchar *text, bool exact)
return false;
}
-bool
+static bool
item_style_match (SPItem *item, const gchar *text, bool exact)
{
if (item->getRepr() == NULL) {
@@ -181,7 +181,8 @@ item_style_match (SPItem *item, const gchar *text, bool exact)
}
}
-bool item_attr_match(SPItem *item, const gchar *name, bool exact)
+static bool
+item_attr_match(SPItem *item, const gchar *name, bool exact)
{
bool result = false;
if (item->getRepr()) {
@@ -196,7 +197,7 @@ bool item_attr_match(SPItem *item, const gchar *name, bool exact)
}
-GSList *
+static GSList *
filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_function)(SPItem *, const gchar *, bool), bool exact)
{
GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field));
@@ -218,13 +219,13 @@ filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_funct
}
-bool
+static bool
type_checkbox (GtkWidget *widget, const gchar *data)
{
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data(G_OBJECT (widget), data)));
}
-bool
+static bool
item_type_match (SPItem *item, GtkWidget *widget)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -263,7 +264,7 @@ item_type_match (SPItem *item, GtkWidget *widget)
return false;
}
-GSList *
+static GSList *
filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidget *))
{
GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), "types"));
@@ -283,7 +284,7 @@ filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidge
}
-GSList *
+static GSList *
filter_list (GSList *l, GObject *dlg, bool exact)
{
l = filter_onefield (l, dlg, "text", item_text_match, exact);
@@ -296,7 +297,7 @@ filter_list (GSList *l, GObject *dlg, bool exact)
return l;
}
-GSList *
+static GSList *
all_items (SPObject *r, GSList *l, bool hidden, bool locked)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -321,7 +322,7 @@ all_items (SPObject *r, GSList *l, bool hidden, bool locked)
return l;
}
-GSList *
+static GSList *
all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -343,7 +344,8 @@ all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool
}
-void sp_find_dialog_find(GObject *, GObject *dlg)
+static void
+sp_find_dialog_find(GObject *, GObject *dlg)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -392,7 +394,7 @@ void sp_find_dialog_find(GObject *, GObject *dlg)
}
}
-void
+static void
sp_find_reset_searchfield (GObject *dlg, const gchar *field)
{
GtkWidget *widget = GTK_WIDGET (g_object_get_data(G_OBJECT (dlg), field));
@@ -400,7 +402,7 @@ sp_find_reset_searchfield (GObject *dlg, const gchar *field)
}
-void
+static void
sp_find_dialog_reset (GObject *, GObject *dlg)
{
sp_find_reset_searchfield (dlg, "text");
@@ -417,7 +419,7 @@ sp_find_dialog_reset (GObject *, GObject *dlg)
#define FIND_LABELWIDTH 80
-void
+static void
sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, const gchar *id, const gchar *tip)
{
#if GTK_CHECK_VERSION(3,0,0)
@@ -442,7 +444,7 @@ sp_find_new_searchfield (GtkWidget *dlg, GtkWidget *vb, const gchar *label, cons
gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
}
-void
+static void
sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gchar *tip, void (*function) (GObject *, GObject *))
{
GtkWidget *b = gtk_button_new_with_mnemonic (label);
@@ -452,7 +454,7 @@ sp_find_new_button (GtkWidget *dlg, GtkWidget *hb, const gchar *label, const gch
gtk_widget_show (b);
}
-void
+static void
toggle_alltypes (GtkToggleButton *tb, gpointer data)
{
GtkWidget *alltypes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "all-pane"));
@@ -475,7 +477,7 @@ toggle_alltypes (GtkToggleButton *tb, gpointer data)
sp_find_squeeze_window();
}
-void
+static void
toggle_shapes (GtkToggleButton *tb, gpointer data)
{
GtkWidget *shapes_pane = GTK_WIDGET (g_object_get_data(G_OBJECT (data), "shapes-pane"));
@@ -492,7 +494,7 @@ toggle_shapes (GtkToggleButton *tb, gpointer data)
}
-GtkWidget *
+static GtkWidget *
sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active,
const gchar *tip,
const gchar *label,
@@ -520,7 +522,7 @@ sp_find_types_checkbox (GtkWidget *w, const gchar *data, gboolean active,
return hb;
}
-GtkWidget *
+static GtkWidget *
sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean active,
const gchar *tip,
const gchar *label,
@@ -548,7 +550,7 @@ sp_find_types_checkbox_indented (GtkWidget *w, const gchar *data, gboolean activ
}
-GtkWidget *
+static GtkWidget *
sp_find_types ()
{
#if GTK_CHECK_VERSION(3,0,0)
diff --git a/src/dir-util.cpp b/src/dir-util.cpp
index 7d4054745..c9b88b007 100644
--- a/src/dir-util.cpp
+++ b/src/dir-util.cpp
@@ -7,6 +7,7 @@
#include <string>
#include <cstring>
#include <glib.h>
+#include "dir-util.h"
std::string sp_relative_path_from_path( std::string const &path, std::string const &base)
{
diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert
index cf211108f..abbd89a68 100644
--- a/src/display/Makefile_insert
+++ b/src/display/Makefile_insert
@@ -47,7 +47,6 @@ ink_common_sources += \
display/guideline.h \
display/nr-3dutils.cpp \
display/nr-3dutils.h \
- display/nr-arena-forward.h \
display/nr-filter-blend.cpp \
display/nr-filter-blend.h \
display/nr-filter-colormatrix.cpp \
@@ -107,6 +106,8 @@ ink_common_sources += \
display/sodipodi-ctrlrect.h \
display/sp-canvas.cpp \
display/sp-canvas.h \
+ display/sp-canvas-item.h \
+ display/sp-canvas-group.h \
display/sp-canvas-util.cpp \
display/sp-canvas-util.h \
display/sp-ctrlcurve.cpp \
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index f0fd63ef4..8e25c1843 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -316,6 +316,18 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event)
ret = sp_canvas_arena_send_event (arena, event);
break;
+ case GDK_SCROLL: {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
+ bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
+ if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
+ /* Zoom is emitted by the canvas as well, ignore here */
+ return FALSE;
+ }
+ ret = sp_canvas_arena_send_event (arena, event);
+ break;
+ }
+
default:
/* Just send event */
ret = sp_canvas_arena_send_event (arena, event);
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index d4e15f475..bfc6f27c4 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -2,7 +2,7 @@
* Authors:
* Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- * Copyright (C) 2006-2011 Authors
+ * Copyright (C) 2006-2012 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -12,47 +12,37 @@
* smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending
* to the right). The x-axis will always have an angle between 0 and 90 degrees.
*/
+
- /*
- * TODO:
- * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO.
- */
-
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include <glibmm/i18n.h>
-#include "ui/widget/registered-widget.h"
#include "display/canvas-axonomgrid.h"
-#include "2geom/line.h"
+
+#include "ui/widget/registered-widget.h"
#include "desktop.h"
-#include "canvas-grid.h"
#include "desktop-handles.h"
#include "display/cairo-utils.h"
#include "display/canvas-grid.h"
#include "display/sp-canvas-util.h"
+#include "display/sp-canvas.h"
#include "document.h"
-#include "helper/units.h"
#include "inkscape.h"
#include "preferences.h"
#include "sp-namedview.h"
#include "sp-object.h"
#include "svg/svg-color.h"
+#include "2geom/line.h"
+#include "2geom/angle.h"
#include "util/mathfns.h"
-#include "xml/node-event-vector.h"
#include "round.h"
-#include "display/sp-canvas.h"
+#include "helper/units.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
enum Dim3 { X=0, Y, Z };
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-static double deg_to_rad(double deg) { return deg*M_PI/180.0;}
-
/**
* This function calls Cairo to render a line on a particular canvas buffer.
* Coordinates are interpreted as SCREENcoordinates
@@ -138,9 +128,9 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0);
angle_deg[Y] = 0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
snapper = new CanvasAxonomGridSnapper(this, &namedview->snap_manager, 0);
@@ -251,17 +241,17 @@ CanvasAxonomGrid::readRepr()
if ( (value = repr->attribute("gridanglex")) ) {
angle_deg[X] = g_ascii_strtod(value, NULL);
- if (angle_deg[X] < 1.0) angle_deg[X] = 1.0;
+ if (angle_deg[X] < 0.) angle_deg[X] = 0.;
if (angle_deg[X] > 89.0) angle_deg[X] = 89.0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
}
if ( (value = repr->attribute("gridanglez")) ) {
angle_deg[Z] = g_ascii_strtod(value, NULL);
- if (angle_deg[Z] < 1.0) angle_deg[Z] = 1.0;
+ if (angle_deg[Z] < 0.) angle_deg[Z] = 0.;
if (angle_deg[Z] > 89.0) angle_deg[Z] = 89.0;
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
}
@@ -477,8 +467,8 @@ CanvasAxonomGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]);
lyw = sw[Geom::Y];
- lxw_x = sw[Geom::X] / tan_angle[X];
- lxw_z = sw[Geom::X] / tan_angle[Z];
+ lxw_x = Geom::are_near(tan_angle[X],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[X];
+ lxw_z = Geom::are_near(tan_angle[Z],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[Z];
if (empspacing == 0) {
scaled = true;
@@ -526,8 +516,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
- gint const y1 = buf->rect.bottom();
+ gint x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
+ gint y1 = buf->rect.bottom();
+ if ( Geom::are_near(tan_angle[X],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (xlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -536,18 +530,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// lines starting from top side
- gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
- xlinenum = xlinestart-1;
- for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
- gint const y0 = buf->rect.top();
- gint const y1 = buf->rect.bottom();
- gint const x0 = round(x);
- gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
-
- if (!scaled && (xlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[X],0.))
+ {
+ gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
+ xlinenum = xlinestart-1;
+ for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
+ gint const y0 = buf->rect.top();
+ gint const y1 = buf->rect.bottom();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
+
+ if (!scaled && (xlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
@@ -575,8 +572,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++, next_y = y) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
- gint const y1 = buf->rect.top();
+ gint x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
+ gint y1 = buf->rect.top();
+ if ( Geom::are_near(tan_angle[Z],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (zlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -585,17 +586,20 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// draw lines from bottom-up
- gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
- for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
- gint const y0 = buf->rect.bottom();
- gint const y1 = buf->rect.top();
- gint const x0 = round(x);
- gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
-
- if (!scaled && (zlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[Z],0.))
+ {
+ gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
+ for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
+ gint const y0 = buf->rect.bottom();
+ gint const y1 = buf->rect.top();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
+
+ if (!scaled && (zlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h
index 04919f947..0e24d3f56 100644
--- a/src/display/canvas-axonomgrid.h
+++ b/src/display/canvas-axonomgrid.h
@@ -2,9 +2,12 @@
#define CANVAS_AXONOMGRID_H
/*
- * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
+ * Authors:
+ * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- */
+ * Copyright (C) 2006-2012 Authors
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
#include "line-snapper.h"
#include "canvas-grid.h"
@@ -15,7 +18,7 @@ struct SPNamedView;
namespace Inkscape {
namespace XML {
- class Node;
+ class Node;
};
class CanvasAxonomGrid : public CanvasGrid {
@@ -36,6 +39,9 @@ public:
bool scaled; /**< Whether the grid is in scaled mode */
+protected:
+ friend class CanvasAxonomGridSnapper;
+
Geom::Point ow; /**< Transformed origin by the affine for the zoom */
double lyw; /**< Transformed length y by the affine for the zoom */
double lxw_x;
@@ -44,7 +50,6 @@ public:
Geom::Point sw; /**< the scaling factors of the affine transform */
-protected:
virtual Gtk::Widget * newSpecificWidget();
private:
@@ -63,7 +68,7 @@ public:
bool ThisSnapperMightSnap() const;
Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
- bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
+ bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
private:
LineList _getSnapLines(Geom::Point const &p) const;
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 498958f08..329b621ae 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -14,6 +14,9 @@
*/
#include <glibmm/i18n.h>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include "ui/widget/registered-widget.h"
#include "desktop.h"
@@ -37,10 +40,6 @@
#include "verbs.h"
#include "display/sp-canvas.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
-
using Inkscape::DocumentUndo;
namespace Inkscape {
@@ -275,9 +274,9 @@ CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * repr, SPDocument * d
switch (gridtype) {
case GRID_RECTANGULAR:
- return (CanvasGrid*) new CanvasXYGrid(nv, repr, doc);
+ return dynamic_cast<CanvasGrid*>(new CanvasXYGrid(nv, repr, doc));
case GRID_AXONOMETRIC:
- return (CanvasGrid*) new CanvasAxonomGrid(nv, repr, doc);
+ return dynamic_cast<CanvasGrid*>(new CanvasAxonomGrid(nv, repr, doc));
}
return NULL;
@@ -351,12 +350,13 @@ CanvasGrid::newWidget()
_rcb_enabled->setSlaveWidgets(slaves);
// set widget values
+ _wr.setUpdating (true);
_rcb_visible->setActive(visible);
if (snapper != NULL) {
_rcb_enabled->setActive(snapper->getEnabled());
_rcb_snap_visible_only->setActive(snapper->getSnapVisibleOnly());
}
-
+ _wr.setUpdating (false);
return dynamic_cast<Gtk::Widget *> (vbox);
}
@@ -366,7 +366,7 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
if (!data)
return;
- ((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
+ (static_cast<CanvasGrid*>(data))->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
}
bool CanvasGrid::isEnabled()
@@ -735,7 +735,6 @@ _wr.setUpdating (true);
new Inkscape::UI::Widget::RegisteredCheckButton( _("_Show dots instead of lines"),
_("If set, displays dots at gridpoints instead of gridlines"),
"dotted", _wr, false, repr, doc) );
-_wr.setUpdating (false);
Gtk::Widget const *const widget_array[] = {
0, _rumg,
@@ -775,6 +774,8 @@ _wr.setUpdating (false);
_rcb_dotted->setActive(render_dotted);
+ _wr.setUpdating (false);
+
_rsu_ox->setProgrammatically = false;
_rsu_oy->setProgrammatically = false;
_rsu_sx->setProgrammatically = false;
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index ddc946d5d..fe60d9c65 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -58,9 +58,9 @@ sp_canvastext_get_type (void)
static void sp_canvastext_class_init(SPCanvasTextClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class_ct = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class_ct = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_canvastext_destroy;
item_class->update = sp_canvastext_update;
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1a788b59a..ae243853e 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -150,7 +150,7 @@ SPCurve::concat(GSList const *list)
SPCurve *new_curve = new SPCurve();
for (GSList const *l = list; l != NULL; l = l->next) {
- SPCurve *c = (SPCurve *) l->data;
+ SPCurve *c = static_cast<SPCurve *>(l->data);
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h
index fb6662202..b8c4667c2 100644
--- a/src/display/drawing-context.h
+++ b/src/display/drawing-context.h
@@ -101,6 +101,8 @@ public:
cairo_t *raw() { return _ct; }
cairo_surface_t *rawTarget() { return cairo_get_group_target(_ct); }
+ DrawingSurface *surface() { return _surface; } // Needed to find scale in drawing-item.cpp
+
private:
DrawingContext(cairo_t *ct, DrawingSurface *surface, bool destroy);
diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp
index 0fb1f0018..1e6e44d6f 100644
--- a/src/display/drawing-item.cpp
+++ b/src/display/drawing-item.cpp
@@ -667,29 +667,24 @@ DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area)
if (!_visible) return;
if (!area.intersects(_bbox)) return;
- // The item used as the clipping path itself has a clipping path.
- // Render this item's clipping path onto a temporary surface, then composite it
- // with the item using the IN operator
- if (_clip) {
- ct.pushAlphaGroup();
- { Inkscape::DrawingContext::Save save(ct);
- ct.setSource(0,0,0,1);
- _clip->clip(ct, area);
- }
- ct.pushAlphaGroup();
- }
-
+ ct.setSource(0,0,0,1);
+ ct.pushGroup();
// rasterize the clipping path
_clipItem(ct, area);
-
if (_clip) {
+ // The item used as the clipping path itself has a clipping path.
+ // Render this item's clipping path onto a temporary surface, then composite it
+ // with the item using the IN operator
+ ct.pushGroup();
+ _clip->clip(ct, area);
ct.popGroupToSource();
ct.setOperator(CAIRO_OPERATOR_IN);
ct.paint();
- ct.popGroupToSource();
- ct.setOperator(CAIRO_OPERATOR_SOURCE);
- ct.paint();
}
+ ct.popGroupToSource();
+ ct.setOperator(CAIRO_OPERATOR_OVER);
+ ct.paint();
+ ct.setSource(0,0,0,0);
}
/**
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp
index 4ca306092..e80f12486 100644
--- a/src/display/drawing-shape.cpp
+++ b/src/display/drawing-shape.cpp
@@ -167,7 +167,7 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne
{ Inkscape::DrawingContext::Save save(ct);
ct.setSource(rgba);
ct.setLineWidth(0.5);
- ct.setTolerance(1.25);
+ ct.setTolerance(0.5);
ct.stroke();
}
} else {
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index 7f63c555a..2a6505c67 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -162,7 +162,7 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
guint32 rgba = _drawing.outlinecolor;
Inkscape::DrawingContext::Save save(ct);
ct.setSource(rgba);
- ct.setTolerance(1.25); // low quality, but good enough for outline mode
+ ct.setTolerance(0.5); // low quality, but good enough for outline mode
for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp
index 77f24caf3..171cc014f 100644
--- a/src/display/drawing.cpp
+++ b/src/display/drawing.cpp
@@ -4,8 +4,9 @@
*//*
* Authors:
* Krzysztof Kosiński <tweenk.pl@gmail.com>
+ * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- * Copyright (C) 2011 Authors
+ * Copyright (C) 2011-2012 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -14,6 +15,12 @@
#include "nr-filter-gaussian.h"
#include "nr-filter-types.h"
+//grayscale colormode:
+#include "nr-filter-colormatrix.h"
+#include "cairo-templates.h"
+#include "drawing-context.h"
+
+
namespace Inkscape {
Drawing::Drawing(SPCanvasArena *arena)
@@ -145,12 +152,37 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl
_pickItemsForCaching();
}
+// hardcoded grayscale color matrix values. could be turned into preference settings in future.
+static const gdouble grayscale_value_matrix[] = {
+ 0.21, 0.72, 0.072, 0, 0,
+ 0.21, 0.72, 0.072, 0, 0,
+ 0.21, 0.72, 0.072, 0, 0,
+ 0 , 0 , 0 , 1, 0
+};
+static Filters::FilterColorMatrix::ColorMatrixMatrix grayscale_colormatrix(
+ std::vector<gdouble> (grayscale_value_matrix, grayscale_value_matrix + sizeof(grayscale_value_matrix) / sizeof(grayscale_value_matrix[0]) )
+);
+
void
Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags)
{
if (_root) {
_root->render(ct, area, flags);
}
+
+ if (colorMode() == COLORMODE_GRAYSCALE) {
+ // apply grayscale filter on top of everything
+ cairo_surface_t *input = ct.rawTarget();
+ cairo_surface_t *out = ink_cairo_surface_create_identical(input);
+ ink_cairo_surface_filter(input, out, grayscale_colormatrix);
+ Geom::Point origin = ct.targetLogicalBounds().min();
+ ct.setSource(out, origin[Geom::X], origin[Geom::Y]);
+ ct.setOperator(CAIRO_OPERATOR_SOURCE);
+ ct.paint();
+ ct.setOperator(CAIRO_OPERATOR_OVER);
+
+ cairo_surface_destroy(out);
+ }
}
DrawingItem *
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index d3385978a..f71bc82ef 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -66,9 +66,9 @@ GType sp_guideline_get_type()
static void sp_guideline_class_init(SPGuideLineClass *c)
{
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
item_class->destroy = sp_guideline_destroy;
item_class->update = sp_guideline_update;
item_class->render = sp_guideline_render;
@@ -191,8 +191,8 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine,
{
SPGuideLine *gl = SP_GUIDELINE(item);
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(item, affine, flags);
}
gl->affine = affine;
diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp
index 33718ed68..fad6215ff 100644
--- a/src/display/nr-filter-colormatrix.cpp
+++ b/src/display/nr-filter-colormatrix.cpp
@@ -32,50 +32,47 @@ FilterPrimitive * FilterColorMatrix::create() {
FilterColorMatrix::~FilterColorMatrix()
{}
-struct ColorMatrixMatrix {
- ColorMatrixMatrix(std::vector<double> const &values) {
- unsigned limit = std::min(static_cast<size_t>(20), values.size());
- for (unsigned i = 0; i < limit; ++i) {
- if (i % 5 == 4) {
- _v[i] = round(values[i]*255*255);
- } else {
- _v[i] = round(values[i]*255);
- }
- }
- for (unsigned i = limit; i < 20; ++i) {
- _v[i] = 0;
+FilterColorMatrix::ColorMatrixMatrix::ColorMatrixMatrix(std::vector<double> const &values) {
+ unsigned limit = std::min(static_cast<size_t>(20), values.size());
+ for (unsigned i = 0; i < limit; ++i) {
+ if (i % 5 == 4) {
+ _v[i] = round(values[i]*255*255);
+ } else {
+ _v[i] = round(values[i]*255);
}
}
+ for (unsigned i = limit; i < 20; ++i) {
+ _v[i] = 0;
+ }
+}
- guint32 operator()(guint32 in) {
- EXTRACT_ARGB32(in, a, r, g, b)
- // we need to un-premultiply alpha values for this type of matrix
- // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel
- if (a != 0) {
- r = unpremul_alpha(r, a);
- g = unpremul_alpha(g, a);
- b = unpremul_alpha(b, a);
- }
-
- gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4];
- gint32 go = r*_v[5] + g*_v[6] + b*_v[7] + a*_v[8] + _v[9];
- gint32 bo = r*_v[10] + g*_v[11] + b*_v[12] + a*_v[13] + _v[14];
- gint32 ao = r*_v[15] + g*_v[16] + b*_v[17] + a*_v[18] + _v[19];
- ro = (pxclamp(ro, 0, 255*255) + 127) / 255;
- go = (pxclamp(go, 0, 255*255) + 127) / 255;
- bo = (pxclamp(bo, 0, 255*255) + 127) / 255;
- ao = (pxclamp(ao, 0, 255*255) + 127) / 255;
+guint32 FilterColorMatrix::ColorMatrixMatrix::operator()(guint32 in) {
+ EXTRACT_ARGB32(in, a, r, g, b)
+ // we need to un-premultiply alpha values for this type of matrix
+ // TODO: unpremul can be ignored if there is an identity mapping on the alpha channel
+ if (a != 0) {
+ r = unpremul_alpha(r, a);
+ g = unpremul_alpha(g, a);
+ b = unpremul_alpha(b, a);
+ }
- ro = premul_alpha(ro, ao);
- go = premul_alpha(go, ao);
- bo = premul_alpha(bo, ao);
+ gint32 ro = r*_v[0] + g*_v[1] + b*_v[2] + a*_v[3] + _v[4];
+ gint32 go = r*_v[5] + g*_v[6] + b*_v[7] + a*_v[8] + _v[9];
+ gint32 bo = r*_v[10] + g*_v[11] + b*_v[12] + a*_v[13] + _v[14];
+ gint32 ao = r*_v[15] + g*_v[16] + b*_v[17] + a*_v[18] + _v[19];
+ ro = (pxclamp(ro, 0, 255*255) + 127) / 255;
+ go = (pxclamp(go, 0, 255*255) + 127) / 255;
+ bo = (pxclamp(bo, 0, 255*255) + 127) / 255;
+ ao = (pxclamp(ao, 0, 255*255) + 127) / 255;
+
+ ro = premul_alpha(ro, ao);
+ go = premul_alpha(go, ao);
+ bo = premul_alpha(bo, ao);
+
+ ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
+ return pxout;
+}
- ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
- return pxout;
- }
-private:
- gint32 _v[20];
-};
struct ColorMatrixSaturate {
ColorMatrixSaturate(double v_in) {
@@ -163,7 +160,7 @@ void FilterColorMatrix::render_cairo(FilterSlot &slot)
switch (type) {
case COLORMATRIX_MATRIX:
- ink_cairo_surface_filter(input, out, ColorMatrixMatrix(values));
+ ink_cairo_surface_filter(input, out, FilterColorMatrix::ColorMatrixMatrix(values));
break;
case COLORMATRIX_SATURATE:
ink_cairo_surface_filter(input, out, ColorMatrixSaturate(value));
diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h
index 5f21a4210..c7e5e91d9 100644
--- a/src/display/nr-filter-colormatrix.h
+++ b/src/display/nr-filter-colormatrix.h
@@ -42,6 +42,15 @@ public:
virtual void set_type(FilterColorMatrixType type);
virtual void set_value(gdouble value);
virtual void set_values(std::vector<gdouble> const &values);
+
+public:
+ struct ColorMatrixMatrix {
+ ColorMatrixMatrix(std::vector<double> const &values);
+ guint32 operator()(guint32 in);
+ private:
+ gint32 _v[20];
+ };
+
private:
std::vector<gdouble> values;
gdouble value;
diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp
index b25ecdf2c..040424cb3 100644
--- a/src/display/nr-filter-composite.cpp
+++ b/src/display/nr-filter-composite.cpp
@@ -48,10 +48,11 @@ struct ComposeArithmetic {
gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4;
gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4;
- ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255);
- ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255);
- go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255);
- bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255);
+ ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel
+ ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255);
+ go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255);
+ bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255);
+ ao = (ao + (255*255/2)) / (255*255);
ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
return pxout;
diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp
index 449255133..56a27ecd7 100644
--- a/src/display/nr-filter-flood.cpp
+++ b/src/display/nr-filter-flood.cpp
@@ -55,11 +55,34 @@ void FilterFlood::render_cairo(FilterSlot &slot)
#endif
cairo_surface_t *out = ink_cairo_surface_create_same_size(input, CAIRO_CONTENT_COLOR_ALPHA);
- cairo_t *ct = cairo_create(out);
- cairo_set_source_rgba(ct, r, g, b, a);
- cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE);
- cairo_paint(ct);
- cairo_destroy(ct);
+
+ // Get filter primitive area in user units
+ Geom::Rect fp = filter_primitive_area( slot.get_units() );
+
+ // Convert to Cairo units
+ Geom::Rect fp_cairo = fp * slot.get_units().get_matrix_user2pb();
+
+ // Get area in slot (tile to fill)
+ Geom::Rect sa = slot.get_slot_area();
+
+ // Get overlap
+ Geom::OptRect optoverlap = intersect( fp_cairo, sa );
+ if( optoverlap ) {
+
+ Geom::Rect overlap = *optoverlap;
+
+ double dx = fp_cairo.min()[Geom::X] - sa.min()[Geom::X];
+ double dy = fp_cairo.min()[Geom::Y] - sa.min()[Geom::Y];
+ if( dx < 0.0 ) dx = 0.0;
+ if( dy < 0.0 ) dy = 0.0;
+
+ cairo_t *ct = cairo_create(out);
+ cairo_set_source_rgba(ct, r, g, b, a);
+ cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle(ct, dx, dy, overlap.width(), overlap.height() );
+ cairo_fill(ct);
+ cairo_destroy(ct);
+ }
slot.set(_output, out);
cairo_surface_destroy(out);
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp
index 390021712..6ef321992 100644
--- a/src/display/nr-filter-gaussian.cpp
+++ b/src/display/nr-filter-gaussian.cpp
@@ -102,15 +102,16 @@ static inline Tt clip_round_cast(Ts const v) {
Ts const minval = std::numeric_limits<Tt>::min();
Ts const maxval = std::numeric_limits<Tt>::max();
Tt const minval_rounded = std::numeric_limits<Tt>::min();
- Ts const maxval_rounded = std::numeric_limits<Tt>::max();
+ Tt const maxval_rounded = std::numeric_limits<Tt>::max();
if ( v < minval ) return minval_rounded;
if ( v > maxval ) return maxval_rounded;
return round_cast<Tt>(v);
}
template<typename Tt, typename Ts>
-static inline Tt clip_round_cast_varmax(Ts const v, Ts const maxval, Tt const maxval_rounded) {
+static inline Tt clip_round_cast_varmax(Ts const v, Tt const maxval_rounded) {
Ts const minval = std::numeric_limits<Tt>::min();
+ Tt const maxval = maxval_rounded;
Tt const minval_rounded = std::numeric_limits<Tt>::min();
if ( v < minval ) return minval_rounded;
if ( v > maxval ) return maxval_rounded;
@@ -339,7 +340,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2,
dstimg -= dstr1;
if ( PREMULTIPLIED_ALPHA ) {
dstimg[alpha_PC] = clip_round_cast<PT>(v[0][alpha_PC]);
- PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax<PT>(v[0][c], v[0][alpha_PC], dstimg[alpha_PC]);
+ PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax<PT>(v[0][c], dstimg[alpha_PC]);
} else {
for(unsigned int c=0; c<PC; c++) dstimg[c] = clip_round_cast<PT>(v[0][c]);
}
@@ -354,7 +355,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2,
dstimg -= dstr1;
if ( PREMULTIPLIED_ALPHA ) {
dstimg[alpha_PC] = clip_round_cast<PT>(v[0][alpha_PC]);
- PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax<PT>(v[0][c], v[0][alpha_PC], dstimg[alpha_PC]);
+ PREMUL_ALPHA_LOOP dstimg[c] = clip_round_cast_varmax<PT>(v[0][c], dstimg[alpha_PC]);
} else {
for(unsigned int c=0; c<PC; c++) dstimg[c] = clip_round_cast<PT>(v[0][c]);
}
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index a9a5ec3e0..bc18cbcc6 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -20,6 +20,7 @@
#include "display/nr-filter-image.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
+#include "enums.h"
#include <glibmm/fileutils.h>
namespace Inkscape {
@@ -50,22 +51,31 @@ void FilterImage::render_cairo(FilterSlot &slot)
//cairo_surface_t *input = slot.getcairo(_input);
+ // Viewport is filter primitive area (in user coordinates).
+ // Note: viewport calculation in non-trivial. Do not rely
+ // on get_matrix_primitiveunits2pb().
+ Geom::Rect vp = filter_primitive_area( slot.get_units() );
+ double feImageX = vp.min()[Geom::X];
+ double feImageY = vp.min()[Geom::Y];
+ double feImageWidth = vp.width();
+ double feImageHeight = vp.height();
+
+ // feImage is suppose to use the same parameters as a normal SVG image.
+ // If a width or height is set to zero, the image is not suppose to be displayed.
+ // This does not seem to be what Firefox or Opera does, nor does the W3C displacement
+ // filter test expect this behavior. If the width and/or height are zero, we use
+ // the width and height of the object bounding box.
Geom::Affine m = slot.get_units().get_matrix_user2filterunits().inverse();
Geom::Point bbox_00 = Geom::Point(0,0) * m;
Geom::Point bbox_w0 = Geom::Point(1,0) * m;
Geom::Point bbox_0h = Geom::Point(0,1) * m;
double bbox_width = Geom::distance(bbox_00, bbox_w0);
double bbox_height = Geom::distance(bbox_00, bbox_0h);
-
- // feImage is suppose to use the same parameters as a normal SVG image.
- // If a width or height is set to zero, the image is not suppose to be displayed.
- // This does not seem to be what Firefox or Opera does, nor does the W3C displacement
- // filter test expect this behavior. If the width and/or height are zero, we use
- // the width and height of the object bounding box.
if( feImageWidth == 0 ) feImageWidth = bbox_width;
if( feImageHeight == 0 ) feImageHeight = bbox_height;
+ // Internal image, like <use>
if (from_element) {
if (!SVGElem) return;
@@ -87,18 +97,20 @@ void FilterImage::render_cairo(FilterSlot &slot)
drawing.setRoot(ai);
Geom::Rect area = *optarea;
- Geom::Affine pu2pb = slot.get_units().get_matrix_primitiveunits2pb();
+ Geom::Affine user2pb = slot.get_units().get_matrix_user2pb();
+ /* FIXME: These variables are currently unused. Why were they calculated?
double scaleX = feImageWidth / area.width();
double scaleY = feImageHeight / area.height();
+ */
Geom::Rect sa = slot.get_slot_area();
cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
sa.width(), sa.height());
Inkscape::DrawingContext ct(out, sa.min());
- ct.transform(pu2pb); // we are now in primitive units
+ ct.transform(user2pb); // we are now in primitive units
ct.translate(feImageX, feImageY);
- ct.scale(scaleX, scaleY);
+// ct.scale(scaleX, scaleY); No scaling should be done
Geom::IntRect render_rect = area.roundOutwards();
ct.translate(render_rect.min());
@@ -113,6 +125,7 @@ void FilterImage::render_cairo(FilterSlot &slot)
return;
}
+ // External image, like <image>
if (!image && !broken_ref) {
broken_ref = true;
try {
@@ -158,9 +171,9 @@ void FilterImage::render_cairo(FilterSlot &slot)
}
// Native size of image
- //width = image->get_width();
- //height = image->get_height();
- //rowstride = image->get_rowstride();
+ // width = image->get_width();
+ // height = image->get_height();
+ // rowstride = image->get_rowstride();
convert_pixbuf_normal_to_argb32(image->gobj());
@@ -174,11 +187,94 @@ void FilterImage::render_cairo(FilterSlot &slot)
cairo_t *ct = cairo_create(out);
cairo_translate(ct, -sa.min()[Geom::X], -sa.min()[Geom::Y]);
- // now ct is in pb coordinates
- ink_cairo_transform(ct, slot.get_units().get_matrix_primitiveunits2pb());
+
+ // now ct is in pb coordinates, note the feWidth etc. are in user units
+ ink_cairo_transform(ct, slot.get_units().get_matrix_user2pb());
+
// now ct is in the coordinates of feImageX etc.
- // TODO: add preserveAspectRatio support here
+ // Now that we have the viewport, we must map image inside.
+ // Partially copied from sp-image.cpp.
+
+ // Do nothing if preserveAspectRatio is "none".
+ if( aspect_align != SP_ASPECT_NONE ) {
+
+ // Check aspect ratio of image vs. viewport
+ double feAspect = feImageHeight/feImageWidth;
+ double aspect = (double)image->get_height()/(double)image->get_width();
+ bool ratio = (feAspect < aspect);
+
+ double ax, ay; // Align side
+ switch( aspect_align ) {
+ case SP_ASPECT_XMIN_YMIN:
+ ax = 0.0;
+ ay = 0.0;
+ break;
+ case SP_ASPECT_XMID_YMIN:
+ ax = 0.5;
+ ay = 0.0;
+ break;
+ case SP_ASPECT_XMAX_YMIN:
+ ax = 1.0;
+ ay = 0.0;
+ break;
+ case SP_ASPECT_XMIN_YMID:
+ ax = 0.0;
+ ay = 0.5;
+ break;
+ case SP_ASPECT_XMID_YMID:
+ ax = 0.5;
+ ay = 0.5;
+ break;
+ case SP_ASPECT_XMAX_YMID:
+ ax = 1.0;
+ ay = 0.5;
+ break;
+ case SP_ASPECT_XMIN_YMAX:
+ ax = 0.0;
+ ay = 1.0;
+ break;
+ case SP_ASPECT_XMID_YMAX:
+ ax = 0.5;
+ ay = 1.0;
+ break;
+ case SP_ASPECT_XMAX_YMAX:
+ ax = 1.0;
+ ay = 1.0;
+ break;
+ default:
+ ax = 0.0;
+ ay = 0.0;
+ break;
+ }
+
+ if( aspect_clip == SP_ASPECT_SLICE ) {
+ // image clipped by viewbox
+
+ if( ratio ) {
+ // clip top/bottom
+ feImageY -= ay * (feImageWidth * aspect - feImageHeight);
+ feImageHeight = feImageWidth * aspect;
+ } else {
+ // clip sides
+ feImageX -= ax * (feImageHeight / aspect - feImageWidth);
+ feImageWidth = feImageHeight / aspect;
+ }
+
+ } else {
+ // image fits into viewbox
+
+ if( ratio ) {
+ // fit to height
+ feImageX += ax * (feImageWidth - feImageHeight / aspect );
+ feImageWidth = feImageHeight / aspect;
+ } else {
+ // fit to width
+ feImageY += ay * (feImageHeight - feImageWidth * aspect);
+ feImageHeight = feImageWidth * aspect;
+ }
+ }
+ }
double scaleX = feImageWidth / image->get_width();
double scaleY = feImageHeight / image->get_height();
@@ -204,6 +300,7 @@ double FilterImage::complexity(Geom::Affine const &)
}
void FilterImage::set_href(const gchar *href){
+
if (feImageHref) g_free (feImageHref);
feImageHref = (href) ? g_strdup (href) : NULL;
@@ -218,13 +315,6 @@ void FilterImage::set_document(SPDocument *doc){
document = doc;
}
-void FilterImage::set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height) {
- feImageX=x.computed;
- feImageY=y.computed;
- feImageWidth=width.computed;
- feImageHeight=height.computed;
-}
-
void FilterImage::set_align( unsigned int align ) {
aspect_align = align;
}
diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h
index c0b9d6e81..05b7d65a8 100644
--- a/src/display/nr-filter-image.h
+++ b/src/display/nr-filter-image.h
@@ -35,7 +35,6 @@ public:
void set_document( SPDocument *document );
void set_href(const gchar *href);
- void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height);
void set_align( unsigned int align );
void set_clip( unsigned int clip );
bool from_element;
diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp
index f1fbd7d33..759d7d6d1 100644
--- a/src/display/nr-filter-merge.cpp
+++ b/src/display/nr-filter-merge.cpp
@@ -31,7 +31,7 @@ FilterMerge::~FilterMerge()
void FilterMerge::render_cairo(FilterSlot &slot)
{
- if (_input_image.size() == 0) return;
+ if (_input_image.empty()) return;
// output is RGBA if at least one input is RGBA
bool rgba32 = false;
diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp
index c6bd8a74e..ce562668a 100644
--- a/src/display/nr-filter-primitive.cpp
+++ b/src/display/nr-filter-primitive.cpp
@@ -15,6 +15,12 @@
#include "display/nr-filter-types.h"
#include "svg/svg-length.h"
+#include "inkscape.h"
+#include "desktop.h"
+#include "desktop-handles.h"
+#include "document.h"
+#include "sp-root.h"
+
namespace Inkscape {
namespace Filters {
@@ -103,6 +109,18 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units)
Geom::OptRect bb = units.get_item_bbox();
Geom::OptRect fa = units.get_filter_area();
+ // This is definitely a hack... but what else to do?
+ // Current viewport might not be document viewport... but how to find?
+ SPDocument* document = inkscape_active_document();
+ SPRoot* root = document->getRoot();
+ Geom::Rect viewport;
+ if( root->viewBox_set ) {
+ viewport = root->viewBox;
+ } else {
+ // Pick some random values
+ viewport = Geom::Rect::from_xywh(0,0,480,360);
+ }
+
/* Update computed values for ex, em, %. For %, assumes primitive unit is objectBoundingBox. */
/* TODO: fetch somehow the object ex and em lengths; 12, 6 are just dummy values. */
double len_x = bb->width();
@@ -144,11 +162,11 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units)
if( _subregion_y._set && _subregion_y.unit != SVGLength::PERCENT ) y = _subregion_y.computed;
if( _subregion_width._set && _subregion_width.unit != SVGLength::PERCENT ) width = _subregion_width.computed;
if( _subregion_height._set && _subregion_height.unit != SVGLength::PERCENT ) height = _subregion_height.computed;
- // TODO: add percent of viewport TEMPORARY HACK FOR TESTING...
- if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = _subregion_x.value * 480; // viewport_x
- if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = _subregion_y.value * 360;
- if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.value * 480;
- if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.value * 360;
+ // Percent of viewport
+ if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = _subregion_x.value * viewport.width();
+ if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = _subregion_y.value * viewport.height();
+ if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.value * viewport.width();
+ if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.value * viewport.height();
}
Geom::Point minp, maxp;
diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp
index 0c455a818..86ab8141e 100644
--- a/src/display/nr-filter-skeleton.cpp
+++ b/src/display/nr-filter-skeleton.cpp
@@ -42,7 +42,8 @@ FilterSkeleton::~FilterSkeleton()
void FilterSkeleton::render_cairo(FilterSlot &slot) {
cairo_surface_t *in = slot.getcairo(_input);
cairo_surface_t *out = ink_cairo_surface_create_identical(in);
- cairo_t *ct = cairo_create(out);
+
+// cairo_t *ct = cairo_create(out);
// cairo_set_source_surface(ct, in, offset[X], offset[Y]);
// cairo_paint(ct);
diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp
index 86102f9e8..ba2340074 100644
--- a/src/display/nr-style.cpp
+++ b/src/display/nr-style.cpp
@@ -60,7 +60,9 @@ NRStyle::~NRStyle()
{
if (fill_pattern) cairo_pattern_destroy(fill_pattern);
if (stroke_pattern) cairo_pattern_destroy(stroke_pattern);
- if (dash) delete dash;
+ if (dash){
+ delete [] dash;
+ }
}
void NRStyle::set(SPStyle *style)
@@ -126,7 +128,9 @@ void NRStyle::set(SPStyle *style)
}
miter_limit = style->stroke_miterlimit.value;
- if (dash) delete [] dash;
+ if (dash){
+ delete [] dash;
+ }
n_dash = style->stroke_dash.n_dash;
if (n_dash != 0) {
diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp
index e095fb9a9..d0c6d2d56 100644
--- a/src/display/nr-svgfonts.cpp
+++ b/src/display/nr-svgfonts.cpp
@@ -43,10 +43,9 @@
static cairo_user_data_key_t key;
static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font,
- cairo_t */*cairo*/, cairo_font_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_t * /*cairo*/, cairo_font_extents_t *metrics){
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_init(scaled_font, metrics);
}
@@ -58,9 +57,8 @@ static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font
cairo_text_cluster_t **clusters,
int *num_clusters,
cairo_text_cluster_flags_t *flags){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags);
}
@@ -68,9 +66,8 @@ static cairo_status_t font_render_glyph_cb (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics);
}
@@ -116,15 +113,15 @@ unsigned int size_of_substring(const char* substring, gchar* str){
}
//TODO: in these macros, verify what happens when using unicode strings.
-#define Match_VKerning_Rule (((SPVkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPVkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPVkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPVkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_VKerning_Rule ((SP_VKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_VKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_VKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_VKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
-#define Match_HKerning_Rule (((SPHkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPHkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPHkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPHkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_HKerning_Rule ((SP_HKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_HKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_HKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_HKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
cairo_status_t
SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
@@ -187,14 +184,14 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){
//apply glyph kerning if appropriate
if (SP_IS_HKERN(node) && is_horizontal_text && Match_HKerning_Rule ){
- x -= (((SPHkern*)node)->k / 1000.0);//TODO: use here the height of the font
+ x -= ((SP_HKERN(node))->k / 1000.0);//TODO: use here the height of the font
}
if (SP_IS_VKERN(node) && !is_horizontal_text && Match_VKerning_Rule ){
- y -= (((SPVkern*)node)->k / 1000.0);//TODO: use here the "height" of the font
+ y -= ((SP_VKERN(node))->k / 1000.0);//TODO: use here the "height" of the font
}
}
- previous_unicode = (char*) this->glyphs[i]->unicode.c_str();//used for kerning checking
- previous_glyph_name = (char*) this->glyphs[i]->glyph_name.c_str();//used for kerning checking
+ previous_unicode = const_cast<char*>(this->glyphs[i]->unicode.c_str());//used for kerning checking
+ previous_glyph_name = const_cast<char*>(this->glyphs[i]->glyph_name.c_str());//used for kerning checking
(*glyphs)[count].index = i;
(*glyphs)[count].x = x;
(*glyphs)[count++].y = y;
@@ -251,7 +248,7 @@ Geom::PathVector
SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){
double units_per_em = 1000;
SPObject* obj;
- for (obj = ((SPObject*) spfont)->children; obj; obj=obj->next){
+ for (obj = (SP_OBJECT(spfont))->children; obj; obj=obj->next){
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);
@@ -282,16 +279,16 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
SPObject* node;
if (glyph == this->glyphs.size()){
if (!this->missingglyph) return CAIRO_STATUS_SUCCESS;
- node = (SPObject*) this->missingglyph;
+ node = SP_OBJECT(this->missingglyph);
} else {
- node = (SPObject*) this->glyphs[glyph];
+ node = SP_OBJECT(this->glyphs[glyph]);
}
if (!SP_IS_GLYPH(node) && !SP_IS_MISSING_GLYPH(node)) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
- SPFont* spfont = (SPFont*) node->parent;
+ SPFont* spfont = SP_FONT(node->parent);
if (!spfont) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
@@ -300,12 +297,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
// or using the d attribute of a glyph node.
// pathv stores the path description from the d attribute:
Geom::PathVector pathv;
- if (SP_IS_GLYPH(node) && ((SPGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPGlyph*)node)->d);
+ if (SP_IS_GLYPH(node) && (SP_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
- } else if (SP_IS_MISSING_GLYPH(node) && ((SPMissingGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPMissingGlyph*)node)->d);
+ } else if (SP_IS_MISSING_GLYPH(node) && (SP_MISSING_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_MISSING_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -314,7 +311,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
//render the SVG described on this glyph's child nodes.
for(node = node->children; node; node=node->next){
if (SP_IS_PATH(node)){
- pathv = ((SPShape*)node)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(node))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -324,12 +321,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
if (SP_IS_USE(node)){
SPItem* item = SP_USE(node)->ref->getObject();
if (SP_IS_PATH(item)){
- pathv = ((SPShape*)item)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(item))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
- glyph_modified_connection = ((SPObject*) item)->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
+ glyph_modified_connection = (SP_OBJECT(item))->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
}
}
}
@@ -342,10 +339,10 @@ SvgFont::get_font_face(){
if (!this->userfont) {
for(SPObject* node = this->font->children;node;node=node->next){
if (SP_IS_GLYPH(node)){
- this->glyphs.push_back((SPGlyph*)node);
+ this->glyphs.push_back(SP_GLYPH(node));
}
if (SP_IS_MISSING_GLYPH(node)){
- this->missingglyph=(SPMissingGlyph*)node;
+ this->missingglyph=SP_MISSING_GLYPH(node);
}
}
this->userfont = new UserFont(this);
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index e21bdff15..45dc38a37 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -63,10 +63,10 @@ sp_ctrl_get_type (void)
static void
sp_ctrl_class_init (SPCtrlClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
GObjectClass *g_object_class = (GObjectClass *) klass;
- parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent (klass));
g_object_class->set_property = sp_ctrl_set_property;
g_object_class->get_property = sp_ctrl_get_property;
@@ -287,8 +287,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
ctrl = SP_CTRL (item);
- if (((SPCanvasItemClass *) parent_class)->update)
- (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update)
+ (* (SP_CANVAS_ITEM_CLASS(parent_class))->update) (item, affine, flags);
sp_canvas_item_reset_bounds (item);
diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp
index b0c997a92..c350e4614 100644
--- a/src/display/sodipodi-ctrlrect.cpp
+++ b/src/display/sodipodi-ctrlrect.cpp
@@ -61,9 +61,9 @@ GType sp_ctrlrect_get_type()
static void sp_ctrlrect_class_init(SPCtrlRectClass *c)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
item_class->destroy = sp_ctrlrect_destroy;
item_class->update = sp_ctrlrect_update;
@@ -119,8 +119,6 @@ void CtrlRect::render(SPCanvasBuf *buf)
using Geom::X;
using Geom::Y;
- static double const dashes[2] = {4.0, 4.0};
-
if (!_area) {
return;
}
@@ -129,6 +127,7 @@ void CtrlRect::render(SPCanvasBuf *buf)
area[X].max() + _shadow_size, area[Y].max() + _shadow_size);
if ( area_w_shadow.intersects(buf->rect) )
{
+ static double const dashes[2] = {4.0, 4.0};
cairo_save(buf->ct);
cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1);
@@ -161,8 +160,8 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags)
using Geom::X;
using Geom::Y;
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(this, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(this, affine, flags);
}
sp_canvas_item_reset_bounds(this);
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 6d4d01e33..536c54609 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1081,7 +1081,7 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig
Geom::OptRect bounds;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *i = (SPCanvasItem *)list->data;
+ SPCanvasItem *i = SP_CANVAS_ITEM(list->data);
sp_canvas_item_invoke_update (i, affine, flags);
@@ -1118,7 +1118,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac
double dist = 0.0;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) {
SPCanvasItem *point_item = NULL; // cater for incomplete item implementations
@@ -1152,7 +1152,7 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf)
SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if ((child->x1 < buf->rect.right()) &&
(child->y1 < buf->rect.bottom()) &&
@@ -1171,7 +1171,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_
SPCanvasGroup *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) {
SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area);
@@ -1649,7 +1649,6 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
{
int button_down = 0;
- double x, y;
if (!canvas->root) // canvas may have already be destroyed by closing desktop durring interrupted display!
return FALSE;
@@ -1709,6 +1708,7 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
// LeaveNotify means that there is no current item, so we don't look for one
if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) {
// these fields don't have the same offsets in both types of events
+ double x, y;
if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
x = canvas->pick_event.crossing.x;
diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp
index d07e9385b..026cc7589 100644
--- a/src/display/sp-ctrlpoint.cpp
+++ b/src/display/sp-ctrlpoint.cpp
@@ -52,9 +52,9 @@ sp_ctrlpoint_get_type (void)
static void sp_ctrlpoint_class_init(SPCtrlPointClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlpoint_destroy;
item_class->update = sp_ctrlpoint_update;
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index ae15d620a..b6a0da109 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -61,9 +61,9 @@ sp_ctrlquadr_get_type (void)
static void
sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlquadr_destroy;
item_class->update = sp_ctrlquadr_update;
diff --git a/src/document-subset.cpp b/src/document-subset.cpp
index 365be64ef..7fad73d9e 100644
--- a/src/document-subset.cpp
+++ b/src/document-subset.cpp
@@ -99,7 +99,7 @@ struct DocumentSubset::Relations : public GC::Managed<GC::ATOMIC>,
Siblings new_children;
bool found_one=false;
for ( Siblings::iterator iter=children.begin()
- ; iter != children.end() ; iter++ )
+ ; iter != children.end() ; ++iter )
{
if (obj->isAncestorOf(*iter)) {
if (!found_one) {
diff --git a/src/document.cpp b/src/document.cpp
index e28356969..172037518 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -7,10 +7,12 @@
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
+ * Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 2004-2005 MenTaLguY
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
+ * Copyright (C) 2012 Tavmjong Bah
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -59,6 +61,7 @@
#include "sp-item-group.h"
#include "sp-namedview.h"
#include "sp-object-repr.h"
+#include "sp-symbol.h"
#include "transf_mat_3x4.h"
#include "unit-constants.h"
#include "xml/repr.h"
@@ -1107,7 +1110,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
/**
Returns true if an item is among the descendants of group (recursively).
*/
-bool item_is_in_group(SPItem *item, SPGroup *group)
+static bool item_is_in_group(SPItem *item, SPGroup *group)
{
bool inGroup = false;
for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) {
@@ -1158,7 +1161,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s
upwards in z-order and returns what it has found so far (i.e. the found item is
guaranteed to be lower than upto).
*/
-SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
+static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
{
SPItem *seen = NULL;
SPItem *newseen = NULL;
@@ -1203,7 +1206,7 @@ SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const
Returns the topmost non-layer group from the descendants of group which is at point
p, or NULL if none. Recurses into layers but not into groups.
*/
-SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
+static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
{
SPItem *seen = NULL;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1374,7 +1377,7 @@ sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data
return TRUE;
}
-unsigned int count_objects_recursive(SPObject *obj, unsigned int count)
+static unsigned int count_objects_recursive(SPObject *obj, unsigned int count)
{
count++; // obj itself
@@ -1385,12 +1388,12 @@ unsigned int count_objects_recursive(SPObject *obj, unsigned int count)
return count;
}
-unsigned int objects_in_document(SPDocument *document)
+static unsigned int objects_in_document(SPDocument *document)
{
return count_objects_recursive(document->getRoot(), 0);
}
-void vacuum_document_recursive(SPObject *obj)
+static void vacuum_document_recursive(SPObject *obj)
{
if (SP_IS_DEFS(obj)) {
for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) {
@@ -1454,9 +1457,10 @@ void SPDocument::importDefs(SPDocument *source)
for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) {
- // Prevent duplicates of solid swatches by checking if equivalent swatch already exists
gboolean duplicate = false;
SPObject *src = source->getObjectByRepr(def);
+
+ // Prevent duplicates of solid swatches by checking if equivalent swatch already exists
if (src && SP_IS_GRADIENT(src)) {
SPGradient *gr = SP_GRADIENT(src);
if (gr->isSolid() || gr->getVector()->isSolid()) {
@@ -1473,6 +1477,35 @@ void SPDocument::importDefs(SPDocument *source)
}
}
+ // Prevent duplication of symbols... could be more clever.
+ // The tag "_inkscape_duplicate" is added to "id" by ClipboardManagerImpl::copySymbol().
+ // We assume that symbols are in defs section (not required by SVG spec).
+ if (src && SP_IS_SYMBOL(src)) {
+
+ Glib::ustring id = src->getRepr()->attribute("id");
+ size_t pos = id.find( "_inkscape_duplicate" );
+ if( pos != Glib::ustring::npos ) {
+
+ // This is our symbol, now get rid of tag
+ id.erase( pos );
+
+ // Check that it really is a duplicate
+ for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
+ if( trg && SP_IS_SYMBOL(trg) && src != trg ) {
+ std::string id2 = trg->getRepr()->attribute("id");
+
+ if( !id.compare( id2 ) ) {
+ duplicate = true;
+ break;
+ }
+ }
+ }
+ if ( !duplicate ) {
+ src->getRepr()->setAttribute("id", id.c_str() );
+ }
+ }
+ }
+
if (!duplicate) {
Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc());
target_defs->appendChild(dup);
diff --git a/src/dom/prop-css.cpp b/src/dom/prop-css.cpp
index a0d66d939..9922b4935 100644
--- a/src/dom/prop-css.cpp
+++ b/src/dom/prop-css.cpp
@@ -1137,7 +1137,7 @@ NULL
-bool printTable()
+static bool printTable()
{
for (CssProp *prop=cssProps; prop->name ; prop++)
{
diff --git a/src/dom/prop-css2.cpp b/src/dom/prop-css2.cpp
index 33548fbb9..9fe998552 100644
--- a/src/dom/prop-css2.cpp
+++ b/src/dom/prop-css2.cpp
@@ -1279,7 +1279,7 @@ bool parseProperty(char *name, char *value)
}
-bool printTable()
+static bool printTable()
{
for (CssProp *prop=cssProps; prop->name ; prop++)
{
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index cf28dfec5..87f43af81 100644
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
@@ -119,7 +119,7 @@ SVGTableEntry interfaceTable[] =
{ "SVGUnitTypes", SVG_UNIT_TYPES },
{ "SVGURIReference", SVG_URI_REFERENCE },
{ "SVGViewSpec", SVG_VIEW_SPEC },
- { "SVGZoomAndPan", SVG_ZOOM_AND_PAN }
+ { "SVGZoomAndPan", static_cast<int>(SVG_ZOOM_AND_PAN)}
};
diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp
index 081bcbbc4..9d9d5685c 100644
--- a/src/dom/util/ziptool.cpp
+++ b/src/dom/util/ziptool.cpp
@@ -126,7 +126,7 @@ static unsigned long crc_table[256];
/**
* make the table for a fast CRC.
*/
-void makeCrcTable()
+static void makeCrcTable()
{
if (crc_table_ready)
return;
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index e33c94bda..5996d600b 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -44,6 +44,7 @@
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
+#include "draw-context.h"
#include <gdk/gdkkeysyms.h>
@@ -103,9 +104,9 @@ static void sp_draw_context_class_init(SPDrawContextClass *klass)
SPEventContextClass *ec_class;
object_class = (GObjectClass *)klass;
- ec_class = (SPEventContextClass *) klass;
+ ec_class = SP_EVENT_CONTEXT_CLASS(klass);
- draw_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+ draw_parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass));
object_class->dispose = sp_draw_context_dispose;
@@ -174,8 +175,8 @@ static void sp_draw_context_setup(SPEventContext *ec)
SPDrawContext *dc = SP_DRAW_CONTEXT(ec);
SPDesktop *dt = ec->desktop;
- if (((SPEventContextClass *) draw_parent_class)->setup) {
- ((SPEventContextClass *) draw_parent_class)->setup(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(draw_parent_class))->setup) {
+ (SP_EVENT_CONTEXT_CLASS(draw_parent_class))->setup(ec);
}
dc->selection = sp_desktop_selection(dt);
@@ -260,8 +261,8 @@ gint sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
}
if (!ret) {
- if (((SPEventContextClass *) draw_parent_class)->root_handler) {
- ret = ((SPEventContextClass *) draw_parent_class)->root_handler(ec, event);
+ if ((SP_EVENT_CONTEXT_CLASS(draw_parent_class))->root_handler) {
+ ret = (SP_EVENT_CONTEXT_CLASS(draw_parent_class))->root_handler(ec, event);
}
}
@@ -304,7 +305,7 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points
lpe->getRepr()->setAttribute("interpolator_beta", "0.2");
}
-void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve)
+static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve)
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -699,7 +700,7 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p)
}
for (GSList *l = dc->white_anchors; l != NULL; l = l->next) {
- SPDrawAnchor *na = sp_draw_anchor_test((SPDrawAnchor *) l->data, p, !active);
+ SPDrawAnchor *na = sp_draw_anchor_test(static_cast<SPDrawAnchor*>(l->data), p, !active);
if ( !active && na ) {
active = na;
}
@@ -719,7 +720,7 @@ static void spdc_reset_white(SPDrawContext *dc)
dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
}
while (dc->white_anchors) {
- sp_draw_anchor_destroy((SPDrawAnchor *) dc->white_anchors->data);
+ sp_draw_anchor_destroy(static_cast<SPDrawAnchor*>(dc->white_anchors->data));
dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);
}
}
@@ -766,7 +767,7 @@ static void spdc_free_colors(SPDrawContext *dc)
dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
}
while (dc->white_anchors) {
- sp_draw_anchor_destroy((SPDrawAnchor *) dc->white_anchors->data);
+ sp_draw_anchor_destroy(static_cast<SPDrawAnchor *>(dc->white_anchors->data));
dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);
}
}
diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp
index 6ac00887b..8b293a9d9 100644
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
@@ -32,6 +32,7 @@
#include "desktop-style.h"
#include "preferences.h"
#include "sp-namedview.h"
+#include "sp-cursor.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
@@ -39,6 +40,8 @@
#include "document-undo.h"
#include "pixmaps/cursor-dropper.xpm"
+#include "pixmaps/cursor-dropper-f.xpm"
+#include "pixmaps/cursor-dropper-s.xpm"
#include "dropper-context.h"
#include "message-context.h"
@@ -57,6 +60,9 @@ static gint sp_dropper_context_root_handler(SPEventContext *ec, GdkEvent * event
static SPEventContextClass *parent_class;
+static GdkCursor *cursor_dropper_fill = NULL;
+static GdkCursor *cursor_dropper_stroke = NULL;
+
GType sp_dropper_context_get_type()
{
static GType type = 0;
@@ -90,9 +96,13 @@ static void sp_dropper_context_class_init(SPDropperContextClass *klass)
static void sp_dropper_context_init(SPDropperContext *dc)
{
SPEventContext *event_context = SP_EVENT_CONTEXT(dc);
- event_context->cursor_shape = cursor_dropper_xpm;
+ event_context->cursor_shape = cursor_dropper_f_xpm;
event_context->hot_x = 7;
event_context->hot_y = 7;
+
+ cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7);
+ cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7);
+
}
static void sp_dropper_context_setup(SPEventContext *ec)
@@ -143,13 +153,34 @@ static void sp_dropper_context_finish(SPEventContext *ec)
sp_canvas_item_destroy(dc->area);
dc->area = NULL;
}
+
+ 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;
+ }
+
+ //Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ //prefs->setBool("/tools/dropper/onetimepick", false);
+
}
/**
* Returns the current dropper context icc-color.
*/
-SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/)
+static SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/)
{
//TODO: implement-me!
@@ -205,6 +236,13 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
} else if (!event_context->space_panning) {
// otherwise, constantly calculate color no matter is any button pressed or not
+ // If one time pick with stroke set the pixmap
+ if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) {
+ //TODO Only set when not set already
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ gdk_window_set_cursor(window, cursor_dropper_stroke);
+ }
+
double rw = 0.0;
double R(0), G(0), B(0), A(0);
@@ -310,14 +348,24 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
double alpha_to_set = setalpha? dc->alpha : 1.0;
+ bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held
+ if (prefs->getBool("/tools/dropper/onetimepick", false)) {
+ // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key)
+ fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false;
+ }
+
// do the actual color setting
sp_desktop_set_color(desktop,
(event->button.state & GDK_MOD1_MASK)?
ColorRGBA(1 - dc->R, 1 - dc->G, 1 - dc->B, alpha_to_set) : ColorRGBA(dc->R, dc->G, dc->B, alpha_to_set),
- false, !(event->button.state & GDK_SHIFT_MASK));
+ false, fill);
// REJON: set aux. toolbar input to hex color!
+ if (event->button.state & GDK_SHIFT_MASK) {
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ gdk_window_set_cursor(window, cursor_dropper_stroke);
+ }
if (!(sp_desktop_selection(desktop)->isEmpty())) {
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER,
@@ -332,25 +380,46 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
ret = TRUE;
}
break;
- case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key)) {
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
- // prevent the zoom field from activation
- if (!MOD__CTRL_ONLY) {
- ret = TRUE;
- }
- break;
- case GDK_KEY_Escape:
- sp_desktop_selection(desktop)->clear();
- default:
- break;
+ case GDK_KEY_PRESS:
+ switch (get_group0_keyval(&event->key)) {
+ case GDK_KEY_Up:
+ case GDK_KEY_Down:
+ case GDK_KEY_KP_Up:
+ case GDK_KEY_KP_Down:
+ // prevent the zoom field from activation
+ if (!MOD__CTRL_ONLY) {
+ ret = TRUE;
}
break;
- default:
+ case GDK_KEY_Escape:
+ sp_desktop_selection(desktop)->clear();
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
+ if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ gdk_window_set_cursor(window, cursor_dropper_stroke);
+ }
+
break;
+ default:
+ break;
+ }
+ break;
+ case GDK_KEY_RELEASE:
+ switch (get_group0_keyval(&event->key)) {
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
+ if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(sp_desktop_canvas(desktop)));
+ gdk_window_set_cursor(window, cursor_dropper_fill);
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
}
if (!ret) {
diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp
index be767a3f3..3f488eca4 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/dyna-draw-context.cpp
@@ -500,7 +500,7 @@ sp_dyna_draw_brush(SPDynaDrawContext *dc)
dc->npoints++;
}
-void
+static void
sp_ddc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
{
desktop->setToolboxAdjustmentValue (id, value);
diff --git a/src/ege-adjustment-action.cpp b/src/ege-adjustment-action.cpp
index 7881498b9..78f3f48d6 100644
--- a/src/ege-adjustment-action.cpp
+++ b/src/ege-adjustment-action.cpp
@@ -47,6 +47,7 @@
#include "icon-size.h"
#include "ege-adjustment-action.h"
+#include "ui/widget/gimpspinscale.h"
static void ege_adjustment_action_class_init( EgeAdjustmentActionClass* klass );
@@ -777,7 +778,7 @@ static GtkWidget* create_menu_item( GtkAction* action )
return item;
}
-void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act )
+static void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act )
{
if ( gtk_widget_has_focus( GTK_WIDGET(spin) ) ) {
gint start = 0, end = 0;
@@ -835,15 +836,8 @@ static GtkWidget* create_tool_item( GtkAction* action )
if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
/* Slider */
- gchar *leakyForNow = g_value_dup_string( &value );
-#if GTK_CHECK_VERSION(3,0,0)
- spinbutton = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, act->private_data->adj);
-#else
- spinbutton = gtk_hscale_new( act->private_data->adj);
-#endif
+ spinbutton = gimp_spin_scale_new (act->private_data->adj, g_value_get_string( &value ), 0);
gtk_widget_set_size_request(spinbutton, 100, -1);
- gtk_scale_set_digits( GTK_SCALE(spinbutton), 0 );
- g_signal_connect( G_OBJECT(spinbutton), "format-value", G_CALLBACK(slider_format_falue), leakyForNow );
} else if ( act->private_data->appearanceMode == APPEARANCE_MINIMAL ) {
spinbutton = gtk_scale_button_new( GTK_ICON_SIZE_MENU, 0, 100, 2, 0 );
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index 0442d768c..76ea5c252 100644
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
@@ -443,7 +443,7 @@ sp_eraser_brush(SPEraserContext *dc)
dc->npoints++;
}
-void
+static void
sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
{
desktop->setToolboxAdjustmentValue (id, value);
diff --git a/src/event-context.cpp b/src/event-context.cpp
index 2c9ed1abd..3c1609d97 100644
--- a/src/event-context.cpp
+++ b/src/event-context.cpp
@@ -172,6 +172,27 @@ static void sp_event_context_dispose(GObject *object) {
}
/**
+ * Set the cursor to a standard GDK cursor
+ */
+static void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursorType cursor_type) {
+
+ GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop));
+ 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
+
+}
+
+/**
* Recreates and draws cursor on desktop related to SPEventContext.
*/
void sp_event_context_update_cursor(SPEventContext *ec) {
@@ -360,6 +381,7 @@ static gint sp_event_context_private_root_handler(
SPEventContext *event_context, GdkEvent *event) {
static Geom::Point button_w;
static unsigned int panning = 0;
+ static unsigned int panning_cursor = 0;
static unsigned int zoom_rb = 0;
SPDesktop *desktop = event_context->desktop;
@@ -393,6 +415,7 @@ static gint sp_event_context_private_root_handler(
switch (event->button.button) {
case 1:
if (event_context->space_panning) {
+
// When starting panning, make sure there are no snap events pending because these might disable the panning again
sp_event_context_discard_delayed_snap_event(event_context);
panning = 1;
@@ -408,6 +431,7 @@ static gint sp_event_context_private_root_handler(
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
sp_event_context_discard_delayed_snap_event(event_context);
panning = 2;
@@ -415,6 +439,7 @@ static gint sp_event_context_private_root_handler(
GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK, NULL,
event->button.time - 1);
+
}
ret = TRUE;
break;
@@ -439,10 +464,23 @@ static gint sp_event_context_private_root_handler(
break;
case GDK_MOTION_NOTIFY:
if (panning) {
+ if (panning == 4 && !xp && !yp ) {
+ // <Space> + mouse panning started, save location and grab canvas
+ xp = event->motion.x;
+ yp = event->motion.y;
+ button_w = Geom::Point(event->motion.x, event->motion.y);
+
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK
+ | GDK_POINTER_MOTION_MASK
+ | GDK_POINTER_MOTION_HINT_MASK, NULL,
+ event->motion.time - 1);
+
+
+ }
if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK))
- || (panning == 1 && !(event->motion.state
- & GDK_BUTTON1_MASK)) || (panning == 3
- && !(event->motion.state & GDK_BUTTON3_MASK))) {
+ || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK))
+ || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) {
/* Gdk seems to lose button release for us sometimes :-( */
panning = 0;
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
@@ -466,6 +504,11 @@ static gint sp_event_context_private_root_handler(
gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning
== 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));
+ if (panning_cursor == 0) {
+ panning_cursor = 1;
+ sp_event_context_set_cursor(event_context, GDK_FLEUR);
+ }
+
Geom::Point const motion_w(event->motion.x, event->motion.y);
Geom::Point const moved_w(motion_w - button_w);
event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
@@ -496,6 +539,11 @@ static gint sp_event_context_private_root_handler(
break;
case GDK_BUTTON_RELEASE:
xp = yp = 0;
+ if (panning_cursor == 1) {
+ panning_cursor = 0;
+ GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop));
+ gdk_window_set_cursor(gtk_widget_get_window (w), event_context->cursor);
+ }
if (within_tolerance && (panning || zoom_rb)) {
zoom_rb = 0;
if (panning) {
@@ -535,6 +583,7 @@ static gint sp_event_context_private_root_handler(
}
ret = TRUE;
}
+
break;
case GDK_KEY_PRESS: {
double const acceleration = prefs->getDoubleLimited(
@@ -637,15 +686,13 @@ static gint sp_event_context_private_root_handler(
}
break;
case GDK_KEY_space:
- if (prefs->getBool("/options/spacepans/value")) {
- event_context->space_panning = true;
- event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE,
- _("<b>Space+mouse drag</b> to pan canvas"));
- ret = TRUE;
- } else {
- sp_toggle_selector(desktop);
- ret = TRUE;
- }
+ xp = yp = 0;
+ within_tolerance = true;
+ panning = 4;
+ event_context->space_panning = true;
+ event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE,
+ _("<b>Space+mouse move</b> to pan canvas"));
+ ret = TRUE;
break;
case GDK_KEY_z:
case GDK_KEY_Z:
@@ -660,17 +707,32 @@ static gint sp_event_context_private_root_handler(
}
break;
case GDK_KEY_RELEASE:
+
+ // Stop panning on any key release
+ if (event_context->space_panning) {
+ event_context->space_panning = false;
+ event_context->_message_context->clear();
+ }
+
+ if (panning) {
+ panning = 0;
+ xp = yp = 0;
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+ event->key.time);
+ desktop->updateNow();
+ }
+
+ if (panning_cursor == 1) {
+ panning_cursor = 0;
+ GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop));
+ gdk_window_set_cursor(gtk_widget_get_window (w), event_context->cursor);
+ }
+
switch (get_group0_keyval(&event->key)) {
case GDK_KEY_space:
- if (event_context->space_panning) {
- event_context->space_panning = false;
- event_context->_message_context->clear();
- if (panning == 1) {
- panning = 0;
- sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
- event->key.time);
- desktop->updateNow();
- }
+ if (within_tolerance == true) {
+ // Space was pressed, but not panned
+ sp_toggle_selector(desktop);
ret = TRUE;
}
break;
@@ -809,8 +871,8 @@ public:
Inkscape::Preferences::Observer(path), _ec(ec) {
}
virtual void notify(Inkscape::Preferences::Entry const &val) {
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) {
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec,
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set) {
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(_ec)))->set(_ec,
const_cast<Inkscape::Preferences::Entry*> (&val));
}
}
@@ -843,8 +905,8 @@ sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path,
prefs->addObserver(*(ec->pref_observer));
}
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup)
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup)
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup(ec);
return ec;
}
@@ -862,8 +924,8 @@ void sp_event_context_finish(SPEventContext *ec) {
g_warning("Finishing event context with active link\n");
}
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish)
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish)
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish(ec);
}
//-------------------------------member functions
@@ -919,11 +981,11 @@ void sp_event_context_read(SPEventContext *ec, gchar const *key) {
g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
g_return_if_fail(key != NULL);
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::Preferences::Entry val = prefs->getEntry(
ec->pref_observer->observed_path + '/' + key);
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val);
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set(ec, &val);
}
}
@@ -939,8 +1001,8 @@ void sp_event_context_activate(SPEventContext *ec) {
// context should take care of this by itself.
sp_event_context_discard_delayed_snap_event(ec);
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate)
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate)
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate(ec);
}
/**
@@ -950,8 +1012,8 @@ void sp_event_context_deactivate(SPEventContext *ec) {
g_return_if_fail(ec != NULL);
g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
- if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate)
- ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate)
+ (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate(ec);
}
/**
@@ -992,7 +1054,7 @@ gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEv
gint ret = false;
if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash
// (see the comment in SPDesktop::set_event_context, and bug LP #622350)
- ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
+ ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->root_handler(event_context, event);
set_event_location(event_context->desktop, event);
}
return ret;
@@ -1031,7 +1093,7 @@ gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPIte
gint ret = false;
if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash
// (see the comment in SPDesktop::set_event_context, and bug LP #622350)
- ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
+ ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->item_handler(event_context, item, event);
if (!ret) {
ret = sp_event_context_virtual_root_handler(event_context, event);
} else {
diff --git a/src/event-context.h b/src/event-context.h
index 9cd754ffb..9936aa668 100644
--- a/src/event-context.h
+++ b/src/event-context.h
@@ -36,6 +36,7 @@ namespace Inkscape {
#define SP_TYPE_EVENT_CONTEXT (sp_event_context_get_type())
#define SP_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_EVENT_CONTEXT, SPEventContext))
+#define SP_EVENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_EVENT_CONTEXT, SPEventContextClass))
#define SP_IS_EVENT_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_EVENT_CONTEXT))
GType sp_event_context_get_type();
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 5761b1e8b..e1f04fa10 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -41,6 +41,7 @@ set(extension_SRC
internal/gdkpixbuf-input.cpp
internal/gimpgrad.cpp
internal/grid.cpp
+ internal/image-resolution.cpp
internal/latex-pstricks.cpp
internal/latex-pstricks-out.cpp
internal/odf.cpp
@@ -50,6 +51,7 @@ set(extension_SRC
internal/javafx-out.cpp
internal/svg.cpp
internal/svgz.cpp
+ internal/vsd-input.cpp
internal/filter/filter-all.cpp
internal/filter/filter-file.cpp
@@ -129,6 +131,7 @@ set(extension_SRC
internal/gdkpixbuf-input.h
internal/gimpgrad.h
internal/grid.h
+ internal/image-resolution.h
internal/javafx-out.h
internal/latex-pstricks-out.h
internal/latex-pstricks.h
@@ -141,6 +144,7 @@ set(extension_SRC
internal/pov-out.h
internal/svg.h
internal/svgz.h
+ internal/vsd-input.h
script/InkscapeScript.h
)
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index ffcee5f9a..4e75de13a 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -3,7 +3,6 @@
ink_common_sources += \
extension/extension.cpp \
extension/extension.h \
- extension/extension-forward.h \
extension/db.cpp \
extension/db.h \
extension/dependency.cpp \
diff --git a/src/extension/effect.h b/src/extension/effect.h
index bb36b9238..6616a23ec 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -67,7 +67,7 @@ class Effect : public Extension {
gchar const * image,
Effect * effect,
bool showPrefs) :
- Verb(id, _(name), _(tip), image),
+ Verb(id, _(name), _(tip), image, _("Extensions")),
_effect(effect),
_showPrefs(showPrefs),
_elip_name(NULL) {
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index b0230b7c4..fb323cd78 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -104,6 +104,7 @@ public:
virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
virtual bool cancelProcessing () { return true; }
+ virtual bool wasCancelled () { return false; }
virtual void commitDocument () {}
// ----- Input functions -----
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index b0732568f..ac3c90421 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -53,6 +53,9 @@
#ifdef WITH_LIBWPG
#include "internal/wpg-input.h"
#endif
+#ifdef WITH_LIBVISIO
+#include "internal/vsd-input.h"
+#endif
#include "preferences.h"
#include "io/sys.h"
#ifdef WITH_DBUS
@@ -99,6 +102,8 @@
#include "internal/filter/filter.h"
+#include "init.h"
+
extern gboolean inkscape_app_use_gui( Inkscape::Application const *app );
namespace Inkscape {
@@ -183,6 +188,9 @@ init()
#ifdef WITH_LIBWPG
Internal::WpgInput::init();
#endif
+#ifdef WITH_LIBVISIO
+ Internal::VsdInput::init();
+#endif
/* Effects */
Internal::BlurEdge::init();
diff --git a/src/extension/input.cpp b/src/extension/input.cpp
index 1662ef073..5cef38009 100644
--- a/src/extension/input.cpp
+++ b/src/extension/input.cpp
@@ -152,6 +152,10 @@ Input::open (const gchar *uri)
SPDocument *const doc = imp->open(this, uri);
+ if (imp->wasCancelled()) {
+ throw Input::open_cancelled();
+ }
+
return doc;
}
@@ -227,8 +231,7 @@ Input::prefs (const gchar *uri)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
} } /* namespace Inkscape, Extension */
diff --git a/src/extension/input.h b/src/extension/input.h
index 8b198495e..b01ffeb86 100644
--- a/src/extension/input.h
+++ b/src/extension/input.h
@@ -39,6 +39,10 @@ public:
virtual ~no_extension_found() throw() {}
const char *what() const throw() { return "No suitable input extension found"; }
};
+ struct open_cancelled : public std::exception {
+ virtual ~open_cancelled() throw() {}
+ const char *what() const throw() { return "Open was cancelled"; }
+ };
Input (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index e9b11553b..1ea6caca9 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -4,7 +4,12 @@ if WITH_LIBWPG
ink_common_sources += \
extension/internal/wpg-input.cpp \
extension/internal/wpg-input.h
+endif
+if WITH_LIBVISIO
+ink_common_sources += \
+ extension/internal/vsd-input.cpp \
+ extension/internal/vsd-input.h
endif
if USE_IMAGE_MAGICK
@@ -127,12 +132,24 @@ ink_common_sources += \
extension/internal/latex-pstricks.h \
extension/internal/latex-pstricks-out.cpp \
extension/internal/latex-pstricks-out.h \
+ extension/internal/filter/bevels.h \
+ extension/internal/filter/blurs.h \
+ extension/internal/filter/bumps.h \
+ extension/internal/filter/color.h \
+ extension/internal/filter/distort.h \
+ extension/internal/filter/filter.h \
+ extension/internal/filter/image.h \
+ extension/internal/filter/morphology.h \
+ extension/internal/filter/overlays.h \
+ extension/internal/filter/paint.h \
+ extension/internal/filter/protrusions.h \
+ extension/internal/filter/shadows.h \
+ extension/internal/filter/textures.h \
+ extension/internal/filter/transparency.h \
extension/internal/filter/filter-all.cpp \
extension/internal/filter/filter-file.cpp \
extension/internal/filter/filter.cpp \
extension/internal/filter/filter.h \
- extension/internal/filter/drop-shadow.h \
- extension/internal/filter/snow.h \
extension/internal/emf-win32-print.h \
extension/internal/emf-win32-print.cpp \
extension/internal/emf-win32-inout.h \
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
index 4751a229a..956fcce9a 100644
--- a/src/extension/internal/cairo-png-out.cpp
+++ b/src/extension/internal/cairo-png-out.cpp
@@ -68,7 +68,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
ctx = renderer->createContext();
/* Render document */
- bool ret = renderer->setupDocument(ctx, doc, TRUE, NULL);
+ bool ret = renderer->setupDocument(ctx, doc, TRUE, 0., NULL);
if (ret) {
renderer->renderItem(ctx, base);
ctx->saveAsPng(filename);
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index 605f0237c..8a39f4ea9 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -104,7 +104,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
bool ret = ctx->setPsTarget(filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, 0., base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -192,7 +192,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -272,7 +272,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 494ff1e8d..773109c77 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -39,6 +39,8 @@
#include <2geom/affine.h>
#include "document.h"
+#include "unit-constants.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -57,7 +59,7 @@ bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/)
static bool
pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level,
bool texttopath, bool omittext, bool filtertobitmap, int resolution,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas)
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px)
{
doc->ensureUpToDate();
@@ -99,7 +101,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
bool ret = ctx->setPdfTarget (filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -191,16 +193,23 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
} catch(...) {
g_warning("Parameter <area> might not exist");
}
-
bool new_exportDrawing = !new_exportCanvas;
+ float new_bleedmargin_px = 0.;
+ try {
+ new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM;
+ }
+ catch(...) {
+ g_warning("Parameter <bleed> might not exist");
+ }
+
// Create PDF file
{
gchar * final_name;
final_name = g_strdup_printf("> %s", filename);
ret = pdf_render_document_to_file(doc, final_name, level,
new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution,
- new_exportId, new_exportDrawing, new_exportCanvas);
+ new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px);
g_free(final_name);
if (!ret)
@@ -209,7 +218,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px, true);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -246,6 +255,7 @@ CairoRendererPdfOutput::init (void)
"<option value=\"page\">" N_("Use document's page size") "</option>"
"<option value=\"drawing\">" N_("Use exported object's size") "</option>"
"</param>"
+ "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n"
"<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.pdf</extension>\n"
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 09d69becb..0a3cff26a 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -604,7 +604,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
}
bool
-CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base)
+CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// PLEASE note when making changes to the boundingbox and transform calculation, corresponding changes should be made to PDFLaTeXRenderer::setupDocument !!!
@@ -625,6 +625,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
if (ctx->_vector_based_target) {
// convert from px to pt
@@ -638,16 +639,21 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
bool ret = ctx->setupSurface(ctx->_width, ctx->_height);
- if (ret && !pageBoundingBox)
- {
- double high = doc->getHeight();
- if (ctx->_vector_based_target)
- high *= PT_PER_PX;
-
- /// @fixme hardcoded dt2doc transform?
- Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
- ctx->transform(tp);
+ if (ret) {
+ if (pageBoundingBox) {
+ // translate to set bleed/margin
+ Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) );
+ ctx->transform(tp);
+ } else {
+ double high = doc->getHeight();
+ if (ctx->_vector_based_target)
+ high *= PT_PER_PX;
+
+ // this transform translates the export drawing to a virtual page (0,0)-(width,height)
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ ctx->transform(tp);
+ }
}
return ret;
diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h
index 7fa7c7ff5..db3068fed 100644
--- a/src/extension/internal/cairo-renderer.h
+++ b/src/extension/internal/cairo-renderer.h
@@ -53,7 +53,7 @@ public:
/** Initializes the CairoRenderContext according to the specified
SPDocument. A set*Target function can only be called on the context
before setupDocument. */
- bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(CairoRenderContext *ctx, SPItem *item);
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index 7593a4806..e9360a0ea 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -61,6 +61,8 @@ namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
+static float device_x;
+static float device_y;
static RECTL rc_old;
static bool clipset = false;
@@ -322,11 +324,11 @@ _pix_y_to_point(PEMF_CALLBACK_DATA d, double px)
static double
pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppx = px * d->dc[d->level].worldTransform.eM11 + py * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
+ double x = _pix_x_to_point(d, ppx);
- double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
x *= device_scale;
+ x -= device_x;
return x;
}
@@ -334,11 +336,11 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
static double
pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppy = px * d->dc[d->level].worldTransform.eM12 + py * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
+ double y = _pix_y_to_point(d, ppy);
- double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
y *= device_scale;
+ y -= device_y;
return y;
}
@@ -773,8 +775,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
d->xDPI = 2540;
d->yDPI = 2540;
- d->dc[d->level].PixelsInX = pEmr->rclFrame.right; // - pEmr->rclFrame.left;
- d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom; // - pEmr->rclFrame.top;
+ d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left;
+ d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top;
+ device_x = pEmr->rclFrame.left/100.0*PX_PER_MM;
+ device_y = pEmr->rclFrame.top/100.0*PX_PER_MM;
d->MMX = d->dc[d->level].PixelsInX / 100.0;
d->MMY = d->dc[d->level].PixelsInY / 100.0;
@@ -1815,7 +1819,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_BITBLT -->\n";
PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR;
- if (pEmr->dwRop == DPA) {
+ if ((pEmr->dwRop == PATCOPY) || (pEmr->dwRop == DPA)) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest);
double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest);
@@ -1905,6 +1909,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
(gchar *) g_utf16_to_utf8( (gunichar2 *) wide_text, pEmr->emrtext.nChars, NULL, NULL, NULL );
if (ansi_text) {
+ if ((wide_text[0] < 32) && (strlen(ansi_text) == 1)) {
+ g_free(ansi_text); // filter out isolated control characters
+ ansi_text = g_strdup("");
+ }
// gchar *p = ansi_text;
// while (*p) {
// if (*p < 32 || *p >= 127) {
@@ -2460,9 +2468,10 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
DWORD dwNeeded = GetEnhMetaFileDescriptionA( hemf, 0, NULL );
if ( dwNeeded > 0 ) {
d.pDesc = (CHAR *) malloc( dwNeeded + 1 );
+ d.pDesc[dwNeeded] = 0;
if ( GetEnhMetaFileDescription( hemf, dwNeeded, d.pDesc ) == 0 )
lstrcpy( d.pDesc, "" );
- if ( lstrlen( d.pDesc ) > 1 )
+ if ((lstrlen(d.pDesc) > 1) && (lstrlen(d.pDesc) < dwNeeded))
d.pDesc[lstrlen(d.pDesc)] = '#';
}
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index b6b194c8b..785059cca 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -615,9 +615,8 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Channel (enum, all colors, default Red) -> colormatrix (values)
- * Background blend (enum, all blend modes, default Multiply) -> blend (mode)
+ * Background blend (enum, Normal, Multiply, Screen, default Normal) -> blend (mode)
* Channel to alpha (boolean, default false) -> colormatrix (values)
- * Invert (boolean, default false) -> colormatrix (values)
*/
class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter {
@@ -637,16 +636,16 @@ public:
"<_item value=\"r\">" N_("Red") "</_item>\n"
"<_item value=\"g\">" N_("Green") "</_item>\n"
"<_item value=\"b\">" N_("Blue") "</_item>\n"
+ "<_item value=\"c\">" N_("Cyan") "</_item>\n"
+ "<_item value=\"m\">" N_("Magenta") "</_item>\n"
+ "<_item value=\"y\">" N_("Yellow") "</_item>\n"
"</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
- "<_item value=\"darken\">" N_("Darken") "</_item>\n"
- "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
"</param>\n"
"<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</param>\n"
- "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -667,45 +666,45 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream blend;
std::ostringstream colors;
- std::ostringstream alpha;
- std::ostringstream invert;
blend << ext->get_param_enum("blend");
const gchar *channel = ext->get_param_enum("source");
if (ext->get_param_bool("alpha")) {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("r", channel) == 0)) {
- colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0";
- } else {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
- }
-
- if (ext->get_param_bool("invert")) {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "-1 0 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 -1 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0";
} else {
- alpha << "0 0 -1 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0";
}
} else {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "1 0 0 0";
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 1 0 0";
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0";
} else {
- alpha << "0 0 1 0";
+ colors << "0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0";
}
}
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Extract Channel\">\n"
- "<feColorMatrix in=\"SourceGraphic\" values=\"%s %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"%s 0 \" result=\"colormatrix\" />\n"
"<feBlend in2=\"BackgroundImage\" mode=\"%s\" result=\"blend\" />\n"
- "</filter>\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() );
+ "</filter>\n", colors.str().c_str(), blend.str().c_str() );
return _filter;
}; /* ExtractChannel filter */
@@ -1157,9 +1156,9 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* Lightness-Contrast filter */
/**
- \brief Custom predefined Nudge filter.
+ \brief Custom predefined Nudge RGB filter.
- Nudge separately RGB channels and blend them to different types of backgrounds
+ Nudge RGB channels separately and blend them to different types of backgrounds
Filter's parameters:
Offsets
@@ -1193,8 +1192,8 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Nudge") "</name>\n"
- "<id>org.inkscape.effect.filter.Nudge</id>\n"
+ "<name>" N_("Nudge RGB") "</name>\n"
+ "<id>org.inkscape.effect.filter.NudgeRGB</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"offsettab\" _gui-text=\"Offset\">\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n"
@@ -1232,7 +1231,7 @@ public:
"<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
- "<menu-tip>" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "</menu-tip>\n"
+ "<menu-tip>" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
"</effect>\n"
"</inkscape-extension>\n", new Nudge());
};
@@ -1277,7 +1276,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
a << (color & 0xff) / 255.0F;
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge RGB\">\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
@@ -1297,7 +1296,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
return _filter;
-}; /* Nudge filter */
+}; /* Nudge RGB filter */
/**
\brief Custom predefined Quadritone filter.
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index debdd7d79..ad396e08f 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -3,7 +3,7 @@
/* Change the 'PAINT' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2012 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -563,13 +563,13 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Lines type (enum, default smooth) ->
- smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2")
- hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1")
- * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation)
- * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation)
- * Lightness (0.->10., default 0.5) -> composite1 (k3)
+ smooth = component2 (type="table"), composite1 (in2="blur2")
+ hard = component2 (type="discrete"), composite1 (in2="component1")
+ * Simplify (0.01->20., default 3) -> blur1 (stdDeviation)
+ * Line width (0.01->20., default 3) -> blur2 (stdDeviation)
+ * Lightness (0.->10., default 1) -> composite1 (k2)
* Blend (enum [normal, multiply, screen], default normal) -> blend (mode)
- * Dark mode (boolean, default false) -> composite1 (true: in2="component2")
+ * Dark mode (boolean, default false) -> composite2 (true: in2="component2")
*/
class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter {
protected:
@@ -588,15 +588,14 @@ public:
"<_item value=\"table\">" N_("Smoothed") "</_item>\n"
"<_item value=\"discrete\">" N_("Contrasted") "</_item>\n"
"</param>\n"
- "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">0.5</param>\n"
+ "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"multiply\">Multiply</_item>\n"
"<_item value=\"screen\">Screen</_item>\n"
"</param>\n"
- "<param name=\"dark\" gui-text=\"" N_("Dark mode") "\" type=\"boolean\" >false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -620,7 +619,6 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream width;
std::ostringstream lightness;
std::ostringstream type;
- std::ostringstream dark;
type << ext->get_param_enum("type");
blend << ext->get_param_enum("blend");
@@ -628,33 +626,26 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
width << ext->get_param_float("width");
lightness << ext->get_param_float("lightness");
- const gchar *typestr = ext->get_param_enum("type");
- if (ext->get_param_bool("dark")) {
- dark << "component2";
- } else if ((g_ascii_strcasecmp("table", typestr) == 0)) {
- dark << "blur2";
- } else {
- dark << "component1";
- }
-
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Neon Draw\">\n"
"<feBlend mode=\"%s\" result=\"blend\" />\n"
"<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color1\" />\n"
"<feComponentTransfer result=\"component1\">\n"
- "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
+ "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
"</feComponentTransfer>\n"
"<feGaussianBlur in=\"component1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
- "<feComponentTransfer in=\"blur2\" result=\"component2\">\n"
- "<feFuncR type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncG type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncB type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color2\" />\n"
+ "<feComponentTransfer in=\"color2\" result=\"component2\">\n"
+ "<feFuncR type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncG type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncB type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
"</feComponentTransfer>\n"
- "<feComposite in=\"component2\" in2=\"%s\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
+ "<feComposite in=\"component2\" in2=\"blur2\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
"<feComposite in=\"composite1\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str());
+ "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), lightness.str().c_str());
return _filter;
}; /* NeonDraw filter */
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index ebd73a033..ecc201733 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -56,7 +56,7 @@ namespace Internal {
*/
bool
latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex)
{
doc->ensureUpToDate();
@@ -84,7 +84,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
bool ret = renderer->setTargetFile(filename);
if (ret) {
/* Render document */
- bool ret = renderer->setupDocument(doc, pageBoundingBox, base);
+ bool ret = renderer->setupDocument(doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(base);
}
@@ -569,7 +569,7 @@ LaTeXTextRenderer::renderItem(SPItem *item)
}
bool
-LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base)
+LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument !
@@ -588,6 +588,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
// scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX
double scale = 1/(d.width());
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 66055a3bc..0fa94c9e6 100644
--- a/src/extension/internal/latex-text-renderer.h
+++ b/src/extension/internal/latex-text-renderer.h
@@ -29,7 +29,7 @@ namespace Extension {
namespace Internal {
bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex);
class LaTeXTextRenderer {
@@ -41,7 +41,7 @@ public:
/** Initializes the LaTeXTextRenderer according to the specified
SPDocument. Important to set the boundingbox to the pdf boundingbox */
- bool setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(SPItem *item);
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index c8c187c77..0639ae8d0 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -969,7 +969,7 @@ static Geom::Affine getODFTransform(const SPItem *item)
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
// TODO: geometric or visual?
- Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds();
+ Geom::OptRect bbox = item->documentVisualBounds();
if (bbox) {
*bbox *= Geom::Affine(Geom::Scale(pxToCm));
}
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index eee1b43bf..03b7c0a90 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -95,11 +95,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -124,11 +120,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 6b6107444..688e3f612 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -111,11 +111,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -140,11 +136,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
@@ -588,12 +580,19 @@ void PdfImportDialog::_setPreviewPage(int page) {
////////////////////////////////////////////////////////////////////////////////
+bool
+PdfInput::wasCancelled () {
+ return _cancelled;
+}
+
/**
* Parses the selected page of the given PDF document using PdfParser.
*/
SPDocument *
PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
+ _cancelled = false;
+
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
@@ -648,6 +647,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
if (inkscape_use_gui()) {
dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
+ _cancelled = true;
delete dlg;
delete pdf_doc;
return NULL;
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 75fcfa69a..e9da5b27c 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -135,7 +135,9 @@ public:
SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
static void init( void );
-
+ virtual bool wasCancelled();
+private:
+ bool _cancelled;
};
} // namespace Implementation
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index 9b1098afd..8b272af60 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -44,7 +44,7 @@ using Inkscape::XML::Node;
-void pruneExtendedAttributes( Inkscape::XML::Node *repr )
+static void pruneExtendedAttributes( Inkscape::XML::Node *repr )
{
if (repr) {
if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
new file mode 100644
index 000000000..6d71ce72a
--- /dev/null
+++ b/src/extension/internal/vsd-input.cpp
@@ -0,0 +1,289 @@
+/*
+ * This file came from libwpg as a source, their utility wpg2svg
+ * specifically. It has been modified to work as an Inkscape extension.
+ * The Inkscape extension code is covered by this copyright, but the
+ * rest is covered by the one bellow.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#include "vsd-input.h"
+
+#ifdef WITH_LIBVISIO
+
+#include <string>
+#include <cstring>
+
+#include <libvisio/libvisio.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+#include <gtkmm/alignment.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/scale.h>
+
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include "document-private.h"
+#include "document-undo.h"
+#include "inkscape.h"
+
+#include "dialogs/dialog-events.h"
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+#include <glibmm/i18n.h>
+
+#include <gdkmm/general.h>
+
+#include "svg-view.h"
+#include "svg-view-widget.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+
+class VsdImportDialog : public Gtk::Dialog {
+public:
+ VsdImportDialog(const std::vector<WPXString> &vec);
+ virtual ~VsdImportDialog();
+
+ bool showDialog();
+ unsigned getSelectedPage();
+ void getImportSettings(Inkscape::XML::Node *prefs);
+
+private:
+ void _setPreviewPage(unsigned page);
+
+ // Signal handlers
+#if !WITH_GTKMM_3_0
+ bool _onExposePreview(GdkEventExpose *event);
+#endif
+
+ void _onPageNumberChanged();
+
+ class Gtk::Button * cancelbutton;
+ class Gtk::Button * okbutton;
+ class Gtk::Label * _labelSelect;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
+ class Gtk::Label * _labelTotalPages;
+ class Gtk::VBox * vbox1;
+ class Gtk::VBox * vbox2;
+ class Gtk::Widget * _previewArea;
+
+ const std::vector<WPXString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ int _preview_width, _preview_height; // Size of the preview area
+};
+
+VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
+ : _vec(vec), _current_page(1)
+{
+ int num_pages = _vec.size();
+ if ( num_pages <= 1 )
+ return;
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+
+ // Page number
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+#else
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+#endif
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+
+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
+ cancelbutton->set_can_focus();
+ cancelbutton->set_can_default();
+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
+ okbutton->set_can_focus();
+ okbutton->set_can_default();
+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ _labelSelect->set_line_wrap(false);
+ _labelSelect->set_use_markup(false);
+ _labelSelect->set_selectable(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_digits(0);
+ _pageNumberSpin->set_wrap(false);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ this->get_vbox()->set_homogeneous(false);
+ this->get_vbox()->set_spacing(0);
+ this->get_vbox()->pack_start(*vbox2);
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize((GtkWidget *)this->gobj()); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+ this->get_action_area()->add(*_labelSelect);
+ this->add_action_widget(*_pageNumberSpin, -7);
+ this->get_action_area()->add(*_labelTotalPages);
+ this->add_action_widget(*cancelbutton, -6);
+ this->add_action_widget(*okbutton, -5);
+ cancelbutton->show();
+ okbutton->show();
+ _labelSelect->show();
+ _pageNumberSpin->show();
+ _labelTotalPages->show();
+ vbox1->show();
+ _previewArea->show();
+ vbox2->show();
+
+ // Connect signals
+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+}
+
+VsdImportDialog::~VsdImportDialog() {}
+
+bool VsdImportDialog::showDialog()
+{
+ show();
+ gint b = run();
+ hide();
+ if ( b == Gtk::RESPONSE_OK ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+unsigned VsdImportDialog::getSelectedPage()
+{
+ return _current_page;
+}
+
+void VsdImportDialog::_onPageNumberChanged()
+{
+ int page = _pageNumberSpin->get_value_as_int();
+ _current_page = CLAMP(page, 1, _vec.size());
+ _setPreviewPage(_current_page);
+}
+
+/**
+ * \brief Renders the given page's thumbnail
+ */
+void VsdImportDialog::_setPreviewPage(unsigned page)
+{
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+ std::swap(_previewArea, tmpPreviewArea);
+ if (tmpPreviewArea) {
+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
+ delete tmpPreviewArea;
+ }
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ _previewArea->show_now();
+}
+
+SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+ WPXFileStream input(uri);
+
+ if (!libvisio::VisioDocument::isSupported(&input)) {
+ return NULL;
+ }
+
+ libvisio::VSDStringVector output;
+ if (!libvisio::VisioDocument::generateSVG(&input, output)) {
+ return NULL;
+ }
+
+ if (output.empty()) {
+ return NULL;
+ }
+
+ std::vector<WPXString> tmpSVGOutput;
+ for (unsigned i=0; i<output.size(); ++i) {
+ WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ tmpString.append(output[i]);
+ tmpSVGOutput.push_back(tmpString);
+ }
+
+ unsigned page_num = 1;
+
+ // If only one page is present, import that one without bothering user
+ if (tmpSVGOutput.size() > 1) {
+ VsdImportDialog *dlg = 0;
+ if (inkscape_use_gui()) {
+ dlg = new VsdImportDialog(tmpSVGOutput);
+ if (!dlg->showDialog()) {
+ delete dlg;
+ return NULL;
+ }
+ }
+
+ // Get needed page
+ if (dlg) {
+ page_num = dlg->getSelectedPage();
+ if (page_num < 1)
+ page_num = 1;
+ if (page_num > tmpSVGOutput.size())
+ page_num = tmpSVGOutput.size();
+ }
+ }
+
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ return doc;
+}
+
+#include "clear-n_.h"
+
+void VsdInput::init(void)
+{
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VSD Input") "</name>\n"
+ "<id>org.inkscape.input.vsd</id>\n"
+ "<input>\n"
+ "<extension>.vsd</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+#endif /* WITH_LIBVISIO */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h
new file mode 100644
index 000000000..acc52debf
--- /dev/null
+++ b/src/extension/internal/vsd-input.h
@@ -0,0 +1,54 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
+#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef WITH_LIBVISIO
+
+#include <gtkmm/dialog.h>
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class VsdInput : public Inkscape::Extension::Implementation::Implementation {
+ VsdInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* WITH_LIBVISIO */
+#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index b1968a4d6..18a73beb6 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -242,11 +242,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
enumentry * entr = reinterpret_cast<enumentry *>(list->data);
Glib::ustring text = entr->guitext;
-#if WITH_GTKMM_2_24
combo->append(text);
-#else
- combo->append_text(text);
-#endif
if ( _value && !entr->value.compare(_value) ) {
settext = entr->guitext;
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index b9ffe68d2..81508f6c0 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -175,9 +176,6 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal);
@@ -187,24 +185,27 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
+
}
+ else if (_mode == MINIMAL) {
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 7cb930f50..c286018fd 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -156,9 +157,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal);
@@ -168,24 +167,26 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
}
+ else if (_mode == MINIMAL) {
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 5b5e179d2..921c322b6 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -305,11 +305,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
switch ( _mode ) {
case MINIMAL:
{
-#if WITH_GTKMM_2_24
cbt->append(*text);
-#else
- cbt->append_text(*text);
-#endif
if (!entr->value->compare(_value)) {
cbt->set_active_text(*text);
comboSet = true;
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
index 94f128a42..2d2604c7f 100644
--- a/src/extension/prefdialog.cpp
+++ b/src/extension/prefdialog.cpp
@@ -32,13 +32,13 @@ namespace Extension {
/** \brief Creates a new preference dialog for extension preferences
- \param name Name of the Extension who's dialog this is
+ \param name Name of the Extension whose dialog this is
\param help The help string for the extension (NULL if none)
\param controls The extension specific widgets in the dialog
This function initializes the dialog with the name of the extension
in the title. It adds a few buttons and sets up handlers for
- them. It also places the passed in widgets into the dialog.
+ them. It also places the passed-in widgets into the dialog.
*/
PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) :
#if WITH_GTKMM_3_0
@@ -102,12 +102,10 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co
Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview);
if (hbox != NULL) {
#if WITH_GTKMM_3_0
- Gtk::Widget * back = hbox->get_children().back();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front());
#else
- Gtk::Widget * back = hbox->children().back().get_widget();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget());
#endif
- Gtk::CheckButton * cb = dynamic_cast<Gtk::CheckButton *>(back);
- _checkbox_preview = cb;
}
preview_toggle();
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index fc20095c5..7fb6e1591 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -144,6 +144,7 @@ SPDocument *open(Extension *key, gchar const *filename)
}
SPDocument *doc = imod->open(filename);
+
if (!doc) {
throw Input::open_failed();
}
diff --git a/src/extract-uri.cpp b/src/extract-uri.cpp
index 76778bacb..a25c8bb70 100644
--- a/src/extract-uri.cpp
+++ b/src/extract-uri.cpp
@@ -1,6 +1,8 @@
#include <string.h>
#include <glib.h>
+#include "extract-uri.h"
+
// FIXME: kill this ugliness when we have a proper CSS parser
// Functions as per 4.3.4 of CSS 2.1
diff --git a/src/file.cpp b/src/file.cpp
index 778306d5d..14f70fc8c 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -235,12 +235,16 @@ bool sp_file_open(const Glib::ustring &uri,
}
SPDocument *doc = NULL;
+ bool cancelled = false;
try {
doc = Inkscape::Extension::open(key, uri.c_str());
} catch (Inkscape::Extension::Input::no_extension_found &e) {
doc = NULL;
} catch (Inkscape::Extension::Input::open_failed &e) {
doc = NULL;
+ } catch (Inkscape::Extension::Input::open_cancelled &e) {
+ doc = NULL;
+ cancelled = true;
}
if (desktop) {
@@ -287,7 +291,7 @@ bool sp_file_open(const Glib::ustring &uri,
}
return TRUE;
- } else {
+ } else if (!cancelled) {
gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), safeUri);
sp_ui_error_dialog(text);
@@ -295,6 +299,8 @@ bool sp_file_open(const Glib::ustring &uri,
g_free(safeUri);
return FALSE;
}
+
+ return FALSE;
}
/**
@@ -669,7 +675,12 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
}
SP_ACTIVE_DESKTOP->event_log->rememberFileSave();
- Glib::ustring msg = Glib::ustring::format(_("Document saved."), " ", doc->getURI());
+ Glib::ustring msg;
+ if (doc->getURI() == NULL) {
+ msg = Glib::ustring::format(_("Document saved."));
+ } else {
+ msg = Glib::ustring::format(_("Document saved."), " ", doc->getURI());
+ }
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.c_str());
return true;
}
@@ -946,7 +957,13 @@ sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
}
}
} else {
- Glib::ustring msg = Glib::ustring::format(_("No changes need to be saved."), " ", doc->getURI());
+ Glib::ustring msg;
+ if ( doc->getURI() == NULL )
+ {
+ msg = Glib::ustring::format(_("No changes need to be saved."));
+ } else {
+ msg = Glib::ustring::format(_("No changes need to be saved."), " ", doc->getURI());
+ }
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg.c_str());
success = TRUE;
}
diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp
index 81cbbf401..fc74ee8a2 100644
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
@@ -242,7 +242,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion
* Creates a simple filter with a blend primitive and a blur primitive of specified radius for
* an item with the given matrix expansion, width and height
*/
-SPFilter *
+static SPFilter *
new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdouble radius, double expansion,
double expansionX, double expansionY, double width, double height)
{
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index f7c4ca365..3c656527e 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -167,7 +167,7 @@ static void sp_flood_context_dispose(GObject *object)
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data)
+static void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data)
{
SPFloodContext *rc = SP_FLOOD_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(rc);
@@ -205,6 +205,10 @@ static void sp_flood_context_setup(SPEventContext *ec)
}
}
+// Changes from 0.48 -> 0.49 (Cairo)
+// 0.49: Ignores alpha in background
+// 0.48: RGBA, 0.49 ARGB
+// 0.49: premultiplied alpha
inline static guint32 compose_onto(guint32 px, guint32 bg)
{
guint ap = 0, rp = 0, gp = 0, bp = 0;
@@ -212,10 +216,12 @@ inline static guint32 compose_onto(guint32 px, guint32 bg)
ExtractARGB32(px, ap, rp, gp, bp);
ExtractRGB32(bg, rb, gb, bb);
- guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255;
- guint ro = (255-ap)*rb + rp; ro = (ro + 127) / 255;
- guint go = (255-ap)*gb + gp; go = (go + 127) / 255;
- guint bo = (255-ap)*bb + bp; bo = (bo + 127) / 255;
+ // guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255;
+ // guint ao = (255-ap)*ab + 255*ap; ao = (ao + 127) / 255;
+ guint ao = 255; // Cairo version doesn't allow background to have alpha != 1.
+ guint ro = (255-ap)*rb + 255*rp; ro = (ro + 127) / 255;
+ guint go = (255-ap)*gb + 255*gp; go = (go + 127) / 255;
+ guint bo = (255-ap)*bb + 255*bp; bo = (bo + 127) / 255;
guint pxout = AssembleARGB32(ao, ro, go, bo);
return pxout;
@@ -314,10 +320,12 @@ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixe
return abs(static_cast<int>(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;
- rmc = (255-ac)*rd + rc; rmc = (rmc + 127) / 255;
- gmc = (255-ac)*gd + gc; gmc = (gmc + 127) / 255;
- bmc = (255-ac)*bd + bc; bmc = (bmc + 127) / 255;
+ //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));
@@ -826,6 +834,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
guchar *px = g_new(guchar, stride * height);
guint32 bgcolor, dtc;
+ // Draw image into data block px
{ // this block limits the lifetime of Drawing and DrawingContext
/* Create DrawingItems and set transform */
unsigned dkey = SPItem::display_key_new(1);
@@ -854,6 +863,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
drawing.render(ct, final_bbox);
+ //cairo_surface_write_to_png( s, "cairo.png" );
+
cairo_surface_flush(s);
cairo_surface_destroy(s);
@@ -861,6 +872,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
document->getRoot()->invoke_hide(dkey);
}
+ // {
+ // // Dump data to png
+ // cairo_surface_t *s = cairo_image_surface_create_for_data(
+ // px, CAIRO_FORMAT_ARGB32, width, height, stride);
+ // cairo_surface_write_to_png( s, "cairo2.png" );
+ // std::cout << " Wrote cairo2.png" << std::endl;
+ // }
+
guchar *trace_px = g_new(guchar, width * height);
memset(trace_px, 0x00, width * height);
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index 34934f75b..6b019ad2a 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -26,7 +26,14 @@
#include "style.h"
#include "document-private.h"
+#include "document-undo.h"
+#include "desktop.h"
#include "desktop-style.h"
+#include "desktop-handles.h"
+#include "event-context.h"
+#include "selection.h"
+#include "verbs.h"
+#include <glibmm/i18n.h>
#include "sp-gradient-reference.h"
#include "sp-gradient-vector.h"
@@ -36,6 +43,7 @@
#include "sp-stop.h"
#include "widgets/gradient-vector.h"
#include "gradient-drag.h"
+#include "gradient-chemistry.h"
#include "sp-text.h"
#include "sp-tspan.h"
@@ -47,6 +55,7 @@
#define noSP_GR_VERBOSE
+using Inkscape::DocumentUndo;
namespace {
@@ -166,7 +175,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr
/**
Count how many times gr is used by the styles of o and its descendants
*/
-guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
+static guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
{
if (!o)
return 1;
@@ -200,8 +209,8 @@ guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
/**
* If gr has other users, create a new private; also check if gr links to vector, relink if not
*/
-SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector,
- SPGradientType type, SPObject *o)
+static SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector,
+ SPGradientType type, SPObject *o)
{
#ifdef SP_GR_VERBOSE
g_message("sp_gradient_fork_private_if_necessary(%p, %p, %d, %p)", gr, vector, type, o);
@@ -952,6 +961,44 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or
g_slist_free (child_objects);
}
+void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke)
+{
+#ifdef SP_GR_VERBOSE
+ g_message("sp_item_gradient_invert_vector_color(%p, %d)", item, fill_or_stroke);
+#endif
+ SPGradient *gradient = getGradient(item, fill_or_stroke);
+ if (!gradient || !SP_IS_GRADIENT(gradient))
+ return;
+
+ SPGradient *vector = gradient->getVector();
+ if (!vector) // orphan!
+ return;
+
+ vector = sp_gradient_fork_vector_if_necessary (vector);
+ if ( gradient != vector && gradient->ref->getObject() != vector ) {
+ sp_gradient_repr_set_link(gradient->getRepr(), vector);
+ }
+
+ for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) {
+ if (SP_IS_STOP(child)) {
+ guint32 color = sp_stop_get_rgba32(SP_STOP(child));
+ //g_message("Stop color %d", color);
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c),
+ SP_RGBA32_U_COMPOSE(
+ (255 - SP_RGBA32_R_U(color)),
+ (255 - SP_RGBA32_G_U(color)),
+ (255 - SP_RGBA32_B_U(color)),
+ SP_RGBA32_A_U(color)
+ )
+ );
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ sp_repr_css_set_property (css, "stop-color", c);
+ sp_repr_css_change(child->getRepr(), css, "style");
+ sp_repr_css_attr_unref (css);
+ }
+ }
+}
/**
Set the position of point point_type of the gradient applied to item (either fill_or_stroke) to
@@ -1507,7 +1554,62 @@ SPGradient *sp_gradient_vector_for_object( SPDocument *const doc, SPDesktop *con
return sp_document_default_gradient_vector( doc, color, singleStop );
}
+void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke)
+{
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+
+ for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
+ sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke);
+ }
+
+ // we did an undoable action
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT,
+ _("Invert gradient colors"));
+}
+
+void sp_gradient_reverse_selected_gradients(SPDesktop *desktop)
+{
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ SPEventContext *ev = sp_desktop_event_context(desktop);
+ if (!ev) {
+ return;
+ }
+
+ GrDrag *drag = ev->get_drag();
+
+ // First try selected dragger
+ if (drag && drag->selected) {
+ drag->selected_reverse_vector();
+ } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients)
+ for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
+ sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL);
+ sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE);
+ }
+ }
+
+ // we did an undoable action
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT,
+ _("Reverse gradient"));
+}
+
+void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id)
+{
+ SPDocument *doc = desktop ? desktop->doc() : 0;
+
+ if (doc) {
+ const GSList *gradients = doc->getResourceList("gradient");
+ for (const GSList *item = gradients; item; item = item->next) {
+ SPGradient* grad = SP_GRADIENT(item->data);
+ if ( id == grad->getId() ) {
+ grad->setSwatch(false);
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT,
+ _("Delete swatch"));
+ break;
+ }
+ }
+ }
+}
/*
Local Variables:
mode:c++
diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h
index 2f3ea4303..66a8e5281 100644
--- a/src/gradient-chemistry.h
+++ b/src/gradient-chemistry.h
@@ -70,6 +70,11 @@ SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_s
void sp_gradient_transform_multiply(SPGradient *gradient, Geom::Affine postmul, bool set);
+void sp_gradient_reverse_selected_gradients(SPDesktop *desktop);
+
+void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke);
+
+void sp_gradient_unset_swatch(SPDesktop *desktop, std::string id);
/**
* Fetches either the fill or the stroke gradient from the given item.
@@ -97,6 +102,7 @@ void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, guint
guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke);
void sp_item_gradient_edit_stop(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke);
void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or_stroke);
+void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fill_or_stroke);
#endif // SEEN_SP_GRADIENT_CHEMISTRY_H
diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp
index aa8c8b929..231490771 100644
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -266,7 +266,7 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Poi
return close;
}
-std::vector<Geom::Point>
+static std::vector<Geom::Point>
sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSList **next_stops)
{
std::vector<Geom::Point> coords;
@@ -419,7 +419,7 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc)
g_slist_free (new_stops);
}
-double sqr(double x) {return x*x;}
+static double sqr(double x) {return x*x;}
static void
sp_gradient_simplify(SPGradientContext *rc, double tolerance)
@@ -837,18 +837,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
case GDK_KEY_r:
case GDK_KEY_R:
if (MOD__SHIFT_ONLY) {
- // First try selected dragger
- if (drag && drag->selected) {
- drag->selected_reverse_vector();
- } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients)
- for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
- sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL);
- sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE);
- }
- }
- // we did an undoable action
- DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
- _("Invert gradient"));
+ sp_gradient_reverse_selected_gradients(desktop);
ret = TRUE;
}
break;
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index c72e47350..904c3b349 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -132,7 +132,7 @@ static void gr_drag_sel_modified(Inkscape::Selection */*selection*/, guint /*fla
* skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if
* any.
*/
-int gr_drag_style_query(SPStyle *style, int property, gpointer data)
+static int gr_drag_style_query(SPStyle *style, int property, gpointer data)
{
GrDrag *drag = (GrDrag *) data;
@@ -2080,28 +2080,33 @@ void GrDrag::updateDraggers()
if (style && (style->fill.isPaintserver())) {
SPPaintServer *server = style->getFillPaintServer();
- if ( server && server->isSolid() ) {
- // Suppress "gradientness" of solid paint
- } else if ( SP_IS_LINEARGRADIENT(server) ) {
- addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL );
- } else if ( SP_IS_RADIALGRADIENT(server) ) {
- addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL );
- } else if ( SP_IS_MESHGRADIENT(server) ) {
- addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL );
+ if ( server && SP_IS_GRADIENT( server ) ) {
+ if ( server->isSolid()
+ || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) {
+ // Suppress "gradientness" of solid paint
+ } else if ( SP_IS_LINEARGRADIENT(server) ) {
+ addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL );
+ } else if ( SP_IS_RADIALGRADIENT(server) ) {
+ addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL );
+ } else if ( SP_IS_MESHGRADIENT(server) ) {
+ addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL );
+ }
}
-
}
if (style && (style->stroke.isPaintserver())) {
SPPaintServer *server = style->getStrokePaintServer();
- if ( server && server->isSolid() ) {
- // Suppress "gradientness" of solid paint
- } else if ( SP_IS_LINEARGRADIENT(server) ) {
- addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE );
- } else if ( SP_IS_RADIALGRADIENT(server) ) {
- addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE );
- } else if ( SP_IS_MESHGRADIENT(server) ) {
- addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE );
+ if ( server && SP_IS_GRADIENT( server ) ) {
+ if ( server->isSolid()
+ || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) {
+ // Suppress "gradientness" of solid paint
+ } else if ( SP_IS_LINEARGRADIENT(server) ) {
+ addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE );
+ } else if ( SP_IS_RADIALGRADIENT(server) ) {
+ addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE );
+ } else if ( SP_IS_MESHGRADIENT(server) ) {
+ addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE );
+ }
}
}
}
@@ -2145,58 +2150,61 @@ void GrDrag::updateLines()
if (style && (style->fill.isPaintserver())) {
SPPaintServer *server = item->style->getFillPaintServer();
- if ( server && server->isSolid() ) {
- // Suppress "gradientness" of solid paint
- } else if ( SP_IS_LINEARGRADIENT(server) ) {
- addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
- } else if ( SP_IS_RADIALGRADIENT(server) ) {
- Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL);
- addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
- addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
- } else if ( SP_IS_MESHGRADIENT(server) ) {
-
- SPMeshGradient *mg = SP_MESHGRADIENT(server);
-
- guint rows = mg->array.patch_rows();
- guint columns = mg->array.patch_columns();
- for ( guint i = 0; i < rows; ++i ) {
- for ( guint j = 0; j < columns; ++j ) {
-
- std::vector<Geom::Point> h;
-
- SPMeshPatchI patch( &(mg->array.nodes), i, j );
-
- // Top line
- h = patch.getPointsForSide( 0 );
- for( guint p = 0; p < 4; ++p ) {
- h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
- }
- addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
-
- // Right line
- if( j == columns - 1 ) {
- h = patch.getPointsForSide( 1 );
+ if ( server && SP_IS_GRADIENT( server ) ) {
+ if ( server->isSolid()
+ || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) {
+ // Suppress "gradientness" of solid paint
+ } else if ( SP_IS_LINEARGRADIENT(server) ) {
+ addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
+ } else if ( SP_IS_RADIALGRADIENT(server) ) {
+ Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL);
+ addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
+ addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL);
+ } else if ( SP_IS_MESHGRADIENT(server) ) {
+
+ SPMeshGradient *mg = SP_MESHGRADIENT(server);
+
+ guint rows = mg->array.patch_rows();
+ guint columns = mg->array.patch_columns();
+ for ( guint i = 0; i < rows; ++i ) {
+ for ( guint j = 0; j < columns; ++j ) {
+
+ std::vector<Geom::Point> h;
+
+ SPMeshPatchI patch( &(mg->array.nodes), i, j );
+
+ // Top line
+ h = patch.getPointsForSide( 0 );
for( guint p = 0; p < 4; ++p ) {
h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
}
addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
- }
- // Bottom line
- if( i == rows - 1 ) {
- h = patch.getPointsForSide( 2 );
+ // Right line
+ if( j == columns - 1 ) {
+ h = patch.getPointsForSide( 1 );
+ for( guint p = 0; p < 4; ++p ) {
+ h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
+ }
+ addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
+ }
+
+ // Bottom line
+ if( i == rows - 1 ) {
+ h = patch.getPointsForSide( 2 );
+ for( guint p = 0; p < 4; ++p ) {
+ h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
+ }
+ addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
+ }
+
+ // Left line
+ h = patch.getPointsForSide( 3 );
for( guint p = 0; p < 4; ++p ) {
h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
}
addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
}
-
- // Left line
- h = patch.getPointsForSide( 3 );
- for( guint p = 0; p < 4; ++p ) {
- h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
- }
- addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL );
}
}
}
@@ -2204,61 +2212,64 @@ void GrDrag::updateLines()
if (style && (style->stroke.isPaintserver())) {
SPPaintServer *server = item->style->getStrokePaintServer();
- if ( server && server->isSolid() ) {
- // Suppress "gradientness" of solid paint
- } else if ( SP_IS_LINEARGRADIENT(server) ) {
- addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
- } else if ( SP_IS_RADIALGRADIENT(server) ) {
- Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE);
- addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
- addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
- } else if ( SP_IS_MESHGRADIENT(server) ) {
-
- // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE.
- SPMeshGradient *mg = SP_MESHGRADIENT(server);
-
- guint rows = mg->array.patch_rows();
- guint columns = mg->array.patch_columns();
- for ( guint i = 0; i < rows; ++i ) {
- for ( guint j = 0; j < columns; ++j ) {
-
- std::vector<Geom::Point> h;
-
- SPMeshPatchI patch( &(mg->array.nodes), i, j );
-
- // Top line
- h = patch.getPointsForSide( 0 );
- for( guint p = 0; p < 4; ++p ) {
- h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
- }
- addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
-
- // Right line
- if( j == columns - 1 ) {
- h = patch.getPointsForSide( 1 );
+ if ( server && SP_IS_GRADIENT( server ) ) {
+ if ( server->isSolid()
+ || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) {
+ // Suppress "gradientness" of solid paint
+ } else if ( SP_IS_LINEARGRADIENT(server) ) {
+ addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
+ } else if ( SP_IS_RADIALGRADIENT(server) ) {
+ Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE);
+ addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
+ addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE);
+ } else if ( SP_IS_MESHGRADIENT(server) ) {
+
+ // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE.
+ SPMeshGradient *mg = SP_MESHGRADIENT(server);
+
+ guint rows = mg->array.patch_rows();
+ guint columns = mg->array.patch_columns();
+ for ( guint i = 0; i < rows; ++i ) {
+ for ( guint j = 0; j < columns; ++j ) {
+
+ std::vector<Geom::Point> h;
+
+ SPMeshPatchI patch( &(mg->array.nodes), i, j );
+
+ // Top line
+ h = patch.getPointsForSide( 0 );
for( guint p = 0; p < 4; ++p ) {
h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
}
addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
- }
- // Bottom line
- if( i == rows - 1 ) {
- h = patch.getPointsForSide( 2 );
+ // Right line
+ if( j == columns - 1 ) {
+ h = patch.getPointsForSide( 1 );
+ for( guint p = 0; p < 4; ++p ) {
+ h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
+ }
+ addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
+ }
+
+ // Bottom line
+ if( i == rows - 1 ) {
+ h = patch.getPointsForSide( 2 );
+ for( guint p = 0; p < 4; ++p ) {
+ h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
+ }
+ addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
+ }
+
+ // Left line
+ h = patch.getPointsForSide( 3 );
for( guint p = 0; p < 4; ++p ) {
h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
}
addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
}
-
- // Left line
- h = patch.getPointsForSide( 3 );
- for( guint p = 0; p < 4; ++p ) {
- h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine();
- }
- addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE );
- }
- }
+ }
+ }
}
}
}
diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index 4bab3aeb2..c92a5c22f 100644
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
@@ -134,8 +134,13 @@ public: // FIXME: make more of this private!
bool hasSelection() {return (selected != NULL);}
guint numSelected() {return (selected? g_list_length(selected) : 0);}
guint numDraggers() {return (draggers? g_list_length(draggers) : 0);}
- guint singleSelectedDraggerNumDraggables() {return (selected? g_slist_length(((GrDragger *) selected->data)->draggables) : 0);}
- guint singleSelectedDraggerSingleDraggableType() {return (selected? ((GrDraggable *) ((GrDragger *) selected->data)->draggables->data)->point_type : 0);}
+
+ guint singleSelectedDraggerNumDraggables() {
+ return (selected? g_slist_length(( static_cast<GrDragger *>(selected->data))->draggables) : 0);
+ }
+
+ guint singleSelectedDraggerSingleDraggableType() {
+ return (selected? (static_cast<GrDraggable*>((static_cast<GrDragger*>(selected->data))->draggables->data))->point_type : 0);}
// especially the selection must be private, fix gradient-context to remove direct access to it
GList *selected; // list of GrDragger*
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert
index 0efb5d6ce..2be40e0e0 100644
--- a/src/helper/Makefile_insert
+++ b/src/helper/Makefile_insert
@@ -12,7 +12,6 @@ ink_common_sources += \
helper/geom-nodetype.h \
helper/gnome-utils.cpp \
helper/gnome-utils.h \
- helper/helper-forward.h \
helper/png-write.cpp \
helper/png-write.h \
helper/sp-marshal.cpp \
diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp
index aa70dd1a2..d0bcaf8cd 100644
--- a/src/helper/gnome-utils.cpp
+++ b/src/helper/gnome-utils.cpp
@@ -16,6 +16,8 @@
#include <ctype.h>
#include <glib.h>
+#include "gnome-utils.h"
+
/**
* gnome_uri_list_extract_uris:
* @uri_list: an uri-list in the standard format.
diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp
index 902aebdeb..a12fa377a 100644
--- a/src/helper/stock-items.cpp
+++ b/src/helper/stock-items.cpp
@@ -33,7 +33,7 @@
#include "inkscape.h"
#include "io/sys.h"
-
+#include "stock-items.h"
@@ -199,6 +199,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock)
SPDocument *doc = sp_desktop_document(desktop);
SPDefs *defs = doc->getDefs();
if (!defs) {
+ g_free(base);
return NULL;
}
SPObject *object = NULL;
diff --git a/src/helper/units.cpp b/src/helper/units.cpp
index 4f5443e72..1593fc131 100644
--- a/src/helper/units.cpp
+++ b/src/helper/units.cpp
@@ -34,12 +34,12 @@
* calls sp_unit_table_sane) to ensure that the two are in sync.
*/
SPUnit const sp_units[] = {
- {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""},
+ {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, SP_NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""},
{SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")},
{SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")},
{SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")},
/* You can add new elements from this point forward */
- {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")},
+ {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, SP_NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")},
{SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")},
{SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")},
{SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit
@@ -47,9 +47,9 @@ SPUnit const sp_units[] = {
{SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")},
/* Volatiles do not have default, so there are none here */
// TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
- {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")},
+ {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")},
// TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
- {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")},
+ {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")},
};
#define sp_num_units G_N_ELEMENTS(sp_units)
@@ -83,18 +83,16 @@ sp_unit_get_plural (SPUnit const *unit)
return unit->plural;
}
-SPMetric
-sp_unit_get_metric(SPUnit const *unit)
+SPMetric sp_unit_get_metric(SPUnit const *unit)
{
- g_return_val_if_fail(unit != NULL, NONE);
+ g_return_val_if_fail(unit != NULL, SP_NONE);
return unit->metric;
}
-guint
-sp_unit_get_svg_unit(SPUnit const *unit)
+guint sp_unit_get_svg_unit(SPUnit const *unit)
{
- g_return_val_if_fail(unit != NULL, NONE);
+ g_return_val_if_fail(unit != NULL, SP_NONE);
return unit->svg_unit;
}
diff --git a/src/ink-action.cpp b/src/ink-action.cpp
index 4c6008b01..c79cebd1e 100644
--- a/src/ink-action.cpp
+++ b/src/ink-action.cpp
@@ -458,8 +458,10 @@ static void ink_toggle_action_update_icon( InkToggleAction* action )
GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
- gtk_widget_show_all( child );
- gtk_tool_button_set_icon_widget( button, child );
+ GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
+ gtk_container_add( GTK_CONTAINER(align), child );
+ gtk_widget_show_all( align );
+ gtk_tool_button_set_icon_widget( button, align );
}
}
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp
index 99a48ae5d..14f8f83a6 100644
--- a/src/ink-comboboxentry-action.cpp
+++ b/src/ink-comboboxentry-action.cpp
@@ -789,7 +789,7 @@ static gboolean match_selected_cb( GtkEntryCompletion* /*widget*/, GtkTreeModel*
return false;
}
-void ink_comboboxentry_action_defocus( Ink_ComboBoxEntry_Action* action )
+static void ink_comboboxentry_action_defocus( Ink_ComboBoxEntry_Action* action )
{
if ( action->focusWidget ) {
gtk_widget_grab_focus( action->focusWidget );
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 8548b398f..fc823f8b7 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -309,8 +309,24 @@ static gint inkscape_autosave(gpointer)
GDir *autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL);
if( !autosave_dir_ptr ){
- g_warning("Cannot open autosave directory!");
- return TRUE;
+ // Try to create the autosave directory if it doesn't exist
+ if (g_mkdir(autosave_dir.c_str(), 0755)) {
+ // the creation failed
+ Glib::ustring msg = Glib::ustring::compose(
+ _("Autosave failed! Cannot create directory %1."), Glib::filename_to_utf8(autosave_dir));
+ g_warning("%s", msg.c_str());
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str());
+ return TRUE;
+ }
+ // Try to read dir again
+ autosave_dir_ptr = g_dir_open(autosave_dir.c_str(), 0, NULL);
+ if( !autosave_dir_ptr ){
+ Glib::ustring msg = Glib::ustring::compose(
+ _("Autosave failed! Cannot open directory %1."), Glib::filename_to_utf8(autosave_dir));
+ g_warning("%s", msg.c_str());
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg.c_str());
+ return TRUE;
+ }
}
time_t sptime = time(NULL);
@@ -1065,7 +1081,7 @@ inkscape_find_desktop_by_dkey (unsigned int dkey)
-unsigned int
+static unsigned int
inkscape_maximum_dkey()
{
unsigned int dkey = 0;
@@ -1081,7 +1097,7 @@ inkscape_maximum_dkey()
-SPDesktop *
+static SPDesktop *
inkscape_next_desktop ()
{
SPDesktop *d = NULL;
@@ -1112,7 +1128,7 @@ inkscape_next_desktop ()
-SPDesktop *
+static SPDesktop *
inkscape_prev_desktop ()
{
SPDesktop *d = NULL;
@@ -1254,6 +1270,10 @@ inkscape_active_document (void)
{
if (SP_ACTIVE_DESKTOP) {
return sp_desktop_document (SP_ACTIVE_DESKTOP);
+ } else if (!inkscape->document_set.empty()) {
+ // If called from the command line there will be no desktop
+ // So 'fall back' to take the first listed document in the Inkscape instance
+ return inkscape->document_set.begin()->first;
}
return NULL;
diff --git a/src/inkview.cpp b/src/inkview.cpp
index 3831cab95..ee93b4134 100644
--- a/src/inkview.cpp
+++ b/src/inkview.cpp
@@ -337,44 +337,37 @@ sp_svgview_ctrlwin_delete (GtkWidget */*widget*/, GdkEvent */*event*/, void */*d
return FALSE;
}
-static GtkWidget *
-sp_svgview_control_show (struct SPSlideShow *ss)
+static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss)
{
if (!ctrlwin) {
- GtkWidget *t, *b;
- ctrlwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_transient_for (GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window));
- g_signal_connect (G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss);
- g_signal_connect (G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL);
- t = gtk_table_new (1, 4, TRUE);
- gtk_container_add ((GtkContainer *) ctrlwin, t);
- b = gtk_button_new_from_stock (GTK_STOCK_GOTO_FIRST);
- gtk_table_attach ((GtkTable *) t, b, 0, 1, 0, 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- 0, 0);
- g_signal_connect ((GObject *) b, "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
- b = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
- gtk_table_attach ((GtkTable *) t, b, 1, 2, 0, 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- 0, 0);
- g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
- b = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
- gtk_table_attach ((GtkTable *) t, b, 2, 3, 0, 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- 0, 0);
- g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
- b = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
- gtk_table_attach ((GtkTable *) t, b, 3, 4, 0, 1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
- 0, 0);
- g_signal_connect (G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
- gtk_widget_show_all (ctrlwin);
+ ctrlwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_resizable(GTK_WINDOW(ctrlwin), FALSE);
+ gtk_window_set_transient_for(GTK_WINDOW(ctrlwin), GTK_WINDOW(ss->window));
+ g_signal_connect(G_OBJECT (ctrlwin), "key_press_event", (GCallback) sp_svgview_main_key_press, ss);
+ g_signal_connect(G_OBJECT (ctrlwin), "delete_event", (GCallback) sp_svgview_ctrlwin_delete, NULL);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *t = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
+#else
+ GtkWidget *t = gtk_hbutton_box_new();
+#endif
+
+ gtk_container_add(GTK_CONTAINER(ctrlwin), t);
+ GtkWidget *b = gtk_button_new_from_stock(GTK_STOCK_GOTO_FIRST);
+ gtk_container_add(GTK_CONTAINER(t), b);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss);
+ b = gtk_button_new_from_stock(GTK_STOCK_GO_BACK);
+ gtk_container_add(GTK_CONTAINER(t), b);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss);
+ b = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+ gtk_container_add(GTK_CONTAINER(t), b);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss);
+ b = gtk_button_new_from_stock(GTK_STOCK_GOTO_LAST);
+ gtk_container_add(GTK_CONTAINER(t), b);
+ g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_last_cb, ss);
+ gtk_widget_show_all(ctrlwin);
} else {
- gtk_window_present ((GtkWindow *) ctrlwin);
+ gtk_window_present(GTK_WINDOW(ctrlwin));
}
return NULL;
diff --git a/src/interface.cpp b/src/interface.cpp
index 710211fe7..823119953 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -59,6 +59,7 @@
#include "dialogs/dialog-events.h"
#include "message-context.h"
#include "ui/uxmanager.h"
+#include "ui/clipboard.h"
#include "display/sp-canvas.h"
#include "color.h"
@@ -79,6 +80,7 @@
// #include "inkscape.h"
#include "ui/dialog/dialog-manager.h"
// #include "../xml/repr.h"
+#include "ui/dialog/layer-properties.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@@ -96,6 +98,7 @@ typedef enum {
APP_X_INKY_COLOR,
APP_X_COLOR,
APP_OSWB_COLOR,
+ APP_X_INK_PASTE
} ui_drop_target_info;
static GtkTargetEntry ui_drop_target_entries [] = {
@@ -108,7 +111,8 @@ static GtkTargetEntry ui_drop_target_entries [] = {
{(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
{(gchar *)"application/x-oswb-color", 0, APP_OSWB_COLOR },
- {(gchar *)"application/x-color", 0, APP_X_COLOR }
+ {(gchar *)"application/x-color", 0, APP_X_COLOR },
+ {(gchar *)"application/x-inkscape-paste", 0, APP_X_INK_PASTE }
};
static GtkTargetEntry *completeDropTargets = 0;
@@ -322,6 +326,7 @@ sp_ui_close_view(GtkWidget */*widget*/)
SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true );
dt->change_document(doc);
sp_namedview_window_from_document(dt);
+ sp_namedview_update_layers_from_document(dt);
return;
}
@@ -394,7 +399,7 @@ sp_ui_menu_deselect(gpointer object)
/**
* Creates and attaches a scaled icon to the given menu item.
*/
-void
+static void
sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name )
{
static bool iconsInjected = false;
@@ -525,7 +530,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb
} // end of sp_ui_menu_append_item_from_verb
-static Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view )
+Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view )
{
Glib::ustring prefPath;
@@ -552,7 +557,7 @@ checkitem_toggled(GtkCheckMenuItem *menuitem, gpointer user_data)
sp_ui_menu_activate(menuitem, action);
} else if (pref) {
- // The Show/Hide menu items without actions
+ // All check menu items should have actions now, but just in case
Glib::ustring pref_path = getLayoutPrefPath( view );
pref_path += pref;
pref_path += "/state";
@@ -594,19 +599,16 @@ static gboolean checkitem_update(GtkWidget *widget, GdkEventExpose * /*event*/,
if (!strcmp(action->id, "ToggleGrid")) {
ison = dt->gridsEnabled();
}
- if (!strcmp(action->id, "ToggleGuides")) {
+ else if (!strcmp(action->id, "ToggleGuides")) {
ison = dt->namedview->getGuides();
}
- if (!strcmp(action->id, "ToggleSnapGlobal")) {
+ else if (!strcmp(action->id, "ToggleSnapGlobal")) {
ison = dt->namedview->getSnapGlobal();
}
- if (!strcmp(action->id, "ViewCmsToggle")) {
+ else if (!strcmp(action->id, "ViewCmsToggle")) {
ison = dt->colorProfAdjustEnabled();
}
- if (!strcmp(action->id, "ToggleRulers")) {
- ison = getViewStateFromPref(view, pref);
- }
- if (!strcmp(action->id, "ToggleScrollbars")) {
+ else {
ison = getViewStateFromPref(view, pref);
}
} else if (pref) {
@@ -684,7 +686,7 @@ static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/,
return FALSE;
}
-void
+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)
@@ -776,96 +778,144 @@ sp_file_new_from_template(GtkWidget */*widget*/, gchar const *uri)
sp_file_new(uri);
}
-void
-sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view)
-{
- std::list<gchar *> sources;
- sources.push_back( profile_path("templates") ); // first try user's local dir
- sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir
- // Use this loop to iterate through a list of possible document locations.
- while (!sources.empty()) {
- gchar *dirname = sources.front();
+static bool
+compare_file_basenames(gchar const *a, gchar const *b) {
+ bool rc;
+ gchar *ba, *bb;
- if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
- GError *err = 0;
- GDir *dir = g_dir_open(dirname, 0, &err);
+ bool sort_by_fullname = true; // Sort by full name (including path) or just filename
+ if (sort_by_fullname) {
+ ba = g_strdup(a);
+ bb = g_strdup(b);
+ } else {
+ ba = g_path_get_basename(a);
+ bb = g_path_get_basename(b);
+ }
- if (dir) {
- for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) {
- if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) {
- continue; // skip non-svg files
- }
+ gchar *fa = g_filename_to_utf8(ba, -1, NULL, NULL, NULL);
+ gchar *fb = g_filename_to_utf8(bb, -1, NULL, NULL, NULL);
+ g_free(ba);
+ g_free(bb);
- {
- gchar *basename = g_path_get_basename(file);
- if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) {
- g_free(basename);
- basename = 0;
- continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already
- }
+ rc = g_utf8_collate(fa, fb) < 0;
+
+ g_free(fa);
+ g_free(fb);
+
+ return rc;
+}
+
+static void
+sp_menu_get_svg_filenames_from_dir(gchar const *dirname, std::list<gchar const*> *files)
+{
+ if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
+ GError *err = 0;
+ GDir *dir = g_dir_open(dirname, 0, &err);
+
+ if (dir) {
+ for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) {
+ if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) {
+ continue; // skip non-svg files
+ }
+
+ {
+ gchar *basename = g_path_get_basename(file);
+ if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) {
g_free(basename);
basename = 0;
+ continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already
}
-
- gchar const *filepath = g_build_filename(dirname, file, NULL);
- gchar *dupfile = g_strndup(file, strlen(file) - 4);
- gchar *filename = g_filename_to_utf8(dupfile, -1, NULL, NULL, NULL);
- g_free(dupfile);
- GtkWidget *item = gtk_menu_item_new_with_label(filename);
- g_free(filename);
-
- gtk_widget_show(item);
- // how does "filepath" ever get freed?
- g_signal_connect(G_OBJECT(item),
- "activate",
- G_CALLBACK(sp_file_new_from_template),
- (gpointer) filepath);
-
- if (view) {
- // set null tip for now; later use a description from the template file
- g_object_set_data(G_OBJECT(item), "view", (gpointer) view);
- g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) NULL );
- g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL);
- }
-
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ g_free(basename);
+ basename = 0;
}
- g_dir_close(dir);
+
+ gchar const *filepath = g_build_filename(dirname, file, NULL);
+ files->push_front(filepath);
}
+ g_dir_close(dir);
+ }
+ }
+
+ files->sort(compare_file_basenames);
+}
+
+static void
+sp_menu_add_filenames_to_menu(GtkWidget *menu, Inkscape::UI::View::View *view, std::list<gchar const*> *files)
+{
+ if (!files->empty()) {
+ GtkWidget *sep = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
+ }
+
+ for(std::list<gchar const*>::iterator it=files->begin(); it != files->end(); ++it) {
+ gchar const *filepath = *it;
+ gchar const *file = g_path_get_basename(filepath);
+ gchar *dupfile = g_strndup(file, strlen(file) - 4);
+ gchar *filename = g_filename_to_utf8(dupfile, -1, NULL, NULL, NULL);
+ g_free(dupfile);
+
+ GtkWidget *item = gtk_menu_item_new_with_label(filename);
+ g_free(filename);
+
+ gtk_widget_show(item);
+ // how does "filepath" ever get freed?
+ g_signal_connect(G_OBJECT(item),
+ "activate",
+ G_CALLBACK(sp_file_new_from_template),
+ (gpointer) filepath);
+
+ if (view) {
+ // set null tip for now; later use a description from the template file
+ g_object_set_data(G_OBJECT(item), "view", (gpointer) view);
+ g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) NULL );
+ g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL);
}
- // toss the dirname
- g_free(dirname);
- sources.pop_front();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
+
}
+static void
+sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view)
+{
+ // user's local dir
+ std::list<gchar const*> userfiles;
+ sp_menu_get_svg_filenames_from_dir(profile_path("templates"), &userfiles);
+ sp_menu_add_filenames_to_menu(menu, view, &userfiles);
-void
+ // system templates dir
+ std::list<gchar const*> templatefiles;
+ sp_menu_get_svg_filenames_from_dir(INKSCAPE_TEMPLATESDIR, &templatefiles);
+ sp_menu_add_filenames_to_menu(menu, view, &templatefiles);
+
+}
+
+static void
sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view)
{
//sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu",
// checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("_Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands",
- checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("Sn_ap Controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox",
- checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("T_ool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel",
- checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox",
- checkitem_toggled, checkitem_update, 0);
+ sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "commands",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_COMMANDS_TOOLBAR));
+ sp_ui_menu_append_check_item_from_verb(m, view,NULL, NULL, "snaptoolbox",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_SNAP_TOOLBAR));
+ sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "toppanel",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_TOOL_TOOLBAR));
+ sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "toolbox",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_TOOLBOX));
sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "rulers",
checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_RULERS));
sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "scrollbars",
checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_SCROLLBARS));
- sp_ui_menu_append_check_item_from_verb(m, view, _("_Palette"), _("Show or hide the color palette"), "panels",
- checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("_Statusbar"), _("Show or hide the statusbar (at the bottom of the window)"), "statusbar",
- checkitem_toggled, checkitem_update, 0);
+ sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "panels",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_PALETTE));
+ sp_ui_menu_append_check_item_from_verb(m, view, NULL, NULL, "statusbar",
+ checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_STATUSBAR));
}
-void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view)
+static void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view)
{
gchar const* data[] = {
C_("Interface setup", "Default"), _("Default interface setup"),
@@ -932,7 +982,7 @@ private:
* @param menu Menu to be added to
* @param view The View that this menu is being built for
*/
-void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view)
+static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view)
{
if (menus == NULL) return;
if (menu == NULL) return;
@@ -1383,6 +1433,13 @@ sp_ui_drag_data_received(GtkWidget *widget,
break;
}
+ case APP_X_INK_PASTE: {
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ cm->paste(desktop);
+ DocumentUndo::done( doc, SP_VERB_NONE, _("Drop Symbol") );
+ break;
+ }
+
case PNG_DATA:
case JPEG_DATA:
case IMAGE_DATA: {
@@ -1822,6 +1879,16 @@ void ContextMenu::MakeItemMenu (void)
mi->show();
select_same_submenu->append(*mi);
+ /* Move to layer */
+ mi = manage(new Gtk::MenuItem(_("_Move to layer ..."),1));
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ } else {
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemMoveTo));
+ }
+ mi->show();
+ append(*mi);
+
/* Create link */
mi = manage(new Gtk::MenuItem(_("Create _Link"),1));
mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ItemCreateLink));
@@ -1937,6 +2004,13 @@ void ContextMenu::ItemSelectThis(void)
_desktop->selection->set(_item);
}
+void ContextMenu::ItemMoveTo(void)
+{
+ Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(_desktop, _desktop->currentLayer());
+}
+
+
+
void ContextMenu::ItemCreateLink(void)
{
Inkscape::XML::Document *xml_doc = _desktop->doc()->getReprDoc();
@@ -2078,6 +2152,15 @@ void ContextMenu::MakeImageMenu (void)
mi->set_sensitive( FALSE );
}
+ /* Trace Bitmap */
+ mi = manage(new Gtk::MenuItem(_("_Trace Bitmap..."),1));
+ mi->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ImageTraceBitmap));
+ mi->show();
+ insert(*mi,positionOfLastDialog++);
+ if (_desktop->selection->isEmpty()) {
+ mi->set_sensitive(FALSE);
+ }
+
/* Embed image */
if (Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" )) {
mi = manage(new Gtk::MenuItem(C_("Context menu", "Embed Image")));
@@ -2189,6 +2272,12 @@ void ContextMenu::ImageEdit(void)
}
}
+void ContextMenu::ImageTraceBitmap(void)
+{
+ inkscape_dialogs_unhide();
+ _desktop->_dlg_mgr->showDialog("Trace");
+}
+
void ContextMenu::ImageEmbed(void)
{
if (_desktop->selection->isEmpty()) {
diff --git a/src/interface.h b/src/interface.h
index aa0281db3..2e9e7fc2e 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -81,6 +81,7 @@ GtkWidget *sp_ui_main_menubar (Inkscape::UI::View::View *view);
void sp_menu_append_recent_documents (GtkWidget *menu);
void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c);
+Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view );
/**
*
@@ -171,6 +172,7 @@ class ContextMenu : public Gtk::Menu
//callbacks for the context menu entries of an SP_TYPE_ITEM object
void ItemProperties(void);
void ItemSelectThis(void);
+ void ItemMoveTo(void);
void SelectSameFillStroke(void);
void SelectSameFillColor(void);
void SelectSameStrokeColor(void);
@@ -224,6 +226,11 @@ class ContextMenu : public Gtk::Menu
void ImageEmbed(void);
/**
+ * callback, is executed on clicking the "Trace Bitmap" menu entry
+ */
+ void ImageTraceBitmap(void);
+
+ /**
* callback, is executed on clicking the "Extract Image" menu entry
*/
void ImageExtract(void);
diff --git a/src/io/ftos.cpp b/src/io/ftos.cpp
index 658c768e8..d0764d86c 100644
--- a/src/io/ftos.cpp
+++ b/src/io/ftos.cpp
@@ -172,7 +172,7 @@ using namespace std;
// This routine counts from the end of a string like '10229000' to find the index
// of the first non-'0' character (5 would be returned for the above number.)
-int countDigs(char *p)
+static int countDigs(char *p)
{
int length =0;
while (*(p+length)!='\0') length++; // Count total length
@@ -186,7 +186,7 @@ int countDigs(char *p)
// is between 0 and 1. Returns 1 if v==0. Return value is positive for numbers
// greater than or equal to 1, negative for numbers less than 0.1, and zero for
// numbers between 0.1 and 1.
-int countLhsDigits(double v)
+static int countLhsDigits(double v)
{
if (v<0) v = -v; // Take abs value
else if (v==0) return 1; // Special case if v==0
diff --git a/src/io/sys.cpp b/src/io/sys.cpp
index 5f19ee5db..26c1993a7 100644
--- a/src/io/sys.cpp
+++ b/src/io/sys.cpp
@@ -239,6 +239,40 @@ bool Inkscape::IO::file_is_writable( char const *utf8name)
return success;
}
+/**Checks if directory of file exists, useful
+ * because inkscape doesn't create directories.*/
+bool Inkscape::IO::file_directory_exists( char const *utf8name ){
+ bool exists = true;
+
+ if ( utf8name) {
+ gchar *filename = NULL;
+ if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) {
+ /* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
+ If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
+ use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
+ to beginning of this function. */
+ filename = g_strdup(utf8name);
+ // Looks like g_get_home_dir isn't safe.
+ //g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
+ } else {
+ filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL );
+ }
+ if ( filename ) {
+ gchar *dirname = g_path_get_dirname(filename);
+ exists = Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS);
+ g_free(filename);
+ g_free(dirname);
+ filename = NULL;
+ dirname = NULL;
+ } else {
+ g_warning( "Unable to convert filename in IO:file_test" );
+ }
+ }
+
+ return exists;
+
+}
+
/** Wrapper around g_dir_open, but taking a utf8name as first argument. */
GDir *
Inkscape::IO::dir_open(gchar const *const utf8name, guint const flags, GError **const error)
diff --git a/src/io/sys.h b/src/io/sys.h
index fbfe4d4c4..78d25afa3 100644
--- a/src/io/sys.h
+++ b/src/io/sys.h
@@ -36,6 +36,8 @@ int file_open_tmp( std::string& name_used, const std::string& prefix );
bool file_test( char const *utf8name, GFileTest test );
+bool file_directory_exists( char const *utf8name );
+
bool file_is_writable( char const *utf8name);
GDir *dir_open(gchar const *utf8name, guint flags, GError **error);
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp
index cb8f29f46..75732f805 100644
--- a/src/knot-holder-entity.cpp
+++ b/src/knot-holder-entity.cpp
@@ -89,8 +89,12 @@ KnotHolderEntity::update_knot()
}
Geom::Point
-KnotHolderEntity::snap_knot_position(Geom::Point const &p)
+KnotHolderEntity::snap_knot_position(Geom::Point const &p, guint state)
{
+ if (state & GDK_SHIFT_MASK) { // Don't snap when shift-key is held
+ return p;
+ }
+
Geom::Affine const i2dt (item->i2dt_affine());
Geom::Point s = p * i2dt;
@@ -103,8 +107,12 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p)
}
Geom::Point
-KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint)
+KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, guint state)
{
+ if (state & GDK_SHIFT_MASK) { // Don't snap when shift-key is held
+ return p;
+ }
+
Geom::Affine const i2d (item->i2dt_affine());
Geom::Point s = p * i2d;
@@ -148,7 +156,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
// FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used.
- Geom::Point p_snapped = snap_knot_position(p);
+ Geom::Point p_snapped = snap_knot_position(p, state);
if ( state & GDK_CONTROL_MASK ) {
if (fabs((p - origin)[Geom::X]) > fabs((p - origin)[Geom::Y])) {
@@ -220,7 +228,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
// FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used.
- Geom::Point p_snapped = snap_knot_position(p);
+ Geom::Point p_snapped = snap_knot_position(p, state);
// get angle from current transform
gdouble theta = sp_pattern_extract_theta(pat);
diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h
index 58dc89bfd..09d70f8c9 100644
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
@@ -65,8 +65,8 @@ public:
void update_knot();
//private:
- Geom::Point snap_knot_position(Geom::Point const &p);
- Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint);
+ Geom::Point snap_knot_position(Geom::Point const &p, guint state);
+ Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, guint state);
SPKnot *knot;
SPItem *item;
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index 894758a97..c02d75d16 100644
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
@@ -159,53 +159,66 @@ void LayerManager::setCurrentLayer( SPObject* obj )
}
}
-void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify )
+/*
+ * Return a unique layer name similar to param label
+ * A unique name is made by substituting or appending the label's number suffix with
+ * the next unique larger number suffix not already used for any layer name
+ */
+Glib::ustring LayerManager::getNextLayerName( SPObject* obj, gchar const *label)
{
- Glib::ustring incoming( label ? label : "" );
+ Glib::ustring incoming( label ? label : "Layer 1" );
Glib::ustring result(incoming);
Glib::ustring base(incoming);
+ Glib::ustring split(" ");
guint startNum = 1;
- if (uniquify) {
+ gint pos = base.length()-1;
+ while (pos >= 0 && g_ascii_isdigit(base[pos])) {
+ pos-- ;
+ }
- Glib::ustring::size_type pos = base.rfind('#');
- if ( pos != Glib::ustring::npos ) {
- gchar* numpart = g_strdup(base.substr(pos+1).c_str());
- if ( numpart ) {
- gchar* endPtr = NULL;
- guint64 val = g_ascii_strtoull( numpart, &endPtr, 10);
- if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) {
- base.erase( pos );
- result = base;
- startNum = static_cast<int>(val);
- }
- g_free(numpart);
- }
+ gchar* numpart = g_strdup(base.substr(pos+1).c_str());
+ if ( numpart ) {
+ gchar* endPtr = NULL;
+ guint64 val = g_ascii_strtoull( numpart, &endPtr, 10);
+ if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) {
+ base.erase( pos+1);
+ result = incoming;
+ startNum = static_cast<int>(val);
+ split = "";
}
+ g_free(numpart);
+ }
- std::set<Glib::ustring> currentNames;
- GSList const *layers=_document->getResourceList("layer");
- SPObject *root=_desktop->currentRoot();
- if ( root ) {
- for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
- SPObject *layer=static_cast<SPObject *>(iter->data);
- if ( layer != obj ) {
- currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() );
- }
+ std::set<Glib::ustring> currentNames;
+ GSList const *layers=_document->getResourceList("layer");
+ SPObject *root=_desktop->currentRoot();
+ if ( root ) {
+ for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
+ SPObject *layer=static_cast<SPObject *>(iter->data);
+ if ( layer != obj ) {
+ currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() );
}
}
+ }
- // Not sure if we need to cap it, but we'll just be paranoid for the moment
- // Intentionally unsigned
- guint endNum = startNum + 3000;
- for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) {
- gchar* suffix = g_strdup_printf("#%d", i);
- result = base;
- result += suffix;
+ // Not sure if we need to cap it, but we'll just be paranoid for the moment
+ // Intentionally unsigned
+ guint endNum = startNum + 3000;
+ for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) {
+ result = Glib::ustring::format(base, split, i);
+ }
- g_free(suffix);
- }
+ return result;
+}
+void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify )
+{
+ Glib::ustring incoming( label ? label : "" );
+ Glib::ustring result(incoming);
+
+ if (uniquify) {
+ result = getNextLayerName(obj, label);
}
obj->setLabel( result.c_str() );
diff --git a/src/layer-manager.h b/src/layer-manager.h
index fbb22d405..1b69324d5 100644
--- a/src/layer-manager.h
+++ b/src/layer-manager.h
@@ -30,6 +30,7 @@ public:
void setCurrentLayer( SPObject* obj );
void renameLayer( SPObject* obj, gchar const *label, bool uniquify );
+ Glib::ustring getNextLayerName( SPObject* obj, gchar const *label);
sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) {
return _layer_changed_signal.connect(slot);
diff --git a/src/libavoid/makepath.cpp b/src/libavoid/makepath.cpp
index 4e15dbca9..774e0d7f5 100644
--- a/src/libavoid/makepath.cpp
+++ b/src/libavoid/makepath.cpp
@@ -82,7 +82,7 @@ class ANode
// it back into a heap) when getting the next node to examine. This way we
// get better complexity -- logarithmic pushs and pops to the heap.
//
-bool operator<(const ANode &a, const ANode &b)
+static bool operator<(const ANode &a, const ANode &b)
{
if (a.f != b.f)
{
diff --git a/src/libavoid/orthogonal.cpp b/src/libavoid/orthogonal.cpp
index e0a30b246..772fc9668 100644
--- a/src/libavoid/orthogonal.cpp
+++ b/src/libavoid/orthogonal.cpp
@@ -204,7 +204,7 @@ class ShiftSegment
};
typedef std::list<ShiftSegment> ShiftSegmentList;
-bool cmpShiftSegment(const ShiftSegment& u, const ShiftSegment& v)
+static bool cmpShiftSegment(const ShiftSegment& u, const ShiftSegment& v)
{
return u < v;
}
@@ -488,7 +488,7 @@ Event **events;
// Used for quicksort. Must return <0, 0, or >0.
-int compare_events(const void *a, const void *b)
+static int compare_events(const void *a, const void *b)
{
Event *ea = *(Event**) a;
Event *eb = *(Event**) b;
diff --git a/src/libcola/connected_components.cpp b/src/libcola/connected_components.cpp
index 0cf6ee45a..1afec55b4 100644
--- a/src/libcola/connected_components.cpp
+++ b/src/libcola/connected_components.cpp
@@ -39,7 +39,7 @@ namespace cola {
Rectangle* r;
};
// Depth first search traversal of graph to find connected component
- void dfs(Node* v,
+ static void dfs(Node* v,
list<Node*>& remaining,
Component* component,
map<unsigned,pair<Component*,unsigned> > &cmap) {
diff --git a/src/libcola/shortest_paths.cpp b/src/libcola/shortest_paths.cpp
index ebc2c93de..514721fb5 100644
--- a/src/libcola/shortest_paths.cpp
+++ b/src/libcola/shortest_paths.cpp
@@ -33,7 +33,7 @@ void floyd_warshall(
}
}
}
-void dijkstra_init(Node* vs, vector<Edge>& es, double* eweights) {
+static void dijkstra_init(Node* vs, vector<Edge>& es, double* eweights) {
for(unsigned i=0;i<es.size();i++) {
unsigned u=es[i].first, v=es[i].second;
vs[u].neighbours.push_back(&vs[v]);
@@ -42,7 +42,7 @@ void dijkstra_init(Node* vs, vector<Edge>& es, double* eweights) {
vs[v].nweights.push_back(eweights[i]);
}
}
-void dijkstra(
+static void dijkstra(
unsigned s,
unsigned n,
Node* vs,
diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp
index 0ecd82faa..650f41aac 100644
--- a/src/libcola/straightener.cpp
+++ b/src/libcola/straightener.cpp
@@ -109,7 +109,7 @@ namespace straightener {
Event(EventType t, Edge *e, double p) : type(t),v(NULL),e(e),pos(p) {};
};
Event **events;
- int compare_events(const void *a, const void *b) {
+ static int compare_events(const void *a, const void *b) {
Event *ea=*(Event**)a;
Event *eb=*(Event**)b;
if((ea->v!=NULL&&ea->v==eb->v)||(ea->e!=NULL&&ea->e==eb->e)) {
diff --git a/src/libcroco/cr-term.c b/src/libcroco/cr-term.c
index 63b39271b..d95c4979f 100644
--- a/src/libcroco/cr-term.c
+++ b/src/libcroco/cr-term.c
@@ -365,9 +365,9 @@ cr_term_to_string (CRTerm * a_this)
tmp_str = NULL;
}
- g_free (content);
- content = NULL;
}
+ g_free (content);
+ content = NULL;
g_string_append (str_buf, ")");
}
diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert
index 788df0673..3f5228a20 100644
--- a/src/libgdl/Makefile_insert
+++ b/src/libgdl/Makefile_insert
@@ -3,7 +3,6 @@
if WITH_EXT_GDL
EXTRA_DIST += \
- libgdl/gdl-tools.h \
libgdl/gdl-dock-object.h \
libgdl/gdl-dock-master.h \
libgdl/gdl-dock.h \
@@ -13,7 +12,6 @@ EXTRA_DIST += \
libgdl/gdl-dock-tablabel.h \
libgdl/gdl-dock-placeholder.h \
libgdl/gdl-dock-bar.h \
- libgdl/gdl-stock-icons.h \
libgdl/gdl-i18n.h \
libgdl/gdl-i18n.c \
libgdl/gdl-dock-object.c \
@@ -47,7 +45,6 @@ libgdl/clean:
rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS)
libgdl_libgdl_a_SOURCES = \
- libgdl/gdl-tools.h \
libgdl/gdl-dock-object.h \
libgdl/gdl-dock-master.h \
libgdl/gdl-dock.h \
@@ -57,7 +54,6 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-tablabel.h \
libgdl/gdl-dock-placeholder.h \
libgdl/gdl-dock-bar.h \
- libgdl/gdl-stock-icons.h \
libgdl/gdl-i18n.h \
libgdl/gdl-i18n.c \
libgdl/gdl-dock-object.c \
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 8de9d4795..ed1e1dc5c 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -22,13 +22,6 @@
#include "libnrtype/font-instance.h"
#include "util/unordered-containers.h"
-#if !PANGO_VERSION_CHECK(1,24,0)
-#define PANGO_WEIGHT_THIN static_cast<PangoWeight>(100)
-#define PANGO_WEIGHT_BOOK static_cast<PangoWeight>(380)
-#define PANGO_WEIGHT_MEDIUM static_cast<PangoWeight>(500)
-#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
-#endif
-
typedef INK_UNORDERED_MAP<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType;
// need to avoid using the size field
@@ -276,7 +269,7 @@ family_name_compare(char const *a, char const *b)
#endif
}
-void noop(...) {}
+static void noop(...) {}
//#define PANGO_DEBUG g_print
#define PANGO_DEBUG noop
@@ -285,7 +278,7 @@ void noop(...) {}
///////////////////// FontFactory
#ifndef USE_PANGO_WIN32
// the substitute function to tell fontconfig to enforce outline fonts
-void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/)
+static void FactorySubstituteFunc(FcPattern *pattern,gpointer /*data*/)
{
FcPatternAddBool(pattern, "FC_OUTLINE",FcTrue);
//char *fam = NULL;
diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp
index f8b2c3b9d..4ca8bf2a0 100644
--- a/src/libnrtype/FontInstance.cpp
+++ b/src/libnrtype/FontInstance.cpp
@@ -27,13 +27,6 @@
#include "livarot/Path.h"
#include "util/unordered-containers.h"
-#if !PANGO_VERSION_CHECK(1,24,0)
-#define PANGO_WEIGHT_THIN static_cast<PangoWeight>(100)
-#define PANGO_WEIGHT_BOOK static_cast<PangoWeight>(380)
-#define PANGO_WEIGHT_MEDIUM static_cast<PangoWeight>(500)
-#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
-#endif
-
struct font_style_hash : public std::unary_function<font_style, size_t> {
size_t operator()(font_style const &x) const;
diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp
index 07bf207c8..10310b4aa 100644
--- a/src/libnrtype/Layout-TNG-Input.cpp
+++ b/src/libnrtype/Layout-TNG-Input.cpp
@@ -19,12 +19,6 @@
#include "sp-string.h"
#include "FontFactory.h"
-#if !PANGO_VERSION_CHECK(1,24,0)
-#define PANGO_WEIGHT_THIN static_cast<PangoWeight>(100)
-#define PANGO_WEIGHT_BOOK static_cast<PangoWeight>(380)
-#define PANGO_WEIGHT_MEDIUM static_cast<PangoWeight>(500)
-#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
-#endif
namespace Inkscape {
namespace Text {
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index 4bdd2c6cb..bf746b41f 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -21,12 +21,6 @@
#include "display/curve.h"
#include <2geom/pathvector.h>
-#if !PANGO_VERSION_CHECK(1,24,0)
-#define PANGO_WEIGHT_THIN static_cast<PangoWeight>(100)
-#define PANGO_WEIGHT_BOOK static_cast<PangoWeight>(380)
-#define PANGO_WEIGHT_MEDIUM static_cast<PangoWeight>(500)
-#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
-#endif
namespace Inkscape {
namespace Extension {
diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert
index 7cd99e1a8..0ce8f1fd5 100644
--- a/src/libnrtype/Makefile_insert
+++ b/src/libnrtype/Makefile_insert
@@ -11,7 +11,6 @@ ink_common_sources += \
libnrtype/nr-type-pos-def.h \
libnrtype/nr-type-primitives.cpp \
libnrtype/nr-type-primitives.h \
- libnrtype/nrtype-forward.h \
libnrtype/FontFactory.cpp \
libnrtype/FontFactory.h \
libnrtype/FontInstance.cpp \
diff --git a/src/libvpsc/csolve_VPSC.h b/src/libvpsc/csolve_VPSC.h
index b0d01e763..edfd16657 100644
--- a/src/libvpsc/csolve_VPSC.h
+++ b/src/libvpsc/csolve_VPSC.h
@@ -60,7 +60,9 @@ int genXConstraints(int n, boxf[], Variable** vs, Constraint*** cs,
int genYConstraints(int n, boxf[], Variable** vs, Constraint*** cs);
void satisfyVPSC(Solver*);
+void deleteVPSC(Solver*);
void solveVPSC(Solver*);
+void splitIncVPSC(IncSolver*);
Solver* newIncSolver(int n, Variable* vs[], int m, Constraint* cs[]);
void splitIncSolver(IncSolver*);
int getSplitCnt(IncSolver *vpsc);
diff --git a/src/libvpsc/generate-constraints.cpp b/src/libvpsc/generate-constraints.cpp
index 8dd2d9331..fabe5217f 100644
--- a/src/libvpsc/generate-constraints.cpp
+++ b/src/libvpsc/generate-constraints.cpp
@@ -105,7 +105,7 @@ bool CmpNodePos::operator() (const Node* u, const Node* v) const {
*/
}
-NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
+static NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
NodeSet *leftv = new NodeSet;
NodeSet::iterator i=scanline.find(v);
while(i--!=scanline.begin()) {
@@ -120,7 +120,7 @@ NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
}
return leftv;
}
-NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) {
+static NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) {
NodeSet *rightv = new NodeSet;
NodeSet::iterator i=scanline.find(v);
for(++i;i!=scanline.end(); ++i) {
@@ -144,7 +144,7 @@ struct Event {
Event(EventType t, Node *v, double p) : type(t),v(v),pos(p) {};
};
Event **events;
-int compare_events(const void *a, const void *b) {
+static int compare_events(const void *a, const void *b) {
Event *ea=*(Event**)a;
Event *eb=*(Event**)b;
if(ea->v->r==eb->v->r) {
diff --git a/src/libvpsc/remove_rectangle_overlap.cpp b/src/libvpsc/remove_rectangle_overlap.cpp
index 381759f3c..d667ffb1e 100644
--- a/src/libvpsc/remove_rectangle_overlap.cpp
+++ b/src/libvpsc/remove_rectangle_overlap.cpp
@@ -15,6 +15,7 @@
#include "solve_VPSC.h"
#include "variable.h"
#include "constraint.h"
+#include "remove_rectangle_overlap.h" /* own include */
#ifdef RECTANGLE_OVERLAP_LOGGING
#include <fstream>
#include "blocks.h"
diff --git a/src/livarot/Makefile_insert b/src/livarot/Makefile_insert
index e4d88efd5..69078d073 100644
--- a/src/livarot/Makefile_insert
+++ b/src/livarot/Makefile_insert
@@ -37,6 +37,5 @@ livarot_libvarot_a_SOURCES = \
livarot/sweep-event.cpp \
livarot/sweep-event.h \
livarot/sweep-event-queue.h \
- livarot/livarot-forward.h \
livarot/path-description.h \
livarot/path-description.cpp
diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp
index d6e916197..d9f609e87 100644
--- a/src/livarot/PathSimplify.cpp
+++ b/src/livarot/PathSimplify.cpp
@@ -70,10 +70,10 @@ void Path::Simplify(double treshhold)
// dichomtomic method to get distance to curve approximation
// a real polynomial solver would get the minimum more efficiently, but since the polynom
// would likely be of degree >= 5, that would imply using some generic solver, liek using the sturm metod
-double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD,
- Geom::Point const &iE, Geom::Point const &ieD,
- Geom::Point &pt, double current, int lev, double st, double et)
-{
+static double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD,
+ Geom::Point const &iE, Geom::Point const &ieD,
+ Geom::Point &pt, double current, int lev, double st, double et)
+{
if ( lev <= 0 ) {
return current;
}
@@ -116,7 +116,7 @@ double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD,
}
-double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Point &pt)
+static double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Point &pt)
{
Geom::Point const sp = pt - start;
Geom::Point const ep = pt - res.p;
diff --git a/src/livarot/PathStroke.cpp b/src/livarot/PathStroke.cpp
index 93280d794..cdd5cae6d 100644
--- a/src/livarot/PathStroke.cpp
+++ b/src/livarot/PathStroke.cpp
@@ -20,7 +20,7 @@
*/
// until i find something better
-Geom::Point StrokeNormalize(const Geom::Point value) {
+static Geom::Point StrokeNormalize(const Geom::Point value) {
double length = L2(value);
if ( length < 0.0000001 ) {
return Geom::Point(0, 0);
@@ -30,7 +30,7 @@ Geom::Point StrokeNormalize(const Geom::Point value) {
}
// faster version if length is known
-Geom::Point StrokeNormalize(const Geom::Point value, double length) {
+static Geom::Point StrokeNormalize(const Geom::Point value, double length) {
if ( length < 0.0000001 ) {
return Geom::Point(0, 0);
} else {
diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp
index 7b170e8a0..a7e5a6cdc 100644
--- a/src/livarot/ShapeMisc.cpp
+++ b/src/livarot/ShapeMisc.cpp
@@ -406,7 +406,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
if (startBord >= 0)
{
// parcours en profondeur pour mettre les leF et riF a leurs valeurs
- swdData[startBord].misc = (void *) (1+nbNest);
+ swdData[startBord].misc = (void *)(intptr_t)(1 + nbNest);
//printf("part de %d\n",startBord);
int curBord = startBord;
bool back = false;
@@ -507,7 +507,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
startBord=nb;
}
}
- swdData[nb].misc = (void *) (1+nbNest);
+ swdData[nb].misc = (void *)(intptr_t)(1 + nbNest);
swdData[nb].ind = searchInd++;
swdData[nb].precParc = curBord;
swdData[curBord].suivParc = nb;
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 44e57addf..3b57de25c 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -120,9 +120,9 @@ const Util::EnumData<EffectType> LPETypeData[] = {
{ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"},
{SKETCH, N_("Sketch"), "sketch"},
{RULER, N_("Ruler"), "ruler"},
-/* 0.49 ?*/
- {POWERSTROKE, N_("[Unstable!] Power stroke"), "powerstroke"},
- {CLONE_ORIGINAL, N_("[Unstable!] Clone original path"), "clone_original"},
+/* 0.49 */
+ {POWERSTROKE, N_("Power stroke"), "powerstroke"},
+ {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp
index ce152bb34..8aa88f1f0 100644
--- a/src/live_effects/lpe-angle_bisector.cpp
+++ b/src/live_effects/lpe-angle_bisector.cpp
@@ -42,8 +42,8 @@ public:
LPEAngleBisector::LPEAngleBisector(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0),
- length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250)
+ length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0),
+ length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250)
{
show_orig_path = true;
_provides_knotholder_entities = true;
@@ -99,11 +99,11 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt
namespace AB {
void
-KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir);
lpe->length_left.param_set_value(-lambda);
@@ -112,11 +112,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori
}
void
-KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir);
lpe->length_right.param_set_value(lambda);
diff --git a/src/live_effects/lpe-boolops.cpp b/src/live_effects/lpe-boolops.cpp
index efaca7e8b..641cf5d50 100644
--- a/src/live_effects/lpe-boolops.cpp
+++ b/src/live_effects/lpe-boolops.cpp
@@ -32,8 +32,8 @@ static const Util::EnumDataConverter<unsigned> BoolopTypeConverter(BoolopTypeDat
LPEBoolops::LPEBoolops(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- bool_path(_("2nd path"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"),
- boolop_type(_("Boolop type"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION)
+ bool_path(_("2nd path:"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"),
+ boolop_type(_("Boolop type:"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION)
{
show_orig_path = true;
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 68242cc94..9ac553ed5 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -48,9 +48,9 @@ public:
LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- starting_angle(_("Starting"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0),
- rotation_angle(_("Rotation angle"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0),
- num_copies(_("Number of copies"), _("Number of copies of the original path"), "num_copies", &wr, this, 5),
+ starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0),
+ rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0),
+ num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 5),
origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"),
dist_angle_handle(100)
{
@@ -152,7 +152,7 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const
{
LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
// I first suspected the minus sign to be a bug in 2geom but it is
// likely due to SVG's choice of coordinate system orientation (max)
@@ -172,7 +172,7 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const
{
LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
// I first suspected the minus sign to be a bug in 2geom but it is
// likely due to SVG's choice of coordinate system orientation (max)
@@ -191,14 +191,14 @@ Geom::Point
KnotHolderEntityStartingAngle::knot_get()
{
LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect);
- return snap_knot_position(lpe->start_pos);
+ return lpe->start_pos;
}
Geom::Point
KnotHolderEntityRotationAngle::knot_get()
{
LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect);
- return snap_knot_position(lpe->rot_pos);
+ return lpe->rot_pos;
}
} // namespace CR
diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp
index a3e2073ee..467fdfd9c 100644
--- a/src/live_effects/lpe-dynastroke.cpp
+++ b/src/live_effects/lpe-dynastroke.cpp
@@ -71,17 +71,17 @@ static const Util::EnumDataConverter<DynastrokeCappingType> DSCTConverter(Dynast
LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
// initialise your parameters here:
- method(_("Method"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST),
- width(_("Pen width"), _("Maximal stroke width"), "width", &wr, this, 25),
- roundness(_("Pen roundness"), _("Min/Max width ratio"), "roundness", &wr, this, .2),
- angle(_("angle"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45),
+ method(_("Method:"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST),
+ width(_("Pen width:"), _("Maximal stroke width"), "width", &wr, this, 25),
+ roundness(_("Pen roundness:"), _("Min/Max width ratio"), "roundness", &wr, this, .2),
+ angle(_("Angle:"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45),
// modulo_pi(_("modulo pi"), _("Give forward and backward moves in one direction the same thickness "), "modulo_pi", &wr, this, false),
- start_cap(_("Start"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP),
- end_cap(_("End"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP),
- growfor(_("Grow for"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100),
- fadefor(_("Fade for"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100),
+ start_cap(_("Start:"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP),
+ end_cap(_("End:"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP),
+ growfor(_("Grow for:"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100),
+ fadefor(_("Fade for:"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100),
round_ends(_("Round ends"), _("Strokes end with a round end"), "round_ends", &wr, this, false),
- capping(_("Capping"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5")
+ capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5")
{
registerParameter( dynamic_cast<Parameter *>(& method) );
@@ -115,7 +115,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
{
using namespace Geom;
- std::cout<<"do effect: debut\n";
+// std::cout<<"do effect: debut\n";
Piecewise<D2<SBasis> > output;
Piecewise<D2<SBasis> > m = pwd2_in;
@@ -156,13 +156,13 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
DynastrokeMethod stroke_method = method.get_value();
if (roundness==1.) {
- std::cout<<"round pen.\n";
+// std::cout<<"round pen.\n";
n1 = n*double(width);
n2 =-n1;
}else{
switch(stroke_method) {
case DSM_ELLIPTIC_PEN:{
- std::cout<<"ellptic pen\n";
+// std::cout<<"ellptic pen\n";
//FIXME: roundness=0???
double c = cos(angle_rad), s = sin(angle_rad);
Affine rot,slant;
@@ -178,7 +178,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
break;
}
case DSM_THICKTHIN_FAST:{
- std::cout<<"fast thick thin pen\n";
+// std::cout<<"fast thick thin pen\n";
D2<Piecewise<SBasis> > n_xy = make_cuts_independent(n);
w = n_xy[X]*sin(angle_rad) - n_xy[Y]*cos(angle_rad);
w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.);
@@ -187,7 +187,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
break;
}
case DSM_THICKTHIN_SLOW:{
- std::cout<<"slow thick thin pen\n";
+// std::cout<<"slow thick thin pen\n";
D2<Piecewise<SBasis> > n_xy = make_cuts_independent(n);
w = n_xy[X]*cos(angle_rad)+ n_xy[Y]*sin(angle_rad);
w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.);
@@ -196,12 +196,12 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
Piecewise<SBasis> dw = derivative(w);
Piecewise<SBasis> ncomp = sqrt(dot(v,v)-dw*dw,.1,3);
//FIXME: is force continuity usefull? compatible with corners?
- std::cout<<"ici\n";
+// std::cout<<"ici\n";
n1 = -dw*v + ncomp*rot90(v);
n1 = w*force_continuity(unitVector(n1),.1);
n2 = -dw*v - ncomp*rot90(v);
n2 = w*force_continuity(unitVector(n2),.1);
- std::cout<<"ici2\n";
+// std::cout<<"ici2\n";
break;
}
default:{
@@ -219,13 +219,13 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
Piecewise<D2<SBasis> > left, right;
if ( m.segs.front().at0() == m.segs.back().at1()){
// if closed:
- std::cout<<"closed input.\n";
+// std::cout<<"closed input.\n";
left = m + n1;//+ n;
right = m + n2;//- n;
} else {
//if not closed, shape the ends:
//TODO: allow fancy ends...
- std::cout<<"shaping the ends\n";
+// std::cout<<"shaping the ends\n";
double grow_length = growfor;// * width;
double fade_length = fadefor;// * width;
Piecewise<SBasis > s = arcLengthSb(m);
@@ -240,7 +240,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
factor_in.concat(Piecewise<SBasis >(Linear(1)));
factor_in.cuts[2]=totlength;
}
- std::cout<<"shaping the ends ici\n";
+// std::cout<<"shaping the ends ici\n";
//scale factor for a sharp end
join[0] = Linear(1,0);
join[1] = Linear(1,1);
@@ -254,7 +254,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
factor_out = Piecewise<SBasis >(join);
factor_out.setDomain(Interval(totlength-fade_length,totlength));
}
- std::cout<<"shaping the ends ici ici\n";
+// std::cout<<"shaping the ends ici ici\n";
Piecewise<SBasis > factor = factor_in*factor_out;
n1 = compose(factor,s)*n1;
@@ -262,10 +262,10 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
left = m + n1;
right = m + n2;
- std::cout<<"shaping the ends ici ici ici\n";
+// std::cout<<"shaping the ends ici ici ici\n";
if (start_cap.get_value() == DSCT_ROUND){
- std::cout<<"shaping round start\n";
+// std::cout<<"shaping round start\n";
SBasis tau(2,Linear(0));
tau[1] = Linear(-1,0);
Piecewise<SBasis > hbump;
@@ -280,7 +280,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
right += - hbump * rot90(n);
}
if (end_cap.get_value() == DSCT_ROUND){
- std::cout<<"shaping round end\n";
+// std::cout<<"shaping round end\n";
SBasis tau(2,Linear(0));
tau[1] = Linear(0,1);
Piecewise<SBasis > hbump;
@@ -299,11 +299,11 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
left = force_continuity(left);
right = force_continuity(right);
- std::cout<<"gathering result: left";
+// std::cout<<"gathering result: left";
output = left;
- std::cout<<" + reverse(right)";
+// std::cout<<" + reverse(right)";
output.concat(reverse(right));
- std::cout<<". done\n";
+// std::cout<<". done\n";
//-----------
return output;
diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp
index e57f5112e..003e22567 100644
--- a/src/live_effects/lpe-gears.cpp
+++ b/src/live_effects/lpe-gears.cpp
@@ -112,7 +112,8 @@ private:
}
};
-void makeContinuous(D2<SBasis> &a, Point const b) {
+static void
+makeContinuous(D2<SBasis> &a, Point const b) {
for(unsigned d=0;d<2;d++)
a[d][0][0] = b[d];
}
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index d3dd10d26..61e457d35 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -51,7 +51,7 @@ public:
};
-Geom::Path::size_type size_nondegenerate(Geom::Path const &path) {
+static Geom::Path::size_type size_nondegenerate(Geom::Path const &path) {
Geom::Path::size_type retval = path.size_open();
// if path is closed and closing segment is not degenerate
@@ -283,7 +283,7 @@ CrossingPoints::get(unsigned const i, unsigned const ni)
return CrossingPoint();
}
-unsigned
+static unsigned
idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p)
{
double dist=-1;
@@ -500,7 +500,8 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in)
//recursively collect gpaths and stroke widths (stolen from "sp-lpe_item.cpp").
-void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){
+static void
+collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){
if (SP_IS_GROUP(lpeitem)) {
GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem));
for ( GSList const *iter = item_list; iter; iter = iter->next ) {
@@ -633,7 +634,7 @@ Geom::Point
KnotHolderEntityCrossingSwitcher::knot_get()
{
LPEKnot* lpe = dynamic_cast<LPEKnot *>(_effect);
- return snap_knot_position(lpe->switcher);
+ return lpe->switcher;
}
void
diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp
index 473469c8a..2d04c4d41 100644
--- a/src/live_effects/lpe-lattice.cpp
+++ b/src/live_effects/lpe-lattice.cpp
@@ -42,22 +42,22 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
// initialise your parameters here:
- grid_point0(_("Control handle 0"), _("Control handle 0"), "gridpoint0", &wr, this),
- grid_point1(_("Control handle 1"), _("Control handle 1"), "gridpoint1", &wr, this),
- grid_point2(_("Control handle 2"), _("Control handle 2"), "gridpoint2", &wr, this),
- grid_point3(_("Control handle 3"), _("Control handle 3"), "gridpoint3", &wr, this),
- grid_point4(_("Control handle 4"), _("Control handle 4"), "gridpoint4", &wr, this),
- grid_point5(_("Control handle 5"), _("Control handle 5"), "gridpoint5", &wr, this),
- grid_point6(_("Control handle 6"), _("Control handle 6"), "gridpoint6", &wr, this),
- grid_point7(_("Control handle 7"), _("Control handle 7"), "gridpoint7", &wr, this),
- grid_point8(_("Control handle 8"), _("Control handle 8"), "gridpoint8", &wr, this),
- grid_point9(_("Control handle 9"), _("Control handle 9"), "gridpoint9", &wr, this),
- grid_point10(_("Control handle 10"), _("Control handle 10"), "gridpoint10", &wr, this),
- grid_point11(_("Control handle 11"), _("Control handle 11"), "gridpoint11", &wr, this),
- grid_point12(_("Control handle 12"), _("Control handle 12"), "gridpoint12", &wr, this),
- grid_point13(_("Control handle 13"), _("Control handle 13"), "gridpoint13", &wr, this),
- grid_point14(_("Control handle 14"), _("Control handle 14"), "gridpoint14", &wr, this),
- grid_point15(_("Control handle 15"), _("Control handle 15"), "gridpoint15", &wr, this)
+ grid_point0(_("Control handle 0:"), _("Control handle 0"), "gridpoint0", &wr, this),
+ grid_point1(_("Control handle 1:"), _("Control handle 1"), "gridpoint1", &wr, this),
+ grid_point2(_("Control handle 2:"), _("Control handle 2"), "gridpoint2", &wr, this),
+ grid_point3(_("Control handle 3:"), _("Control handle 3"), "gridpoint3", &wr, this),
+ grid_point4(_("Control handle 4:"), _("Control handle 4"), "gridpoint4", &wr, this),
+ grid_point5(_("Control handle 5:"), _("Control handle 5"), "gridpoint5", &wr, this),
+ grid_point6(_("Control handle 6:"), _("Control handle 6"), "gridpoint6", &wr, this),
+ grid_point7(_("Control handle 7:"), _("Control handle 7"), "gridpoint7", &wr, this),
+ grid_point8(_("Control handle 8:"), _("Control handle 8"), "gridpoint8", &wr, this),
+ grid_point9(_("Control handle 9:"), _("Control handle 9"), "gridpoint9", &wr, this),
+ grid_point10(_("Control handle 10:"), _("Control handle 10"), "gridpoint10", &wr, this),
+ grid_point11(_("Control handle 11:"), _("Control handle 11"), "gridpoint11", &wr, this),
+ grid_point12(_("Control handle 12:"), _("Control handle 12"), "gridpoint12", &wr, this),
+ grid_point13(_("Control handle 13:"), _("Control handle 13"), "gridpoint13", &wr, this),
+ grid_point14(_("Control handle 14:"), _("Control handle 14"), "gridpoint14", &wr, this),
+ grid_point15(_("Control handle 15:"), _("Control handle 15"), "gridpoint15", &wr, this)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp
index f0d5bab0a..6619b85ce 100644
--- a/src/live_effects/lpe-line_segment.cpp
+++ b/src/live_effects/lpe-line_segment.cpp
@@ -31,7 +31,7 @@ static const Util::EnumDataConverter<EndType> EndTypeConverter(EndTypeData, size
LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- end_type(_("End type"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH)
+ end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH)
{
/* register all your parameters here, so Inkscape knows which parameters this effect has: */
registerParameter( dynamic_cast<Parameter *>(&end_type) );
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp
index 7bfaf2d99..a56909338 100644
--- a/src/live_effects/lpe-mirror_symmetry.cpp
+++ b/src/live_effects/lpe-mirror_symmetry.cpp
@@ -30,7 +30,7 @@ namespace LivePathEffect {
LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false),
- reflection_line(_("Reflection line"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100")
+ reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100")
{
show_orig_path = true;
diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp
index a6b894ce3..4d4b0c17d 100644
--- a/src/live_effects/lpe-parallel.cpp
+++ b/src/live_effects/lpe-parallel.cpp
@@ -48,8 +48,8 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
// initialise your parameters here:
offset_pt(_("Offset"), _("Adjust the offset"), "offset_pt", &wr, this),
- length_left(_("Length left"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150),
- length_right(_("Length right"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150)
+ length_left(_("Length left:"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150),
+ length_right(_("Length right:"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150)
{
show_orig_path = true;
_provides_knotholder_entities = true;
@@ -113,13 +113,13 @@ void LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt
namespace Pl {
void
-KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
using namespace Geom;
LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir));
lpe->length_left.param_set_value(-lambda);
@@ -128,13 +128,13 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori
}
void
-KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
using namespace Geom;
LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir));
lpe->length_right.param_set_value(lambda);
diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp
index 1b9e7be48..d3edcda27 100644
--- a/src/live_effects/lpe-path_length.cpp
+++ b/src/live_effects/lpe-path_length.cpp
@@ -23,9 +23,9 @@ namespace LivePathEffect {
LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0),
+ scale(_("Scale:"), _("Scaling factor"), "scale", &wr, this, 1.0),
info_text(this),
- unit(_("Unit"), _("Unit"), "unit", &wr, this),
+ unit(_("Unit:"), _("Unit"), "unit", &wr, this),
display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true)
{
registerParameter(dynamic_cast<Parameter *>(&scale));
diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
index 7417c166f..c528ef692 100644
--- a/src/live_effects/lpe-perp_bisector.cpp
+++ b/src/live_effects/lpe-perp_bisector.cpp
@@ -31,7 +31,7 @@ namespace PB {
class KnotHolderEntityEnd : public LPEKnotHolderEntity {
public:
KnotHolderEntityEnd(LPEPerpBisector *effect) : LPEKnotHolderEntity(effect) {};
- void bisector_end_set(Geom::Point const &p, bool left = true);
+ void bisector_end_set(Geom::Point const &p, guint state, bool left = true);
};
class KnotHolderEntityLeftEnd : public KnotHolderEntityEnd {
@@ -61,11 +61,11 @@ KnotHolderEntityRightEnd::knot_get() {
}
void
-KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) {
+KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, guint state, bool left) {
LPEPerpBisector *lpe = dynamic_cast<LPEPerpBisector *>(_effect);
if (!lpe) return;
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = Geom::nearest_point(s, lpe->M, lpe->perp_dir);
if (left) {
@@ -81,21 +81,21 @@ KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) {
}
void
-KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) {
- bisector_end_set(p);
+KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) {
+ bisector_end_set(p, state);
}
void
-KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) {
- bisector_end_set(p, false);
+KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) {
+ bisector_end_set(p, state, false);
}
} //namescape PB
LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200),
- length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200),
+ length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200),
+ length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200),
A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0)
{
show_orig_path = true;
diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h
index 823717e62..f5a918028 100644
--- a/src/live_effects/lpe-perp_bisector.h
+++ b/src/live_effects/lpe-perp_bisector.h
@@ -27,7 +27,7 @@ namespace PB {
class KnotHolderEntityEnd;
class KnotHolderEntityLeftEnd;
class KnotHolderEntityRightEnd;
- void bisector_end_set(SPItem *item, Geom::Point const &p, bool left);
+ void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left);
}
class LPEPerpBisector : public Effect {
@@ -46,7 +46,7 @@ public:
friend class PB::KnotHolderEntityEnd;
friend class PB::KnotHolderEntityLeftEnd;
friend class PB::KnotHolderEntityRightEnd;
- friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, bool left = true);
+ friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true);
void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
private:
diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp
index f3cf802a1..aeee77482 100644
--- a/src/live_effects/lpe-perspective_path.cpp
+++ b/src/live_effects/lpe-perspective_path.cpp
@@ -149,13 +149,13 @@ void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop
namespace PP {
void
-KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint /*state*/)
+KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state)
{
using namespace Geom;
LPEPerspectivePath* lpe = dynamic_cast<LPEPerspectivePath *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
lpe->offsetx.param_set_value((s - origin)[Geom::X]);
lpe->offsety.param_set_value(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index 048742452..b042f8d41 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -28,6 +28,8 @@
#include <2geom/path-intersection.h>
#include <2geom/crossing.h>
#include <2geom/ellipse.h>
+#include <2geom/math-utils.h>
+#include <math.h>
#include "spiro.h"
@@ -36,7 +38,7 @@ namespace Geom {
/** Find the point where two straight lines cross.
*/
-boost::optional<Point> intersection_point( Point const & origin_a, Point const & vector_a,
+static boost::optional<Point> intersection_point( Point const & origin_a, Point const & vector_a,
Point const & origin_b, Point const & vector_b)
{
Coord denom = cross(vector_b, vector_a);
@@ -47,7 +49,7 @@ boost::optional<Point> intersection_point( Point const & origin_a, Point const &
return boost::none;
}
-Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2<Geom::SBasis> const & sbasis_in)
+static Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2<Geom::SBasis> const & sbasis_in)
{
std::vector<Geom::Point> temp;
sbasis_to_bezier(temp, sbasis_in, 4);
@@ -86,6 +88,96 @@ static Ellipse find_ellipse(Point P, Point Q, Point O)
return Ellipse(A, B, C, D, E, F);
}
+/**
+ * Refer to: Weisstein, Eric W. "Circle-Circle Intersection."
+ From MathWorld--A Wolfram Web Resource.
+ http://mathworld.wolfram.com/Circle-CircleIntersection.html
+ *
+ * @return 0 if no intersection
+ * @return 1 if one circle is contained in the other
+ * @return 2 if intersections are found (they are written to p0 and p1)
+ */
+static int circle_circle_intersection(Circle const &circle0, Circle const &circle1,
+ Point & p0, Point & p1)
+{
+ Point X0 = circle0.center();
+ double r0 = circle0.ray();
+ Point X1 = circle1.center();
+ double r1 = circle1.ray();
+
+ /* dx and dy are the vertical and horizontal distances between
+ * the circle centers.
+ */
+ Point D = X1 - X0;
+
+ /* Determine the straight-line distance between the centers. */
+ double d = L2(D);
+
+ /* Check for solvability. */
+ if (d > (r0 + r1))
+ {
+ /* no solution. circles do not intersect. */
+ return 0;
+ }
+ if (d <= fabs(r0 - r1))
+ {
+ /* no solution. one circle is contained in the other */
+ return 1;
+ }
+
+ /* 'point 2' is the point where the line through the circle
+ * intersection points crosses the line between the circle
+ * centers.
+ */
+
+ /* Determine the distance from point 0 to point 2. */
+ double a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;
+
+ /* Determine the coordinates of point 2. */
+ Point p2 = X0 + D * (a/d);
+
+ /* Determine the distance from point 2 to either of the
+ * intersection points.
+ */
+ double h = std::sqrt((r0*r0) - (a*a));
+
+ /* Now determine the offsets of the intersection points from
+ * point 2.
+ */
+ Point r = (h/d)*rot90(D);
+
+ /* Determine the absolute intersection points. */
+ p0 = p2 + r;
+ p1 = p2 - r;
+
+ return 2;
+}
+
+/**
+ * Find circle that touches inside of the curve, with radius matching the curvature, at time value \c t.
+ * Because this method internally uses unitTangentAt, t should be smaller than 1.0 (see unitTangentAt).
+ */
+static Circle touching_circle( D2<SBasis> const &curve, double t, double tol=0.01 )
+{
+ //Piecewise<SBasis> k = curvature(curve, tol);
+ D2<SBasis> dM=derivative(curve);
+ if ( are_near(L2sq(dM(t)),0.) ) {
+ dM=derivative(dM);
+ }
+ if ( are_near(L2sq(dM(t)),0.) ) { // try second time
+ dM=derivative(dM);
+ }
+ Piecewise<D2<SBasis> > unitv = unitVector(dM,tol);
+ Piecewise<SBasis> dMlength = dot(Piecewise<D2<SBasis> >(dM),unitv);
+ Piecewise<SBasis> k = cross(derivative(unitv),unitv);
+ k = divide(k,dMlength,tol,3);
+ double curv = k(t); // note that this value is signed
+
+ Geom::Point normal = unitTangentAt(curve, t).cw();
+ double radius = 1/curv;
+ Geom::Point center = curve(t) + radius*normal;
+ return Geom::Circle(center, fabs(radius));
+}
} // namespace Geom
@@ -121,7 +213,8 @@ enum LineJoinType {
LINEJOIN_ROUND,
LINEJOIN_EXTRP_MITER,
LINEJOIN_MITER,
- LINEJOIN_SPIRO
+ LINEJOIN_SPIRO,
+ LINEJOIN_EXTRP_MITER_ARC
};
static const Util::EnumData<unsigned> LineJoinTypeData[] = {
{LINEJOIN_BEVEL, N_("Beveled"), "bevel"},
@@ -129,19 +222,22 @@ static const Util::EnumData<unsigned> LineJoinTypeData[] = {
{LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"},
{LINEJOIN_MITER, N_("Miter"), "miter"},
{LINEJOIN_SPIRO, N_("Spiro"), "spiro"},
+#ifdef LPE_ENABLE_TEST_EFFECTS
+ {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"},
+#endif
};
static const Util::EnumDataConverter<unsigned> LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData));
LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this),
- sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true),
- interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN),
- interpolator_beta(_("Smoothness"), _("Sets the smoothness for the CubicBezierJohan interpolator. 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2),
- start_linecap_type(_("Start cap"), _("Determines the shape of the path's start."), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND),
- linejoin_type(_("Join"), _("Specifies the shape of the path's corners."), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND),
- miter_limit(_("Miter limit"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.),
- end_linecap_type(_("End cap"), _("Determines the shape of the path's end."), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND)
+ sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve"), "sort_points", &wr, this, true),
+ interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN),
+ interpolator_beta(_("Smoothness:"), _("Sets the smoothness for the CubicBezierJohan interpolator; 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2),
+ start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND),
+ linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND),
+ miter_limit(_("Miter limit:"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.),
+ end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND)
{
show_orig_path = true;
@@ -205,12 +301,12 @@ static bool compare_offsets (Geom::Point first, Geom::Point second)
return first[Geom::X] < second[Geom::X];
}
-Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> > const & B,
- Geom::Piecewise<Geom::SBasis> const & y, // width path
- LineJoinType jointype,
- double miter_limit,
- bool /*forward_direction*/,
- double tol=Geom::EPSILON)
+static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> > const & B,
+ Geom::Piecewise<Geom::SBasis> const & y, // width path
+ LineJoinType jointype,
+ double miter_limit,
+ bool /*forward_direction*/,
+ double tol=Geom::EPSILON)
{
/* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type
*/
@@ -310,6 +406,65 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis>
}
break;
}
+ case LINEJOIN_EXTRP_MITER_ARC: {
+ Geom::Circle circle1 = Geom::touching_circle(reverse(B[prev_i]),0.);
+ Geom::Circle circle2 = Geom::touching_circle(B[i],0.);
+ Geom::Point points[2];
+ int solutions = circle_circle_intersection(circle1, circle2, points[0], points[1]);
+ if (solutions == 2) {
+ Geom::Point sol(0.,0.);
+ if ( dot(tang2,points[0]-B[i].at0()) > 0 ) {
+ // points[0] is bad, choose points[1]
+ sol = points[1];
+ } else if ( dot(tang2,points[1]-B[i].at0()) > 0 ) { // points[0] could be good, now check points[1]
+ // points[1] is bad, choose points[0]
+ sol = points[0];
+ } else {
+ // both points are good, choose nearest
+ sol = ( distanceSq(B[i].at0(), points[0]) < distanceSq(B[i].at0(), points[1]) ) ?
+ points[0] : points[1];
+ }
+
+ Geom::EllipticalArc *arc0 = circle1.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+sol), sol, true);
+ Geom::EllipticalArc *arc1 = circle2.arc(sol, 0.5*(sol+B[i].at0()), B[i].at0(), true);
+
+ if (arc0) {
+ build_from_sbasis(pb,arc0->toSBasis(), tol, false);
+ delete arc0;
+ arc0 = NULL;
+ }
+ if (arc1) {
+ build_from_sbasis(pb,arc1->toSBasis(), tol, false);
+ delete arc1;
+ arc1 = NULL;
+ }
+
+ break;
+ } else {
+ // fall back to miter
+ boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1,
+ B[i].at0(), tang2 );
+ if (p) {
+ // check size of miter
+ Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width;
+ Geom::Coord len = distance(*p, point_on_path);
+ if (len <= fabs(width) * miter_limit) {
+ // miter OK
+ pb.lineTo(*p);
+ }
+ }
+ pb.lineTo(B[i].at0());
+ }
+ /*else if (solutions == 1) { // one circle is inside the other
+ // don't know what to do: default to bevel
+ pb.lineTo(B[i].at0());
+ } else { // no intersections
+ // don't know what to do: default to bevel
+ pb.lineTo(B[i].at0());
+ } */
+
+ break;
+ }
case LINEJOIN_MITER: {
boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1,
B[i].at0(), tang2 );
diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp
index cd1140950..906c430c1 100644
--- a/src/live_effects/lpe-recursiveskeleton.cpp
+++ b/src/live_effects/lpe-recursiveskeleton.cpp
@@ -27,7 +27,7 @@ namespace LivePathEffect {
LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- iterations(_("Iterations"), _("recursivity"), "iterations", &wr, this, 2)
+ iterations(_("Iterations:"), _("recursivity"), "iterations", &wr, this, 2)
{
show_orig_path = true;
concatenate_before_pwd2 = true;
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index de40d4fb5..f52977fcb 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -68,7 +68,7 @@ struct LevelCrossingInfoOrder {
typedef std::vector<LevelCrossing> LevelCrossings;
-std::vector<double>
+static std::vector<double>
discontinuities(Piecewise<D2<SBasis> > const &f){
std::vector<double> result;
if (f.size()==0) return result;
@@ -211,7 +211,7 @@ public:
// Bend a path...
//-------------------------------------------------------
-Piecewise<D2<SBasis> > bend(Piecewise<D2<SBasis> > const &f, Piecewise<SBasis> bending){
+static Piecewise<D2<SBasis> > bend(Piecewise<D2<SBasis> > const &f, Piecewise<SBasis> bending){
D2<Piecewise<SBasis> > ff = make_cuts_independent(f);
ff[X] += compose(bending, ff[Y]);
return sectionize(ff);
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index 93dacf3e0..b40d404ae 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -58,10 +58,10 @@ public:
LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0),
- t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5),
- length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150),
- length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150)
+ angle(_("Angle:"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0),
+ t_attach(_("Location along curve:"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5),
+ length_left(_("Length left:"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150),
+ length_right(_("Length right:"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150)
{
show_orig_path = true;
_provides_knotholder_entities = true;
@@ -122,13 +122,13 @@ LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desk
namespace TtC {
void
-KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
using namespace Geom;
LPETangentToCurve* lpe = dynamic_cast<LPETangentToCurve *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
// FIXME: There must be a better way of converting the path's SPCurve* to pwd2.
SPCurve *curve = SP_PATH(item)->get_curve_for_edit();
@@ -146,11 +146,11 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or
}
void
-KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA);
lpe->length_left.param_set_value(-lambda);
@@ -159,11 +159,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori
}
void
-KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA);
lpe->length_right.param_set_value(lambda);
diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp
index b678e35c1..03e3e7997 100644
--- a/src/live_effects/lpe-test-doEffect-stack.cpp
+++ b/src/live_effects/lpe-test-doEffect-stack.cpp
@@ -19,9 +19,9 @@ namespace LivePathEffect {
LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- step(_("Stack step"), ("How deep we should go into the stack"), "step", &wr, this),
- point(_("point param"), "tooltip of point parameter", "point_param", &wr, this),
- path(_("path param"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0")
+ step(_("Stack step:"), ("How deep we should go into the stack"), "step", &wr, this),
+ point(_("Point param:"), "tooltip of point parameter", "point_param", &wr, this),
+ path(_("Path param:"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0")
{
registerParameter( dynamic_cast<Parameter *>(&step) );
registerParameter( dynamic_cast<Parameter *>(&point) );
diff --git a/src/live_effects/lpe-text_label.cpp b/src/live_effects/lpe-text_label.cpp
index b59722566..602a6897c 100644
--- a/src/live_effects/lpe-text_label.cpp
+++ b/src/live_effects/lpe-text_label.cpp
@@ -20,7 +20,7 @@ namespace LivePathEffect {
LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- label(_("Label"), _("Text label attached to the path"), "label", &wr, this, "This is a label")
+ label(_("Label:"), _("Text label attached to the path"), "label", &wr, this, "This is a label")
{
registerParameter( dynamic_cast<Parameter *>(&label) );
}
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index f56df980e..8615721b0 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -51,8 +51,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,
Effect* effect, gdouble default_value)
: Parameter(label, tip, key, wr, effect),
value(default_value),
- min(-Geom::infinity()),
- max(Geom::infinity()),
+ min(-G_MAXDOUBLE),
+ max(G_MAXDOUBLE),
integer(false),
defvalue(default_value),
digits(2),
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index b751aeda3..2be87e048 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -141,9 +141,9 @@ private:
};
void
-PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
pparam->param_setValue(s);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}
diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp
index 68d0175ca..93161ec0d 100644
--- a/src/live_effects/parameter/powerstrokepointarray.cpp
+++ b/src/live_effects/parameter/powerstrokepointarray.cpp
@@ -144,7 +144,7 @@ PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolder
}
void
-PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
+PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
using namespace Geom;
@@ -156,7 +156,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom:
Piecewise<D2<SBasis> > const & pwd2 = _pparam->get_pwd2();
Piecewise<D2<SBasis> > const & n = _pparam->get_pwd2_normal();
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
double t = nearest_point(s, pwd2);
double offset = dot(s - pwd2.valueAt(t), n.valueAt(t));
_pparam->_vector.at(_index) = Geom::Point(t, offset);
diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp
index 8b62ba91e..a20c46042 100644
--- a/src/live_effects/parameter/vector.cpp
+++ b/src/live_effects/parameter/vector.cpp
@@ -149,8 +149,8 @@ public:
VectorParamKnotHolderEntity_Origin(VectorParam *p) : param(p) { }
virtual ~VectorParamKnotHolderEntity_Origin() {}
- virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) {
- Geom::Point const s = snap_knot_position(p);
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) {
+ Geom::Point const s = snap_knot_position(p, state);
param->setOrigin(s);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
};
diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp
index 14df5e92e..f50399a77 100644
--- a/src/live_effects/spiro.cpp
+++ b/src/live_effects/spiro.cpp
@@ -83,7 +83,7 @@ int n = 4;
#endif
/* Integrate polynomial spiral curve over range -.5 .. .5. */
-void
+static void
integrate_spiro(const double ks[4], double xy[2])
{
#if 0
@@ -631,7 +631,7 @@ banbks11(const bandmat *m, const int *perm, double *v, int n)
}
}
-int compute_jinc(char ty0, char ty1)
+static int compute_jinc(char ty0, char ty1)
{
if (ty0 == 'o' || ty1 == 'o' ||
ty0 == ']' || ty1 == '[')
@@ -645,7 +645,7 @@ int compute_jinc(char ty0, char ty1)
return 0;
}
-int count_vec(const spiro_seg *s, int nseg)
+static int count_vec(const spiro_seg *s, int nseg)
{
int i;
int n = 0;
@@ -807,7 +807,7 @@ spiro_iter(spiro_seg *s, bandmat *m, int *perm, double *v, int n)
return norm;
}
-int
+static int
solve_spiro(spiro_seg *s, int nseg)
{
bandmat *m;
diff --git a/src/main.cpp b/src/main.cpp
index e3862589d..20330edbb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -169,10 +169,10 @@ enum {
int sp_main_gui(int argc, char const **argv);
int sp_main_console(int argc, char const **argv);
-static void sp_do_export_png(SPDocument *doc);
-static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime);
+static int sp_do_export_png(SPDocument *doc);
+static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime);
#ifdef WIN32
-static void do_export_emf(SPDocument* doc, gchar const* uri, char const *mime);
+static int do_export_emf(SPDocument* doc, gchar const* uri, char const *mime);
#endif //WIN32
static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id);
static void do_query_all (SPDocument *doc);
@@ -390,7 +390,7 @@ struct poptOption options[] = {
{"export-text-to-path", 'T',
POPT_ARG_NONE, &sp_export_text_to_path, SP_ARG_EXPORT_TEXT_TO_PATH,
- N_("Convert text object to paths on export (PS, EPS, PDF)"),
+ N_("Convert text object to paths on export (PS, EPS, PDF, SVG)"),
NULL},
{"export-ignore-filters", 0,
@@ -625,6 +625,8 @@ main(int argc, char **argv)
bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR(""));
# else
bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ // needed by Python/Gettext
+ g_setenv("PACKAGE_LOCALE_DIR", PACKAGE_LOCALE_DIR, TRUE);
# endif
#endif
@@ -731,7 +733,7 @@ main(int argc, char **argv)
-void fixupSingleFilename( gchar **orig, gchar **spare )
+static void fixupSingleFilename( gchar **orig, gchar **spare )
{
if ( orig && *orig && **orig ) {
GError *error = NULL;
@@ -749,7 +751,7 @@ void fixupSingleFilename( gchar **orig, gchar **spare )
-GSList *fixupFilenameEncoding( GSList* fl )
+static GSList *fixupFilenameEncoding( GSList* fl )
{
GSList *newFl = NULL;
while ( fl ) {
@@ -788,7 +790,7 @@ GSList *fixupFilenameEncoding( GSList* fl )
return newFl;
}
-int sp_common_main( int argc, char const **argv, GSList **flDest )
+static int sp_common_main( int argc, char const **argv, GSList **flDest )
{
/// \todo fixme: Move these to some centralized location (Lauris)
sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW);
@@ -1002,7 +1004,7 @@ sp_main_gui(int argc, char const **argv)
/**
* Process file list
*/
-int sp_process_file_list(GSList *fl)
+static int sp_process_file_list(GSList *fl)
{
int retVal = 0;
while (fl) {
@@ -1030,6 +1032,9 @@ int sp_process_file_list(GSList *fl)
g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename);
retVal++;
} else {
+
+ inkscape_add_document(doc);
+
if (sp_vacuum_defs) {
doc->vacuumDocument();
}
@@ -1041,7 +1046,7 @@ int sp_process_file_list(GSList *fl)
sp_print_document_to_file(doc, sp_global_printer);
}
if (sp_export_png || (sp_export_id && sp_export_use_hints)) {
- sp_do_export_png(doc);
+ retVal |= sp_do_export_png(doc);
}
if (sp_export_svg) {
if (sp_export_text_to_path) {
@@ -1076,17 +1081,17 @@ int sp_process_file_list(GSList *fl)
doc->getBase(), sp_export_svg);
}
if (sp_export_ps) {
- do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript");
+ retVal |= do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript");
}
if (sp_export_eps) {
- do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript");
+ retVal |= do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript");
}
if (sp_export_pdf) {
- do_export_ps_pdf(doc, sp_export_pdf, "application/pdf");
+ retVal |= do_export_ps_pdf(doc, sp_export_pdf, "application/pdf");
}
#ifdef WIN32
if (sp_export_emf) {
- do_export_emf(doc, sp_export_emf, "image/x-emf");
+ retVal |= do_export_emf(doc, sp_export_emf, "image/x-emf");
}
#endif //WIN32
if (sp_query_all) {
@@ -1097,6 +1102,8 @@ int sp_process_file_list(GSList *fl)
do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id);
}
+ inkscape_remove_document(doc);
+
delete doc;
}
fl = g_slist_remove(fl, fl->data);
@@ -1108,7 +1115,7 @@ int sp_process_file_list(GSList *fl)
* Run the application as an interactive shell, parsing command lines from stdin
* Returns -1 on error.
*/
-int sp_main_shell(char const* command_name)
+static int sp_main_shell(char const* command_name)
{
int retval = 0;
@@ -1292,7 +1299,7 @@ do_query_all_recurse (SPObject *o)
}
-static void sp_do_export_png(SPDocument *doc)
+static int sp_do_export_png(SPDocument *doc)
{
Glib::ustring filename;
bool filename_from_hint = false;
@@ -1323,7 +1330,7 @@ static void sp_do_export_png(SPDocument *doc)
if (o) {
if (!SP_IS_ITEM (o)) {
g_warning("Object with id=\"%s\" is not a visible item. Nothing exported.", sp_export_id);
- return;
+ return 1;
}
items = g_slist_prepend (items, SP_ITEM(o));
@@ -1370,11 +1377,11 @@ static void sp_do_export_png(SPDocument *doc)
area = *areaMaybe;
} else {
g_warning("Unable to determine a valid bounding box. Nothing exported.");
- return;
+ return 1;
}
} else {
g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id);
- return;
+ return 1;
}
}
@@ -1383,7 +1390,7 @@ static void sp_do_export_png(SPDocument *doc)
gdouble x0,y0,x1,y1;
if (sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &x0, &y0, &x1, &y1) != 4) {
g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'. Nothing exported.", sp_export_area);
- return;
+ return 1;
}
area = Geom::Rect(Geom::Interval(x0,x1), Geom::Interval(y0,y1));
} else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) {
@@ -1397,7 +1404,7 @@ static void sp_do_export_png(SPDocument *doc)
if (filename.empty()) {
if (!sp_export_png) {
g_warning ("No export filename given and no filename hint. Nothing exported.");
- return;
+ return 1;
}
filename = sp_export_png;
}
@@ -1406,7 +1413,7 @@ static void sp_do_export_png(SPDocument *doc)
dpi = atof(sp_export_dpi);
if ((dpi < 0.1) || (dpi > 10000.0)) {
g_warning("DPI value %s out of range [0.1 - 10000.0]. Nothing exported.", sp_export_dpi);
- return;
+ return 1;
}
g_print("DPI: %g\n", dpi);
}
@@ -1428,7 +1435,7 @@ static void sp_do_export_png(SPDocument *doc)
width = strtoul(sp_export_width, NULL, 0);
if ((width < 1) || (width > PNG_UINT_31_MAX) || (errno == ERANGE) ) {
g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX);
- return;
+ return 1;
}
dpi = (gdouble) width * PX_PER_IN / area.width();
}
@@ -1438,7 +1445,7 @@ static void sp_do_export_png(SPDocument *doc)
height = strtoul(sp_export_height, NULL, 0);
if ((height < 1) || (height > PNG_UINT_31_MAX)) {
g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX);
- return;
+ return 1;
}
dpi = (gdouble) height * PX_PER_IN / area.height();
}
@@ -1501,19 +1508,28 @@ static void sp_do_export_png(SPDocument *doc)
path = filename;
}
- g_print("Background RRGGBBAA: %08x\n", bgcolor);
+ int retcode = 0;
+ //check if specified directory exists
- g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
+ if (!Inkscape::IO::file_directory_exists(filename.c_str())) {
+ g_warning("File path \"%s\" includes directory that doesn't exist.\n", filename.c_str());
+ retcode = 1;
+ } else {
+ g_print("Background RRGGBBAA: %08x\n", bgcolor);
- g_print("Bitmap saved as: %s\n", filename.c_str());
+ g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
- if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
- sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
- } else {
- g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
+ g_print("Bitmap saved as: %s\n", filename.c_str());
+
+ if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
+ sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
+ } else {
+ g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
+ }
}
g_slist_free (items);
+ return retcode;
}
@@ -1525,7 +1541,7 @@ static void sp_do_export_png(SPDocument *doc)
* \param mime MIME type to export as.
*/
-static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime)
+static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime)
{
Inkscape::Extension::DB::OutputList o;
Inkscape::Extension::db.get_output_list(o);
@@ -1537,14 +1553,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime
if (i == o.end())
{
g_warning ("Could not find an extension to export to MIME type %s.", mime);
- return;
+ return 1;
}
if (sp_export_id) {
SPObject *o = doc->getObjectById(sp_export_id);
if (o == NULL) {
g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id);
- return;
+ return 1;
}
(*i)->set_param_string ("exportId", sp_export_id);
} else {
@@ -1557,25 +1573,21 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime
}
if (sp_export_area_drawing) {
- (*i)->set_param_bool ("areaDrawing", TRUE);
- } else {
- (*i)->set_param_bool ("areaDrawing", FALSE);
+ (*i)->set_param_optiongroup ("area", "drawing");
}
if (sp_export_area_page) {
if (sp_export_eps) {
g_warning ("EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the page, --export-area-page will clip it to drawing.");
}
- (*i)->set_param_bool ("areaPage", TRUE);
- } else {
- (*i)->set_param_bool ("areaPage", FALSE);
+ (*i)->set_param_optiongroup ("area", "page");
}
if (!sp_export_area_drawing && !sp_export_area_page && !sp_export_id) {
// neither is set, set page as default for ps/pdf and drawing for eps
if (sp_export_eps) {
try {
- (*i)->set_param_bool("areaDrawing", TRUE);
+ (*i)->set_param_optiongroup("area", "drawing");
} catch (...) {}
}
}
@@ -1609,7 +1621,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime
(*i)->set_param_int("resolution", (int) dpi);
}
+ //check if specified directory exists
+ if (!Inkscape::IO::file_directory_exists(uri)) {
+ g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri);
+ return 1;
+ }
+
(*i)->save(doc, uri);
+ return 0;
}
#ifdef WIN32
@@ -1621,7 +1640,7 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime
* \param mime MIME type to export as (should be "image/x-emf")
*/
-static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime)
+static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime)
{
Inkscape::Extension::DB::OutputList o;
Inkscape::Extension::db.get_output_list(o);
@@ -1633,10 +1652,18 @@ static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime)
if (i == o.end())
{
g_warning ("Could not find an extension to export to MIME type %s.", mime);
- return;
+ return 1;
+ }
+
+ //check if specified directory exists
+ if (!Inkscape::IO::file_directory_exists(uri)){
+ g_warning("File path \"%s\" includes directory that doesn't exist.\n",
+ uri);
+ return 1;
}
(*i)->save(doc, uri);
+ return 0;
}
#endif //WIN32
diff --git a/src/marker.cpp b/src/marker.cpp
index 45582caa4..8acac805b 100644
--- a/src/marker.cpp
+++ b/src/marker.cpp
@@ -119,7 +119,7 @@ sp_marker_init (SPMarker *marker)
* parent class' build routine to attach the object to its document and
* repr. The result will be creation of the whole document tree.
*
- * \see sp_object_build()
+ * \see SPObject::build()
*/
static void sp_marker_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
@@ -147,7 +147,7 @@ static void sp_marker_build(SPObject *object, SPDocument *document, Inkscape::XM
* and release its SPRepr bindings. The result will be the destruction
* of the entire document tree.
*
- * \see sp_object_release()
+ * \see SPObject::release()
*/
static void sp_marker_release(SPObject *object)
{
diff --git a/src/measure-context.cpp b/src/measure-context.cpp
index cc6a9b04e..7a04b9915 100644
--- a/src/measure-context.cpp
+++ b/src/measure-context.cpp
@@ -306,7 +306,7 @@ static gint sp_measure_context_item_handler(SPEventContext *event_context, SPIte
return ret;
}
-bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2)
+static bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2)
{
if (p1[Geom::Y] == p2[Geom::Y]) {
return p1[Geom::X] < p2[Geom::X];
@@ -315,7 +315,7 @@ bool GeomPointSortPredicate(const Geom::Point& p1, const Geom::Point& p2)
}
}
-void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector const &lineseg, SPCurve *curve, std::vector<Geom::Point> &intersections)
+static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector const &lineseg, SPCurve *curve, std::vector<Geom::Point> &intersections)
{
curve->transform(item->i2doc_affine());
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 999fb52fc..fa39dbd3a 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -167,6 +167,7 @@ static char const menus_skeleton[] =
" <separator/>\n"
" <verb verb-id=\"LayerMoveToNext\" />\n"
" <verb verb-id=\"LayerMoveToPrev\" />\n"
+" <verb verb-id=\"LayerMoveTo\" />\n"
" <separator/>\n"
" <verb verb-id=\"LayerRaise\" />\n"
" <verb verb-id=\"LayerLower\" />\n"
@@ -181,6 +182,7 @@ static char const menus_skeleton[] =
" <submenu name=\"" N_("_Object") "\">\n"
" <verb verb-id=\"DialogFillStroke\" />\n"
" <verb verb-id=\"DialogObjectProperties\" />\n"
+" <verb verb-id=\"DialogSymbols\" />\n"
" <separator/>\n"
" <verb verb-id=\"SelectionGroup\" />\n"
" <verb verb-id=\"SelectionUnGroup\" />\n"
@@ -197,6 +199,10 @@ static char const menus_skeleton[] =
" <verb verb-id=\"ObjectsToPattern\" />\n"
" <verb verb-id=\"ObjectsFromPattern\" />\n"
" </submenu>\n"
+" <submenu name=\"" N_("Symbo_l") "\">\n"
+" <verb verb-id=\"ObjectsToSymbol\" />\n"
+" <verb verb-id=\"ObjectsFromSymbol\" />\n"
+" </submenu>\n"
" <verb verb-id=\"ObjectsToMarker\" />\n"
" <verb verb-id=\"ObjectsToGuides\" />\n"
" <separator/>\n"
diff --git a/src/mod360.cpp b/src/mod360.cpp
index 13e9aa36a..ce5cea33a 100644
--- a/src/mod360.cpp
+++ b/src/mod360.cpp
@@ -1,6 +1,8 @@
#include <glib.h>
#include <math.h>
+#include "mod360.h"
+
/** Returns \a x wrapped around to between 0 and less than 360,
or 0 if \a x isn't finite.
**/
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index b91a6d1e9..1c7f76a7f 100644
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -141,7 +141,7 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
//the radius then we should have a constrained snap. snap_knot_position() is unconstrained
- Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)));
+ Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)), state);
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
@@ -190,7 +190,7 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
//the radius then we should have a constrained snap. snap_knot_position() is unconstrained
- Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)));
+ Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)), state);
if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry,
// resulting in a perfect circle (and not an ellipse)
@@ -279,13 +279,13 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
// snap to horizontal or diagonal
if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->height.computed = MAX(h_orig + minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->height.computed = MAX(h_orig, 0);
@@ -296,13 +296,13 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
// snap to vertical or diagonal
if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->width.computed = MAX(w_orig + miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->width.computed = MAX(w_orig, 0);
@@ -315,7 +315,7 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
} else {
// move freely
- s = snap_knot_position(p);
+ s = snap_knot_position(p, state);
rect->width.computed = MAX(s[Geom::X] - rect->x.computed, 0);
rect->height.computed = MAX(s[Geom::Y] - rect->y.computed, 0);
rect->width._set = rect->height._set = true;
@@ -369,14 +369,14 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
// snap to horizontal or diagonal
if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
rect->height.computed = MAX(h_orig - minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->y.computed = MIN(origin[Geom::Y], opposite_y);
@@ -388,14 +388,14 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
// snap to vertical or diagonal
if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x);
rect->width.computed = MAX(w_orig - miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
- s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)));
+ s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
rect->x.computed = MIN(origin[Geom::X], opposite_x);
@@ -409,7 +409,7 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
} else {
// move freely
- s = snap_knot_position(p);
+ s = snap_knot_position(p, state);
minx = s[Geom::X] - origin[Geom::X];
miny = s[Geom::Y] - origin[Geom::Y];
@@ -483,7 +483,7 @@ Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id)
void
Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, guint state)
{
- Geom::Point const s = snap_knot_position(new_pos);
+ Geom::Point const s = snap_knot_position(new_pos, state);
g_assert(item != NULL);
SPBox3D *box = SP_BOX3D(item);
@@ -660,7 +660,7 @@ Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &
void
Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, guint state)
{
- Geom::Point const s = snap_knot_position(new_pos);
+ Geom::Point const s = snap_knot_position(new_pos, state);
SPBox3D *box = SP_BOX3D(item);
Geom::Affine const i2dt (item->i2dt_affine ());
@@ -875,7 +875,7 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi
{
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
ge->rx.computed = fabs( ge->cx.computed - s[Geom::X] );
@@ -910,7 +910,7 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi
{
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] );
@@ -995,7 +995,7 @@ StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origi
{
SPStar *star = SP_STAR(item);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
Geom::Point d = s - star->center;
@@ -1021,7 +1021,7 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi
{
SPStar *star = SP_STAR(item);
- Geom::Point const s = snap_knot_position(p);
+ Geom::Point const s = snap_knot_position(p, state);
if (star->flatsided == false) {
Geom::Point d = s - star->center;
@@ -1086,13 +1086,13 @@ sp_star_knot_click(SPItem *item, guint state)
void
StarKnotHolderEntity1::knot_click(guint state)
{
- return sp_star_knot_click(item, state);
+ sp_star_knot_click(item, state);
}
void
StarKnotHolderEntity2::knot_click(guint state)
{
- return sp_star_knot_click(item, state);
+ sp_star_knot_click(item, state);
}
StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
@@ -1305,7 +1305,7 @@ SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde
entity_outer->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER,
_("Roll/unroll the spiral from <b>outside</b>; with <b>Ctrl</b> to snap angle; "
- "with <b>Shift</b> to scale/rotate"));
+ "with <b>Shift</b> to scale/rotate; with <b>Alt</b> to lock radius"));
entity.push_back(entity_inner);
entity.push_back(entity_outer);
diff --git a/src/path-prefix.h b/src/path-prefix.h
index bdb6b35f7..be57ae354 100644
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
@@ -34,6 +34,7 @@ extern "C" {
# define INKSCAPE_PALETTESDIR BR_DATADIR( "/inkscape/palettes" )
# define INKSCAPE_PATTERNSDIR BR_DATADIR( "/inkscape/patterns" )
# define INKSCAPE_SCREENSDIR BR_DATADIR( "/inkscape/screens" )
+# define INKSCAPE_SYMBOLSDIR BR_DATADIR( "/inkscape/symbols" )
# define INKSCAPE_TUTORIALSDIR BR_DATADIR( "/inkscape/tutorials" )
# define INKSCAPE_TEMPLATESDIR BR_DATADIR( "/inkscape/templates" )
# define INKSCAPE_UIDIR BR_DATADIR( "/inkscape/ui" )
@@ -56,6 +57,7 @@ extern "C" {
# define INKSCAPE_PALETTESDIR WIN32_DATADIR("share\\palettes")
# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("share\\patterns")
# define INKSCAPE_SCREENSDIR WIN32_DATADIR("share\\screens")
+# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("share\\symbols")
# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("share\\tutorials")
# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("share\\templates")
# define INKSCAPE_UIDIR WIN32_DATADIR("share\\ui")
@@ -77,6 +79,7 @@ extern "C" {
# define INKSCAPE_PALETTESDIR "Contents/Resources/palettes"
# define INKSCAPE_PATTERNSDIR "Contents/Resources/patterns"
# define INKSCAPE_SCREENSDIR "Contents/Resources/screens"
+# define INKSCAPE_SYMBOLSDIR "Contents/Resources/symbols"
# define INKSCAPE_TUTORIALSDIR "Contents/Resources/tutorials"
# define INKSCAPE_TEMPLATESDIR "Contents/Resources/templates"
# define INKSCAPE_UIDIR "Contents/Resources/ui"
@@ -98,6 +101,7 @@ extern "C" {
# define INKSCAPE_PALETTESDIR INKSCAPE_DATADIR "/inkscape/palettes"
# define INKSCAPE_PATTERNSDIR INKSCAPE_DATADIR "/inkscape/patterns"
# define INKSCAPE_SCREENSDIR INKSCAPE_DATADIR "/inkscape/screens"
+# define INKSCAPE_SYMBOLSDIR INKSCAPE_DATADIR "/inkscape/symbols"
# define INKSCAPE_TUTORIALSDIR INKSCAPE_DATADIR "/inkscape/tutorials"
# define INKSCAPE_TEMPLATESDIR INKSCAPE_DATADIR "/inkscape/templates"
# define INKSCAPE_UIDIR INKSCAPE_DATADIR "/inkscape/ui"
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index ade041019..cb20eb3eb 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -861,7 +861,7 @@ static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton cons
return ret;
}
-void pen_redraw_all (SPPenContext *const pc)
+static void pen_redraw_all (SPPenContext *const pc)
{
// green
if (pc->green_bpaths) {
@@ -915,7 +915,7 @@ void pen_redraw_all (SPPenContext *const pc)
}
}
-void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
{
if (pc->npoints != 5)
return;
@@ -936,12 +936,12 @@ void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
pen_redraw_all(pc);
}
-void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y)
{
pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom());
}
-void pen_lastpoint_tocurve (SPPenContext *const pc)
+static void pen_lastpoint_tocurve (SPPenContext *const pc)
{
if (pc->npoints != 5)
return;
@@ -956,7 +956,7 @@ void pen_lastpoint_tocurve (SPPenContext *const pc)
pen_redraw_all(pc);
}
-void pen_lastpoint_toline (SPPenContext *const pc)
+static void pen_lastpoint_toline (SPPenContext *const pc)
{
if (pc->npoints != 5)
return;
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index d5b61e1f0..19a040b24 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -789,11 +789,13 @@ interpolate(SPPencilContext *pc)
/* Set up direction of next curve. */
{
- Geom::CubicBezier const * last_seg = dynamic_cast<Geom::CubicBezier const *>(pc->green_curve->last_segment());
- g_assert( last_seg ); // Relevance: validity of (*last_seg)[2]
+ Geom::Curve const * last_seg = pc->green_curve->last_segment();
+ g_assert( last_seg ); // Relevance: validity of (*last_seg)
pc->p[0] = last_seg->finalPoint();
pc->npoints = 1;
- Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] );
+ Geom::Curve *last_seg_reverse = last_seg->reverse();
+ Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) );
+ delete last_seg_reverse;
pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) )
? Geom::Point(0, 0)
: Geom::unit_vector(req_vec) );
@@ -881,11 +883,13 @@ sketch_interpolate(SPPencilContext *pc)
/* Set up direction of next curve. */
{
- Geom::CubicBezier const * last_seg = dynamic_cast<Geom::CubicBezier const *>(pc->green_curve->last_segment());
- g_assert( last_seg ); // Relevance: validity of (*last_seg)[2]
+ Geom::Curve const * last_seg = pc->green_curve->last_segment();
+ g_assert( last_seg ); // Relevance: validity of (*last_seg)
pc->p[0] = last_seg->finalPoint();
pc->npoints = 1;
- Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] );
+ Geom::Curve *last_seg_reverse = last_seg->reverse();
+ Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) );
+ delete last_seg_reverse;
pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) )
? Geom::Point(0, 0)
: Geom::unit_vector(req_vec) );
@@ -926,16 +930,19 @@ fit_and_split(SPPencilContext *pc)
/* Set up direction of next curve. */
{
- Geom::CubicBezier const * last_seg = dynamic_cast<Geom::CubicBezier const *>(pc->red_curve->last_segment());
- g_assert( last_seg ); // Relevance: validity of (*last_seg)[2]
+ Geom::Curve const * last_seg = pc->red_curve->last_segment();
+ g_assert( last_seg ); // Relevance: validity of (*last_seg)
pc->p[0] = last_seg->finalPoint();
pc->npoints = 1;
- Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] );
+ Geom::Curve *last_seg_reverse = last_seg->reverse();
+ Geom::Point const req_vec( -last_seg_reverse->unitTangentAt(0) );
+ delete last_seg_reverse;
pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) )
? Geom::Point(0, 0)
: Geom::unit_vector(req_vec) );
}
+
pc->green_curve->append_continuous(pc->red_curve, 0.0625);
SPCurve *curve = pc->red_curve->copy();
diff --git a/src/pixmaps/cursor-adj-a.xpm b/src/pixmaps/cursor-adj-a.xpm
new file mode 100644
index 000000000..7af3d9c12
--- /dev/null
+++ b/src/pixmaps/cursor-adj-a.xpm
@@ -0,0 +1,38 @@
+/* XPM */
+static const char * cursor_adj_a_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+" .. ",
+" .++. ",
+" .++. ",
+" .+..+. ",
+" .+..+. ",
+" .++++. ",
+" .+ .+. ",
+" .... .+..+. ",
+" .++. . ...... ",
+" .++. .+. ",
+" ....++.... .+. ",
+" .++++++++. .+. ",
+" .++++++++. .+. ",
+" ....++.... .+. ",
+" .++. .+. ",
+" .++. .+. ",
+" .... .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. .......... ",
+" .+. .++++++++. ",
+" .+. .++++++++. ",
+" .+. .......... ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" .+. ",
+" . ",
+" ",
+" "};
diff --git a/src/pixmaps/cursor-dropper-f.xpm b/src/pixmaps/cursor-dropper-f.xpm
new file mode 100644
index 000000000..3bf1e80e1
--- /dev/null
+++ b/src/pixmaps/cursor-dropper-f.xpm
@@ -0,0 +1,38 @@
+/* XPM */
+static const char * cursor_dropper_f_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+" ... ............",
+" .+. .++++++++++.",
+" .+. .+........+.",
+" .+. .+........+.",
+".... .... .+........+.",
+".+++ +++. .+........+.",
+".... .... .+........+.",
+" .+. .+........+.",
+" .+. .... .+........+.",
+" .+. .+++. .+........+.",
+" ... .+..+. .++++++++++.",
+" .++..+. ............",
+" .++..+. ",
+" .++..+. ",
+" .++..+. . ",
+" .++..+.+. ",
+" .++..+++. ",
+" .++++.+. ",
+" .++++.+.. ",
+" .++++++.++. ",
+" .++++++..+. ",
+" ..+++++.+. ",
+" .++++++. ",
+" .+++++. ",
+" .+++. ",
+" ... ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
diff --git a/src/pixmaps/cursor-dropper-s.xpm b/src/pixmaps/cursor-dropper-s.xpm
new file mode 100644
index 000000000..1a12934d8
--- /dev/null
+++ b/src/pixmaps/cursor-dropper-s.xpm
@@ -0,0 +1,38 @@
+/* XPM */
+static const char * cursor_dropper_s_xpm[] = {
+"32 32 3 1",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+" ... ............",
+" .+. .+++.++.+++.",
+" .+. .+........+.",
+" .+. .+. .+.",
+".... .... ... ...",
+".+++ +++. .+. .+.",
+".... .... .+. .+.",
+" .+. ... ...",
+" .+. .... .+. .+.",
+" .+. .+++. .+........+.",
+" ... .+..+. .+++.++.+++.",
+" .++..+. ............",
+" .++..+. ",
+" .++..+. ",
+" .++..+. . ",
+" .++..+.+. ",
+" .++..+++. ",
+" .++++.+. ",
+" .++++.+.. ",
+" .++++++.++. ",
+" .++++++..+. ",
+" ..+++++.+. ",
+" .++++++. ",
+" .+++++. ",
+" .+++. ",
+" ... ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 2cd391150..77ffe429a 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -337,6 +337,10 @@ static char const preferences_skeleton[] =
" check_on_reading=\"0\" "
" check_on_editing=\"0\" "
" check_on_writing=\"0\"/>\n"
+" <group id=\"externalresources\">\n"
+" <group id=\"xml\" "
+" allow_net_access=\"0\"/>\n"
+" </group>\n"
" <group id=\"forkgradientvectors\" value=\"1\"/>\n"
" <group id=\"iconrender\" named_nodelay=\"0\"/>\n"
" <group id=\"autosave\" enable=\"0\" interval=\"10\" path=\"\" max=\"10\"/>\n"
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 1f985a629..3f12c4f64 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -504,6 +504,17 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
sp_repr_css_attr_unref(current);
}
+/**
+ * Remove an entry
+ * Make sure observers have been removed before calling
+ */
+void Preferences::remove(Glib::ustring const &pref_path)
+{
+ Inkscape::XML::Node *node = _getNode(pref_path, false);
+ if (node && node->parent()) {
+ node->parent()->removeChild(node);
+ }
+}
/**
* Class that holds additional information for registered Observers.
diff --git a/src/preferences.h b/src/preferences.h
index 5dcf4524d..66fa11542 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -503,6 +503,13 @@ public:
static void unload(bool save=true);
/*@}*/
+ /**
+ * Remove a node from prefs
+ * @param pref_path Path to entry
+ *
+ */
+ void remove(Glib::ustring const &pref_path);
+
protected:
/* helper methods used by Entry
* This will enable using the same Entry class with different backends.
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index d96ddf09a..33ccee93c 100644
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -168,7 +168,7 @@ static void sp_rect_context_dispose(GObject *object)
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer data)
+static void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer data)
{
SPRectContext *rc = SP_RECT_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(rc);
diff --git a/src/registrytool.cpp b/src/registrytool.cpp
index d2cec0080..72b53821e 100644
--- a/src/registrytool.cpp
+++ b/src/registrytool.cpp
@@ -70,6 +70,7 @@ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
//Get or create the key
gunichar2 *keyw = g_utf8_to_utf16(keyName.data(), -1, 0,0,0);
gunichar2 *valuenamew = g_utf8_to_utf16(valueName.data(), -1, 0,0,0);
+ gunichar2 *valuew = g_utf8_to_utf16(value.data(), -1, 0,0,0);
HKEY key;
if (RegCreateKeyExW(rootKey, (WCHAR*) keyw,
@@ -82,7 +83,7 @@ bool RegistryTool::setStringValue(const Glib::ustring &keyNameArg,
// Set the value
if (RegSetValueExW(key, (WCHAR*) valuenamew,
- 0, REG_SZ, (LPBYTE) value.data(), (DWORD) (value.size() + 1)))
+ 0, REG_SZ, (LPBYTE) valuew, (DWORD) (2*value.size() + 2)))
{
fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
goto failkey;
diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp
index 0c45e34a9..ba5740e55 100644
--- a/src/removeoverlap.cpp
+++ b/src/removeoverlap.cpp
@@ -17,6 +17,7 @@
#include "sp-item-transform.h"
#include "libvpsc/generate-constraints.h"
#include "libvpsc/remove_rectangle_overlap.h"
+#include "removeoverlap.h"
using vpsc::Rectangle;
diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp
index c42ce6feb..8e2e95988 100644
--- a/src/resource-manager.cpp
+++ b/src/resource-manager.cpp
@@ -28,7 +28,7 @@
namespace Inkscape {
-std::vector<std::string> splitPath( std::string const &path )
+static std::vector<std::string> splitPath( std::string const &path )
{
std::vector<std::string> parts;
@@ -50,7 +50,7 @@ std::vector<std::string> splitPath( std::string const &path )
return parts;
}
-std::string convertPathToRelative( std::string const &path, std::string const &docbase )
+static std::string convertPathToRelative( std::string const &path, std::string const &docbase )
{
std::string result = path;
diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp
index 7aca3b0bd..57d4ffce3 100644
--- a/src/satisfied-guide-cns.cpp
+++ b/src/satisfied-guide-cns.cpp
@@ -1,8 +1,9 @@
-#include <desktop-handles.h>
-#include <sp-guide.h>
-#include <sp-guide-constraint.h>
-#include <sp-namedview.h>
-#include <approx-equal.h>
+#include "desktop-handles.h"
+#include "sp-guide.h"
+#include "sp-guide-constraint.h"
+#include "sp-namedview.h"
+#include "approx-equal.h"
+#include "satisfied-guide-cns.h"
void satisfied_guide_cns(SPDesktop const &desktop,
std::vector<Inkscape::SnapCandidatePoint> const &snappoints,
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 4555e51aa..bc096d528 100644
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -272,7 +272,7 @@ sp_select_context_abort(SPEventContext *event_context)
return false;
}
-bool
+static bool
key_is_a_modifier (guint key) {
return (key == GDK_KEY_Alt_L ||
key == GDK_KEY_Alt_R ||
@@ -284,7 +284,7 @@ key_is_a_modifier (guint key) {
key == GDK_KEY_Meta_R);
}
-void
+static void
sp_select_context_up_one_layer(SPDesktop *desktop)
{
/* Click in empty place, go up one level -- but don't leave a layer to root.
@@ -1140,8 +1140,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
}
// set cursor to default.
if (!desktop->isWaitingCursor()) {
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
- gdk_window_set_cursor(window, event_context->cursor);
+ // Do we need to reset the cursor here on key release ?
+ //GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (sp_desktop_canvas(desktop)));
+ //gdk_window_set_cursor(window, event_context->cursor);
}
break;
default:
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 068928d8f..3b1028ab8 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -11,6 +11,7 @@
* Martin Sucha <martin.sucha-inkscape@jts-sro.sk>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
+ * Tavmjong Bah <tavmjong@free.fr> (Symbol additions)
*
* Copyright (C) 1999-2010,2012 authors
* Copyright (C) 2001-2002 Ximian, Inc.
@@ -71,6 +72,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-gradient-reference.h"
#include "sp-linear-gradient-fns.h"
#include "sp-pattern.h"
+#include "sp-symbol.h"
#include "sp-radial-gradient-fns.h"
#include "gradient-context.h"
#include "sp-namedview.h"
@@ -256,7 +258,7 @@ void SelectionHelper::selectPrev(SPDesktop *dt)
* Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
* then prepends the copy to 'clip'.
*/
-void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
+static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
{
Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
@@ -275,7 +277,7 @@ void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSLis
*clip = g_slist_prepend(*clip, copy);
}
-void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc)
+static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc)
{
// Sort items:
GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items));
@@ -290,7 +292,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D
g_slist_free(static_cast<GSList *>(sorted_items));
}
-GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip)
+static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip)
{
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
@@ -321,7 +323,7 @@ GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip
return copied;
}
-void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true)
+static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true)
{
for (GSList const *i = items ; i ; i = i->next ) {
sp_object_ref((SPObject *)i->data, NULL);
@@ -372,7 +374,7 @@ void sp_selection_delete(SPDesktop *desktop)
_("Delete"));
}
-void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
+static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
{
if (obj) {
ids.push_back(obj->getId());
@@ -540,7 +542,7 @@ GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onl
return list;
}
-void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool invert)
+static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool invert)
{
if (!dt)
return;
@@ -626,7 +628,7 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop)
sp_edit_select_all_full(desktop, true, true);
}
-void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
+static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position);
@@ -845,7 +847,7 @@ enclose_items(GSList const *items)
}
// TODO determine if this is intentionally different from SPObject::getPrev()
-SPObject *prev_sibling(SPObject *child)
+static SPObject *prev_sibling(SPObject *child)
{
SPObject *prev = 0;
if ( child && SP_IS_GROUP(child->parent) ) {
@@ -1153,7 +1155,7 @@ void sp_selection_paste_livepatheffect(SPDesktop *desktop)
}
-void sp_selection_remove_livepatheffect_impl(SPItem *item)
+static void sp_selection_remove_livepatheffect_impl(SPItem *item)
{
if ( item && SP_IS_LPE_ITEM(item) &&
sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) {
@@ -1314,7 +1316,37 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
g_slist_free(const_cast<GSList *>(items));
}
-bool
+void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)
+{
+ Inkscape::Selection *selection = sp_desktop_selection(dt);
+
+ // check if something is selected
+ if (selection->isEmpty()) {
+ dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move."));
+ return;
+ }
+
+ GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
+
+ if (moveto) {
+ GSList *temp_clip = NULL;
+ sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
+ sp_selection_delete_impl(items, false, false);
+ GSList *copied = sp_selection_paste_impl(sp_desktop_document(dt), moveto, &temp_clip);
+ selection->setReprList((GSList const *) copied);
+ g_slist_free(copied);
+ if (temp_clip) g_slist_free(temp_clip);
+ if (moveto) dt->setCurrentLayer(moveto);
+ if ( !suppressDone ) {
+ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO,
+ _("Move selection to layer"));
+ }
+ }
+
+ g_slist_free(const_cast<GSList *>(items));
+}
+
+static bool
selection_contains_original(SPItem *item, Inkscape::Selection *selection)
{
bool contains_original = false;
@@ -1341,7 +1373,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection)
}
-bool
+static bool
selection_contains_both_clone_and_original(Inkscape::Selection *selection)
{
bool clone_with_original = false;
@@ -1852,7 +1884,7 @@ GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrok
return matches;
}
-bool item_type_match (SPItem *i, SPItem *j)
+static bool item_type_match (SPItem *i, SPItem *j)
{
if ( SP_IS_RECT(i)) {
return ( SP_IS_RECT(j) );
@@ -2857,6 +2889,162 @@ void sp_selection_to_guides(SPDesktop *desktop)
DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));
}
+/*
+ * Convert <g> to <symbol>, leaving all <use> elements referencing group unchanged.
+ */
+void sp_selection_symbol(SPDesktop *desktop, bool apply )
+{
+
+ if (desktop == NULL) {
+ return;
+ }
+
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
+
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+
+ // Check if something is selected.
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one <b>group</b> to convert to symbol."));
+ return;
+ }
+
+ SPObject* group = selection->single();
+
+ // Make sure we have only one object in selection.
+ if( group == NULL ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>group</b> to convert to symbol."));
+ return;
+ }
+
+ // Make sure we convert the original.
+ if( SP_IS_USE( group ) ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select original (<b>Shift+D</b>) to convert to symbol."));
+ return;
+ }
+
+ // Require that we really have a group.
+ if( !SP_IS_GROUP( group ) ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Group selection first to convert to symbol."));
+ return;
+ }
+
+ doc->ensureUpToDate();
+
+ Inkscape::XML::Node *symbol = xml_doc->createElement("svg:symbol");
+ symbol->setAttribute("style", group->getAttribute("style"));
+ symbol->setAttribute("title", group->getAttribute("title"));
+ symbol->setAttribute("transform", group->getAttribute("transform"));
+
+ Glib::ustring id = group->getAttribute("id");
+
+ // Now we need to copy all children of group
+ GSList* children = group->childList(false);
+ children = g_slist_reverse(children);
+ for (GSList* i = children; i != NULL; i = i->next ) {
+ SPObject* child = SP_OBJECT(i->data);
+ Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc);
+ symbol->appendChild(dup);
+ child->deleteObject(true);
+ }
+
+ // Need to delete <g>; all <use> elements that referenced <g> should
+ // auto-magically reference <symbol>.
+ doc->getDefs()->getRepr()->appendChild(symbol);
+ symbol->setAttribute("id",id.c_str()); // After we delete group with same id.
+ // Mysterious, must set symbol ID before deleting group or all <use>
+ // refering to symbol get turned into groups. (Linked to unlinking clones?)
+ group->deleteObject(true);
+
+ Inkscape::GC::release(symbol);
+ selection->clear();
+ // Group just disappears, nothing to select.
+
+ // Need to signal Symbol dialog to update
+
+ g_slist_free(children);
+
+ DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol"));
+}
+
+/*
+ * Convert <symbol> to <g>. All <use> elements referencing symbol remain unchanged.
+ */
+void sp_selection_unsymbol(SPDesktop *desktop)
+{
+
+ if (desktop == NULL) {
+ return;
+ }
+
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
+
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+
+ // Check if something is selected.
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>symbol</b> to extract objects from."));
+ return;
+ }
+
+ SPObject* use = selection->single();
+
+ // Make sure we have only one object in selection.
+ if( use == NULL ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> to convert to group."));
+ return;
+ }
+
+ // Require that we really have a <use> that references a <symbol>.
+ if( !SP_IS_USE( use ) && !SP_IS_SYMBOL( use->firstChild() ) ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> to convert to group."));
+ return;
+ }
+
+ doc->ensureUpToDate();
+
+ SPObject* symbol = use->firstChild();
+
+ Inkscape::XML::Node *group = xml_doc->createElement("svg:g");
+ group->setAttribute("style", symbol->getAttribute("style"));
+ group->setAttribute("title", symbol->getAttribute("title"));
+ group->setAttribute("transform", symbol->getAttribute("transform"));
+
+ Glib::ustring id = symbol->getAttribute("id");
+
+ // Now we need to copy all children of symbol
+ GSList* children = symbol->childList(false);
+ children = g_slist_reverse(children);
+ for (GSList* i = children; i != NULL; i = i->next ) {
+ SPObject* child = SP_OBJECT(i->data);
+ Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc);
+ group->appendChild(dup);
+ child->deleteObject(true);
+ }
+
+ SPObject* parent = use->parent; // So we insert <g> next to <use> (easier to find)
+
+ // Need to delete <symbol>; all other <use> elements that referenced <symbol> should
+ // auto-magically reference <g>.
+ symbol->deleteObject(true);
+ group->setAttribute("id",id.c_str()); // After we delete symbol with same id.
+ parent->getRepr()->appendChild(group);
+ //use->deleteObject(true);
+
+ SPItem *group_item = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(group));
+ Inkscape::GC::release(group);
+ selection->clear();
+ selection->set(group_item);
+
+ // Need to signal Symbol dialog to update
+
+ g_slist_free(children);
+
+ DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol"));
+}
+
void
sp_selection_tile(SPDesktop *desktop, bool apply)
{
@@ -3262,7 +3450,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Run filter, if any
if (run) {
g_print("Running external filter: %s\n", run);
- system(run);
+ int result = system(run);
+
+ if(result == -1)
+ g_warning("Could not run external filter: %s\n", run);
}
// Import the image back
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 0ae2a9b06..5b35ded09 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -11,7 +11,7 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
- * Copyright (C) 1999-2010 authors
+ * Copyright (C) 1999-2012 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -67,6 +67,9 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop);
void sp_selection_to_marker(SPDesktop *desktop, bool apply = true);
void sp_selection_to_guides(SPDesktop *desktop);
+void sp_selection_symbol(SPDesktop *desktop, bool apply = true);
+void sp_selection_unsymbol(SPDesktop *desktop);
+
void sp_selection_tile(SPDesktop *desktop, bool apply = true);
void sp_selection_untile(SPDesktop *desktop);
@@ -97,6 +100,7 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a
void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false );
void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false );
+void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false );
void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true);
void sp_selection_remove_transform (SPDesktop *desktop);
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index 3d1b97b04..391db8950 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -24,6 +24,7 @@
#include "sp-offset.h"
#include "sp-flowtext.h"
#include "sp-use.h"
+#include "sp-symbol.h"
#include "sp-rect.h"
#include "box3d.h"
#include "sp-ellipse.h"
@@ -36,7 +37,7 @@
#include "sp-polyline.h"
#include "sp-spiral.h"
-const gchar *
+static const gchar *
type2term(GType type)
{
if (type == SP_TYPE_ANCHOR)
@@ -80,7 +81,7 @@ type2term(GType type)
return NULL;
}
-GSList *collect_terms (GSList *items)
+static GSList *collect_terms (GSList *items)
{
GSList *r = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
@@ -92,7 +93,7 @@ GSList *collect_terms (GSList *items)
}
// Returns the number of filtered items in the list
-int count_filtered (GSList *items)
+static int count_filtered (GSList *items)
{
int count=0;
SPItem *item=NULL;
@@ -192,7 +193,11 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
if (!items->next) { // one item
char *item_desc = item->description();
- if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
+ if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) {
+ _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
+ item_desc, in_phrase,
+ _("Convert symbol to group to edit"), _when_selected);
+ } else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up original"), _when_selected);
diff --git a/src/selection.cpp b/src/selection.cpp
index d769b402c..72f50137c 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -443,15 +443,13 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc
SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center
- //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source
- //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference
std::vector<Inkscape::SnapCandidatePoint> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
SPItem *this_item = SP_ITEM(iter->data);
this_item->getSnappoints(p, &snapprefs_dummy);
//Include the transformation origin for snapping
- //For a selection or group only the overall origin is considered
+ //For a selection or group only the overall center is considered, not for each item individually
if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) {
p.push_back(Inkscape::SnapCandidatePoint(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER));
}
@@ -460,36 +458,6 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc
return p;
}
-// TODO: both getSnapPoints and getSnapPointsConvexHull are called, subsequently. Can we do this more efficient?
-// Why do we need to include the transformation center in one case and not the other?
-std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const {
- GSList const *items = const_cast<Selection *>(this)->itemList();
-
- SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
- snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source
- snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference
-
- std::vector<Inkscape::SnapCandidatePoint> p;
- for (GSList const *iter = items; iter != NULL; iter = iter->next) {
- SP_ITEM(iter->data)->getSnappoints(p, &snapprefs_dummy);
- }
-
- std::vector<Inkscape::SnapCandidatePoint> pHull;
- if (!p.empty()) {
- Geom::Rect cvh((p.front()).getPoint(), (p.front()).getPoint());
- for (std::vector<Inkscape::SnapCandidatePoint>::iterator i = p.begin(); i != p.end(); ++i) {
- // these are the points we get back
- cvh.expandTo((*i).getPoint());
- }
-
- for ( unsigned i = 0 ; i < 4 ; ++i ) {
- pHull.push_back(Inkscape::SnapCandidatePoint(cvh.corner(i), SNAPSOURCE_CONVEX_HULL_CORNER));
- }
- }
-
- return pHull;
-}
-
void Selection::_removeObjectDescendants(SPObject *obj) {
GSList *iter, *next;
for ( iter = _objs ; iter ; iter = next ) {
diff --git a/src/selection.h b/src/selection.h
index 168c70dd4..85e06a5c6 100644
--- a/src/selection.h
+++ b/src/selection.h
@@ -267,12 +267,6 @@ public:
std::vector<Inkscape::SnapCandidatePoint> getSnapPoints(SnapPreferences const *snapprefs) const;
/**
- * Gets the snap points of a selection that form a convex hull.
- * @return Selection's convex hull points
- */
- std::vector<Inkscape::SnapCandidatePoint> getSnapPointsConvexHull(SnapPreferences const *snapprefs) const;
-
- /**
* Connects a slot to be notified of selection changes.
*
* This method connects the given slot such that it will
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 15cea9198..64bb95508 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -298,30 +298,21 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// Next, get all points to consider for snapping
SnapManager const &m = _desktop->namedview->snap_manager;
_snap_points.clear();
- _snap_points = selection->getSnapPoints(&m.snapprefs);
- std::vector<Inkscape::SnapCandidatePoint> snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs);
+ if (m.someSnapperMightSnap(false)) { // Only search for snap sources when really needed, to avoid unnecessary delays
+ _snap_points = selection->getSnapPoints(&m.snapprefs); // This might take some time!
+ }
if (_snap_points.size() > 200 && !(prefs->getBool("/options/snapclosestonly/value", false))) {
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
A typical user would rarely ever try to snap such a large number of nodes anyway, because
(s)he would hardly be able to discern which node would be snapping */
- _snap_points = snap_points_hull;
- //}
+ _snap_points.resize(200);
// Unfortunately, by now we will have lost the font-baseline snappoints :-(
}
// Find bbox hulling all special points, which excludes stroke width. Here we need to include the
// path nodes, for example because a rectangle which has been converted to a path doesn't have
// any other special points
- Geom::Rect snap_points_bbox;
- if ( snap_points_hull.empty() == false ) {
- std::vector<Inkscape::SnapCandidatePoint>::iterator i = snap_points_hull.begin();
- snap_points_bbox = Geom::Rect((*i).getPoint(), (*i).getPoint());
- i++;
- while (i != snap_points_hull.end()) {
- snap_points_bbox.expandTo((*i).getPoint());
- i++;
- }
- }
+ Geom::OptRect snap_points_bbox = selection->bounds(SPItem::GEOMETRIC_BBOX);
_bbox_points.clear();
// Collect the bounding box's corners and midpoints for each selected item
@@ -329,11 +320,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER);
bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT);
bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT);
- // 1) Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations
- // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the
- // stroke width. (see get_scale_transform_for_stroke()). This however is currently only implemented for a single bbox.
- // 2) More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl
- // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole
+ // Preferably we'd use the bbox of each selected item, but for example 50 items will produce at least 200 bbox points,
+ // which might make Inkscape crawl(see the comment a few lines above). In that case we will use the bbox of the selection as a whole
bool c1 = (_items.size() > 0) && (_items.size() < 50);
bool c2 = prefs->getBool("/options/snapclosestonly/value", false);
if (translating && (c1 || c2)) {
@@ -353,10 +341,14 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// - one for snapping the boundingbox, which can be either visual or geometric
// - one for snapping the special points
// The "opposite" in case of a geometric boundingbox always coincides with the "opposite" for the special points
- // These distinct "opposites" are needed in the snapmanager to avoid bugs such as #sf1540195 (in which
+ // These distinct "opposites" are needed in the snapmanager to avoid bugs such as LP167905 (in which
// a box is caught between two guides)
_opposite_for_bboxpoints = _bbox->min() + _bbox->dimensions() * Geom::Scale(1-x, 1-y);
- _opposite_for_specpoints = snap_points_bbox.min() + snap_points_bbox.dimensions() * Geom::Scale(1-x, 1-y);
+ if (snap_points_bbox) {
+ _opposite_for_specpoints = (*snap_points_bbox).min() + (*snap_points_bbox).dimensions() * Geom::Scale(1-x, 1-y);
+ } else {
+ _opposite_for_specpoints = _opposite_for_bboxpoints;
+ }
_opposite = _opposite_for_bboxpoints;
}
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index 796962b11..9ececbb3b 100644
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
@@ -28,6 +28,7 @@
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
+#include <glibmm/i18n.h>
#include "helper/action.h"
#include "io/sys.h"
@@ -36,12 +37,24 @@
#include "verbs.h"
#include "xml/node-iterators.h"
#include "xml/repr.h"
+#include "document.h"
+#include "preferences.h"
+#include "event-context.h"
+#include "inkscape.h"
+#include "desktop.h"
+#include "path-prefix.h"
+#include "ui/dialog/filedialog.h"
using namespace Inkscape;
-static void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary);
+using Inkscape::IO::Resource::get_path;
+using Inkscape::IO::Resource::SYSTEM;
+using Inkscape::IO::Resource::USER;
+using Inkscape::IO::Resource::KEYS;
+
+
static void try_shortcuts_file(char const *filename);
-static void read_shortcuts_file(char const *filename);
+static void read_shortcuts_file(char const *filename, bool const is_user_set=false);
/* Returns true if action was performed */
@@ -61,19 +74,22 @@ sp_shortcut_invoke(unsigned int shortcut, Inkscape::UI::View::View *view)
static std::map<unsigned int, Inkscape::Verb * > *verbs = NULL;
static std::map<Inkscape::Verb *, unsigned int> *primary_shortcuts = NULL;
+static std::map<Inkscape::Verb *, unsigned int> *user_shortcuts = NULL;
-static void
-sp_shortcut_init()
+void sp_shortcut_init()
{
- using Inkscape::IO::Resource::get_path;
- using Inkscape::IO::Resource::SYSTEM;
- using Inkscape::IO::Resource::USER;
- using Inkscape::IO::Resource::KEYS;
verbs = new std::map<unsigned int, Inkscape::Verb * >();
primary_shortcuts = new std::map<Inkscape::Verb *, unsigned int>();
+ user_shortcuts = new std::map<Inkscape::Verb *, unsigned int>();
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring shortcutfile = prefs->getString("/options/kbshortcuts/shortcutfile");
+ if (shortcutfile.empty()) {
+ shortcutfile = Glib::ustring(get_path(SYSTEM, KEYS, "default.xml"));
+ }
- read_shortcuts_file(get_path(SYSTEM, KEYS, "default.xml"));
+ read_shortcuts_file(shortcutfile.c_str());
try_shortcuts_file(get_path(USER, KEYS, "default.xml"));
}
@@ -82,11 +98,451 @@ static void try_shortcuts_file(char const *filename) {
/* ah, if only we had an exception to catch... (permission, forgiveness) */
if (file_test(filename, G_FILE_TEST_EXISTS)) {
- read_shortcuts_file(filename);
+ read_shortcuts_file(filename, true);
}
}
-static void read_shortcuts_file(char const *filename) {
+/*
+ * Inkscape expects to add the Shift modifier to any accel_keys create with Shift
+ * For exmaple on en_US keyboard <Shift>+6 = "&" - in this case return <Shift>+&
+ * See get_group0_keyval() for explanation on why
+ */
+unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmodifier, guint hardware_keycode) {
+
+
+ unsigned int shortcut = 0;
+ GdkEventKey event;
+ event.state = gdkmodifier;
+ event.keyval = accel_key;
+ event.hardware_keycode = hardware_keycode;
+ guint keyval = get_group0_keyval (&event);
+
+ shortcut = accel_key |
+ ( (gdkmodifier & GDK_SHIFT_MASK) || ( accel_key != keyval) ?
+ SP_SHORTCUT_SHIFT_MASK : 0 ) |
+ ( gdkmodifier & GDK_CONTROL_MASK ?
+ SP_SHORTCUT_CONTROL_MASK : 0 ) |
+ ( gdkmodifier & GDK_MOD1_MASK ?
+ SP_SHORTCUT_ALT_MASK : 0 );
+
+ return shortcut;
+}
+
+Glib::ustring sp_shortcut_to_label(unsigned int const shortcut) {
+
+ Glib::ustring modifiers = "";
+
+ if (shortcut & SP_SHORTCUT_CONTROL_MASK)
+ modifiers += "Ctrl,";
+ if (shortcut & SP_SHORTCUT_SHIFT_MASK)
+ modifiers += "Shift,";
+ if (shortcut & SP_SHORTCUT_ALT_MASK)
+ modifiers += "Alt,";
+
+ if(modifiers.length() > 0 &&
+ modifiers.find(',',modifiers.length()-1)!=modifiers.npos) {
+ modifiers.erase(modifiers.length()-1, 1);
+ }
+
+ return modifiers;
+}
+
+/*
+ * REmove all shortucts from the users file
+ */
+
+void sp_shortcuts_delete_all_from_file() {
+
+
+ char const *filename = get_path(USER, KEYS, "default.xml");
+
+ XML::Document *doc=sp_repr_read_file(filename, NULL);
+ if (!doc) {
+ g_warning("Unable to read keys file %s", filename);
+ return;
+ }
+
+ XML::Node *root=doc->root();
+ g_return_if_fail(!strcmp(root->name(), "keys"));
+
+ XML::Node *iter=root->firstChild();
+ while (iter) {
+
+ if (strcmp(iter->name(), "bind")) {
+ // some unknown element, do not complain
+ iter = iter->next();
+ continue;
+ }
+
+ // Delete node
+ sp_repr_unparent(iter);
+ iter=root->firstChild();
+ }
+
+
+ sp_repr_save_file(doc, filename, NULL);
+
+ GC::release(doc);
+}
+
+Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) {
+
+ gchar const *buffer =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> "
+ "<keys name=\"My custom shortcuts\">"
+ "</keys>";
+
+ Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), NULL);
+ sp_repr_save_file(doc, filename, NULL);
+
+ return sp_repr_read_file(filename, NULL);
+}
+
+/*
+ * Get a list of keyboard shortcut files names and paths from the system and users paths
+ * Dont add the users custom keyboards file
+ */
+void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<Glib::ustring> *paths) {
+
+ std::list<gchar *> sources;
+ sources.push_back( profile_path("keys") );
+ sources.push_back( g_strdup(INKSCAPE_KEYSDIR) );
+
+ // loop through possible keyboard shortcut file locations.
+ while (!sources.empty()) {
+ gchar *dirname = sources.front();
+ if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS )
+ && Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) {
+ GError *err = 0;
+ GDir *directory = g_dir_open(dirname, 0, &err);
+ if (!directory) {
+ gchar *safeDir = Inkscape::IO::sanitizeString(dirname);
+ g_warning(_("Keyboard directory (%s) is unavailable."), safeDir);
+ g_free(safeDir);
+ } else {
+ gchar *filename = 0;
+ while ((filename = (gchar *) g_dir_read_name(directory)) != NULL) {
+ gchar* lower = g_ascii_strdown(filename, -1);
+ if (!strcmp(dirname, profile_path("keys")) &&
+ !strcmp(lower, "default.xml")) {
+ // Dont add the users custom keys file
+ continue;
+ }
+ if (!strcmp(dirname, INKSCAPE_KEYSDIR) &&
+ !strcmp(lower, "inkscape.xml")) {
+ // Dont add system inkscape.xml (since its a duplicate? of dfefault.xml)
+ continue;
+ }
+ if (g_str_has_suffix(lower, ".xml")) {
+ gchar* full = g_build_filename(dirname, filename, NULL);
+ if (!Inkscape::IO::file_test(full, G_FILE_TEST_IS_DIR)) {
+
+ // Get the "key name" from the root element of each file
+ XML::Document *doc=sp_repr_read_file(full, NULL);
+ if (!doc) {
+ g_warning("Unable to read keyboard shortcut file %s", full);
+ continue;
+ }
+ XML::Node *root=doc->root();
+ if (strcmp(root->name(), "keys")) {
+ g_warning("Not a shortcut keys file %s", full);
+ Inkscape::GC::release(doc);
+ continue;
+ }
+
+ gchar const *name=root->attribute("name");
+ Glib::ustring label(filename);
+ if (name) {
+ label = Glib::ustring(name)+ " (" + filename + ")";
+ }
+
+ if (!strcmp(filename, "default.xml")) {
+ paths->insert(paths->begin(), full);
+ names->insert(names->begin(), label.c_str());
+ } else {
+ paths->push_back(full);
+ names->push_back(label.c_str());
+ }
+
+ Inkscape::GC::release(doc);
+ }
+ g_free(full);
+ }
+ g_free(lower);
+ }
+ g_dir_close(directory);
+ }
+ }
+
+ g_free(dirname);
+ sources.pop_front();
+ }
+
+}
+
+Glib::ustring sp_shortcut_get_file_path()
+{
+ //# Get the current directory for finding files
+ Glib::ustring open_path;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ Glib::ustring attr = prefs->getString("/dialogs/save_export/path");
+ if (!attr.empty()) open_path = attr;
+
+ //# Test if the open_path directory exists
+ if (!Inkscape::IO::file_test(open_path.c_str(),
+ (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+ open_path = "";
+
+ if (open_path.empty()) {
+ /* Grab document directory */
+ const gchar* docURI = SP_ACTIVE_DOCUMENT->getURI();
+ if (docURI) {
+ open_path = Glib::path_get_dirname(docURI);
+ open_path.append(G_DIR_SEPARATOR_S);
+ }
+ }
+
+ //# If no open path, default to our home directory
+ if (open_path.empty())
+ {
+ open_path = g_get_home_dir();
+ open_path.append(G_DIR_SEPARATOR_S);
+ }
+
+ return open_path;
+}
+
+//static Inkscape::UI::Dialog::FileSaveDialog * saveDialog = NULL;
+
+void sp_shortcut_file_export()
+{
+ Glib::ustring open_path = sp_shortcut_get_file_path();
+ open_path.append("shortcut_keys.xml");
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ Glib::ustring filename;
+
+ Inkscape::UI::Dialog::FileSaveDialog *saveDialog =
+ Inkscape::UI::Dialog::FileSaveDialog::create(
+ *(desktop->getToplevel()),
+ open_path,
+ Inkscape::UI::Dialog::CUSTOM_TYPE,
+ _("Select a filename for exporting"),
+ "",
+ "",
+ Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS
+ );
+ saveDialog->addFileType("All Files", "*");
+
+ bool success = saveDialog->show();
+ if (!success) {
+ delete saveDialog;
+ return;
+ }
+
+ Glib::ustring fileName = saveDialog->getFilename();
+ if (fileName.size() > 0) {
+ Glib::ustring newFileName = Glib::filename_to_utf8(fileName);
+ sp_shortcut_file_export_do(newFileName.c_str());
+ }
+
+ delete saveDialog;
+}
+
+bool sp_shortcut_file_import() {
+
+ Glib::ustring open_path = sp_shortcut_get_file_path();
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+
+ Inkscape::UI::Dialog::FileOpenDialog *importFileDialog =
+ Inkscape::UI::Dialog::FileOpenDialog::create(
+ *desktop->getToplevel(),
+ open_path,
+ Inkscape::UI::Dialog::CUSTOM_TYPE,
+ _("Select a file to import"));
+ importFileDialog->addFilterMenu("All Files", "*");
+
+ //# Show the dialog
+ bool const success = importFileDialog->show();
+
+ if (!success) {
+ delete importFileDialog;
+ return false;
+ }
+
+ Glib::ustring fileName = importFileDialog->getFilename();
+ sp_shortcut_file_import_do(fileName.c_str());
+
+ delete importFileDialog;
+
+ return true;
+}
+
+void sp_shortcut_file_import_do(char const *importname) {
+
+ XML::Document *doc=sp_repr_read_file(importname, NULL);
+ if (!doc) {
+ g_warning("Unable to read keyboard shortcut file %s", importname);
+ return;
+ }
+
+ char const *filename = get_path(USER, KEYS, "default.xml");
+ sp_repr_save_file(doc, filename, NULL);
+
+ GC::release(doc);
+
+ sp_shortcut_init();
+}
+
+void sp_shortcut_file_export_do(char const *exportname) {
+
+ char const *filename = get_path(USER, KEYS, "default.xml");
+
+ XML::Document *doc=sp_repr_read_file(filename, NULL);
+ if (!doc) {
+ g_warning("Unable to read keyboard shortcut file %s", filename);
+ return;
+ }
+
+ sp_repr_save_file(doc, exportname, NULL);
+
+ GC::release(doc);
+}
+/*
+ * Add or delete a shortcut to the users default.xml keys file
+ * @param addremove - when true add/override a shortcut, when false remove shortcut
+ * @param addshift - when true addthe Shifg modifier to the non-display element
+ *
+ * Shortcut file consists of pairs of bind elements :
+ * Element (a) is used for shortcut display in menus (display="True") and contains the gdk_keyval_name of the shortcut key
+ * Element (b) is used in shortcut lookup and contains an uppercase version of the gdk_keyval_name,
+ * or a gdk_keyval_name name and the "Shift" modifier for Shift altered hardware code keys (see get_group0_keyval() for explanation)
+ */
+void sp_shortcut_delete_from_file(char const *action, unsigned int const shortcut) {
+
+ char const *filename = get_path(USER, KEYS, "default.xml");
+
+ XML::Document *doc=sp_repr_read_file(filename, NULL);
+ if (!doc) {
+ g_warning("Unable to read keyboard shortcut file %s", filename);
+ return;
+ }
+
+ gchar *key = gdk_keyval_name (shortcut & (~SP_SHORTCUT_MODIFIER_MASK));
+ std::string modifiers = sp_shortcut_to_label(shortcut & (SP_SHORTCUT_MODIFIER_MASK));
+
+ if (!key) {
+ g_warning("Unknown key for shortcut %u", shortcut);
+ return;
+ }
+
+ //g_message("Removing key %s, mods %s action %s", key, modifiers.c_str(), action);
+
+ XML::Node *root=doc->root();
+ g_return_if_fail(!strcmp(root->name(), "keys"));
+ XML::Node *iter=root->firstChild();
+ while (iter) {
+
+ if (strcmp(iter->name(), "bind")) {
+ // some unknown element, do not complain
+ iter = iter->next();
+ continue;
+ }
+
+ gchar const *verb_name=iter->attribute("action");
+ if (!verb_name) {
+ iter = iter->next();
+ continue;
+ }
+
+ gchar const *keyval_name = iter->attribute("key");
+ if (!keyval_name || !*keyval_name) {
+ // that's ok, it's just listed for reference without assignment, skip it
+ iter = iter->next();
+ continue;
+ }
+
+ if (Glib::ustring(key).lowercase() != Glib::ustring(keyval_name).lowercase()) {
+ // If deleting, then delete both the upper and lower case versions
+ iter = iter->next();
+ continue;
+ }
+
+ gchar const *modifiers_string = iter->attribute("modifiers");
+ if ((modifiers_string && !strcmp(modifiers.c_str(), modifiers_string)) ||
+ (!modifiers_string && modifiers.empty())) {
+ //Looks like a match
+ // Delete node
+ sp_repr_unparent(iter);
+ iter = root->firstChild();
+ continue;
+ }
+ iter = iter->next();
+ }
+
+ sp_repr_save_file(doc, filename, NULL);
+
+ GC::release(doc);
+
+}
+
+void sp_shortcut_add_to_file(char const *action, unsigned int const shortcut) {
+
+ char const *filename = get_path(USER, KEYS, "default.xml");
+
+ XML::Document *doc=sp_repr_read_file(filename, NULL);
+ if (!doc) {
+ g_warning("Unable to read keyboard shortcut file %s, creating ....", filename);
+ doc = sp_shortcut_create_template_file(filename);
+ if (!doc) {
+ g_warning("Unable to create keyboard shortcut file %s", filename);
+ return;
+ }
+ }
+
+ gchar *key = gdk_keyval_name (shortcut & (~SP_SHORTCUT_MODIFIER_MASK));
+ std::string modifiers = sp_shortcut_to_label(shortcut & (SP_SHORTCUT_MODIFIER_MASK));
+
+ if (!key) {
+ g_warning("Unknown key for shortcut %u", shortcut);
+ return;
+ }
+
+ //g_message("Adding key %s, mods %s action %s", key, modifiers.c_str(), action);
+
+ // Add node
+ Inkscape::XML::Node *newnode;
+ newnode = doc->createElement("bind");
+ newnode->setAttribute("key", key);
+ if (!modifiers.empty()) {
+ newnode->setAttribute("modifiers", modifiers.c_str());
+ }
+ newnode->setAttribute("action", action);
+ newnode->setAttribute("display", "true");
+
+ doc->root()->appendChild(newnode);
+
+ if (strlen(key) == 1) {
+ // Add another uppercase version if a character
+ Inkscape::XML::Node *newnode;
+ newnode = doc->createElement("bind");
+ newnode->setAttribute("key", Glib::ustring(key).uppercase().c_str());
+ if (!modifiers.empty()) {
+ newnode->setAttribute("modifiers", modifiers.c_str());
+ }
+
+ newnode->setAttribute("action", action);
+ doc->root()->appendChild(newnode);
+ }
+
+ sp_repr_save_file(doc, filename, NULL);
+
+ GC::release(doc);
+
+}
+static void read_shortcuts_file(char const *filename, bool const is_user_set) {
XML::Document *doc=sp_repr_read_file(filename, NULL);
if (!doc) {
g_warning("Unable to read keys file %s", filename);
@@ -153,13 +609,37 @@ static void read_shortcuts_file(char const *filename) {
}
}
- sp_shortcut_set(keyval | modifiers, verb, is_primary);
+ sp_shortcut_set(keyval | modifiers, verb, is_primary, is_user_set);
}
GC::release(doc);
}
/**
+ * Removes a keyboard shortcut for the given verb.
+ * (Removes any existing binding for the given shortcut, including appropriately
+ * adjusting sp_shortcut_get_primary if necessary.)*
+ */
+void
+sp_shortcut_unset(unsigned int const shortcut)
+{
+ if (!verbs) sp_shortcut_init();
+
+ Inkscape::Verb *verb = (*verbs)[shortcut];
+
+ /* Maintain the invariant that sp_shortcut_get_primary(v) returns either 0 or a valid shortcut for v. */
+ if (verb) {
+
+ (*verbs)[shortcut] = 0;
+
+ unsigned int const old_primary = (*primary_shortcuts)[verb];
+ if (old_primary == shortcut) {
+ (*primary_shortcuts)[verb] = 0;
+ }
+
+ }
+}
+/**
* Adds a keyboard shortcut for the given verb.
* (Removes any existing binding for the given shortcut, including appropriately
* adjusting sp_shortcut_get_primary if necessary.)
@@ -169,8 +649,8 @@ static void read_shortcuts_file(char const *filename) {
* \post sp_shortcut_get_verb(shortcut) == verb.
* \post !is_primary or sp_shortcut_get_primary(verb) == shortcut.
*/
-static void
-sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary)
+void
+sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary, bool const is_user_set)
{
if (!verbs) sp_shortcut_init();
@@ -183,11 +663,13 @@ sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool co
if (old_primary == shortcut) {
(*primary_shortcuts)[old_verb] = 0;
+ (*user_shortcuts)[old_verb] = 0;
}
}
if (is_primary) {
(*primary_shortcuts)[verb] = shortcut;
+ (*user_shortcuts)[verb] = is_user_set;
}
}
@@ -211,6 +693,20 @@ unsigned int sp_shortcut_get_primary(Inkscape::Verb *verb)
return result;
}
+bool sp_shortcut_is_user_set(Inkscape::Verb *verb)
+{
+ unsigned int result = false;
+ if (!primary_shortcuts) {
+ sp_shortcut_init();
+ }
+
+ if (primary_shortcuts->count(verb)) {
+ result = (*user_shortcuts)[verb];
+ }
+ return result;
+}
+
+
gchar *sp_shortcut_get_label(unsigned int shortcut)
{
// The comment below was copied from the function sp_ui_shortcut_string in interface.cpp (which was subsequently removed)
diff --git a/src/shortcuts.h b/src/shortcuts.h
index 9d84aa6d1..118909bd3 100644
--- a/src/shortcuts.h
+++ b/src/shortcuts.h
@@ -1,6 +1,8 @@
#ifndef __SP_SHORTCUTS_H__
#define __SP_SHORTCUTS_H__
+#include <gtkmm/cellrendereraccel.h>
+
/*
* Keyboard shortcut processing
*
@@ -29,9 +31,23 @@ namespace Inkscape {
/* Returns true if action was performed */
bool sp_shortcut_invoke (unsigned int shortcut, Inkscape::UI::View::View *view);
+void sp_shortcut_init();
Inkscape::Verb * sp_shortcut_get_verb (unsigned int shortcut);
unsigned int sp_shortcut_get_primary (Inkscape::Verb * verb); // Returns GDK_VoidSymbol if no shortcut is found.
char* sp_shortcut_get_label (unsigned int shortcut); // Returns the human readable form of the shortcut (or NULL), for example Shift+Ctrl+F. Free the returned string with g_free.
+void sp_shortcut_set(unsigned int const shortcut, Inkscape::Verb *const verb, bool const is_primary, bool const is_user_set=false);
+void sp_shortcut_unset(unsigned int const shortcut);
+void sp_shortcut_add_to_file(char const *action, unsigned int const shortcut);
+void sp_shortcut_delete_from_file(char const *action, unsigned int const shortcut);
+void sp_shortcuts_delete_all_from_file();
+Glib::ustring sp_shortcut_to_label(unsigned int const shortcut);
+unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmodifier, guint hardware_keycode);
+void sp_shortcut_get_file_names(std::vector<Glib::ustring> *names, std::vector<Glib::ustring> *paths);
+bool sp_shortcut_is_user_set(Inkscape::Verb *verb);
+void sp_shortcut_file_export();
+bool sp_shortcut_file_import();
+void sp_shortcut_file_import_do(char const *importname);
+void sp_shortcut_file_export_do(char const *exportname);
#endif
diff --git a/src/snap-candidate.h b/src/snap-candidate.h
index db0c3fd67..8bb7cb52f 100644
--- a/src/snap-candidate.h
+++ b/src/snap-candidate.h
@@ -25,6 +25,8 @@ namespace Inkscape {
class SnapCandidatePoint
{
public:
+ SnapCandidatePoint() {}; // only needed / used for resizing() of a vector in seltrans.cpp; do not use uninitialized instances!
+
SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num, Inkscape::SnapTargetType const target, Geom::OptRect const &bbox)
: _point(point),
_source_type(source),
@@ -39,10 +41,10 @@ public:
: _point(point),
_source_type(source),
_target_type(target),
+ _target_bbox(Geom::OptRect()),
_dist()
{
_source_num = -1;
- _target_bbox = Geom::OptRect();
}
SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source)
@@ -50,10 +52,10 @@ public:
_source_type(source),
_target_type(Inkscape::SNAPTARGET_UNDEFINED),
_source_num(-1),
+ _target_bbox(Geom::OptRect()),
_dist()
{
- _target_bbox = Geom::OptRect();
- }
+ };
inline Geom::Point const & getPoint() const {return _point;}
inline Inkscape::SnapSourceType getSourceType() const {return _source_type;}
diff --git a/src/snap.cpp b/src/snap.cpp
index 1ee55fcf8..695424194 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -77,9 +77,14 @@ SnapManager::SnapperList SnapManager::getGridSnappers() const
return s;
}
-bool SnapManager::someSnapperMightSnap() const
+bool SnapManager::someSnapperMightSnap(bool immediately) const
{
- if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) {
+ if ( !snapprefs.getSnapEnabledGlobally() ) {
+ return false;
+ }
+
+ // If we're asking if some snapper might snap RIGHT NOW (without the snap being postponed)...
+ if ( immediately && snapprefs.getSnapPostponedGlobally() ) {
return false;
}
diff --git a/src/snap.h b/src/snap.h
index 3a8e18ad3..67af20063 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -93,7 +93,7 @@ public:
*
* @return true if one of the snappers will try to snap to something.
*/
- bool someSnapperMightSnap() const;
+ bool someSnapperMightSnap(bool immediately = true) const;
/**
* @return true if one of the grids might be snapped to.
diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp
index f8d5694da..cabda82d3 100644
--- a/src/sp-conn-end.cpp
+++ b/src/sp-conn-end.cpp
@@ -152,7 +152,7 @@ sp_conn_get_route_and_redraw(SPPath *const path,
// Set sensible values incase there the connector ends are not
// attached to any shapes.
Geom::PathVector conn_pv = path->_curve->get_pathvector();
- double endPos[2] = { 0, conn_pv[0].size() };
+ double endPos[2] = { 0.0, static_cast<double>(conn_pv[0].size()) };
SPConnEnd** _connEnd = path->connEndPair.getConnEnds();
for (unsigned h = 0; h < 2; ++h) {
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 5efa3c84f..d7add805d 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -2051,13 +2051,32 @@ sp_radialgradient_create_pattern(SPPaintServer *ps,
double scale = 1.0;
double tolerance = cairo_get_tolerance(ct);
+ // NOTE: SVG2 will allow the use of a focus circle which can
+ // have its center outside the first circle.
+
// code below suggested by Cairo devs to overcome tolerance problems
// more: https://bugs.freedesktop.org/show_bug.cgi?id=40918
+
+ // Corrected for
+ // https://bugs.launchpad.net/inkscape/+bug/970355
+
+ Geom::Affine gs2user = gr->gradientTransform;
+ Geom::Scale gs2user_scale;
+
+ if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) {
+ Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
+ gs2user *= bbox2user;
+ gs2user_scale = Geom::Scale( gs2user[0], gs2user[3] );
+ }
+
Geom::Point d = focus - center;
- if (d.length() + tolerance > radius) {
- scale = radius / d.length();
+ Geom::Point d_user = d * gs2user_scale;
+ Geom::Point r_user( radius, 0 );
+ r_user *= gs2user_scale;
- double dx = d.x(), dy = d.y();
+ if (d_user.length() + tolerance > r_user.length()) {
+ scale = r_user.length() / d_user.length();
+ double dx = d_user.x(), dy = d_user.y();
cairo_user_to_device_distance(ct, &dx, &dy);
if (!Geom::are_near(dx, 0, tolerance) ||
!Geom::are_near(dy, 0, tolerance))
@@ -2104,15 +2123,15 @@ static cairo_pattern_t *sp_meshgradient_create_pattern(SPPaintServer *ps,
cp = cairo_pattern_create_mesh();
- for( uint i = 0; i < array->patch_rows(); ++i ) {
- for( uint j = 0; j < array->patch_columns(); ++j ) {
+ for( unsigned int i = 0; i < array->patch_rows(); ++i ) {
+ for( unsigned int j = 0; j < array->patch_columns(); ++j ) {
SPMeshPatchI patch( &(array->nodes), i, j );
cairo_mesh_pattern_begin_patch( cp );
cairo_mesh_pattern_move_to( cp, patch.getPoint( 0, 0 )[X], patch.getPoint( 0, 0 )[Y] );
- for( uint k = 0; k < 4; ++k ) {
+ for( unsigned int k = 0; k < 4; ++k ) {
#ifdef DEBUG_MESH
std::cout << i << " " << j << " "
<< patch.getPathType( k ) << " (";
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 07885ff4d..7293c49fa 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -234,7 +234,7 @@ private:
PushPull(const PushPull& other);
};
-void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length )
+static void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length )
{
// g_message( "user_read_data(%d)", length );
@@ -255,12 +255,12 @@ void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length )
// g_message("things out");
}
-void user_write_data( png_structp /*png_ptr*/, png_bytep /*data*/, png_size_t /*length*/ )
+static void user_write_data( png_structp /*png_ptr*/, png_bytep /*data*/, png_size_t /*length*/ )
{
//g_message( "user_write_data(%d)", length );
}
-void user_flush_data( png_structp /*png_ptr*/ )
+static void user_flush_data( png_structp /*png_ptr*/ )
{
//g_message( "user_flush_data" );
}
@@ -424,7 +424,7 @@ static bool readPngAndHeaders( PushPull &youme, gint & dpiX, gint & dpiY )
return good;
}
-static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath, GError **/*error*/ )
+GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, gchar*& pixPath, GError **/*error*/ )
{
GdkPixbuf* buf = NULL;
PushPull youme;
@@ -433,10 +433,16 @@ static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, g
modTime = 0;
if ( pixPath ) {
g_free(pixPath);
- pixPath = 0;
+ pixPath = NULL;
+ }
+
+ struct stat stdir;
+ g_stat(filename, &stdir);
+ if (stdir.st_mode & S_IFDIR){
+ //filename is not correct: it is a directory name and hence further code can not return valid results
+ return NULL;
}
- //buf = gdk_pixbuf_new_from_file( filename, error );
dump_fopen_call( filename, "pixbuf_new_from_file" );
FILE* fp = fopen_utf8name( filename, "r" );
if ( fp )
@@ -479,7 +485,6 @@ static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, g
}
} else if ( !latter ) {
latter = TRUE;
- //g_message(" READing latter");
}
// Now clear out the buffer so we can read more.
// (dumping out unused)
@@ -492,23 +497,6 @@ static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, g
buf = gdk_pixbuf_loader_get_pixbuf( loader );
if ( buf ) {
g_object_ref(buf);
-
- if ( dpiX ) {
- gchar *tmp = g_strdup_printf( "%d", dpiX );
- if ( tmp ) {
- //g_message("Need to set DpiX: %s", tmp);
- //gdk_pixbuf_set_option( buf, "Inkscape::DpiX", tmp );
- g_free( tmp );
- }
- }
- if ( dpiY ) {
- gchar *tmp = g_strdup_printf( "%d", dpiY );
- if ( tmp ) {
- //g_message("Need to set DpiY: %s", tmp);
- //gdk_pixbuf_set_option( buf, "Inkscape::DpiY", tmp );
- g_free( tmp );
- }
- }
}
} else {
// do something
@@ -525,22 +513,6 @@ static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, g
g_warning ("Unable to open linked file: %s", filename);
}
-/*
- if ( buf )
- {
- const gchar* bloop = gdk_pixbuf_get_option( buf, "Inkscape::DpiX" );
- if ( bloop )
- {
- g_message("DPI X is [%s]", bloop);
- }
- bloop = gdk_pixbuf_get_option( buf, "Inkscape::DpiY" );
- if ( bloop )
- {
- g_message("DPI Y is [%s]", bloop);
- }
- }
-*/
-
return buf;
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index b54ec65e2..de2c79ec6 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -766,7 +766,9 @@ void CGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *a
if (SP_IS_ITEM (o)) {
child = SP_ITEM (o);
ac = child->invoke_show (drawing, key, flags);
- ai->appendChild(ac);
+ if (ac) {
+ ai->appendChild(ac);
+ }
}
l = g_slist_remove (l, o);
}
diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp
index fd27c896a..0f5117289 100644
--- a/src/sp-item-notify-moveto.cpp
+++ b/src/sp-item-notify-moveto.cpp
@@ -6,6 +6,7 @@
#include <2geom/transforms.h>
#include <sp-guide.h>
#include <sp-item-rm-unsatisfied-cns.h>
+#include <sp-item-notify-moveto.h>
using std::vector;
diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp
index de4c7dca1..c35e4fa48 100644
--- a/src/sp-item-rm-unsatisfied-cns.cpp
+++ b/src/sp-item-rm-unsatisfied-cns.cpp
@@ -6,6 +6,7 @@
#include "sp-guide.h"
#include "sp-guide-constraint.h"
#include "sp-item.h"
+#include "sp-item-rm-unsatisfied-cns.h"
using std::vector;
diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp
index a8d553e9f..a27a1bc78 100644
--- a/src/sp-item-transform.cpp
+++ b/src/sp-item-transform.cpp
@@ -16,6 +16,7 @@
#include <2geom/transforms.h>
#include "sp-item.h"
+#include "sp-item-transform.h"
void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation)
{
diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp
index 315d09108..750f0d94f 100644
--- a/src/sp-item-update-cns.cpp
+++ b/src/sp-item-update-cns.cpp
@@ -1,8 +1,9 @@
#include "satisfied-guide-cns.h"
#include "sp-guide-constraint.h"
-#include <sp-guide.h>
-#include <sp-item.h>
+#include "sp-item-update-cns.h"
+#include "sp-guide.h"
+#include "sp-item.h"
#include <algorithm>
using std::find;
using std::vector;
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index b1eb5a24a..363aa8c17 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -103,12 +103,10 @@ SPItem::getType(void)
/**
* SPItem vtable initialization.
*/
-void
-SPItemClass::sp_item_class_init(SPItemClass *klass)
+void SPItemClass::sp_item_class_init(SPItemClass *klass)
{
- SPObjectClass *sp_object_class = (SPObjectClass *) klass;
-
- static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
+ SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass);
+ static_parent_class = SP_OBJECT_CLASS(g_type_class_ref(SP_TYPE_OBJECT));
sp_object_class->build = SPItem::sp_item_build;
sp_object_class->release = SPItem::sp_item_release;
@@ -427,14 +425,14 @@ void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML
object->readAttr( "inkscape:connector-avoid" );
object->readAttr( "inkscape:connection-points" );
- if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) {
- (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr);
+ if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build) {
+ (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->build)(object, document, repr);
}
}
void SPItem::sp_item_release(SPObject *object)
{
- SPItem *item = (SPItem *) object;
+ SPItem *item = SP_ITEM(object);
// Note: do this here before the clip_ref is deleted, since calling
// ensureUpToDate() for triggered routing may reference
@@ -447,8 +445,8 @@ void SPItem::sp_item_release(SPObject *object)
delete item->clip_ref;
delete item->mask_ref;
- if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) {
- ((SPObjectClass *) SPItemClass::static_parent_class)->release(object);
+ if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release) {
+ (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->release(object);
}
while (item->display) {
@@ -460,7 +458,7 @@ void SPItem::sp_item_release(SPObject *object)
void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value)
{
- SPItem *item = (SPItem *) object;
+ SPItem *item = SP_ITEM(object);
switch (key) {
case SP_ATTR_TRANSFORM: {
@@ -544,8 +542,8 @@ void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value)
sp_style_read_from_object(object->style, object);
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
} else {
- if (((SPObjectClass *) (SPItemClass::static_parent_class))->set) {
- (* ((SPObjectClass *) (SPItemClass::static_parent_class))->set)(object, key, value);
+ if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set) {
+ (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->set)(object, key, value);
}
}
break;
@@ -605,8 +603,8 @@ void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
{
SPItem *item = SP_ITEM(object);
- if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) {
- (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags);
+ if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update) {
+ (* (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->update)(object, ctx, flags);
}
// any of the modifications defined in sp-object.h might change bbox,
@@ -721,8 +719,8 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML
}
}
- if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) {
- ((SPObjectClass *) (SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags);
+ if ((SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write) {
+ (SP_OBJECT_CLASS(SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags);
}
return repr;
@@ -737,8 +735,8 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const
{
Geom::OptRect bbox;
// call the subclass method
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
- bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::GEOMETRIC_BBOX);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) {
+ bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, transform, SPItem::GEOMETRIC_BBOX);
}
return bbox;
}
@@ -757,8 +755,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const
if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) {
// call the subclass method
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
- bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) {
+ bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, Geom::identity(), SPItem::VISUAL_BBOX);
}
SPFilter *filter = SP_FILTER(style->getFilter());
@@ -803,8 +801,8 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const
*bbox *= transform;
} else {
// call the subclass method
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
- bbox = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, transform, SPItem::VISUAL_BBOX);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox) {
+ bbox = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->bbox(this, transform, SPItem::VISUAL_BBOX);
}
}
if (clip_ref->getObject()) {
@@ -915,7 +913,7 @@ void SPItem::sp_item_private_snappoints(SPItem const * /*item*/, std::vector<Ink
void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const
{
// Get the snappoints of the item
- SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this);
+ SPItemClass const &item_class = *SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this));
if (item_class.snappoints) {
item_class.snappoints(this, p, snapprefs);
}
@@ -982,8 +980,8 @@ gchar *SPItem::sp_item_private_description(SPItem */*item*/)
*/
gchar *SPItem::description()
{
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) {
- gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description) {
+ gchar *s = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description(this);
if (s && clip_ref->getObject()) {
gchar *snew = g_strdup_printf (_("%s; <i>clipped</i>"), s);
g_free (s);
@@ -1019,7 +1017,7 @@ gchar *SPItem::description()
int SPItem::ifilt()
{
int retval=0;
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) {
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->description) {
if ( style && style->filter.href && style->filter.href->getObject() ) { retval=1; }
}
return retval;
@@ -1043,8 +1041,8 @@ unsigned SPItem::display_key_new(unsigned numkeys)
Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned key, unsigned flags)
{
Inkscape::DrawingItem *ai = NULL;
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) {
- ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, drawing, key, flags);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->show) {
+ ai = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->show(this, drawing, key, flags);
}
if (ai != NULL) {
@@ -1096,8 +1094,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned
void SPItem::invoke_hide(unsigned key)
{
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) {
- ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->hide) {
+ (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->hide(this, key);
}
SPItemView *ref = NULL;
@@ -1204,7 +1202,7 @@ void SPItem::adjust_stroke( gdouble ex )
/**
* Find out the inverse of previous transform of an item (from its repr)
*/
-Geom::Affine sp_item_transform_repr (SPItem *item)
+static Geom::Affine sp_item_transform_repr (SPItem *item)
{
Geom::Affine t_old(Geom::identity());
gchar const *t_attr = item->getRepr()->attribute("transform");
@@ -1253,7 +1251,7 @@ void SPItem::freeze_stroke_width_recursive(bool freeze)
/**
* Recursively adjust rx and ry of rects.
*/
-void
+static void
sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform)
{
if (SP_IS_RECT (item)) {
@@ -1388,13 +1386,13 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra
gint preserve = prefs->getBool("/options/preservetransform/value", 0);
Geom::Affine transform_attr (transform);
if ( // run the object's set_transform (i.e. embed transform) only if:
- ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform && // it does have a set_transform method
+ (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->set_transform && // it does have a set_transform method
!preserve && // user did not chose to preserve all transforms
!clip_ref->getObject() && // the object does not have a clippath
!mask_ref->getObject() && // the object does not have a mask
!(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters)
) {
- transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform);
+ transform_attr = (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->set_transform(this, transform);
if (freeze_stroke_width) {
freeze_stroke_width_recursive(false);
}
@@ -1427,8 +1425,8 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra
gint SPItem::emitEvent(SPEvent &event)
{
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) {
- return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->event) {
+ return (SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->event(this, &event);
}
return FALSE;
@@ -1451,8 +1449,8 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix)
void SPItem::convert_item_to_guides() {
// Use derived method if present ...
- if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) {
- (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this);
+ if ((SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->convert_to_guides) {
+ (*(SP_ITEM_CLASS(G_OBJECT_GET_CLASS(this)))->convert_to_guides)(this);
} else {
// .. otherwise simply place the guides around the item's bounding box
@@ -1516,8 +1514,6 @@ Geom::Affine SPItem::i2dt_affine() const
ret = i2doc_affine()
* Geom::Scale(1, -1)
* Geom::Translate(0, document->getHeight());
-
- g_return_val_if_fail(desktop != NULL, ret);
}
return ret;
}
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index f17422d02..3b8999eda 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -87,18 +87,13 @@ sp_lpe_item_get_type()
return lpe_item_type;
}
-static void
-sp_lpe_item_class_init(SPLPEItemClass *klass)
+static void sp_lpe_item_class_init(SPLPEItemClass *klass)
{
- GObjectClass *gobject_class;
- SPObjectClass *sp_object_class;
-
- gobject_class = (GObjectClass *) klass;
- sp_object_class = (SPObjectClass *) klass;
- parent_class = (SPItemClass *)g_type_class_peek_parent (klass);
-
+ GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass);
+ parent_class = SP_ITEM_CLASS(g_type_class_peek_parent(klass));
+
gobject_class->finalize = sp_lpe_item_finalize;
-
sp_object_class->build = sp_lpe_item_build;
sp_object_class->release = sp_lpe_item_release;
sp_object_class->set = sp_lpe_item_set;
@@ -122,8 +117,7 @@ sp_lpe_item_init(SPLPEItem *lpeitem)
lpeitem->lpe_modified_connection_list = new std::list<sigc::connection>();
}
-static void
-sp_lpe_item_finalize(GObject *object)
+static void sp_lpe_item_finalize(GObject *object)
{
if (((GObjectClass *) (parent_class))->finalize) {
(* ((GObjectClass *) (parent_class))->finalize)(object);
@@ -135,23 +129,21 @@ sp_lpe_item_finalize(GObject *object)
* our name must be associated with a repr via "sp_object_type_register". Best done through
* sp-object-repr.cpp's repr_name_entries array.
*/
-static void
-sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
+static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
object->readAttr( "inkscape:path-effect" );
- if (((SPObjectClass *) parent_class)->build) {
- ((SPObjectClass *) parent_class)->build(object, document, repr);
+ if ((SP_OBJECT_CLASS(parent_class))->build) {
+ (SP_OBJECT_CLASS(parent_class))->build(object, document, repr);
}
}
/**
* Drops any allocated memory.
*/
-static void
-sp_lpe_item_release(SPObject *object)
+static void sp_lpe_item_release(SPObject *object)
{
- SPLPEItem *lpeitem = (SPLPEItem *) object;
+ SPLPEItem *lpeitem = SP_LPE_ITEM(object);
// disconnect all modified listeners:
for (std::list<sigc::connection>::iterator mod_it = lpeitem->lpe_modified_connection_list->begin();
@@ -173,17 +165,16 @@ sp_lpe_item_release(SPObject *object)
delete lpeitem->path_effect_list;
lpeitem->path_effect_list = NULL;
- if (((SPObjectClass *) parent_class)->release)
- ((SPObjectClass *) parent_class)->release(object);
+ if ((SP_OBJECT_CLASS(parent_class))->release)
+ (SP_OBJECT_CLASS(parent_class))->release(object);
}
/**
* Sets a specific value in the SPLPEItem.
*/
-static void
-sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value)
+static void sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value)
{
- SPLPEItem *lpeitem = (SPLPEItem *) object;
+ SPLPEItem *lpeitem = SP_LPE_ITEM(object);
switch (key) {
case SP_ATTR_INKSCAPE_PATH_EFFECT:
@@ -243,8 +234,8 @@ sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value)
}
break;
default:
- if (((SPObjectClass *) parent_class)->set) {
- ((SPObjectClass *) parent_class)->set(object, key, value);
+ if ((SP_OBJECT_CLASS(parent_class))->set) {
+ (SP_OBJECT_CLASS(parent_class))->set(object, key, value);
}
break;
}
@@ -256,8 +247,8 @@ sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value)
static void
sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags)
{
- if (((SPObjectClass *) parent_class)->update) {
- ((SPObjectClass *) parent_class)->update(object, ctx, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->update) {
+ (SP_OBJECT_CLASS(parent_class))->update(object, ctx, flags);
}
// update the helperpaths of all LPEs applied to the item
@@ -267,25 +258,23 @@ sp_lpe_item_update(SPObject *object, SPCtx *ctx, guint flags)
/**
* Sets modified flag for all sub-item views.
*/
-static void
-sp_lpe_item_modified (SPObject *object, unsigned int flags)
+static void sp_lpe_item_modified (SPObject *object, unsigned int flags)
{
if (SP_IS_GROUP(object) && (flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)) {
sp_lpe_item_update_patheffect(SP_LPE_ITEM(object), true, true);
}
- if (((SPObjectClass *) (parent_class))->modified) {
- (* ((SPObjectClass *) (parent_class))->modified) (object, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->modified) {
+ (* (SP_OBJECT_CLASS(parent_class))->modified) (object, flags);
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
-static Inkscape::XML::Node *
-sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
+static Inkscape::XML::Node * sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
- SPLPEItem *lpeitem = (SPLPEItem *) object;
+ SPLPEItem *lpeitem = SP_LPE_ITEM(object);
if (flags & SP_OBJECT_WRITE_EXT) {
if ( sp_lpe_item_has_path_effect(lpeitem) ) {
@@ -296,8 +285,8 @@ sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
}
}
- if (((SPObjectClass *)(parent_class))->write) {
- ((SPObjectClass *)(parent_class))->write(object, xml_doc, repr, flags);
+ if ((SP_OBJECT_CLASS(parent_class))->write) {
+ (SP_OBJECT_CLASS(parent_class))->write(object, xml_doc, repr, flags);
}
return repr;
@@ -675,11 +664,10 @@ void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt)
}
}
-static void
-sp_lpe_item_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
+static void sp_lpe_item_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
- if (((SPObjectClass *) (parent_class))->child_added)
- (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
+ if ((SP_OBJECT_CLASS(parent_class))->child_added)
+ (* (SP_OBJECT_CLASS(parent_class))->child_added) (object, child, ref);
if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) {
SPObject *ochild = object->get_child_by_repr(child);
@@ -689,8 +677,7 @@ sp_lpe_item_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape:
}
}
-static void
-sp_lpe_item_remove_child (SPObject * object, Inkscape::XML::Node * child)
+static void sp_lpe_item_remove_child(SPObject * object, Inkscape::XML::Node * child)
{
if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) {
SPObject *ochild = object->get_child_by_repr(child);
@@ -699,8 +686,8 @@ sp_lpe_item_remove_child (SPObject * object, Inkscape::XML::Node * child)
}
}
- if (((SPObjectClass *) (parent_class))->remove_child)
- (* ((SPObjectClass *) (parent_class))->remove_child) (object, child);
+ if ((SP_OBJECT_CLASS(parent_class))->remove_child)
+ (* (SP_OBJECT_CLASS(parent_class))->remove_child) (object, child);
}
static std::string patheffectlist_write_svg(PathEffectList const & list)
@@ -782,8 +769,8 @@ bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathE
* Writes a new "inkscape:path-effect" string to xml, where the old_lpeobjects are substituted by the new ones.
* Note that this method messes up the item's \c PathEffectList.
*/
-void SPLPEItem::replacePathEffects( std::vector<LivePathEffectObject const *> const old_lpeobjs,
- std::vector<LivePathEffectObject const *> const new_lpeobjs )
+void SPLPEItem::replacePathEffects( std::vector<LivePathEffectObject const *> const &old_lpeobjs,
+ std::vector<LivePathEffectObject const *> const &new_lpeobjs )
{
HRefList hreflist;
for (PathEffectList::const_iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it)
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index 8f99ae1b0..69fde5d58 100644
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
@@ -49,8 +49,8 @@ public:
Inkscape::LivePathEffect::LPEObjectReference* current_path_effect;
std::vector<Inkscape::Display::TemporaryItem*> lpe_helperpaths;
- void replacePathEffects( std::vector<LivePathEffectObject const *> const old_lpeobjs,
- std::vector<LivePathEffectObject const *> const new_lpeobjs );
+ void replacePathEffects( std::vector<LivePathEffectObject const *> const &old_lpeobjs,
+ std::vector<LivePathEffectObject const *> const &new_lpeobjs );
};
struct SPLPEItemClass {
diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp
index 2b7611bde..3b2d33bbd 100644
--- a/src/sp-mesh-array.cpp
+++ b/src/sp-mesh-array.cpp
@@ -72,7 +72,7 @@
enum { ROW, COL };
-void swap_p( Geom::Point *p1, Geom::Point *p2 ) {
+static void swap_p( Geom::Point *p1, Geom::Point *p2 ) {
Geom::Point temp = *p1;
*p1 = *p2;
*p2 = temp;
@@ -957,7 +957,7 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) {
Find default color based on color of first stop in "vector" gradient.
This should be rewritten if dependence on "vector" is removed.
*/
-SPColor default_color( SPItem *item ) {
+static SPColor default_color( SPItem *item ) {
// Set initial color to the color of the object before adding the mesh.
// This is a bit tricky as at the moment, a "vector" gradient is created
diff --git a/src/sp-metric.h b/src/sp-metric.h
index 5f0e5c8f6..31f3330fa 100644
--- a/src/sp-metric.h
+++ b/src/sp-metric.h
@@ -3,7 +3,7 @@
/** Known metrics so far. (I don't know why this doesn't include pica.) */
enum SPMetric {
- NONE,
+ SP_NONE,
SP_MM,
SP_CM,
SP_IN,
diff --git a/src/sp-metrics.cpp b/src/sp-metrics.cpp
index 5e34d9ab9..2b421cf05 100644
--- a/src/sp-metrics.cpp
+++ b/src/sp-metrics.cpp
@@ -37,7 +37,7 @@ sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, con
case SP_PX:
src = PX_PER_IN;
break;
- case NONE:
+ case SP_NONE:
src = 1;
break;
}
@@ -67,7 +67,7 @@ sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, con
case SP_PX:
dst = PX_PER_IN;
break;
- case NONE:
+ case SP_NONE:
dst = 1;
break;
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 9d5821897..2f158df9d 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -790,7 +790,7 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
{
SPNamedView *nv = desktop->namedview;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool geometry_from_file = prefs->getBool("/options/savewindowgeometry/value");
+ bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0));
bool show_dialogs = TRUE;
// restore window size and position stored with the document
@@ -888,7 +888,7 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
void sp_namedview_document_from_window(SPDesktop *desktop)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0);
+ bool save_geometry_in_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0));
bool save_viewport_in_file = prefs->getBool("/options/savedocviewport/value", true);
Inkscape::XML::Node *view = desktop->namedview->getRepr();
Geom::Rect const r = desktop->get_display_area();
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 16e64ff49..992001f99 100644
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
@@ -20,6 +20,7 @@
#include "sp-mesh-gradient-fns.h"
#include "sp-mesh-row-fns.h"
#include "sp-mesh-patch-fns.h"
+#include "sp-object-repr.h"
#include "sp-path.h"
#include "sp-radial-gradient-fns.h"
#include "sp-rect.h"
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 9ceeaf262..2cf28137a 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -64,11 +64,11 @@ using std::strstr;
guint update_in_progress = 0; // guard against update-during-update
Inkscape::XML::NodeEventVector object_event_vector = {
- SPObject::sp_object_repr_child_added,
- SPObject::sp_object_repr_child_removed,
- SPObject::sp_object_repr_attr_changed,
- SPObject::sp_object_repr_content_changed,
- SPObject::sp_object_repr_order_changed
+ SPObject::repr_child_added,
+ SPObject::repr_child_removed,
+ SPObject::repr_attr_changed,
+ SPObject::repr_content_changed,
+ SPObject::repr_order_changed
};
// A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API
@@ -104,18 +104,18 @@ public:
GObjectClass * SPObjectClass::static_parent_class = 0;
-GType SPObject::sp_object_get_type()
+GType SPObject::get_type()
{
static GType type = 0;
if (!type) {
GTypeInfo info = {
sizeof(SPObjectClass),
NULL, NULL,
- (GClassInitFunc) SPObjectClass::sp_object_class_init,
+ (GClassInitFunc) SPObjectClass::init,
NULL, NULL,
sizeof(SPObject),
16,
- (GInstanceInitFunc) sp_object_init,
+ (GInstanceInitFunc)init,
NULL
};
type = g_type_register_static(G_TYPE_OBJECT, "SPObject", &info, (GTypeFlags)0);
@@ -123,7 +123,7 @@ GType SPObject::sp_object_get_type()
return type;
}
-void SPObjectClass::sp_object_class_init(SPObjectClass *klass)
+void SPObjectClass::init(SPObjectClass *klass)
{
GObjectClass *object_class;
@@ -131,21 +131,18 @@ void SPObjectClass::sp_object_class_init(SPObjectClass *klass)
static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT);
- object_class->finalize = SPObject::sp_object_finalize;
+ object_class->finalize = SPObject::finalize;
- klass->child_added = SPObject::sp_object_child_added;
- klass->remove_child = SPObject::sp_object_remove_child;
- klass->order_changed = SPObject::sp_object_order_changed;
-
- klass->release = SPObject::sp_object_release;
-
- klass->build = SPObject::sp_object_build;
-
- klass->set = SPObject::sp_object_private_set;
- klass->write = SPObject::sp_object_private_write;
+ klass->child_added = SPObject::child_added;
+ klass->remove_child = SPObject::remove_child;
+ klass->order_changed = SPObject::order_changed;
+ klass->release = SPObject::release;
+ klass->build = SPObject::build;
+ klass->set = SPObject::private_set;
+ klass->write = SPObject::private_write;
}
-void SPObject::sp_object_init(SPObject *object)
+void SPObject::init(SPObject *object)
{
debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object));
@@ -178,7 +175,7 @@ void SPObject::sp_object_init(SPObject *object)
object->_default_label = NULL;
}
-void SPObject::sp_object_finalize(GObject *object)
+void SPObject::finalize(GObject *object)
{
SPObject *spobject = (SPObject *)object;
@@ -339,7 +336,7 @@ SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const {
return longest_common_suffix<SPObject::ConstParentIterator>(this, object, NULL, &same_objects);
}
-SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) {
+static SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) {
SPObject const *result = 0;
if ( obj && ancestor ) {
if (obj->parent == ancestor) {
@@ -616,7 +613,7 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr)
return result;
}
-void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
+void SPObject::child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
GType type = sp_repr_type_lookup(child);
if (!type) {
@@ -630,7 +627,7 @@ void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *chil
ochild->invoke_build(object->document, child, object->cloned);
}
-void SPObject::sp_object_release(SPObject *object)
+void SPObject::release(SPObject *object)
{
debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
while (object->children) {
@@ -638,7 +635,7 @@ void SPObject::sp_object_release(SPObject *object)
}
}
-void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child)
+void SPObject::remove_child(SPObject *object, Inkscape::XML::Node *child)
{
debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
SPObject *ochild = object->get_child_by_repr(child);
@@ -648,7 +645,7 @@ void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *chi
}
}
-void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/,
+void SPObject::order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node * /*old_ref*/,
Inkscape::XML::Node *new_ref)
{
SPObject *ochild = object->get_child_by_repr(child);
@@ -658,7 +655,7 @@ void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *ch
ochild->_position_changed_signal.emit(ochild);
}
-void SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
+void SPObject::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
/* Nothing specific here */
debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
@@ -709,7 +706,7 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns
gchar const *id = this->repr->attribute("id");
if (!document->isSeeking()) {
{
- gchar *realid = sp_object_get_unique_id(this, id);
+ gchar *realid = get_unique_id(this, id);
g_assert(realid != NULL);
this->document->bindObjectToId(realid, this);
@@ -820,7 +817,7 @@ SPObject *SPObject::getPrev()
return prev;
}
-void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data)
+void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data)
{
SPObject *object = SP_OBJECT(data);
@@ -829,7 +826,7 @@ void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscap
}
}
-void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data)
+void SPObject::repr_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node * /*ref*/, gpointer data)
{
SPObject *object = SP_OBJECT(data);
@@ -838,7 +835,7 @@ void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inksc
}
}
-void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data)
+void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data)
{
SPObject *object = SP_OBJECT(data);
@@ -847,7 +844,7 @@ void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inksc
}
}
-void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value)
+void SPObject::private_set(SPObject *object, unsigned int key, gchar const *value)
{
g_assert(key != SP_ATTR_INVALID);
@@ -869,7 +866,7 @@ void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar c
if (!document->isSeeking()) {
sp_object_ref(conflict, NULL);
// give the conflicting object a new ID
- gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL);
+ gchar *new_conflict_id = get_unique_id(conflict, NULL);
conflict->getRepr()->setAttribute("id", new_conflict_id);
g_free(new_conflict_id);
sp_object_unref(conflict, NULL);
@@ -960,7 +957,7 @@ void SPObject::readAttr(gchar const *key)
}
}
-void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data)
+void SPObject::repr_attr_changed(Inkscape::XML::Node * /*repr*/, gchar const *key, gchar const * /*oldval*/, gchar const * /*newval*/, bool is_interactive, gpointer data)
{
SPObject *object = SP_OBJECT(data);
@@ -973,7 +970,7 @@ void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar
}
}
-void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data)
+void SPObject::repr_content_changed(Inkscape::XML::Node * /*repr*/, gchar const * /*oldcontent*/, gchar const * /*newcontent*/, gpointer data)
{
SPObject *object = SP_OBJECT(data);
@@ -997,7 +994,7 @@ static gchar const *sp_xml_get_space_string(unsigned int space)
}
}
-Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
+Inkscape::XML::Node * SPObject::private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
{
if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) {
repr = object->getRepr()->duplicate(doc);
@@ -1302,7 +1299,7 @@ bool SPObject::storeAsDouble( gchar const *key, double *val ) const
/* Helper */
-gchar * SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id)
+gchar * SPObject::get_unique_id(SPObject *object, gchar const *id)
{
static unsigned long count = 0;
@@ -1409,6 +1406,9 @@ void SPObject::_requireSVGVersion(Inkscape::Version version) {
be made. The same applies to 'desc' elements. Therefore, these functions
ignore all but the first 'title' child element and first 'desc' child
element, except when deleting a title or description.
+
+ This will change in SVG 2, where multiple 'title' and 'desc' elements will
+ be allowed with different localized strings.
*/
gchar * SPObject::title() const
diff --git a/src/sp-object.h b/src/sp-object.h
index b08706b0b..0c4429a74 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -18,7 +18,7 @@
class SPObject;
class SPObjectClass;
-#define SP_TYPE_OBJECT (SPObject::sp_object_get_type ())
+#define SP_TYPE_OBJECT (SPObject::get_type ())
#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject))
#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass))
#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT))
@@ -193,8 +193,6 @@ SPObject *sp_object_hunref(SPObject *object, gpointer owner);
* SPObjects are bound to the higher-level container SPDocument, which
* provides document level functionality such as the undo stack,
* dictionary and so on. Source: doc/architecture.txt
- *
- * @todo need to remove redundant sp_object_... prefixing on methods.
*/
class SPObject : public GObject {
public:
@@ -260,7 +258,7 @@ public:
* Represents the style properties, whether from presentation attributes, the <tt>style</tt>
* attribute, or inherited.
*
- * sp_object_private_set doesn't handle SP_ATTR_STYLE or any presentation attributes at the
+ * private_set() doesn't handle SP_ATTR_STYLE or any presentation attributes at the
* time of writing, so this is probably NULL for all SPObject's that aren't an SPItem.
*
* However, this gives rise to the bugs mentioned in sp_object_get_style_property.
@@ -801,18 +799,18 @@ private:
/**
* Callback to initialize the SPObject object.
*/
- static void sp_object_init(SPObject *object);
+ static void init(SPObject *object);
/**
* Callback to destroy all members and connections of object and itself.
*/
- static void sp_object_finalize(GObject *object);
+ static void finalize(GObject *object);
/**
* Callback for child_added event.
* Invoked whenever the given mutation event happens in the XML tree.
*/
- static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
+ static void child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
/**
* Remove object's child whose node equals repr, release and
@@ -822,7 +820,7 @@ private:
* tree, BEFORE removal from the XML tree happens, so grouping
* objects can safely release the child data.
*/
- static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child);
+ static void remove_child(SPObject *object, Inkscape::XML::Node *child);
/**
* Move object corresponding to child after sibling object corresponding
@@ -830,7 +828,7 @@ private:
* Invoked whenever the given mutation event happens in the XML tree.
* @param old_ref Ignored
*/
- static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
+ static void order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
/**
* Removes, releases and unrefs all children of object.
@@ -841,9 +839,9 @@ private:
* document and releases the SPRepr bindings; implementations should free
* state data and release all child objects. Invoking release on
* SPRoot destroys the whole document tree.
- * @see sp_object_build()
+ * @see build()
*/
- static void sp_object_release(SPObject *object);
+ static void release(SPObject *object);
/**
* Virtual build callback.
@@ -854,21 +852,21 @@ private:
* generate the children objects and so on. Invoking build on the SPRoot
* object results in creation of the whole document tree (this is, what
* SPDocument does after the creation of the XML tree).
- * @see sp_object_release()
+ * @see release()
*/
- static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
+ static void build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
/**
* Callback for set event.
*/
- static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value);
+ static void private_set(SPObject *object, unsigned int key, gchar const *value);
/**
* Callback for write event.
*/
- static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+ static Inkscape::XML::Node *private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
- static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid);
+ static gchar *get_unique_id(SPObject *object, gchar const *defid);
/* Real handlers of repr signals */
@@ -877,34 +875,34 @@ public:
/**
* Registers the SPObject class with Gdk and returns its type number.
*/
- static GType sp_object_get_type();
+ static GType get_type();
/**
* Callback for attr_changed node event.
*/
- static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data);
+ static void repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data);
/**
* Callback for content_changed node event.
*/
- static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data);
+ static void repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data);
/**
* Callback for child_added node event.
*/
- static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data);
+ static void repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data);
/**
* Callback for remove_child node event.
*/
- static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data);
+ static void repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data);
/**
* Callback for order_changed node event.
*
* \todo fixme:
*/
- static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data);
+ static void repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data);
friend class SPObjectClass;
@@ -942,7 +940,7 @@ private:
/**
* Initializes the SPObject vtable.
*/
- static void sp_object_class_init(SPObjectClass *klass);
+ static void init(SPObjectClass *klass);
friend class SPObject;
};
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 817db92e8..b98399171 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -750,7 +750,7 @@ static void sp_offset_snappoints(SPItem const *item, std::vector<Inkscape::SnapC
* dot(A, rot90(B))*dot(C, rot90(B)) == -1.
* -- njh
*/
-bool
+static bool
vectors_are_clockwise (Geom::Point A, Geom::Point B, Geom::Point C)
{
using Geom::rot90;
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index 03afc1bf3..137864101 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -290,7 +290,7 @@ sp_pattern_set (SPObject *object, unsigned int key, const gchar *value)
/* fixme: We need ::order_changed handler too (Lauris) */
-GSList *pattern_getchildren(SPPattern *pat)
+static GSList *pattern_getchildren(SPPattern *pat)
{
GSList *l = NULL;
@@ -381,7 +381,7 @@ static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern
/**
Count how many times pat is used by the styles of o and its descendants
*/
-guint
+static guint
count_pattern_hrefs(SPObject *o, SPPattern *pat)
{
if (!o)
@@ -590,7 +590,7 @@ Geom::OptRect pattern_viewBox (SPPattern *pat)
return viewbox;
}
-bool pattern_hasItemChildren (SPPattern *pat)
+static bool pattern_hasItemChildren (SPPattern *pat)
{
bool hasChildren = false;
for (SPObject *child = pat->firstChild() ; child && !hasChildren ; child = child->getNext() ) {
@@ -608,8 +608,7 @@ sp_pattern_create_pattern(SPPaintServer *ps,
double opacity)
{
SPPattern *pat = SP_PATTERN (ps);
- Geom::Affine ps2user;
- Geom::Affine vb2ps = Geom::identity();
+
bool needs_opacity = (1.0 - opacity) >= 1e-3;
bool visible = opacity >= 1e-3;
@@ -646,6 +645,8 @@ sp_pattern_create_pattern(SPPaintServer *ps,
}
}
+ // viewBox to pattern server
+ Geom::Affine vb2ps = Geom::identity();
if (pat->viewBox_set) {
Geom::Rect vb = *pattern_viewBox(pat);
gdouble tmp_x = pattern_width (pat) / vb.width();
@@ -655,6 +656,11 @@ sp_pattern_create_pattern(SPPaintServer *ps,
vb2ps = Geom::Affine(tmp_x, 0.0, 0.0, tmp_y, pattern_x(pat) - vb.left() * tmp_x, pattern_y(pat) - vb.top() * tmp_y);
}
+ // We must determine the size and scaling of the pattern at the time it is displayed and render
+ // the pattern onto a surface with that size and at that resolution.
+
+ // Pattern server to user
+ Geom::Affine ps2user;
ps2user = pattern_patternTransform(pat);
if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
/* BBox to user coordinate system */
@@ -663,6 +669,7 @@ sp_pattern_create_pattern(SPPaintServer *ps,
}
ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user;
+ // Pattern size in pattern space
Geom::Rect pattern_tile = Geom::Rect::from_xywh(pattern_x(pat), pattern_y(pat),
pattern_width(pat), pattern_height(pat));
@@ -672,22 +679,34 @@ sp_pattern_create_pattern(SPPaintServer *ps,
pattern_tile = pattern_tile * bbox2user;
}
+ // Transform of object with pattern (includes screen scaling)
cairo_matrix_t cm;
cairo_get_matrix(base_ct, &cm);
Geom::Affine full(cm.xx, cm.yx, cm.xy, cm.yy, 0, 0);
+ // The DrawingSurface class is suppose to handle the mapping from "logical space"
+ // (coordinates in the rendering) to "physical space" (surface pixels).
+ // An oversampling is done as the pattern may not pixel align with the final surface.
+ // The cairo surface is created when the DrawingContext is declared.
+
// oversample the pattern slightly
// TODO: find optimum value
// TODO: this is lame. instead of using descrim(), we should extract
// the scaling component from the complete matrix and use it
// to find the optimum tile size for rendering
+ // c is number of pixels in buffer x and y.
Geom::Point c(pattern_tile.dimensions()*vb2ps.descrim()*ps2user.descrim()*full.descrim()*1.1);
+
c[Geom::X] = ceil(c[Geom::X]);
c[Geom::Y] = ceil(c[Geom::Y]);
-
+
+ // Create drawing surface with size of pattern tile (in tile space) but with number of pixels
+ // based on required resolution (c).
+ Inkscape::DrawingSurface pattern_surface(pattern_tile, c.ceil());
+ Inkscape::DrawingContext ct(pattern_surface);
+
+ pattern_tile *= pattern_surface.drawingTransform();
Geom::IntRect one_tile = pattern_tile.roundOutwards();
- Inkscape::DrawingSurface temp(pattern_tile, c.ceil());
- Inkscape::DrawingContext ct(temp);
// render pattern.
if (needs_opacity) {
@@ -695,9 +714,13 @@ sp_pattern_create_pattern(SPPaintServer *ps,
}
// TODO: make sure there are no leaks.
- Inkscape::UpdateContext ctx;
- ctx.ctm = vb2ps;
+ Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm!
+ ctx.ctm = vb2ps * pattern_surface.drawingTransform();
+ ct.transform( pattern_surface.drawingTransform().inverse() );
drawing.update(Geom::IntRect::infinite(), ctx);
+
+ // Render drawing to pattern_surface via drawing context, this calls root->render
+ // which is really DrawingItem->render().
drawing.render(ct, one_tile);
for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) {
if (SP_IS_ITEM (child)) {
@@ -705,15 +728,23 @@ sp_pattern_create_pattern(SPPaintServer *ps,
}
}
+ // Uncomment to debug
+ // cairo_surface_t* raw = pattern_surface.raw();
+ // std::cout << " cairo_surface (sp-pattern): "
+ // << " width: " << cairo_image_surface_get_width( raw )
+ // << " height: " << cairo_image_surface_get_height( raw )
+ // << std::endl;
+ // cairo_surface_write_to_png( pattern_surface.raw(), "sp-pattern.png" );
+
if (needs_opacity) {
ct.popGroupToSource(); // pop raw pattern
ct.paint(opacity); // apply opacity
}
- cairo_pattern_t *cp = cairo_pattern_create_for_surface(temp.raw());
-
+ cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw());
// Apply transformation to user space. Also compensate for oversampling.
- ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * temp.drawingTransform());
+ ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform());
+
cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT);
return cp;
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index a9a9c7781..d5556ba9e 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -146,7 +146,7 @@ void SPShape::sp_shape_finalize(GObject *object)
*
* This is to be invoked immediately after creation of an SPShape.
*
- * \see sp_object_build()
+ * \see SPObject::build()
*/
void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
{
@@ -167,7 +167,7 @@ void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::X
* by other objects. This routine also disconnects/unrefs markers and
* curves attached to it.
*
- * \see sp_object_release()
+ * \see SPObject::release()
*/
void SPShape::sp_shape_release(SPObject *object)
{
@@ -1193,10 +1193,10 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap
// Find the internal intersections of each path and consider these for snapping
// (using "Method 1" as described in Inkscape::ObjectSnapper::_collectNodes())
- if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) {
+ if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION) || snapprefs->isSourceSnappable(Inkscape::SNAPSOURCE_PATH_INTERSECTION)) {
Geom::Crossings cs;
try {
- cs = self_crossings(*path_it);
+ cs = self_crossings(*path_it); // This can be slow!
if (!cs.empty()) { // There might be multiple intersections...
for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); ++i) {
Geom::Point p_ix = (*path_it).pointAt((*i).ta);
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp
index 87cd210e4..56f862bf3 100644
--- a/src/sp-symbol.cpp
+++ b/src/sp-symbol.cpp
@@ -405,6 +405,11 @@ static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &tran
Geom::Affine const a( symbol->c2p * transform );
bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type);
}
+ } else {
+ // Need bounding box for Symbols dialog
+
+ Geom::Affine const a;
+ bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type);
}
return bbox;
}
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index e39f560c3..0f45f5444 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -321,6 +321,14 @@ sp_use_description(SPItem *item)
char *ret;
if (use->child) {
+
+ if( SP_IS_SYMBOL( use->child ) ) {
+ //char *symbol_desc = SP_ITEM(use->child)->description();
+ //g_free(symbol_desc);
+ return g_strdup(_("<b>Clone of Symbol</b>"));
+ //return g_strdup_printf(_("<b>Clone of Symbol</b>: %s"), symbol_desc );
+ }
+
static unsigned recursion_depth = 0;
if (recursion_depth >= 4) {
/* TRANSLATORS: Used for statusbar description for long <use> chains:
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index f344a3d92..052c9e853 100644
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
@@ -162,7 +162,7 @@ sp_spiral_context_dispose(GObject *object)
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data)
+static void sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer data)
{
SPSpiralContext *sc = SP_SPIRAL_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(sc);
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index 4c1421684..f1360adda 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -1778,7 +1778,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
//return true if we changed something, else false
-bool
+static bool
sp_selected_path_simplify_item(SPDesktop *desktop,
Inkscape::Selection *selection, SPItem *item,
float threshold, bool justCoalesce,
@@ -1982,7 +1982,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
return didSomething;
}
-void
+static void
sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool justCoalesce,
float angleLimit, bool breakableAngles)
{
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index bcdc69805..07539a080 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -134,7 +134,7 @@ static void sp_spray_context_class_init(SPSprayContextClass *klass)
}
/* Method to rotate items */
-void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation)
+static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation)
{
Geom::Translate const s(c);
Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s);
@@ -150,7 +150,7 @@ void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Ge
}
/* Method to scale items */
-void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale)
+static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale)
{
Geom::Translate const s(c);
item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s);
@@ -207,7 +207,7 @@ static void sp_spray_context_dispose(GObject *object)
G_OBJECT_CLASS(parent_class)->dispose(object);
}
-bool is_transform_modes(gint mode)
+static bool is_transform_modes(gint mode)
{
return (mode == SPRAY_MODE_COPY ||
mode == SPRAY_MODE_CLONE ||
@@ -215,7 +215,7 @@ bool is_transform_modes(gint mode)
mode == SPRAY_OPTION);
}
-void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/)
+static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/)
{
SPEventContext *event_context = SP_EVENT_CONTEXT(tc);
SPDesktop *desktop = event_context->desktop;
@@ -232,13 +232,13 @@ void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/)
switch (tc->mode) {
case SPRAY_MODE_COPY:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>copies</b> of the initial selection."), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>copies</b> of the initial selection."), sel_message);
break;
case SPRAY_MODE_CLONE:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>clones</b> of the initial selection."), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>clones</b> of the initial selection."), sel_message);
break;
case SPRAY_MODE_SINGLE_PATH:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a <b>single path</b> of the initial selection."), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a <b>single path</b> of the initial selection."), sel_message);
break;
default:
break;
@@ -342,12 +342,12 @@ static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event)
}
}
-double get_dilate_radius(SPSprayContext *tc)
+static double get_dilate_radius(SPSprayContext *tc)
{
return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
}
-double get_path_force(SPSprayContext *tc)
+static double get_path_force(SPSprayContext *tc)
{
double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE)
/sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom());
@@ -357,28 +357,28 @@ double get_path_force(SPSprayContext *tc)
return force * tc->force;
}
-double get_path_mean(SPSprayContext *tc)
+static double get_path_mean(SPSprayContext *tc)
{
return tc->mean;
}
-double get_path_standard_deviation(SPSprayContext *tc)
+static double get_path_standard_deviation(SPSprayContext *tc)
{
return tc->standard_deviation;
}
-double get_move_force(SPSprayContext *tc)
+static double get_move_force(SPSprayContext *tc)
{
double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE);
return force * tc->force;
}
-double get_move_mean(SPSprayContext *tc)
+static double get_move_mean(SPSprayContext *tc)
{
return tc->mean;
}
-double get_move_standard_deviation(SPSprayContext *tc)
+static double get_move_standard_deviation(SPSprayContext *tc)
{
return tc->standard_deviation;
}
@@ -392,7 +392,7 @@ double get_move_standard_deviation(SPSprayContext *tc)
* @param[in] choice :
*/
-void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/)
+static void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/)
{
// angle is taken from an uniform distribution
angle = g_random_double_range(0, M_PI*2.0);
@@ -411,7 +411,7 @@ void random_position(double &radius, double &angle, double &a, double &s, int /*
}
-bool sp_spray_recursive(SPDesktop *desktop,
+static bool sp_spray_recursive(SPDesktop *desktop,
Inkscape::Selection *selection,
SPItem *item,
Geom::Point p,
@@ -572,7 +572,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
return did;
}
-bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
+static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
@@ -617,7 +617,7 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p,
return did;
}
-void sp_spray_update_area(SPSprayContext *tc)
+static void sp_spray_update_area(SPSprayContext *tc)
{
double radius = get_dilate_radius(tc);
Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
@@ -625,7 +625,7 @@ void sp_spray_update_area(SPSprayContext *tc)
sp_canvas_item_show(tc->dilate_area);
}
-void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
+static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
{
// select the button mode
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode);
@@ -634,7 +634,7 @@ void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
sp_spray_update_cursor(tc, with_shift);
}
-void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift)
+static void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Juggling about so that prefs have the old value but tc->mode and the button show new mode:
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 7861354e9..66e6b3116 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -170,7 +170,7 @@ sp_star_context_dispose (GObject *object)
*
* @param selection Should not be NULL.
*/
-void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data)
+static void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data)
{
g_assert (selection != NULL);
diff --git a/src/style.cpp b/src/style.cpp
index 616474298..3e58a0404 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -4567,7 +4567,7 @@ sp_css_attr_unset_text(SPCSSAttr *css)
return css;
}
-bool
+static bool
is_url(char const *p)
{
if (p == NULL)
@@ -4607,7 +4607,7 @@ sp_css_attr_unset_uris(SPCSSAttr *css)
/**
* Scale a single-value property.
*/
-void
+static void
sp_css_attr_scale_property_single(SPCSSAttr *css, gchar const *property,
double ex, bool only_with_units = false)
{
@@ -4631,7 +4631,7 @@ sp_css_attr_scale_property_single(SPCSSAttr *css, gchar const *property,
/**
* Scale a list-of-values property.
*/
-void
+static void
sp_css_attr_scale_property_list(SPCSSAttr *css, gchar const *property, double ex)
{
gchar const *string = sp_repr_css_property(css, property, NULL);
diff --git a/src/svg/itos.cpp b/src/svg/itos.cpp
index ff7ca516c..78726d068 100644
--- a/src/svg/itos.cpp
+++ b/src/svg/itos.cpp
@@ -18,6 +18,8 @@
#include <string> // for string
#include <cstring>
+#include "../io/ftos.h" /* own include */ /* note - why in different dirs? */
+
using std::string;
string itos(int n)
diff --git a/src/svg/round.cpp b/src/svg/round.cpp
index 9e7b91e4e..0a4ca9d05 100644
--- a/src/svg/round.cpp
+++ b/src/svg/round.cpp
@@ -26,6 +26,7 @@
// on the average.
///////////////////////////////////////////////////////////////////////
#include <math.h>
+#include "../io/ftos.h" /* own include */ /* note - why in different dirs? */
double rround(double x)
{
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index 3446795ed..2046784f1 100644
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
@@ -40,7 +40,7 @@
using Inkscape::DocumentUndo;
-SPItem *
+static SPItem *
text_in_selection(Inkscape::Selection *selection)
{
for (GSList *items = (GSList *) selection->itemList();
@@ -52,7 +52,7 @@ text_in_selection(Inkscape::Selection *selection)
return NULL;
}
-SPItem *
+static SPItem *
flowtext_in_selection(Inkscape::Selection *selection)
{
for (GSList *items = (GSList *) selection->itemList();
@@ -64,7 +64,7 @@ flowtext_in_selection(Inkscape::Selection *selection)
return NULL;
}
-SPItem *
+static SPItem *
text_or_flowtext_in_selection(Inkscape::Selection *selection)
{
for (GSList *items = (GSList *) selection->itemList();
@@ -76,7 +76,7 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection)
return NULL;
}
-SPItem *
+static SPItem *
shape_in_selection(Inkscape::Selection *selection)
{
for (GSList *items = (GSList *) selection->itemList();
@@ -233,7 +233,7 @@ text_remove_from_path()
}
}
-void
+static void
text_remove_all_kerns_recursively(SPObject *o)
{
o->getRepr()->setAttribute("dx", NULL);
diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp
index cbf269387..f0535e2ff 100644
--- a/src/tools-switch.cpp
+++ b/src/tools-switch.cpp
@@ -144,7 +144,7 @@ tools_switch(SPDesktop *dt, int num)
dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]);
dt->activate_guides(true);
inkscape_eventcontext_set(sp_desktop_event_context(dt));
- dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b>, <b>click</b> or <b>scroll</b> to spray the selected objects."));
+ dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b>, <b>click</b> or <b>click and scroll</b> to spray the selected objects."));
break;
case TOOLS_SHAPES_RECT:
dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]);
diff --git a/src/trace/quantize.cpp b/src/trace/quantize.cpp
index 2db1bbf34..ba9306da8 100644
--- a/src/trace/quantize.cpp
+++ b/src/trace/quantize.cpp
@@ -16,6 +16,7 @@
#include "pool.h"
#include "imagemap.h"
+#include "quantize.h"
typedef struct Ocnode_def Ocnode;
@@ -211,16 +212,19 @@ static void ocnodePrint(Ocnode *node, int indent)
ocnodePrint(node->child[i], indent+2);
}
}
+
+#if 0
void octreePrint(Ocnode *node)
{
printf("<<octree>>\n");
if (node) printf("[r:%p] ", node); ocnodePrint(node, 2);
}
+#endif
/**
* builds a single <rgb> color leaf at location <ref>
*/
-void ocnodeLeaf(pool<Ocnode> *pool, Ocnode **ref, RGB rgb)
+static void ocnodeLeaf(pool<Ocnode> *pool, Ocnode **ref, RGB rgb)
{
assert(ref);
Ocnode *node = ocnodeNew(pool);
@@ -237,7 +241,7 @@ void ocnodeLeaf(pool<Ocnode> *pool, Ocnode **ref, RGB rgb)
/**
* merge nodes <node1> and <node2> at location <ref> with parent <parent>
*/
-int octreeMerge(pool<Ocnode> *pool, Ocnode *parent, Ocnode **ref, Ocnode *node1, Ocnode *node2)
+static int octreeMerge(pool<Ocnode> *pool, Ocnode *parent, Ocnode **ref, Ocnode *node1, Ocnode *node2)
{
assert(ref);
if (!node1 && !node2) return 0;
@@ -415,7 +419,7 @@ static void ocnodeStrip(pool<Ocnode> *pool, Ocnode **ref, int *count, unsigned l
/**
* reduce the leaves of an octree to a given number
*/
-void octreePrune(pool<Ocnode> *pool, Ocnode **ref, int ncolor)
+static void octreePrune(pool<Ocnode> *pool, Ocnode **ref, int ncolor)
{
assert(ref);
assert(ncolor > 0);
@@ -435,8 +439,8 @@ void octreePrune(pool<Ocnode> *pool, Ocnode **ref, int ncolor)
* build an octree associated to the area of a color map <rgbmap>,
* included in the specified (x1,y1)--(x2,y2) rectangle.
*/
-void octreeBuildArea(pool<Ocnode> *pool, RgbMap *rgbmap, Ocnode **ref,
- int x1, int y1, int x2, int y2, int ncolor)
+static void octreeBuildArea(pool<Ocnode> *pool, RgbMap *rgbmap, Ocnode **ref,
+ int x1, int y1, int x2, int y2, int ncolor)
{
int dx = x2 - x1, dy = y2 - y1;
int xm = x1 + dx/2, ym = y1 + dy/2;
@@ -465,7 +469,7 @@ void octreeBuildArea(pool<Ocnode> *pool, RgbMap *rgbmap, Ocnode **ref,
* build an octree associated to the <rgbmap> color map,
* pruned to <ncolor> colors.
*/
-Ocnode *octreeBuild(pool<Ocnode> *pool, RgbMap *rgbmap, int ncolor)
+static Ocnode *octreeBuild(pool<Ocnode> *pool, RgbMap *rgbmap, int ncolor)
{
//create the octree
Ocnode *node = NULL;
diff --git a/src/trace/trace.h b/src/trace/trace.h
index f811f4891..9f9f44b14 100644
--- a/src/trace/trace.h
+++ b/src/trace/trace.h
@@ -48,12 +48,11 @@ public:
*/
TracingEngineResult(const std::string &theStyle,
const std::string &thePathData,
- long theNodeCount)
- {
- style = theStyle;
- pathData = thePathData;
- nodeCount = theNodeCount;
- }
+ long theNodeCount) :
+ style(theStyle),
+ pathData(thePathData),
+ nodeCount(theNodeCount)
+ {}
TracingEngineResult(const TracingEngineResult &other)
{ assign(other); }
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 0205fc703..33dab447c 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -176,7 +176,7 @@ sp_tweak_context_dispose(GObject *object)
G_OBJECT_CLASS(parent_class)->dispose(object);
}
-bool is_transform_mode (gint mode)
+static bool is_transform_mode (gint mode)
{
return (mode == TWEAK_MODE_MOVE ||
mode == TWEAK_MODE_MOVE_IN_OUT ||
@@ -186,12 +186,12 @@ bool is_transform_mode (gint mode)
mode == TWEAK_MODE_MORELESS);
}
-bool is_color_mode (gint mode)
+static bool is_color_mode (gint mode)
{
return (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER || mode == TWEAK_MODE_BLUR);
}
-void
+static void
sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift)
{
SPEventContext *event_context = SP_EVENT_CONTEXT(tc);
@@ -376,14 +376,14 @@ sp_tweak_extinput(SPTweakContext *tc, GdkEvent *event)
}
}
-double
+static double
get_dilate_radius (SPTweakContext *tc)
{
// 10 times the pen width:
return 500 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
}
-double
+static double
get_path_force (SPTweakContext *tc)
{
double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE)
@@ -394,14 +394,14 @@ get_path_force (SPTweakContext *tc)
return force * tc->force;
}
-double
+static double
get_move_force (SPTweakContext *tc)
{
double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE);
return force * tc->force;
}
-bool
+static bool
sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::Point p, Geom::Point vector, gint mode, double radius, double force, double fidelity, bool reverse)
{
bool did = false;
@@ -697,7 +697,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
return did;
}
-void
+static void
tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l)
{
float rgb_g[3];
@@ -729,7 +729,7 @@ tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s
}
}
-void
+static void
tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l)
{
float hsl_c[3];
@@ -754,7 +754,7 @@ tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l)
sp_color_hsl_to_rgb_floatv (color, hsl_c[0], hsl_c[1], hsl_c[2]);
}
-void
+static void
tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l)
{
if (mode == TWEAK_MODE_COLORPAINT) {
@@ -764,7 +764,7 @@ tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bo
}
}
-void
+static void
tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, double force)
{
double opacity = SP_SCALE24_TO_FLOAT (style_opacity->value);
@@ -780,7 +780,7 @@ tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, doubl
}
-double
+static double
tweak_profile (double dist, double radius)
{
if (radius == 0) {
@@ -797,9 +797,9 @@ tweak_profile (double dist, double radius)
}
}
-void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke,
- guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode,
- bool do_h, bool do_s, bool do_l, bool /*do_o*/)
+static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke,
+ guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode,
+ bool do_h, bool do_s, bool do_l, bool /*do_o*/)
{
SPGradient *gradient = getGradient(item, fill_or_stroke);
@@ -917,7 +917,7 @@ void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke
}
}
-bool
+static bool
sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
guint32 fill_goal, bool do_fill,
guint32 stroke_goal, bool do_stroke,
@@ -1051,7 +1051,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
}
-bool
+static bool
sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse)
{
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
@@ -1141,7 +1141,7 @@ sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::P
return did;
}
-void
+static void
sp_tweak_update_area (SPTweakContext *tc)
{
double radius = get_dilate_radius(tc);
@@ -1150,7 +1150,7 @@ sp_tweak_update_area (SPTweakContext *tc)
sp_canvas_item_show(tc->dilate_area);
}
-void
+static void
sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift)
{
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode);
@@ -1159,7 +1159,7 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift)
sp_tweak_update_cursor (tc, with_shift);
}
-void
+static void
sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index b3bcb3fdd..8fd8eb4e3 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -42,6 +42,7 @@ set(ui_SRC
dialog/filter-effects-dialog.cpp
dialog/find.cpp
dialog/floating-behavior.cpp
+ dialog/font-substitution.cpp
dialog/glyphs.cpp
dialog/guides.cpp
dialog/icon-preview.cpp
@@ -59,6 +60,7 @@ set(ui_SRC
dialog/print-colors-preview-dialog.cpp
dialog/print.cpp
dialog/scriptdialog.cpp
+ dialog/symbols.cpp
dialog/xml-tree.cpp
# dialog/session-player.cpp
dialog/spellcheck.cpp
@@ -82,6 +84,7 @@ set(ui_SRC
widget/entry.cpp
widget/filter-effect-chooser.cpp
widget/frame.cpp
+ widget/gimpspinscale.c
widget/imageicon.cpp
widget/imagetoggler.cpp
widget/labelled.cpp
@@ -101,6 +104,7 @@ set(ui_SRC
widget/scalar-unit.cpp
widget/scalar.cpp
widget/selected-style.cpp
+ widget/spin-scale.cpp
widget/spin-slider.cpp
widget/spinbutton.cpp
widget/style-subject.cpp
@@ -117,6 +121,7 @@ set(ui_SRC
# Headers
clipboard.h
control-manager.h
+ control-types.h
icon-names.h
previewable.h
previewfillable.h
@@ -148,6 +153,7 @@ set(ui_SRC
dialog/filter-effects-dialog.h
dialog/find.h
dialog/floating-behavior.h
+ dialog/font-substitution.h
dialog/glyphs.h
dialog/guides.h
dialog/icon-preview.h
@@ -169,6 +175,7 @@ set(ui_SRC
dialog/spellcheck.h
dialog/svg-fonts-dialog.h
dialog/swatches.h
+ dialog/symbols.h
dialog/text-edit.h
dialog/tile.h
dialog/tracedialog.h
@@ -204,6 +211,7 @@ set(ui_SRC
widget/entry.h
widget/filter-effect-chooser.h
widget/frame.h
+ widget/gimpspinscale.h
widget/imageicon.h
widget/imagetoggler.h
widget/labelled.h
@@ -224,6 +232,7 @@ set(ui_SRC
widget/scalar-unit.h
widget/scalar.h
widget/selected-style.h
+ widget/spin-scale.h
widget/spin-slider.h
widget/spinbutton.h
widget/style-subject.h
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index f1f6c4ab4..8cdb37f4f 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -7,9 +7,11 @@
* Jon A. Cruz <jon@joncruz.org>
* Incorporates some code from selection-chemistry.cpp, see that file for more credits.
* Abhishek Sharma
+ * Tavmjong Bah
*
* Copyright (C) 2008 authors
* Copyright (C) 2010 Jon A. Cruz
+ * Copyright (C) 2012 Tavmjong Bah (Symbol additions)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -66,6 +68,8 @@
#include "sp-mask.h"
#include "sp-textpath.h"
#include "sp-rect.h"
+#include "sp-use.h"
+#include "sp-symbol.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
@@ -109,6 +113,7 @@ class ClipboardManagerImpl : public ClipboardManager {
public:
virtual void copy(SPDesktop *desktop);
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *);
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style);
virtual 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);
@@ -295,6 +300,43 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam
}
/**
+ * Copy a symbol from the symbol dialog.
+ * @param symbol The Inkscape::XML::Node for the symbol.
+ */
+void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* style)
+{
+ //std::cout << "ClipboardManagerImpl::copySymbol" << std::endl;
+ if ( symbol == NULL ) {
+ return;
+ }
+
+ _discardInternalClipboard();
+ _createInternalClipboard();
+
+ // We add "_duplicate" to have a well defined symbol name that
+ // bypasses the "prevent_id_classes" routine. We'll get rid of it
+ // when we paste.
+ Inkscape::XML::Node *repr = symbol->duplicate(_doc);
+ Glib::ustring symbol_name = repr->attribute("id");
+
+ symbol_name += "_inkscape_duplicate";
+ repr->setAttribute("id", symbol_name.c_str());
+ _defs->appendChild(repr);
+
+ Glib::ustring id("#");
+ id += symbol->attribute("id");
+
+ Inkscape::XML::Node *use = _doc->createElement("svg:use");
+ use->setAttribute("xlink:href", id.c_str() );
+ // Set a default style in <use> rather than <symbol> so it can be changed.
+ use->setAttribute("style", style );
+ _root->appendChild(use);
+
+ fit_canvas_to_drawing(_clipboardSPDoc);
+ _setClipboardTargets();
+}
+
+/**
* Paste from the system clipboard into the active desktop.
* @param in_place Whether to put the contents where they were when copied.
*/
@@ -725,6 +767,14 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
+ // Copy symbols: We may want to be more clever...
+ // if (SP_IS_USE(item)) {
+ // SPObject *symbol = SP_USE(item)->child;
+ // if( symbol && SP_IS_SYMBOL(symbol) ) {
+ // _copyNode(symbol->getRepr(), _doc, _defs);
+ // }
+ // }
+
// recurse
for (SPObject *o = item->children ; o != NULL ; o = o->next) {
if (SP_IS_ITEM(o)) {
diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h
index fb28bfc14..b565740c3 100644
--- a/src/ui/clipboard.h
+++ b/src/ui/clipboard.h
@@ -25,6 +25,7 @@
class SPDesktop;
namespace Inkscape {
class Selection;
+namespace XML { class Node; }
namespace LivePathEffect { class PathParam; }
namespace UI {
@@ -43,6 +44,7 @@ class ClipboardManager {
public:
virtual void copy(SPDesktop *desktop) = 0;
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0;
+ virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style) = 0;
virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0;
virtual bool pasteStyle(SPDesktop *desktop) = 0;
virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0;
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert
index ba2f53a9e..580b47522 100644
--- a/src/ui/dialog/Makefile_insert
+++ b/src/ui/dialog/Makefile_insert
@@ -89,6 +89,8 @@ ink_common_sources += \
ui/dialog/svg-fonts-dialog.h \
ui/dialog/swatches.cpp \
ui/dialog/swatches.h \
+ ui/dialog/symbols.cpp \
+ ui/dialog/symbols.h \
ui/dialog/text-edit.cpp \
ui/dialog/text-edit.h \
ui/dialog/tile.cpp \
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 67980cdc1..dbd06d9e8 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -755,7 +755,7 @@ struct Baselines
{}
};
-bool operator< (const Baselines &a, const Baselines &b)
+static bool operator< (const Baselines &a, const Baselines &b)
{
return (a._base[a._orientation] < b._base[b._orientation]);
}
@@ -873,14 +873,14 @@ private :
-void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad)
+static void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop && sp_desktop_event_context(desktop))
daad->setMode(tools_active(desktop) == TOOLS_NODES);
}
-void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad)
+static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad)
{
daad->randomize_bbox = Geom::OptRect();
}
@@ -1040,7 +1040,6 @@ AlignAndDistribute::AlignAndDistribute()
//Rest of the widgetry
-#if WITH_GTKMM_2_24
_combo.append(_("Last selected"));
_combo.append(_("First selected"));
_combo.append(_("Biggest object"));
@@ -1048,15 +1047,6 @@ AlignAndDistribute::AlignAndDistribute()
_combo.append(_("Page"));
_combo.append(_("Drawing"));
_combo.append(_("Selection"));
-#else
- _combo.append_text(_("Last selected"));
- _combo.append_text(_("First selected"));
- _combo.append_text(_("Biggest object"));
- _combo.append_text(_("Smallest object"));
- _combo.append_text(_("Page"));
- _combo.append_text(_("Drawing"));
- _combo.append_text(_("Selection"));
-#endif
_combo.set_active(prefs->getInt("/dialogs/align/align-to", 6));
_combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change));
@@ -1154,21 +1144,12 @@ void AlignAndDistribute::on_selgrp_toggled(){
void AlignAndDistribute::setMode(bool nodeEdit)
{
//Act on widgets used in node mode
-#if WITH_GTKMM_2_24
void ( Gtk::Widget::*mNode) () = nodeEdit ?
&Gtk::Widget::show_all : &Gtk::Widget::hide;
//Act on widgets used in selection mode
void ( Gtk::Widget::*mSel) () = nodeEdit ?
&Gtk::Widget::hide : &Gtk::Widget::show_all;
-#else
- void ( Gtk::Widget::*mNode) () = nodeEdit ?
- &Gtk::Widget::show_all : &Gtk::Widget::hide_all;
-
- //Act on widgets used in selection mode
- void ( Gtk::Widget::*mSel) () = nodeEdit ?
- &Gtk::Widget::hide_all : &Gtk::Widget::show_all;
-#endif
((_alignFrame).*(mSel))();
((_distributeFrame).*(mSel))();
@@ -1314,7 +1295,6 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
}
}
return master;
- break;
}
case SMALLEST:
@@ -1331,7 +1311,6 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
}
}
return master;
- break;
}
default:
diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h
index 969703807..c9165a83e 100644
--- a/src/ui/dialog/align-and-distribute.h
+++ b/src/ui/dialog/align-and-distribute.h
@@ -213,7 +213,7 @@ private :
SPDesktop *desktop = _dialog.getDesktop();
if (!desktop) return;
- ActionAlign::do_action(desktop, _index);
+ do_action(desktop, _index);
}
static void do_action(SPDesktop *desktop, int index);
diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp
index c6633df0b..77a4f4f03 100644
--- a/src/ui/dialog/calligraphic-profile-rename.cpp
+++ b/src/ui/dialog/calligraphic-profile-rename.cpp
@@ -30,6 +30,8 @@ namespace Dialog {
CalligraphicProfileRename::CalligraphicProfileRename() :
_applied(false)
{
+ set_title(_("Edit profile"));
+
Gtk::Box *mainVBox = get_vbox();
_layout_table.set_spacings(4);
_layout_table.resize (1, 2);
@@ -49,19 +51,27 @@ CalligraphicProfileRename::CalligraphicProfileRename() :
_close_button.set_label(Gtk::Stock::CANCEL.id);
_close_button.set_can_default();
+ _delete_button.set_use_underline(true);
+ _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_can_default();
_close_button.signal_clicked()
- .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_close));
+ .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_close));
+ _delete_button.signal_clicked()
+ .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_delete));
_apply_button.signal_clicked()
- .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_apply));
+ .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_apply));
signal_delete_event().connect( sigc::bind_return(
sigc::hide(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)), true ) );
add_action_widget(_close_button, Gtk::RESPONSE_CLOSE);
+ add_action_widget(_delete_button, Gtk::RESPONSE_DELETE_EVENT);
add_action_widget(_apply_button, Gtk::RESPONSE_APPLY);
_apply_button.grab_default();
@@ -73,6 +83,15 @@ void CalligraphicProfileRename::_apply()
{
_profile_name = _profile_name_entry.get_text();
_applied = true;
+ _deleted = false;
+ _close();
+}
+
+void CalligraphicProfileRename::_delete()
+{
+ _profile_name = _profile_name_entry.get_text();
+ _applied = true;
+ _deleted = true;
_close();
}
@@ -81,11 +100,25 @@ void CalligraphicProfileRename::_close()
this->Gtk::Dialog::hide();
}
-void CalligraphicProfileRename::show(SPDesktop *desktop)
+void CalligraphicProfileRename::show(SPDesktop *desktop, const Glib::ustring profile_name)
{
CalligraphicProfileRename &dial = instance();
dial._applied=false;
+ dial._deleted=false;
dial.set_modal(true);
+
+ dial._profile_name = profile_name;
+ dial._profile_name_entry.set_text(profile_name);
+
+ if (profile_name.empty()) {
+ dial.set_title(_("Add profile"));
+ dial._delete_button.set_visible(false);
+
+ } else {
+ dial.set_title(_("Edit profile"));
+ dial._delete_button.set_visible(true);
+ }
+
desktop->setWindowTransient (dial.gobj());
dial.property_destroy_with_parent() = true;
// dial.Gtk::Dialog::show();
diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h
index f0eb0b491..8fe82d7bb 100644
--- a/src/ui/dialog/calligraphic-profile-rename.h
+++ b/src/ui/dialog/calligraphic-profile-rename.h
@@ -29,10 +29,13 @@ public:
return "CalligraphicProfileRename";
}
- static void show(SPDesktop *desktop);
+ static void show(SPDesktop *desktop, const Glib::ustring profile_name);
static bool applied() {
return instance()._applied;
}
+ static bool deleted() {
+ return instance()._deleted;
+ }
static Glib::ustring getProfileName() {
return instance()._profile_name;
}
@@ -40,14 +43,17 @@ public:
protected:
void _close();
void _apply();
+ void _delete();
Gtk::Label _profile_name_label;
Gtk::Entry _profile_name_entry;
Gtk::Table _layout_table;
Gtk::Button _close_button;
+ Gtk::Button _delete_button;
Gtk::Button _apply_button;
Glib::ustring _profile_name;
bool _applied;
+ bool _deleted;
private:
static CalligraphicProfileRename &instance() {
static CalligraphicProfileRename instance_;
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 47ec03b30..e971cfb09 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -815,9 +815,15 @@ CloneTiler::CloneTiler (void) :
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();
+ 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);
@@ -893,9 +899,16 @@ CloneTiler::CloneTiler (void) :
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();
+ 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);
{
@@ -935,10 +948,15 @@ CloneTiler::CloneTiler (void) :
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();
+ 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);
{
@@ -987,10 +1005,17 @@ CloneTiler::CloneTiler (void) :
// Rows/columns, width/height
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *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_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
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);
{
@@ -1326,8 +1351,8 @@ void CloneTiler::on_picker_color_changed(guint rgba)
void CloneTiler::clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
{
- GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles");
- GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
+ 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);
@@ -2204,7 +2229,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
desktop->setWaitingCursor();
// set statusbar text
- GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
+ 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));
gdk_window_process_all_updates();
@@ -2807,15 +2832,29 @@ void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, fl
{
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, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(table, GTK_ALIGN_FILL);
+ gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), a, col, row, 1, 1);
+#else
+ 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)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *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_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
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)
@@ -2870,10 +2909,10 @@ void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data
}
-void CloneTiler::clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg)
+void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg)
{
- GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
- GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
+ 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);
@@ -2887,10 +2926,10 @@ void CloneTiler::clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget
}
-void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg)
+void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg)
{
- GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
- GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
+ 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);
@@ -2929,7 +2968,7 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u
void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg)
{
- GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
+ 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));
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
index b0da4aecc..e370a0342 100644
--- a/src/ui/dialog/color-item.cpp
+++ b/src/ui/dialog/color-item.cpp
@@ -35,6 +35,7 @@
#include "xml/node.h"
#include "xml/repr.h"
#include "verbs.h"
+#include "widgets/gradient-vector.h"
#include "color.h" // for SP_RGBA32_U_COMPOSE
@@ -143,7 +144,7 @@ static void dieDieDie( GObject *obj, gpointer user_data )
g_message("die die die %p %p", obj, user_data );
}
-static bool getBlock( std::string& dst, guchar ch, std::string const str )
+static bool getBlock( std::string& dst, guchar ch, std::string const & str )
{
bool good = false;
std::string::size_type pos = str.find(ch);
@@ -355,6 +356,23 @@ void ColorItem::setGradient(SPGradient *grad)
_grad = grad;
// TODO regen and push to listeners
}
+
+ setName( gr_prepare_label(_grad) );
+}
+
+void ColorItem::setName(const Glib::ustring name)
+{
+ //def.descr = name;
+
+ for ( std::vector<Gtk::Widget*>::iterator it = _previews.begin(); it != _previews.end(); ++it ) {
+ Gtk::Widget* widget = *it;
+ if ( IS_EEK_PREVIEW(widget->gobj()) ) {
+ gtk_widget_set_tooltip_text(GTK_WIDGET(widget->gobj()), name.c_str());
+ }
+ else if ( GTK_IS_LABEL(widget->gobj()) ) {
+ gtk_label_set_text(GTK_LABEL(widget->gobj()), name.c_str());
+ }
+ }
}
void ColorItem::setPattern(cairo_pattern_t *pattern)
@@ -366,6 +384,7 @@ void ColorItem::setPattern(cairo_pattern_t *pattern)
cairo_pattern_destroy(_pattern);
}
_pattern = pattern;
+
_updatePreviews();
}
@@ -546,7 +565,7 @@ void ColorItem::_regenPreview(EekPreview * preview)
| (_isLive ? PREVIEW_LINK_OTHER:0)) );
}
-Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio)
+Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio, guint border)
{
Gtk::Widget* widget = 0;
if ( style == PREVIEW_STYLE_BLURB) {
@@ -565,7 +584,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
_regenPreview(preview);
- eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
+ eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio, border );
def.addCallback( _colorDefChanged, this );
diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h
index e6f5c7b76..3a0b33193 100644
--- a/src/ui/dialog/color-item.h
+++ b/src/ui/dialog/color-item.h
@@ -53,12 +53,14 @@ public:
virtual Gtk::Widget* getPreview(PreviewStyle style,
ViewType view,
::PreviewSize size,
- guint ratio);
+ guint ratio,
+ guint border);
void buttonClicked(bool secondary = false);
void setGradient(SPGradient *grad);
SPGradient * getGradient() const { return _grad; }
void setPattern(cairo_pattern_t *pattern);
+ void setName(const Glib::ustring name);
void setState( bool fill, bool stroke );
bool isFill() { return _isFill; }
diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp
index a026f3501..da38e2dde 100644
--- a/src/ui/dialog/debug.cpp
+++ b/src/ui/dialog/debug.cpp
@@ -171,10 +171,10 @@ void DebugDialog::showInstance()
/*##### THIS IS THE IMPORTANT PART ##### */
-void dialogLoggingFunction(const gchar */*log_domain*/,
- GLogLevelFlags /*log_level*/,
- const gchar *messageText,
- gpointer user_data)
+static void dialogLoggingFunction(const gchar */*log_domain*/,
+ GLogLevelFlags /*log_level*/,
+ const gchar *messageText,
+ gpointer user_data)
{
DebugDialogImpl *dlg = static_cast<DebugDialogImpl *>(user_data);
dlg->message(messageText);
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 60011ca9d..faba47769 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -33,6 +33,7 @@
#include "ui/dialog/memory.h"
#include "ui/dialog/messages.h"
#include "ui/dialog/scriptdialog.h"
+#include "ui/dialog/symbols.h"
#include "ui/dialog/tile.h"
#include "ui/dialog/tracedialog.h"
#include "ui/dialog/transformation.h"
@@ -121,6 +122,7 @@ DialogManager::DialogManager() {
registerFactory("SvgFontsDialog", &create<SvgFontsDialog, FloatingBehavior>);
#endif
registerFactory("Swatches", &create<SwatchesPanel, FloatingBehavior>);
+ registerFactory("Symbols", &create<SymbolsDialog, FloatingBehavior>);
registerFactory("TileDialog", &create<TileDialog, FloatingBehavior>);
registerFactory("Trace", &create<TraceDialog, FloatingBehavior>);
registerFactory("Transformation", &create<Transformation, FloatingBehavior>);
@@ -156,6 +158,7 @@ DialogManager::DialogManager() {
registerFactory("SvgFontsDialog", &create<SvgFontsDialog, DockBehavior>);
#endif
registerFactory("Swatches", &create<SwatchesPanel, DockBehavior>);
+ registerFactory("Symbols", &create<SymbolsDialog, DockBehavior>);
registerFactory("TileDialog", &create<TileDialog, DockBehavior>);
registerFactory("Trace", &create<TraceDialog, DockBehavior>);
registerFactory("Transformation", &create<Transformation, DockBehavior>);
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index f5f712103..f27d344fa 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -61,7 +61,7 @@ void sp_dialog_shutdown(GObject * /*object*/, gpointer dlgPtr)
}
-void hideCallback(GObject * /*object*/, gpointer dlgPtr)
+static void hideCallback(GObject * /*object*/, gpointer dlgPtr)
{
g_return_if_fail( dlgPtr != NULL );
@@ -69,7 +69,7 @@ void hideCallback(GObject * /*object*/, gpointer dlgPtr)
dlg->onHideF12();
}
-void unhideCallback(GObject * /*object*/, gpointer dlgPtr)
+static void unhideCallback(GObject * /*object*/, gpointer dlgPtr)
{
g_return_if_fail( dlgPtr != NULL );
diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp
index 6318ffbbb..efe25d843 100644
--- a/src/ui/dialog/document-metadata.cpp
+++ b/src/ui/dialog/document-metadata.cpp
@@ -61,13 +61,30 @@ 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);
_getContents()->pack_start(_notebook, true, true);
+ _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"));
@@ -98,50 +115,6 @@ DocumentMetadata::~DocumentMetadata()
delete (*it);
}
-//========================================================================
-
-/**
- * Helper function that attachs widgets in a 3xn table. The widgets come in an
- * array that has two entries per table row. The two entries code for four
- * possible cases: (0,0) means insert space in first column; (0, non-0) means
- * 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.
- */
-inline void attach_all(Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0)
-{
- for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2)
- {
- if (arr[i] && arr[i+1])
- {
- table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
- if (arr[i+1])
- table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- else if (arr[i])
- {
- Gtk::Label& label = static_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
- label.set_alignment (0.0);
- table.attach (label, 0, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
- Gtk::HBox *space = manage (new Gtk::HBox);
- space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
- table.attach (*space, 0, 1, r, r+1,
- (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
- }
- }
- ++r;
- }
-}
-
void
DocumentMetadata::build_metadata()
{
@@ -152,7 +125,14 @@ DocumentMetadata::build_metadata()
Gtk::Label *label = manage (new Gtk::Label);
label->set_markup (_("<b>Dublin Core Entities</b>"));
label->set_alignment (0.0);
- _page_metadata1.table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,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;
int row = 1;
@@ -162,9 +142,22 @@ DocumentMetadata::build_metadata()
_rdflist.push_back (w);
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
- _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);
+
+#if WITH_GTKMM_3_0
+ space->set_valign(Gtk::ALIGN_CENTER);
+ _page_metadata1.attach(*space, 0, row, 1, 1);
+
+ w->_label.set_valign(Gtk::ALIGN_CENTER);
+ _page_metadata1.attach(w->_label, 1, row, 1, 1);
+
+ 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
}
}
@@ -174,14 +167,31 @@ DocumentMetadata::build_metadata()
Gtk::Label *llabel = manage (new Gtk::Label);
llabel->set_markup (_("<b>License</b>"));
llabel->set_alignment (0.0);
- _page_metadata2.table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,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 = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
- _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);
+
+#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 f201679b5..3b7ed1ec8 100644
--- a/src/ui/dialog/document-metadata.h
+++ b/src/ui/dialog/document-metadata.h
@@ -13,12 +13,22 @@
#ifndef INKSCAPE_UI_DIALOG_DOCUMENT_METADATA_H
#define INKSCAPE_UI_DIALOG_DOCUMENT_METADATA_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <list>
#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 "ui/widget/licensor.h"
-#include "ui/widget/notebook-page.h"
#include "ui/widget/registry.h"
namespace Inkscape {
@@ -51,8 +61,13 @@ protected:
Gtk::Notebook _notebook;
- UI::Widget::NotebookPage _page_metadata1;
- UI::Widget::NotebookPage _page_metadata2;
+#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 c7be0877d..ab1e8fbd8 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -150,6 +150,7 @@ DocumentProperties::DocumentProperties()
_notebook.append_page(_page_metadata1, _("Metadata"));
_notebook.append_page(_page_metadata2, _("License"));
+ _wr.setUpdating (true);
build_page();
build_guides();
build_gridspage();
@@ -159,6 +160,7 @@ DocumentProperties::DocumentProperties()
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
build_scripting();
build_metadata();
+ _wr.setUpdating (false);
_grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid));
_grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
@@ -201,41 +203,36 @@ 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.
*/
-inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0)
+inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0)
{
- for (unsigned i = 0, r = start; i < n; i += 2)
- {
- if (arr[i] && arr[i+1])
- {
- 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);
- }
- else
- {
+ for (unsigned i = 0, r = start; i < n; i += 2) {
+ if (arr[i] && arr[i+1]) {
+ 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);
+ } else {
if (arr[i+1]) {
Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0;
if (dynamic_cast<Inkscape::UI::Widget::PageSizer*>(arr[i+1])) {
// only the PageSizer in Document Properties|Page should be stretched vertically
yoptions = Gtk::FILL|Gtk::EXPAND;
}
- table.attach(*arr[i+1], 1, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
- }
- else if (arr[i])
- {
+ if (docum_prop_flag) {
+ if( i==(n-4) || i==(n-6) ) {
+ table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0);
+ } else {
+ table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
+ }
+ } else {
+ table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
+ }
+ } else if (arr[i]) {
Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
label.set_alignment (0.0);
- table.attach (label, 0, 3, r, r+1,
- Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- }
- else
- {
+ table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
+ } else {
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
- table.attach (*space, 0, 1, r, r+1,
- (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
+ table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
}
}
++r;
@@ -273,7 +270,12 @@ void DocumentProperties::build_page()
_rcp_bord._label, &_rcp_bord,
};
- attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array));
+ std::list<Gtk::Widget*> _slaveList;
+ _slaveList.push_back(&_rcb_bord);
+ _slaveList.push_back(&_rcb_shad);
+ _rcb_canb.setSlaveWidgets(_slaveList);
+
+ attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array),0,1);
}
void DocumentProperties::build_guides()
@@ -331,21 +333,13 @@ void DocumentProperties::build_snap()
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
/// Populates the available color profiles combo box
void DocumentProperties::populate_available_profiles(){
-#if WITH_GTKMM_2_24
_combo_avail.remove_all(); // Clear any existing items in the combo box
-#else
- _combo_avail.clear_items(); // Clear any existing items in the combo box
-#endif
// Iterate through the list of profiles and add the name to the combo box.
std::vector<std::pair<Glib::ustring, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames();
for ( std::vector<std::pair<Glib::ustring, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) {
Glib::ustring name = it->second;
-#if WITH_GTKMM_2_24
_combo_avail.append(name);
-#else
- _combo_avail.append_text(name);
-#endif
}
}
@@ -926,7 +920,7 @@ void DocumentProperties::removeExternalScript(){
while ( current ) {
if (current->data && SP_IS_OBJECT(current->data)) {
SPObject* obj = SP_OBJECT(current->data);
- SPScript* script = (SPScript*) obj;
+ SPScript* script = SP_SCRIPT(obj);
if (name == script->xlinkhref){
//XML Tree being used directly here while it shouldn't be.
@@ -959,16 +953,18 @@ void DocumentProperties::removeEmbeddedScript(){
const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
while ( current ) {
- SPObject* obj = SP_OBJECT(current->data);
- if (id == obj->getId()){
+ if (current->data && SP_IS_OBJECT(current->data)) {
+ SPObject* obj = SP_OBJECT(current->data);
+ if (id == obj->getId()){
- //XML Tree being used directly here while it shouldn't be.
- Inkscape::XML::Node *repr = obj->getRepr();
- if (repr){
- sp_repr_unparent(repr);
+ //XML Tree being used directly here while it shouldn't be.
+ Inkscape::XML::Node *repr = obj->getRepr();
+ if (repr){
+ sp_repr_unparent(repr);
- // inform the document, so we can undo
- DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script"));
+ // inform the document, so we can undo
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script"));
+ }
}
}
current = g_slist_next(current);
@@ -1081,7 +1077,7 @@ void DocumentProperties::populate_script_lists(){
if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent);
while ( current ) {
SPObject* obj = SP_OBJECT(current->data);
- SPScript* script = (SPScript*) obj;
+ SPScript* script = SP_SCRIPT(obj);
if (script->xlinkhref)
{
Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append());
@@ -1156,11 +1152,7 @@ void DocumentProperties::build_gridspage()
_grids_hbox_crea.pack_start(_grids_button_new, true, true);
for (gint t = 0; t <= GRID_MAXTYPENR; t++) {
-#if WITH_GTKMM_2_24
_grids_combo_gridtype.append( CanvasGrid::getName( (GridType) t ) );
-#else
- _grids_combo_gridtype.append_text( CanvasGrid::getName( (GridType) t ) );
-#endif
}
_grids_combo_gridtype.set_active_text( CanvasGrid::getName(GRID_RECTANGULAR) );
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 62dd93126..f267c5ae9 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -296,7 +296,7 @@ Export::Export (void) :
batch_box.pack_start(batch_export, false, false);
hide_export.set_sensitive(true);
- hide_export.set_active (true);
+ hide_export.set_active (prefs->getBool("/dialogs/export/hideexceptselected/value", false));
hide_box.pack_start(hide_export, false, false);
@@ -328,6 +328,7 @@ Export::Export (void) :
browse_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBrowse));
batch_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBatchClicked));
export_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onExport));
+ hide_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onHideExceptSelected));
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Export::setTargetDesktop) );
deskTrack.connect(GTK_WIDGET(gobj()));
@@ -547,7 +548,7 @@ void Export::updateCheckbuttons ()
batch_export.set_sensitive(false);
}
- hide_export.set_sensitive (num > 0 && current_key == SELECTION_SELECTION);
+ //hide_export.set_sensitive (num > 0);
}
inline void Export::findDefaultSelection()
@@ -786,8 +787,6 @@ void Export::onAreaToggled ()
}
}
- hide_export.set_sensitive (key == SELECTION_SELECTION);
-
return;
} // end of sp_export_area_toggled()
@@ -919,6 +918,11 @@ Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, c
return path;
}
+void Export::onHideExceptSelected ()
+{
+ prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active());
+}
+
/// Called when export button is clicked
void Export::onExport ()
{
@@ -1256,6 +1260,14 @@ void Export::onBrowse ()
WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL);
// Copy the selected file name, converting from UTF-8 to UTF-16
+ std::string dirname = Glib::path_get_dirname(filename.raw());
+ if ( !Glib::file_test(dirname, Glib::FILE_TEST_EXISTS) ||
+ Glib::file_test(filename, Glib::FILE_TEST_IS_DIR) ||
+ dirname.empty() )
+ {
+ Glib::ustring tmp;
+ filename = create_filepath_from_id(tmp, tmp);
+ }
WCHAR _filename[_MAX_PATH + 1];
memset(_filename, 0, sizeof(_filename));
gunichar2* utf16_path_string = g_utf8_to_utf16(filename.c_str(), -1, NULL, NULL, NULL);
@@ -1434,7 +1446,7 @@ void Export::areaXChange (Gtk::Adjustment *adj)
return;
}
- if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) {
+ if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) {
return;
}
@@ -1481,7 +1493,7 @@ void Export::areaYChange (Gtk::Adjustment *adj)
return;
}
- if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) {
+ if (sp_unit_selector_update_test (SP_UNIT_SELECTOR(unit_selector->gobj()))) {
return;
}
@@ -1636,7 +1648,7 @@ void Export::onBitmapWidthChange ()
return;
}
- if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) {
+ if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) {
return;
}
@@ -1670,7 +1682,7 @@ void Export::onBitmapHeightChange ()
return;
}
- if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) {
+ if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) {
return;
}
@@ -1730,7 +1742,7 @@ void Export::onExportXdpiChange()
return;
}
- if (sp_unit_selector_update_test ((SPUnitSelector *)unit_selector->gobj())) {
+ if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) {
return;
}
@@ -1832,7 +1844,7 @@ void Export::setValuePx(Glib::RefPtr<Gtk::Adjustment>& adj, double val)
void Export::setValuePx( Gtk::Adjustment *adj, double val)
#endif
{
- const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)unit_selector->gobj() );
+ const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()) );
setValue(adj, sp_pixels_get_units (val, *unit));
@@ -1882,7 +1894,7 @@ float Export::getValuePx( Gtk::Adjustment *adj )
#endif
{
float value = getValue( adj);
- const SPUnit *unit = sp_unit_selector_get_unit ((SPUnitSelector *)unit_selector->gobj());
+ const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()));
return sp_units_get_pixels (value, *unit);
} // end of sp_export_value_get_px()
diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h
index e899009a7..c8376cdcb 100644
--- a/src/ui/dialog/export.h
+++ b/src/ui/dialog/export.h
@@ -178,6 +178,11 @@ private:
#endif
/**
+ * Hide except selected callback
+ */
+ void onHideExceptSelected ();
+
+ /**
* Area width value changed callback
*/
void onAreaWidthChange ();
diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp
index 47ba6c748..b3af6fc00 100644
--- a/src/ui/dialog/filedialog.cpp
+++ b/src/ui/dialog/filedialog.cpp
@@ -152,6 +152,9 @@ Glib::ustring FileSaveDialog::getDocTitle()
void FileSaveDialog::appendExtension(Glib::ustring& path, Inkscape::Extension::Output* outputExtension)
{
+ if (!outputExtension)
+ return;
+
try {
bool appendExtension = true;
Glib::ustring utf8Name = Glib::filename_to_utf8( path );
diff --git a/src/ui/dialog/filedialog.h b/src/ui/dialog/filedialog.h
index 6a3436aea..63cee6bdc 100644
--- a/src/ui/dialog/filedialog.h
+++ b/src/ui/dialog/filedialog.h
@@ -208,6 +208,8 @@ public:
virtual Glib::ustring getCurrentDirectory() = 0;
+ virtual void addFileType(Glib::ustring name, Glib::ustring pattern) = 0;
+
protected:
/**
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 1663eb0b6..553acac84 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -141,13 +141,12 @@ bool SVGPreview::setDocument(SPDocument *doc)
//This should remove it from the box, and free resources
if (viewerGtk)
- gtk_widget_destroy(viewerGtk);
-
- viewerGtk = sp_svg_view_widget_new(doc);
- GtkWidget *vbox = (GtkWidget *)gobj();
- gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);
- gtk_widget_show(viewerGtk);
+ Gtk::Container::remove(*viewerGtk);
+ viewerGtk = Glib::wrap(sp_svg_view_widget_new(doc));
+ Gtk::VBox *vbox = Glib::wrap(gobj());
+ vbox->pack_start(*viewerGtk, TRUE, TRUE, 0);
+ viewerGtk->show();
return true;
}
@@ -1048,7 +1047,9 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow,
fileTypeCheckbox.set_active(prefs->getBool("/dialogs/save_as/append_extension", true));
}
- createFileTypeMenu();
+ if (_dialogType != CUSTOM_TYPE)
+ createFileTypeMenu();
+
fileTypeComboBox.set_size_request(200,40);
fileTypeComboBox.signal_changed().connect(
sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback) );
@@ -1175,8 +1176,21 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback()
updateNameAndExtension();
}
+void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring pattern)
+{
+ //#Let user choose
+ FileType guessType;
+ guessType.name = name;
+ guessType.pattern = pattern;
+ guessType.extension = NULL;
+ fileTypeComboBox.append(guessType.name);
+ fileTypes.push_back(guessType);
+ fileTypeComboBox.set_active(0);
+ fileTypeChangedCallback(); //call at least once to set the filter
+}
+
void FileSaveDialogImplGtk::createFileTypeMenu()
{
Inkscape::Extension::DB::OutputList extension_list;
@@ -1198,11 +1212,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu()
knownExtensions.insert( extension.casefold() );
fileDialogExtensionToPattern (type.pattern, extension);
type.extension= omod;
-#if WITH_GTKMM_2_24
fileTypeComboBox.append(type.name);
-#else
- fileTypeComboBox.append_text(type.name);
-#endif
fileTypes.push_back(type);
}
@@ -1211,11 +1221,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu()
guessType.name = _("Guess from extension");
guessType.pattern = "*";
guessType.extension = NULL;
-#if WITH_GTKMM_2_24
fileTypeComboBox.append(guessType.name);
-#else
- fileTypeComboBox.append_text(guessType.name);
-#endif
fileTypes.push_back(guessType);
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h
index 2c22e7367..7501b5e14 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.h
+++ b/src/ui/dialog/filedialogimpl-gtkmm.h
@@ -121,7 +121,7 @@ private:
/**
* The sp_svg_view widget
*/
- GtkWidget *viewerGtk;
+ Gtk::Widget *viewerGtk;
/**
* are we currently showing the "no preview" image?
@@ -291,6 +291,7 @@ public:
virtual void setSelectionType( Inkscape::Extension::Extension * key );
Glib::ustring getCurrentDirectory();
+ void addFileType(Glib::ustring name, Glib::ustring pattern);
private:
//void change_title(const Glib::ustring& title);
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index 5891f25ac..6425d9fee 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -188,7 +188,8 @@ FileOpenDialogImplWin32::FileOpenDialogImplWin32(Gtk::Window &parent,
_mutex = NULL;
- createFilterMenu();
+ if (dialogType != CUSTOM_TYPE)
+ createFilterMenu();
}
@@ -1748,6 +1749,72 @@ void FileSaveDialogImplWin32::createFilterMenu()
_filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd
}
+
+void FileSaveDialogImplWin32::addFileType(Glib::ustring name, Glib::ustring pattern)
+{
+ list<Filter> filter_list;
+
+ knownExtensions.clear();
+
+ int extension_index = 0;
+ int filter_length = 1;
+
+ ustring all_exe_files_filter = pattern;
+ Filter all_exe_files;
+
+ const gchar *all_exe_files_filter_name = name.data();
+
+ // Calculate the amount of memory required
+ int filter_count = 1;
+
+
+ // Filter Executable Files
+ all_exe_files.name = g_utf8_to_utf16(all_exe_files_filter_name,
+ -1, NULL, &all_exe_files.name_length, NULL);
+ all_exe_files.filter = g_utf8_to_utf16(all_exe_files_filter.data(),
+ -1, NULL, &all_exe_files.filter_length, NULL);
+ all_exe_files.mod = NULL;
+ filter_list.push_front(all_exe_files);
+
+ knownExtensions.insert( Glib::ustring(all_exe_files_filter).casefold() );
+
+ _extension_map = new Inkscape::Extension::Extension*[filter_count];
+
+ _filter = new wchar_t[filter_length];
+ wchar_t *filterptr = _filter;
+
+ for(list<Filter>::iterator filter_iterator = filter_list.begin();
+ filter_iterator != filter_list.end(); ++filter_iterator)
+ {
+ const Filter &filter = *filter_iterator;
+
+ wcsncpy(filterptr, (wchar_t*)filter.name, filter.name_length);
+ filterptr += filter.name_length;
+ g_free(filter.name);
+
+ *(filterptr++) = L'\0';
+ *(filterptr++) = L'*';
+
+ if(filter.filter != NULL)
+ {
+ wcsncpy(filterptr, (wchar_t*)filter.filter, filter.filter_length);
+ filterptr += filter.filter_length;
+ g_free(filter.filter);
+ }
+
+ *(filterptr++) = L'\0';
+
+ // Associate this input extension with the file type name
+ _extension_map[extension_index++] = filter.mod;
+ }
+ *(filterptr++) = L'\0';
+
+ _filter_count = extension_index;
+ _filter_index = 1; // Select the 1st filter in the list
+
+
+}
+
void FileSaveDialogImplWin32::GetSaveFileName_thread()
{
OPENFILENAMEEXW ofn;
@@ -1814,7 +1881,7 @@ FileSaveDialogImplWin32::show()
if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true))
g_main_loop_run(_main_loop);
- if(_result)
+ if(_result && _extension)
appendExtension(myFilename, (Inkscape::Extension::Output*)_extension);
}
@@ -1827,6 +1894,7 @@ void FileSaveDialogImplWin32::setSelectionType( Inkscape::Extension::Extension *
}
+
UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
HWND hdlg, UINT uiMsg, WPARAM, LPARAM lParam)
{
diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h
index d016b0a24..15953f9d8 100644
--- a/src/ui/dialog/filedialogimpl-win32.h
+++ b/src/ui/dialog/filedialogimpl-win32.h
@@ -343,6 +343,8 @@ public:
virtual void setSelectionType( Inkscape::Extension::Extension *key );
+ virtual void addFileType(Glib::ustring name, Glib::ustring pattern);
+
private:
/// A handle to the title label and edit box
HWND _title_label;
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index 74c19fea7..5ba4e7e39 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -22,6 +22,7 @@
#include "filter-chemistry.h"
#include "inkscape.h"
#include "selection.h"
+#include "preferences.h"
#include "style.h"
#include "svg/css-ostringstream.h"
#include "ui/icon-names.h"
@@ -59,11 +60,13 @@ FillAndStroke::FillAndStroke()
_notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON("object-stroke")));
_notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON("object-stroke-style")));
+ _notebook.signal_switch_page().connect(sigc::mem_fun(this, &FillAndStroke::_onSwitchPage));
+
_layoutPageFill();
_layoutPageStrokePaint();
_layoutPageStrokeStyle();
- contents->pack_start(_composite_settings, false, false, 0);
+ contents->pack_start(_composite_settings, true, true, 0);
show_all_children();
@@ -105,6 +108,23 @@ 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);
+}
+
+void
+FillAndStroke::_savePagePref(guint page_num)
+{
+ // remember the current page
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/dialogs/fillstroke/page", page_num);
+}
+
void
FillAndStroke::_layoutPageFill()
{
@@ -133,6 +153,8 @@ FillAndStroke::showPageFill()
{
present();
_notebook.set_current_page(0);
+ _savePagePref(0);
+
}
void
@@ -140,6 +162,7 @@ FillAndStroke::showPageStrokePaint()
{
present();
_notebook.set_current_page(1);
+ _savePagePref(1);
}
void
@@ -147,6 +170,8 @@ FillAndStroke::showPageStrokeStyle()
{
present();
_notebook.set_current_page(2);
+ _savePagePref(2);
+
}
Gtk::HBox&
diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h
index 596205c58..255cea89a 100644
--- a/src/ui/dialog/fill-and-stroke.h
+++ b/src/ui/dialog/fill-and-stroke.h
@@ -60,6 +60,12 @@ protected:
void _layoutPageFill();
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 317cb2773..ddafcd481 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -62,6 +62,7 @@
#include "io/sys.h"
#include <iostream>
+#include "selection-chemistry.h"
#include <gtkmm/checkbutton.h>
#include <gtkmm/colorbutton.h>
@@ -78,12 +79,12 @@ namespace Dialog {
using Inkscape::UI::Widget::AttrWidget;
using Inkscape::UI::Widget::ComboBoxEnum;
-using Inkscape::UI::Widget::DualSpinSlider;
-using Inkscape::UI::Widget::SpinSlider;
+using Inkscape::UI::Widget::DualSpinScale;
+using Inkscape::UI::Widget::SpinScale;
// Returns the number of inputs available for the filter primitive type
-int input_count(const SPFilterPrimitive* prim)
+static int input_count(const SPFilterPrimitive* prim)
{
if(!prim)
return 0;
@@ -484,8 +485,8 @@ public:
: AttrWidget(SP_ATTR_VALUES),
// TRANSLATORS: this dialog is accessible via menu Filters - Filter editor
_matrix(SP_ATTR_VALUES, _("This matrix determines a linear transform on color space. Each line affects one of the color components. Each column determines how much of each color component from the input is passed to the output. The last column does not depend on input colors, so can be used to adjust a constant component value.")),
- _saturation(0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES),
- _angle(0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES),
+ _saturation("", 0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES),
+ _angle("", 0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES),
_label(_("None"), Gtk::ALIGN_START),
_use_stored(false),
_saturation_store(0),
@@ -567,8 +568,8 @@ private:
}
MatrixAttr _matrix;
- SpinSlider _saturation;
- SpinSlider _angle;
+ SpinScale _saturation;
+ SpinScale _angle;
Gtk::Label _label;
// Store separate values for the different color modes
@@ -808,22 +809,22 @@ public:
return cmv;
}
- // SpinSlider
- SpinSlider* add_spinslider(double def, const SPAttributeEnum attr, const Glib::ustring& label,
+ // SpinScale
+ SpinScale* add_spinscale(double def, 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_text = NULL)
{
- SpinSlider* spinslider = new SpinSlider(def, lo, hi, step_inc, climb, digits, attr, tip_text);
+ SpinScale* spinslider = new SpinScale("", def, lo, hi, step_inc, climb, digits, attr, tip_text);
add_widget(spinslider, label);
add_attr_widget(spinslider);
return spinslider;
}
- // DualSpinSlider
- DualSpinSlider* add_dualspinslider(const SPAttributeEnum attr, const Glib::ustring& label,
+ // DualSpinScale
+ DualSpinScale* add_dualspinscale(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_text1 = NULL, char* tip_text2 = NULL)
{
- DualSpinSlider* dss = new DualSpinSlider(lo, lo, hi, step_inc, climb, digits, attr, tip_text1, tip_text2);
+ DualSpinScale* dss = new DualSpinScale("", "", lo, lo, hi, step_inc, climb, digits, attr, tip_text1, tip_text2);
add_widget(dss, label);
add_attr_widget(dss);
return dss;
@@ -971,8 +972,8 @@ public:
// FIXME: these range values are complete crap
_settings.type(LIGHT_DISTANT);
- _settings.add_spinslider(0, SP_ATTR_AZIMUTH, _("Azimuth"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the XY plane, in degrees"));
- _settings.add_spinslider(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees"));
+ _settings.add_spinscale(0, SP_ATTR_AZIMUTH, _("Azimuth"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the XY plane, in degrees"));
+ _settings.add_spinscale(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees"));
_settings.type(LIGHT_POINT);
_settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate"));
@@ -982,9 +983,9 @@ public:
_settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0,
SP_ATTR_POINTSATX, SP_ATTR_POINTSATY, SP_ATTR_POINTSATZ,
_("Points At"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate"));
- _settings.add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source"));
+ _settings.add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source"));
//TODO: here I have used 100 degrees as default value. But spec says that if not specified, no limiting cone is applied. So, there should be a way for the user to set a "no limiting cone" option.
- _settings.add_spinslider(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone."));
+ _settings.add_spinscale(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone."));
}
Gtk::VBox& get_box()
@@ -1057,11 +1058,7 @@ private:
void update()
{
-#if WITH_GTKMM_2_24
- _box.hide();
-#else
- _box.hide_all();
-#endif
+ _box.hide();
_box.show();
_light_box.show_all();
@@ -1087,8 +1084,8 @@ FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_ligh
return ls;
}
-Glib::RefPtr<Gtk::Menu> create_popup_menu(Gtk::Widget& parent, sigc::slot<void> dup,
- sigc::slot<void> rem)
+static Glib::RefPtr<Gtk::Menu> create_popup_menu(Gtk::Widget& parent, sigc::slot<void> dup,
+ sigc::slot<void> rem)
{
Glib::RefPtr<Gtk::Menu> menu(new Gtk::Menu);
@@ -1127,13 +1124,8 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d)
if(col)
col->add_attribute(_cell_toggle.property_active(), _columns.sel);
_list.append_column_editable(_("_Filter"), _columns.label);
-#if WITH_GTKMM_2_24
((Gtk::CellRendererText*)_list.get_column(1)->get_first_cell())->
signal_edited().connect(sigc::mem_fun(*this, &FilterEffectsDialog::FilterModifier::on_name_edited));
-#else
- ((Gtk::CellRendererText*)_list.get_column(1)->get_first_cell_renderer())->
- signal_edited().connect(sigc::mem_fun(*this, &FilterEffectsDialog::FilterModifier::on_name_edited));
-#endif
sw->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
sw->set_shadow_type(Gtk::SHADOW_IN);
@@ -1193,6 +1185,17 @@ void FilterEffectsDialog::FilterModifier::setTargetDesktop(SPDesktop *desktop)
}
}
+// When the document changes, update connection to resources
+void FilterEffectsDialog::FilterModifier::on_document_replaced(SPDesktop *desktop, SPDocument *document)
+{
+ if (_resource_changed) {
+ _resource_changed.disconnect();
+ }
+ _resource_changed = document->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters));
+
+ update_filters();
+}
+
// When the selection changes, show the active filter(s) in the dialog
void FilterEffectsDialog::FilterModifier::on_change_selection()
{
@@ -1316,7 +1319,7 @@ void FilterEffectsDialog::FilterModifier::update_filters()
for(const GSList *l = filters; l; l = l->next) {
Gtk::TreeModel::Row row = *_model->append();
- SPFilter* f = (SPFilter*)l->data;
+ SPFilter* f = SP_FILTER(l->data);
row[_columns.filter] = f;
const gchar* lbl = f->label();
const gchar* id = f->getId();
@@ -1387,6 +1390,29 @@ void FilterEffectsDialog::FilterModifier::remove_filter()
if(filter) {
SPDocument* doc = filter->document;
+ // Delete all references to this filter
+ GSList *all = get_all_items(NULL, _desktop->currentRoot(), _desktop, false, false, true, NULL);
+ for (GSList *i = all; i != NULL; i = i->next) {
+ if (!SP_IS_ITEM(i->data)) {
+ continue;
+ }
+ SPItem *item = SP_ITEM(i->data);
+ if (!item->style) {
+ continue;
+ }
+
+ const SPIFilter *ifilter = &(item->style->filter);
+ if (ifilter && ifilter->href) {
+ const SPObject *obj = ifilter->href->getObject();
+ if (obj && obj == (SPObject *)filter) {
+ ::remove_filter(item, false);
+ }
+ }
+ }
+ if (all) {
+ g_slist_free(all);
+ }
+
//XML Tree being used directly here while it shouldn't be.
sp_repr_unparent(filter->getRepr());
@@ -1443,7 +1469,7 @@ void FilterEffectsDialog::CellRendererConnection::get_size_vfunc(
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 = (SPFilterPrimitive*)_primitive.get_value();
+ SPFilterPrimitive* prim = SP_FILTER_PRIMITIVE(_primitive.get_value());
(*height) = size * input_count(prim);
}
}
@@ -1525,11 +1551,10 @@ void FilterEffectsDialog::PrimitiveList::update()
{
SPFilter* f = _dialog._filter_modifier.get_selected_filter();
const SPFilterPrimitive* active_prim = get_selected();
- bool active_found = false;
-
_model->clear();
if(f) {
+ bool active_found = false;
_dialog._primitive_box.set_sensitive(true);
_dialog.update_filter_general_settings_view();
for(SPObject *prim_obj = f->children;
@@ -1635,8 +1660,30 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
{
cr->set_line_width(1.0);
- // TODO: Use Gtk::StyleContext instead
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *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);
+
+ GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0,
+ (bg_color.green + fg_color.green)/2.0,
+ (bg_color.blue + fg_color.blue)/2.0,
+ (bg_color.alpha + fg_color.alpha)/2.0};
+
+ GdkRGBA bg_color_active, fg_color_active;
+ gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_ACTIVE, &bg_color_active);
+ gtk_style_context_get_color(sc, GTK_STATE_FLAG_ACTIVE, &fg_color_active);
+
+ GdkRGBA mid_color_active = {(bg_color_active.red + fg_color_active.red)/2.0,
+ (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};
+
+ GdkRGBA black = {0,0,0,1};
+#else
GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj()));
+#endif
SPFilterPrimitive* prim = get_selected();
int row_count = get_model()->children().size();
@@ -1655,13 +1702,25 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
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();
@@ -1682,7 +1741,13 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
// 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);
// Side outline
@@ -1703,10 +1768,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
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);
@@ -1726,10 +1798,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
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);
@@ -1747,10 +1826,17 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
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);
@@ -1765,7 +1851,11 @@ bool FilterEffectsDialog::PrimitiveList::on_draw(const Cairo::RefPtr<Cairo::Cont
// Draw drag connection
if(row_prim == prim && _in_drag) {
cr->save();
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_cairo_set_source_rgba(cr->cobj(), &black);
+#else
gdk_cairo_set_source_color(cr->cobj(), &(style->black));
+#endif
cr->move_to(outline_x, con_drag_y);
cr->line_to(mx, con_drag_y);
cr->line_to(mx, my);
@@ -1784,8 +1874,22 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
{
cr->save();
- // TODO: Use Gtk::StyleContext instead
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *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);
+
+ GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0,
+ (bg_color.green + fg_color.green)/2.0,
+ (bg_color.blue + fg_color.blue)/2.0,
+ (bg_color.alpha + fg_color.alpha)/2.0};
+
+ GdkRGBA black = {0,0,0,1};
+#else
GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj()));
+#endif
int src_id = 0;
Gtk::TreeIter res = find_result(input, attr, src_id);
@@ -1800,10 +1904,17 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
const int tw = get_input_type_width();
gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1;
+#if GTK_CHECK_VERSION(3,0,0)
+ if(use_default && is_first)
+ gdk_cairo_set_source_rgba(cr->cobj(), &mid_color);
+ else
+ gdk_cairo_set_source_rgba(cr->cobj(), &black);
+#else
if(use_default && is_first)
gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL]));
else
gdk_cairo_set_source_color(cr->cobj(), &(style->black));
+#endif
cr->rectangle(end_x-2, y1-2, 5, 5);
cr->fill_preserve();
@@ -1831,7 +1942,11 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai
const int y2 = rct.get_y() + rct.get_height();
// Draw a bevelled 'L'-shaped connection
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_cairo_set_source_rgba(cr->cobj(), &black);
+#else
gdk_cairo_set_source_color(cr->cobj(), &(style->black));
+#endif
cr->move_to(x1, y1);
cr->line_to(x2-fheight/4, y1);
cr->line_to(x2, y1-fheight/4);
@@ -2123,7 +2238,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
}
// Checks all of prim's inputs, removes any that use result
-void check_single_connection(SPFilterPrimitive* prim, const int result)
+static void check_single_connection(SPFilterPrimitive* prim, const int result)
{
if (prim && (result >= 0)) {
if (prim->image_in == result) {
@@ -2331,7 +2446,7 @@ void FilterEffectsDialog::show_all_vfunc()
void FilterEffectsDialog::init_settings_widgets()
{
- // TODO: Find better range/climb-rate/digits values for the SpinSliders,
+ // TODO: Find better range/climb-rate/digits values for the SpinScales,
// most of the current values are complete guesses!
_empty_settings.set_sensitive(false);
@@ -2358,18 +2473,18 @@ void FilterEffectsDialog::init_settings_widgets()
/*
//TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html
_settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter);
- _ct_slope = _settings->add_spinslider(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2);
- _ct_intercept = _settings->add_spinslider(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2);
- _ct_amplitude = _settings->add_spinslider(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2);
- _ct_exponent = _settings->add_spinslider(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2);
- _ct_offset = _settings->add_spinslider(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/
+ _ct_slope = _settings->add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2);
+ _ct_intercept = _settings->add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2);
+ _ct_amplitude = _settings->add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2);
+ _ct_exponent = _settings->add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2);
+ _ct_offset = _settings->add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/
_settings->type(NR_FILTER_COMPOSITE);
_settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator:"), CompositeOperatorConverter);
- _k1 = _settings->add_spinslider(0, SP_ATTR_K1, _("K1:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
- _k2 = _settings->add_spinslider(0, SP_ATTR_K2, _("K2:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
- _k3 = _settings->add_spinslider(0, SP_ATTR_K3, _("K3:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
- _k4 = _settings->add_spinslider(0, SP_ATTR_K4, _("K4:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
+ _k1 = _settings->add_spinscale(0, SP_ATTR_K1, _("K1:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
+ _k2 = _settings->add_spinscale(0, SP_ATTR_K2, _("K2:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
+ _k3 = _settings->add_spinscale(0, SP_ATTR_K3, _("K3:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
+ _k4 = _settings->add_spinscale(0, SP_ATTR_K4, _("K4:"), -10, 10, 0.1, 0.01, 2, _("If the arithmetic operation is chosen, each result pixel is computed using the formula k1*i1*i2 + k2*i1 + k3*i2 + k4 where i1 and i2 are the pixel values of the first and second inputs respectively."));
_settings->type(NR_FILTER_CONVOLVEMATRIX);
_convolve_order = _settings->add_dualspinbutton((char*)"3", SP_ATTR_ORDER, _("Size:"), 1, 5, 1, 1, 0, _("width of the convolve matrix"), _("height of the convolve matrix"));
@@ -2377,50 +2492,50 @@ void FilterEffectsDialog::init_settings_widgets()
//TRANSLATORS: for info on "Kernel", see http://en.wikipedia.org/wiki/Kernel_(matrix)
_convolve_matrix = _settings->add_matrix(SP_ATTR_KERNELMATRIX, _("Kernel:"), _("This matrix describes the convolve operation that is applied to the input image in order to calculate the pixel colors at the output. Different arrangements of values in this matrix result in various possible visual effects. An identity matrix would lead to a motion blur effect (parallel to the matrix diagonal) while a matrix filled with a constant non-zero value would lead to a common blur effect."));
_convolve_order->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::convolve_order_changed));
- _settings->add_spinslider(0, SP_ATTR_DIVISOR, _("Divisor:"), 0, 1000, 1, 0.1, 2, _("After applying the kernelMatrix to the input image to yield a number, that number is divided by divisor to yield the final destination color value. A divisor that is the sum of all the matrix values tends to have an evening effect on the overall color intensity of the result."));
- _settings->add_spinslider(0, SP_ATTR_BIAS, _("Bias:"), -10, 10, 1, 0.01, 1, _("This value is added to each component. This is useful to define a constant value as the zero response of the filter."));
+ _settings->add_spinscale(0, SP_ATTR_DIVISOR, _("Divisor:"), 0, 1000, 1, 0.1, 2, _("After applying the kernelMatrix to the input image to yield a number, that number is divided by divisor to yield the final destination color value. A divisor that is the sum of all the matrix values tends to have an evening effect on the overall color intensity of the result."));
+ _settings->add_spinscale(0, SP_ATTR_BIAS, _("Bias:"), -10, 10, 1, 0.01, 1, _("This value is added to each component. This is useful to define a constant value as the zero response of the filter."));
_settings->add_combo(CONVOLVEMATRIX_EDGEMODE_DUPLICATE, SP_ATTR_EDGEMODE, _("Edge Mode:"), ConvolveMatrixEdgeModeConverter, _("Determines how to extend the input image as necessary with color values so that the matrix operations can be applied when the kernel is positioned at or near the edge of the input image."));
_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->type(NR_FILTER_DIFFUSELIGHTING);
_settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Diffuse Color:"), _("Defines the color of the light source"));
- _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.01, 0.001, 3, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
- _settings->add_spinslider(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
- _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
+ _settings->add_spinscale(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.01, 0.001, 3, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
+ _settings->add_spinscale(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
+ _settings->add_dualspinscale(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
_settings->add_lightsource();
_settings->type(NR_FILTER_DISPLACEMENTMAP);
- _settings->add_spinslider(0, SP_ATTR_SCALE, _("Scale:"), 0, 100, 1, 0.01, 1, _("This defines the intensity of the displacement effect."));
+ _settings->add_spinscale(0, SP_ATTR_SCALE, _("Scale:"), 0, 100, 1, 0.01, 1, _("This defines the intensity of the displacement effect."));
_settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_XCHANNELSELECTOR, _("X displacement:"), DisplacementMapChannelConverter, _("Color component that controls the displacement in the X direction"));
_settings->add_combo(DISPLACEMENTMAP_CHANNEL_ALPHA, SP_ATTR_YCHANNELSELECTOR, _("Y displacement:"), DisplacementMapChannelConverter, _("Color component that controls the displacement in the Y direction"));
_settings->type(NR_FILTER_FLOOD);
_settings->add_color(/*default: black*/ 0, SP_PROP_FLOOD_COLOR, _("Flood Color:"), _("The whole filter region will be filled with this color."));
- _settings->add_spinslider(1, SP_PROP_FLOOD_OPACITY, _("Opacity:"), 0, 1, 0.1, 0.01, 2);
+ _settings->add_spinscale(1, SP_PROP_FLOOD_OPACITY, _("Opacity:"), 0, 1, 0.1, 0.01, 2);
_settings->type(NR_FILTER_GAUSSIANBLUR);
- _settings->add_dualspinslider(SP_ATTR_STDDEVIATION, _("Standard Deviation:"), 0.01, 100, 1, 0.01, 1, _("The standard deviation for the blur operation."));
+ _settings->add_dualspinscale(SP_ATTR_STDDEVIATION, _("Standard Deviation:"), 0.01, 100, 1, 0.01, 1, _("The standard deviation for the blur operation."));
_settings->type(NR_FILTER_MERGE);
_settings->add_no_params();
_settings->type(NR_FILTER_MORPHOLOGY);
_settings->add_combo(MORPHOLOGY_OPERATOR_ERODE, SP_ATTR_OPERATOR, _("Operator:"), MorphologyOperatorConverter, _("Erode: performs \"thinning\" of input image.\nDilate: performs \"fattenning\" of input image."));
- _settings->add_dualspinslider(SP_ATTR_RADIUS, _("Radius:"), 0, 100, 1, 0.01, 1);
+ _settings->add_dualspinscale(SP_ATTR_RADIUS, _("Radius:"), 0, 100, 1, 0.01, 1);
_settings->type(NR_FILTER_IMAGE);
_settings->add_fileorelement(SP_ATTR_XLINK_HREF, _("Source of Image:"));
_settings->type(NR_FILTER_OFFSET);
- _settings->add_spinslider(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_spinslider(0, SP_ATTR_DY, _("Delta Y:"), -100, 100, 1, 0.01, 1, _("This is how far the input image gets shifted downwards"));
+ _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"));
_settings->type(NR_FILTER_SPECULARLIGHTING);
_settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Specular Color:"), _("Defines the color of the light source"));
- _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.1, 0.01, 2, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
- _settings->add_spinslider(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
- _settings->add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 50, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\"."));
- _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
+ _settings->add_spinscale(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.1, 0.01, 2, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
+ _settings->add_spinscale(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
+ _settings->add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 50, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\"."));
+ _settings->add_dualspinscale(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
_settings->add_lightsource();
_settings->type(NR_FILTER_TILE);
@@ -2429,9 +2544,9 @@ void FilterEffectsDialog::init_settings_widgets()
_settings->type(NR_FILTER_TURBULENCE);
// _settings->add_checkbutton(false, SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch");
_settings->add_combo(TURBULENCE_TURBULENCE, SP_ATTR_TYPE, _("Type:"), TurbulenceTypeConverter, _("Indicates whether the filter primitive should perform a noise or turbulence function."));
- _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3);
- _settings->add_spinslider(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0);
- _settings->add_spinslider(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator."));
+ _settings->add_dualspinscale(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3);
+ _settings->add_spinscale(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0);
+ _settings->add_spinscale(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator."));
}
void FilterEffectsDialog::add_primitive()
@@ -2614,11 +2729,7 @@ void FilterEffectsDialog::update_filter_general_settings_view()
}
else {
std::vector<Gtk::Widget*> vect = _settings_tab2.get_children();
-#if WITH_GTKMM_2_24
vect[0]->hide();
-#else
- vect[0]->hide_all();
-#endif
_no_filter_selected.show();
}
@@ -2637,11 +2748,7 @@ void FilterEffectsDialog::update_settings_view()
std::vector<Gtk::Widget*> vect1 = _settings_tab1.get_children();
for(unsigned int i=0; i<vect1.size(); i++)
-#if WITH_GTKMM_2_24
vect1[i]->hide();
-#else
- vect1[i]->hide_all();
-#endif
_empty_settings.show();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -2665,11 +2772,7 @@ void FilterEffectsDialog::update_settings_view()
//Second Tab
std::vector<Gtk::Widget*> vect2 = _settings_tab2.get_children();
-#if WITH_GTKMM_2_24
vect2[0]->hide();
-#else
- vect2[0]->hide_all();
-#endif
_no_filter_selected.show();
SPFilter* filter = _filter_modifier.get_selected_filter();
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 38811354e..1652a314f 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -20,6 +20,7 @@
#include "sp-filter.h"
#include "ui/widget/combo-enums.h"
#include "ui/widget/spin-slider.h"
+#include "ui/widget/spin-scale.h"
#include "xml/helper-observer.h"
#include "ui/dialog/desktop-tracker.h"
@@ -76,12 +77,8 @@ private:
};
void setTargetDesktop(SPDesktop *desktop);
-
- void on_document_replaced(SPDesktop*, SPDocument*)
- {
- update_filters();
- }
+ void on_document_replaced(SPDesktop *desktop, SPDocument *document);
void on_change_selection();
void on_modified_selection( guint flags );
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index d449bad67..24588946e 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -207,7 +207,7 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *
// Check if any document styles are not in the actual layout
std::map<SPItem *, Glib::ustring>::const_iterator mapIter;
- for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); mapIter++) {
+ for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); ++mapIter) {
SPItem *item = mapIter->first;
Glib::ustring fonts = mapIter->second;
@@ -241,7 +241,7 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *
}
std::set<Glib::ustring>::const_iterator setIter;
- for (setIter = setErrors.begin(); setIter != setErrors.end(); setIter++) {
+ for (setIter = setErrors.begin(); setIter != setErrors.end(); ++setIter) {
Glib::ustring err = (*setIter);
out->append(err + "\n");
g_warning("%s", err.c_str());
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp
index 1eed8d804..eec904ee4 100644
--- a/src/ui/dialog/glyphs.cpp
+++ b/src/ui/dialog/glyphs.cpp
@@ -364,11 +364,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
scriptCombo = new Gtk::ComboBoxText();
for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it)
{
-#if WITH_GTKMM_2_24
scriptCombo->append(it->second);
-#else
- scriptCombo->append_text(it->second);
-#endif
}
scriptCombo->set_active_text(getScriptToName()[G_UNICODE_SCRIPT_INVALID_CODE]);
@@ -393,11 +389,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) :
rangeCombo = new Gtk::ComboBoxText();
for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) {
-#if WITH_GTKMM_2_24
rangeCombo->append(it->second);
-#else
- rangeCombo->append_text(it->second);
-#endif
}
rangeCombo->set_active_text(getRanges()[1].second);
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index d20f2a220..1f02002ca 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -168,30 +168,54 @@ void GuidelinePropertiesDialog::_setup() {
Gtk::Box *mainVBox = get_vbox();
+#if WITH_GTKMM_3_0
+ _layout_table.set_row_spacing(4);
+ _layout_table.set_column_spacing(4);
+#else
_layout_table.set_spacings(4);
_layout_table.resize (3, 4);
+#endif
mainVBox->pack_start(_layout_table, false, false, 0);
_label_name.set_label("foo0");
- _layout_table.attach(_label_name,
- 0, 3, 0, 1, Gtk::FILL, Gtk::FILL);
_label_name.set_alignment(0, 0.5);
_label_descr.set_label("foo1");
- _layout_table.attach(_label_descr,
- 0, 3, 1, 2, Gtk::FILL, Gtk::FILL);
_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);
+
+ _label_descr.set_halign(Gtk::ALIGN_FILL);
+ _label_descr.set_valign(Gtk::ALIGN_FILL);
+ _layout_table.attach(_label_descr, 0, 1, 3, 1);
+
+ _label_entry.set_halign(Gtk::ALIGN_FILL);
+ _label_entry.set_valign(Gtk::ALIGN_FILL);
+ _label_entry.set_hexpand();
+ _layout_table.attach(_label_entry, 1, 2, 2, 1);
+
+ _color.set_halign(Gtk::ALIGN_FILL);
+ _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);
- // indent
-// _layout_table.attach(*manage(new Gtk::Label(" ")),
-// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10);
+ _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
+
_color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged));
@@ -211,6 +235,22 @@ void GuidelinePropertiesDialog::_setup() {
_spin_button_y.setDigits(3);
_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();
+ _layout_table.attach(_spin_button_x, 1, 4, 1, 1);
+
+ _spin_button_y.set_halign(Gtk::ALIGN_FILL);
+ _spin_button_y.set_valign(Gtk::ALIGN_FILL);
+ _spin_button_y.set_hexpand();
+ _layout_table.attach(_spin_button_y, 1, 5, 1, 1);
+
+ _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,
@@ -218,17 +258,33 @@ void GuidelinePropertiesDialog::_setup() {
_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();
+ _layout_table.attach(_spin_angle, 1, 6, 2, 1);
+
+ // mode radio button
+ _relative_toggle.set_halign(Gtk::ALIGN_FILL);
+ _relative_toggle.set_valign(Gtk::ALIGN_FILL);
+ _relative_toggle.set_hexpand();
+ _layout_table.attach(_relative_toggle, 1, 7, 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);
+#endif
+
_relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged));
_relative_toggle.set_active(_relative_toggle_status);
diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h
index d06c3afc8..a15667152 100644
--- a/src/ui/dialog/guides.h
+++ b/src/ui/dialog/guides.h
@@ -11,8 +11,18 @@
#ifndef INKSCAPE_DIALOG_GUIDELINE_H
#define INKSCAPE_DIALOG_GUIDELINE_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#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>
#include "ui/widget/button.h"
@@ -62,7 +72,13 @@ private:
SPDesktop *_desktop;
SPGuide *_guide;
+
+#if WITH_GTKMM_3_0
+ Gtk::Grid _layout_table;
+#else
Gtk::Table _layout_table;
+#endif
+
Gtk::Label _label_name;
Gtk::Label _label_descr;
Inkscape::UI::Widget::CheckButton _relative_toggle;
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 62f48cce0..cc145c16b 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -47,7 +47,11 @@
#include "display/canvas-grid.h"
#include "path-prefix.h"
#include "io/resource.h"
+#include "io/sys.h"
#include "inkscape.h"
+#include "shortcuts.h"
+#include "document.h"
+
#ifdef HAVE_ASPELL
# include <aspell.h>
@@ -137,6 +141,7 @@ InkscapePreferences::InkscapePreferences()
initPageRendering();
initPageSpellcheck();
+
signalPresent().connect(sigc::mem_fun(*this, &InkscapePreferences::_presentPages));
//calculate the size request for this dialog
@@ -200,7 +205,7 @@ void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring cons
}
-void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch)
+static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL)
@@ -480,7 +485,7 @@ void InkscapePreferences::initPageTools()
_misc_gradientangle.init("/dialogs/gradienteditor/angle", -359, 359, 1, 90, 0, false, false);
_page_gradient.add_line( false, _("Linear gradient _angle:"), _misc_gradientangle, "",
- _("Default angle of new linear gradients in degrees (clockwise from horizontal"), false);
+ _("Default angle of new linear gradients in degrees (clockwise from horizontal)"), false);
//Dropper
@@ -741,6 +746,8 @@ void InkscapePreferences::initPageUI()
_grids_axonom.add_line( false, _("Major grid line every:"), _grids_axonom_empspacing, "", "", false);
this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS);
+
+ initKeyboardShortcuts(iter_ui);
}
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -811,7 +818,7 @@ void InkscapePreferences::initPageIO()
_("Maximum mouse drag (in screen pixels) which is considered a click, not a drag"), false);
_mouse_grabsize.init("/options/grabsize/value", 1, 7, 1, 2, 3, 0);
- _page_mouse.add_line(false, _("_Handle size"), _mouse_grabsize, "",
+ _page_mouse.add_line(false, _("_Handle size:"), _mouse_grabsize, "",
_("Set the relative size of node handles"), true);
_mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "/options/useextinput/value", true);
@@ -979,18 +986,10 @@ void InkscapePreferences::initPageIO()
Glib::ustring current = prefs->getString( "/options/displayprofile/uri" );
gint index = 0;
-#if WITH_GTKMM_2_24
_cms_display_profile.append(_("<none>"));
-#else
- _cms_display_profile.append_text(_("<none>"));
-#endif
index++;
for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) {
-#if WITH_GTKMM_2_24
_cms_display_profile.append( *it );
-#else
- _cms_display_profile.append_text( *it );
-#endif
Glib::ustring path = CMSSystem::getPathForProfile(*it);
if ( !path.empty() && path == current ) {
_cms_display_profile.set_active(index);
@@ -1005,11 +1004,7 @@ void InkscapePreferences::initPageIO()
current = prefs->getString("/options/softproof/uri");
index = 0;
for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) {
-#if WITH_GTKMM_2_24
_cms_proof_profile.append( *it );
-#else
- _cms_proof_profile.append_text( *it );
-#endif
Glib::ustring path = CMSSystem::getPathForProfile(*it);
if ( !path.empty() && path == current ) {
_cms_proof_profile.set_active(index);
@@ -1041,10 +1036,14 @@ void InkscapePreferences::initPageIO()
// Autosave options
_save_autosave_enable.init( _("Enable autosave (requires restart)"), "/options/autosave/enable", false);
_page_autosave.add_line(false, "", _save_autosave_enable, "", _("Automatically save the current document(s) at a given interval, thus minimizing loss in case of a crash"), false);
+ _save_autosave_path.init("/options/autosave/path", true);
+ if (prefs->getString("/options/autosave/path").empty()) {
+ // Show the default fallback "tmp dir" if autosave path is not set.
+ _save_autosave_path.set_text(Glib::get_tmp_dir());
+ }
+ _page_autosave.add_line(false, C_("Filesystem", "Autosave _directory:"), _save_autosave_path, "", _("The directory where autosaves will be written. This should be an absolute path (starts with / on UNIX or a drive letter such as C: on Windows). "), false);
_save_autosave_interval.init("/options/autosave/interval", 1.0, 10800.0, 1.0, 10.0, 10.0, true, false);
_page_autosave.add_line(false, _("_Interval (in minutes):"), _save_autosave_interval, "", _("Interval (in minutes) at which document will be autosaved"), false);
- _save_autosave_path.init("/options/autosave/path", true);
- _page_autosave.add_line(false, C_("Filesystem", "_Path:"), _save_autosave_path, "", _("The directory where autosaves will be written"), false);
_save_autosave_max.init("/options/autosave/max", 1.0, 100.0, 1.0, 10.0, 10.0, true, false);
_page_autosave.add_line(false, _("_Maximum number of autosaves:"), _save_autosave_max, "", _("Maximum number of autosaved files; use this to limit the storage space used"), false);
@@ -1163,9 +1162,11 @@ void InkscapePreferences::initPageBehavior()
_scroll_auto_thres.init ( "/options/autoscrolldistance/value", -600.0, 600.0, 1.0, 1.0, -10.0, true, false);
_page_scrolling.add_line( true, _("_Threshold:"), _scroll_auto_thres, _("pixels"),
_("How far (in screen pixels) you need to be from the canvas edge to trigger autoscroll; positive is outside the canvas, negative is within the canvas"), false);
+/*
_scroll_space.init ( _("Left mouse button pans when Space is pressed"), "/options/spacepans/value", false);
_page_scrolling.add_line( false, "", _scroll_space, "",
_("When on, pressing and holding Space and dragging with left mouse button pans canvas (as in Adobe Illustrator); when off, Space temporarily switches to Selector tool (default)"));
+*/
_wheel_zoom.init ( _("Mouse wheel zooms by default"), "/options/wheelzooms/value", false);
_page_scrolling.add_line( false, "", _wheel_zoom, "",
_("When on, mouse wheel zooms without Ctrl and scrolls canvas with Ctrl; when off, it zooms with Ctrl and scrolls without Ctrl"));
@@ -1401,6 +1402,316 @@ void InkscapePreferences::initPageBitmaps()
this->AddPage(_page_bitmaps, _("Bitmaps"), PREFS_PAGE_BITMAPS);
}
+void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui)
+{
+ std::vector<Glib::ustring> fileNames;
+ std::vector<Glib::ustring> fileLabels;
+
+ sp_shortcut_get_file_names(&fileLabels, &fileNames);
+
+ _kb_filelist.init( "/options/kbshortcuts/shortcutfile", &fileLabels[0], &fileNames[0], fileLabels.size(), fileNames[0]);
+
+ Glib::ustring tooltip(_("Select a file of predefined shortcuts to use. Any customized shortcuts you create will be added seperately to "));
+ tooltip += Glib::ustring(IO::Resource::get_path(IO::Resource::USER, IO::Resource::KEYS, "default.xml"));
+
+ _page_keyshortcuts.add_line( false, _("Shortcut file:"), _kb_filelist, "", tooltip.c_str(), false);
+
+ _kb_search.init("/options/kbshortcuts/value", true);
+ _page_keyshortcuts.add_line( false, _("Search:"), _kb_search, "", "", true);
+
+ _kb_store = Gtk::TreeStore::create( _kb_columns );
+ _kb_store->set_sort_column (_kb_columns.id, Gtk::SORT_ASCENDING );
+
+ _kb_filter = Gtk::TreeModelFilter::create(_kb_store);
+ _kb_filter->set_visible_func (sigc::mem_fun(*this, &InkscapePreferences::onKBSearchFilter));
+
+ _kb_shortcut_renderer.property_editable() = true;
+
+ _kb_tree.set_model(_kb_filter);
+ _kb_tree.append_column(_("Name"), _kb_columns.name);
+ _kb_tree.append_column(_("Shortcut"), _kb_shortcut_renderer);
+ _kb_tree.append_column(_("Description"), _kb_columns.description);
+ _kb_tree.append_column(_("ID"), _kb_columns.id);
+
+ _kb_tree.set_expander_column(*_kb_tree.get_column(0));
+
+ _kb_tree.get_column(0)->set_resizable(true);
+ _kb_tree.get_column(0)->set_clickable(true);
+ _kb_tree.get_column(0)->set_fixed_width (200);
+
+ _kb_tree.get_column(1)->set_resizable(true);
+ _kb_tree.get_column(1)->set_clickable(true);
+ _kb_tree.get_column(1)->set_fixed_width (150);
+ //_kb_tree.get_column(1)->add_attribute(_kb_shortcut_renderer.property_text(), _kb_columns.shortcut);
+ _kb_tree.get_column(1)->set_cell_data_func(_kb_shortcut_renderer, sigc::ptr_fun(InkscapePreferences::onKBShortcutRenderer));
+
+ _kb_tree.get_column(2)->set_resizable(true);
+ _kb_tree.get_column(2)->set_clickable(true);
+
+ _kb_tree.get_column(3)->set_resizable(true);
+ _kb_tree.get_column(3)->set_clickable(true);
+
+ _kb_shortcut_renderer.signal_accel_edited().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBTreeEdited) );
+ _kb_shortcut_renderer.signal_accel_cleared().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBTreeCleared) );
+
+ Gtk::ScrolledWindow* scroller = new Gtk::ScrolledWindow();
+ scroller->add(_kb_tree);
+
+ int row = 3;
+ _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL);
+ row++;
+
+ Gtk::HButtonBox *box_buttons = manage (new Gtk::HButtonBox);
+ box_buttons->set_layout(Gtk::BUTTONBOX_END);
+ box_buttons->set_spacing(4);
+ _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
+
+ UI::Widget::Button *kb_reset = 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);
+ box_buttons->set_child_secondary(*kb_reset);
+
+ UI::Widget::Button *kb_import = manage(new UI::Widget::Button(_("Import ..."), _("Import custom keyboard shortcuts from a file")));
+ box_buttons->pack_end(*kb_import, true, true, 6);
+
+ UI::Widget::Button *kb_export = manage(new UI::Widget::Button(_("Export ..."), _("Export custom keyboard shortcuts to a file")));
+ box_buttons->pack_end(*kb_export, true, true, 6);
+
+ kb_reset->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBReset) );
+ kb_import->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBImport) );
+ kb_export->signal_clicked().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBExport) );
+ _kb_search.signal_key_release_event().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBSearchKeyEvent) );
+ _kb_filelist.signal_changed().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBList) );
+ _page_keyshortcuts.signal_realize().connect( sigc::mem_fun(*this, &InkscapePreferences::onKBRealize) );
+
+ this->AddPage(_page_keyshortcuts, _("Keyboard Shortcuts"), iter_ui, PREFS_PAGE_UI_KEYBOARD_SHORTCUTS);
+
+ _kb_shortcuts_loaded = false;
+ Gtk::TreeStore::iterator iter_group = _kb_store->append();
+ (*iter_group)[_kb_columns.name] = "Loading ...";
+ (*iter_group)[_kb_columns.shortcut] = "";
+ (*iter_group)[_kb_columns.id] = "";
+ (*iter_group)[_kb_columns.description] = "";
+ (*iter_group)[_kb_columns.shortcutid] = 0;
+ (*iter_group)[_kb_columns.user_set] = 0;
+
+}
+
+void InkscapePreferences::onKBList()
+{
+ sp_shortcut_init();
+ onKBListKeyboardShortcuts();
+}
+
+void InkscapePreferences::onKBReset()
+{
+ sp_shortcuts_delete_all_from_file();
+ sp_shortcut_init();
+ onKBListKeyboardShortcuts();
+}
+
+void InkscapePreferences::onKBImport()
+{
+ if (sp_shortcut_file_import()) {
+ onKBListKeyboardShortcuts();
+ }
+}
+
+void InkscapePreferences::onKBExport()
+{
+ sp_shortcut_file_export();
+}
+
+bool InkscapePreferences::onKBSearchKeyEvent(GdkEventKey *event)
+{
+ _kb_filter->refilter();
+ return FALSE;
+}
+
+void InkscapePreferences::onKBTreeCleared(const Glib::ustring& path)
+{
+ Gtk::TreeModel::iterator iter = _kb_filter->get_iter(path);
+ Glib::ustring id = (*iter)[_kb_columns.id];
+ unsigned int const current_shortcut_id = (*iter)[_kb_columns.shortcutid];
+
+ // Remove current shortcut from file
+ sp_shortcut_delete_from_file(id.c_str(), current_shortcut_id);
+
+ sp_shortcut_init();
+ onKBListKeyboardShortcuts();
+
+}
+
+void InkscapePreferences::onKBTreeEdited (const Glib::ustring& path, guint accel_key, Gdk::ModifierType accel_mods, guint hardware_keycode)
+{
+ Gtk::TreeModel::iterator iter = _kb_filter->get_iter(path);
+
+ Glib::ustring id = (*iter)[_kb_columns.id];
+ Glib::ustring current_shortcut = (*iter)[_kb_columns.shortcut];
+ unsigned int const current_shortcut_id = (*iter)[_kb_columns.shortcutid];
+
+ Inkscape::Verb *const verb = Inkscape::Verb::getbyid(id.c_str());
+ if (!verb) {
+ return;
+ }
+
+ unsigned int const new_shortcut_id = sp_gdkmodifier_to_shortcut(accel_key, accel_mods, hardware_keycode);
+ if (new_shortcut_id) {
+
+ // Delete current shortcut if it existed
+ sp_shortcut_delete_from_file(id.c_str(), current_shortcut_id);
+ // Delete any references to the new shortcut
+ sp_shortcut_delete_from_file(id.c_str(), new_shortcut_id);
+ // Add the new shortcut
+ sp_shortcut_add_to_file(id.c_str(), new_shortcut_id);
+
+ sp_shortcut_init();
+ onKBListKeyboardShortcuts();
+ }
+}
+
+bool InkscapePreferences::onKBSearchFilter(const Gtk::TreeModel::const_iterator& iter)
+{
+ Glib::ustring search = _kb_search.get_text().lowercase();
+ if (search.empty()) {
+ return TRUE;
+ }
+
+ Glib::ustring name = (*iter)[_kb_columns.name];
+ Glib::ustring desc = (*iter)[_kb_columns.description];
+ Glib::ustring shortcut = (*iter)[_kb_columns.shortcut];
+ Glib::ustring id = (*iter)[_kb_columns.id];
+
+ if (id.empty()) {
+ return TRUE; // Keep all group nodes visible
+ }
+
+ return (name.lowercase().find(search) != name.npos
+ || shortcut.lowercase().find(search) != name.npos
+ || desc.lowercase().find(search) != name.npos
+ || id.lowercase().find(search) != name.npos);
+}
+
+void InkscapePreferences::onKBRealize()
+{
+ if (!_kb_shortcuts_loaded /*&& _current_page == &_page_keyshortcuts*/) {
+ _kb_shortcuts_loaded = true;
+ onKBListKeyboardShortcuts();
+ }
+}
+
+InkscapePreferences::ModelColumns &InkscapePreferences::onKBGetCols()
+{
+ static InkscapePreferences::ModelColumns cols;
+ return cols;
+}
+
+void InkscapePreferences::onKBShortcutRenderer(Gtk::CellRenderer *renderer, Gtk::TreeIter const &iter) {
+
+ Glib::ustring shortcut = (*iter)[onKBGetCols().shortcut];
+ unsigned int user_set = (*iter)[onKBGetCols().user_set];
+ Gtk::CellRendererAccel *accel = dynamic_cast<Gtk::CellRendererAccel *>(renderer);
+ if (user_set) {
+ accel->property_markup() = Glib::ustring("<span foreground=\"blue\"> " + shortcut + " </span>").c_str();
+ } else {
+ accel->property_markup() = Glib::ustring("<span> " + shortcut + " </span>").c_str();
+ }
+}
+
+void InkscapePreferences::onKBListKeyboardShortcuts()
+{
+ // Save the current selection
+ Gtk::TreeStore::iterator iter = _kb_tree.get_selection()->get_selected();
+ Glib::ustring selected_id = "";
+ if (iter) {
+ selected_id = (*iter)[_kb_columns.id];
+ }
+
+ _kb_store->clear();
+
+ std::vector<Verb *>verbs = Inkscape::Verb::getList();
+
+ for (unsigned int i = 0; i < verbs.size(); i++) {
+
+ Inkscape::Verb* verb = verbs[i];
+ if (!verb) {
+ continue;
+ }
+ if (!verb->get_name()){
+ continue;
+ }
+
+ Gtk::TreeStore::Path path;
+ if (_kb_store->iter_is_valid(_kb_store->get_iter("0"))) {
+ path = _kb_store->get_path(_kb_store->get_iter("0"));
+ }
+
+ // Find this group in the tree
+ Glib::ustring group = verb->get_group() ? verb->get_group() : "Misc";
+ Gtk::TreeStore::iterator iter_group;
+ bool found = false;
+ while (path) {
+ iter_group = _kb_store->get_iter(path);
+ if (!_kb_store->iter_is_valid(iter_group)) {
+ break;
+ }
+ Glib::ustring name = (*iter_group)[_kb_columns.name];
+ if ((*iter_group)[_kb_columns.name] == group) {
+ found = true;
+ break;
+ }
+ path.next();
+ }
+
+ if (!found) {
+ // Add the group if not there
+ iter_group = _kb_store->append();
+ (*iter_group)[_kb_columns.name] = group;
+ (*iter_group)[_kb_columns.shortcut] = "";
+ (*iter_group)[_kb_columns.id] = "";
+ (*iter_group)[_kb_columns.description] = "";
+ (*iter_group)[_kb_columns.shortcutid] = 0;
+ (*iter_group)[_kb_columns.user_set] = 0;
+ }
+
+ // Remove the key accelerators from the verb name
+ Glib::ustring name = verb->get_name();
+ std::string::size_type k = 0;
+ while((k=name.find('_',k))!=name.npos) {
+ name.erase(k, 1);
+ }
+
+ // Get the shortcut label
+ unsigned int shortcut_id = sp_shortcut_get_primary(verb);
+ Glib::ustring shortcut_label = "";
+ if (shortcut_id != GDK_KEY_VoidSymbol) {
+ gchar* str = sp_shortcut_get_label(shortcut_id);
+ if (str) {
+ shortcut_label = str;
+ g_free(str);
+ str = 0;
+ }
+ }
+ // Add the verb to the group
+ Gtk::TreeStore::iterator row = _kb_store->append(iter_group->children());
+ (*row)[_kb_columns.name] = name;
+ (*row)[_kb_columns.shortcut] = shortcut_label;
+ (*row)[_kb_columns.description] = verb->get_short_tip() ? verb->get_short_tip() : "";
+ (*row)[_kb_columns.shortcutid] = shortcut_id;
+ (*row)[_kb_columns.id] = verb->get_id();
+ (*row)[_kb_columns.user_set] = sp_shortcut_is_user_set(verb);
+
+ if (selected_id == verb->get_id()) {
+ Gtk::TreeStore::Path sel_path = _kb_filter->convert_child_path_to_path(_kb_store->get_path(row));
+ _kb_tree.expand_to_path(sel_path);
+ _kb_tree.get_selection()->select(sel_path);
+ }
+ }
+
+ if (selected_id.empty()) {
+ _kb_tree.expand_to_path(_kb_store->get_path(_kb_store->get_iter("0:1")));
+ }
+
+}
void InkscapePreferences::initPageSpellcheck()
{
@@ -1605,7 +1916,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter)
_page_list.expand_row(_path_tools, false);
if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL)
_page_list.expand_row(_path_shapes, false);
- if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_GRIDS)
+ if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_KEYBOARD_SHORTCUTS)
_page_list.expand_row(_path_ui, false);
if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS)
_page_list.expand_row(_path_behavior, false);
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index d60035515..690016556 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -18,15 +18,19 @@
#include <iostream>
#include <vector>
#include "ui/widget/preferences-widget.h"
+#include "ui/widget/button.h"
+#include <stddef.h>
#include <gtkmm/colorbutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/treestore.h>
#include <gtkmm/treeview.h>
#include <gtkmm/frame.h>
#include <gtkmm/notebook.h>
-#include <stddef.h>
#include <gtkmm/textview.h>
#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treemodel.h>
+#include <gtkmm/treemodelfilter.h>
#include "ui/widget/panel.h"
@@ -60,6 +64,7 @@ enum {
PREFS_PAGE_UI,
PREFS_PAGE_UI_WINDOWS,
PREFS_PAGE_UI_GRIDS,
+ PREFS_PAGE_UI_KEYBOARD_SHORTCUTS,
PREFS_PAGE_BEHAVIOR,
PREFS_PAGE_BEHAVIOR_SELECTING,
PREFS_PAGE_BEHAVIOR_TRANSFORMS,
@@ -79,6 +84,7 @@ enum {
PREFS_PAGE_BITMAPS,
PREFS_PAGE_RENDERING,
PREFS_PAGE_SPELLCHECK
+
};
namespace Inkscape {
@@ -166,6 +172,8 @@ protected:
UI::Widget::DialogPage _page_bitmaps;
UI::Widget::DialogPage _page_spellcheck;
+ UI::Widget::DialogPage _page_keyshortcuts;
+
UI::Widget::PrefSpinButton _mouse_sens;
UI::Widget::PrefSpinButton _mouse_thres;
UI::Widget::PrefSlider _mouse_grabsize;
@@ -337,12 +345,16 @@ protected:
UI::Widget::PrefCheckButton _spell_ignorenumbers;
UI::Widget::PrefCheckButton _spell_ignoreallcaps;
+
UI::Widget::PrefCombo _misc_overs_bitmap;
UI::Widget::PrefEntryFileButtonHBox _misc_bitmap_editor;
UI::Widget::PrefCheckButton _misc_bitmap_autoreload;
UI::Widget::PrefSpinButton _bitmap_copy_res;
UI::Widget::PrefCombo _bitmap_import;
+ UI::Widget::PrefEntry _kb_search;
+ UI::Widget::PrefCombo _kb_filelist;
+
UI::Widget::PrefCheckButton _save_use_current_dir;
UI::Widget::PrefCheckButton _save_autosave_enable;
UI::Widget::PrefSpinButton _save_autosave_interval;
@@ -411,6 +423,37 @@ protected:
UI::Widget::PrefEntry _importexport_ocal_username;
UI::Widget::PrefEntry _importexport_ocal_password;
+ /*
+ * Keyboard shortcut members
+ */
+ class ModelColumns: public Gtk::TreeModel::ColumnRecord {
+ public:
+ ModelColumns() {
+ add(name);
+ add(id);
+ add(shortcut);
+ add(description);
+ add(shortcutid);
+ add(user_set);
+ }
+ virtual ~ModelColumns() {
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ Gtk::TreeModelColumn<Glib::ustring> id;
+ Gtk::TreeModelColumn<Glib::ustring> shortcut;
+ Gtk::TreeModelColumn<Glib::ustring> description;
+ Gtk::TreeModelColumn<unsigned int> shortcutid;
+ Gtk::TreeModelColumn<unsigned int> user_set;
+ };
+ ModelColumns _kb_columns;
+ static ModelColumns &onKBGetCols();
+ Glib::RefPtr<Gtk::TreeStore> _kb_store;
+ Gtk::TreeView _kb_tree;
+ Gtk::CellRendererAccel _kb_shortcut_renderer;
+ Glib::RefPtr<Gtk::TreeModelFilter> _kb_filter;
+ gboolean _kb_shortcuts_loaded;
+
int _max_dialog_width;
int _max_dialog_height;
int _sb_width;
@@ -441,9 +484,26 @@ protected:
void initPageBitmaps();
void initPageSystem();
void initPageI18n(); // Do we still need it?
+ void initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui);
void _presentPages();
+ /*
+ * Functions for the Keyboard shortcut editor panel
+ */
+ void onKBReset();
+ void onKBImport();
+ void onKBExport();
+ void onKBList();
+ void onKBRealize();
+ void onKBListKeyboardShortcuts();
+ void onKBTreeEdited (const Glib::ustring& path, guint accel_key, Gdk::ModifierType accel_mods, guint hardware_keycode);
+ void onKBTreeCleared(const Glib::ustring& path_string);
+ bool onKBSearchKeyEvent(GdkEventKey *event);
+ bool onKBSearchFilter(const Gtk::TreeModel::const_iterator& iter);
+ static void onKBShortcutRenderer(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter);
+
+
private:
InkscapePreferences();
InkscapePreferences(InkscapePreferences const &d);
diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp
index b3c1bddfd..4c567a6e3 100644
--- a/src/ui/dialog/input.cpp
+++ b/src/ui/dialog/input.cpp
@@ -357,6 +357,15 @@ static std::map<Gdk::InputMode, Glib::ustring> &getModeToString()
return mapping;
}
+static int getModeId(Gdk::InputMode im)
+{
+ if (im == Gdk::MODE_DISABLED) return 0;
+ if (im == Gdk::MODE_SCREEN) return 1;
+ if (im == Gdk::MODE_WINDOW) return 2;
+
+ return 0;
+}
+
static std::map<Glib::ustring, Gdk::InputMode> &getStringToMode()
{
static std::map<Glib::ustring, Gdk::InputMode> mapping;
@@ -400,15 +409,59 @@ private:
static void setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter);
void saveSettings();
+ void onTreeSelect();
void useExtToggled();
- Glib::RefPtr<Gtk::TreeStore> store;
- Gtk::TreeIter tabletIter;
- Gtk::TreeView tree;
- Gtk::ScrolledWindow treeScroller;
+ void onModeChange();
+ void setKeys(gint count);
+ void setAxis(gint count);
+
+ Glib::RefPtr<Gtk::TreeStore> confDeviceStore;
+ Gtk::TreeIter confDeviceIter;
+ Gtk::TreeView confDeviceTree;
+ Gtk::ScrolledWindow confDeviceScroller;
Blink watcher;
Gtk::CheckButton useExt;
Gtk::Button save;
+
+ Gtk::HPaned pane;
+ Gtk::VBox detailsBox;
+ Gtk::HBox titleFrame;
+ Gtk::Label titleLabel;
+ Inkscape::UI::Widget::Frame axisFrame;
+ Inkscape::UI::Widget::Frame keysFrame;
+ Gtk::VBox axisVBox;
+ Gtk::ComboBoxText modeCombo;
+ Gtk::Label modeLabel;
+ Gtk::HBox modeBox;
+
+ class KeysColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ KeysColumns()
+ {
+ add(name);
+ add(value);
+ }
+ virtual ~KeysColumns() {}
+
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ Gtk::TreeModelColumn<Glib::ustring> value;
+ };
+
+ KeysColumns keysColumns;
+ KeysColumns axisColumns;
+
+ Glib::RefPtr<Gtk::ListStore> axisStore;
+ Gtk::TreeView axisTree;
+ Gtk::ScrolledWindow axisScroll;
+
+ Glib::RefPtr<Gtk::ListStore> keysStore;
+ Gtk::TreeView keysTree;
+ Gtk::ScrolledWindow keysScroll;
+ Gtk::CellRendererAccel _kb_shortcut_renderer;
+
+
};
static DeviceModelColumns &getCols();
@@ -425,11 +478,11 @@ private:
GdkInputSource lastSourceSeen;
Glib::ustring lastDevnameSeen;
- Glib::RefPtr<Gtk::TreeStore> store;
- Gtk::TreeIter tabletIter;
- Gtk::TreeView tree;
- Inkscape::UI::Widget::Frame detailFrame;
+ Glib::RefPtr<Gtk::TreeStore> deviceStore;
+ Gtk::TreeIter deviceIter;
+ Gtk::TreeView deviceTree;
Inkscape::UI::Widget::Frame testFrame;
+ Inkscape::UI::Widget::Frame axisFrame;
Gtk::ScrolledWindow treeScroller;
Gtk::ScrolledWindow detailScroller;
Gtk::HPaned splitter;
@@ -439,12 +492,13 @@ private:
Gtk::Label devAxesCount;
Gtk::ComboBoxText axesCombo;
Gtk::ProgressBar axesValues[6];
+ Gtk::Table axisTable;
+
Gtk::ComboBoxText buttonCombo;
Gtk::ComboBoxText linkCombo;
sigc::connection linkConnection;
Gtk::Label keyVal;
Gtk::Entry keyEntry;
- Gtk::Table devDetails;
Gtk::Notebook topHolder;
Gtk::Image testThumb;
Gtk::Image testButtons[24];
@@ -454,6 +508,7 @@ private:
ConfPanel cfgPanel;
+
static void setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet );
void setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo );
void updateTestButtons( Glib::ustring const& key, gint hotButton );
@@ -526,17 +581,17 @@ InputDialogImpl::InputDialogImpl() :
lastSourceSeen((GdkInputSource)-1),
lastDevnameSeen(""),
- store(Gtk::TreeStore::create(getCols())),
- tabletIter(),
- tree(store),
- detailFrame(),
+ deviceStore(Gtk::TreeStore::create(getCols())),
+ deviceIter(),
+ deviceTree(deviceStore),
testFrame(_("Test Area")),
+ axisFrame(_("Axis")),
treeScroller(),
detailScroller(),
splitter(),
split2(),
+ axisTable(11, 2),
linkCombo(),
- devDetails(12, 2),
topHolder(),
imageTable(8, 7),
testDetector(),
@@ -547,10 +602,12 @@ InputDialogImpl::InputDialogImpl() :
treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
treeScroller.set_shadow_type(Gtk::SHADOW_IN);
- treeScroller.add(tree);
+ treeScroller.add(deviceTree);
treeScroller.set_size_request(50, 0);
- split2.pack1(testFrame, false, false);
- split2.pack2(detailFrame, true, true);
+
+ split2.pack1(axisFrame, false, false);
+ split2.pack2(testFrame, true, true);
+
splitter.pack1(treeScroller);
splitter.pack2(split2);
@@ -585,54 +642,60 @@ InputDialogImpl::InputDialogImpl() :
}
- topHolder.append_page(cfgPanel, _("Configuration"));
- topHolder.append_page(splitter, _("Hardware"));
- topHolder.show_all();
- topHolder.set_current_page(0);
+ // This is a hidden preference to enable the "hardware" details in a separate tab
+ // By default this is not available to users
+ if (Preferences::get()->getBool("/dialogs/inputdevices/test")) {
+ topHolder.append_page(cfgPanel, _("Configuration"));
+ topHolder.append_page(splitter, _("Hardware"));
+ topHolder.show_all();
+ topHolder.set_current_page(0);
+ contents->pack_start(topHolder);
+ } else {
+ contents->pack_start(cfgPanel);
+ }
- contents->pack_start(topHolder);
int rowNum = 0;
/* Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devName, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devName, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
rowNum++;*/
+ axisFrame.add(axisTable);
+
Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
-#if WITH_GTKMM_2_24
linkCombo.append(_("None"));
-#else
- linkCombo.append_text(_("None"));
-#endif
linkCombo.set_active_text(_("None"));
linkCombo.set_sensitive(false);
linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged));
- devDetails.attach(linkCombo, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
rowNum++;
+
lbl = Gtk::manage(new Gtk::Label(_("Axes count:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devAxesCount, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
rowNum++;
+
/*
lbl = Gtk::manage(new Gtk::Label(_("Actual axes count:")));
devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
@@ -647,22 +710,24 @@ InputDialogImpl::InputDialogImpl() :
for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) {
lbl = Gtk::manage(new Gtk::Label(_("axis:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::FILL,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ ::Gtk::EXPAND,
::Gtk::SHRINK);
- devDetails.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1,
::Gtk::EXPAND,
::Gtk::SHRINK);
axesValues[barNum].set_sensitive(false);
rowNum++;
+
+
}
lbl = Gtk::manage(new Gtk::Label(_("Button count:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devKeyCount, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
@@ -680,7 +745,7 @@ InputDialogImpl::InputDialogImpl() :
rowNum++;
*/
- devDetails.attach(keyVal, 0, 2, rowNum, rowNum + 1,
+ axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
rowNum++;
@@ -700,19 +765,18 @@ InputDialogImpl::InputDialogImpl() :
#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);
- devDetails.attach(keyEntry, 0, 2, rowNum, rowNum + 1,
+ axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
rowNum++;
- devDetails.set_sensitive(false);
- detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ axisTable.set_sensitive(false);
+
+/* detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
detailScroller.set_shadow_type(Gtk::SHADOW_NONE);
detailScroller.set_border_width (0);
- detailScroller.add(devDetails);
- detailFrame.add(detailScroller);
- detailFrame.set_size_request(0, 60);
+ detailScroller.add(devDetails);*/
//- 16x16/devices
// gnome-dev-mouse-optical
@@ -721,25 +785,24 @@ InputDialogImpl::InputDialogImpl() :
// mouse
-
//Add the TreeView's view columns:
- tree.append_column("I", getCols().thumbnail);
- tree.append_column("Bar", getCols().description);
+ deviceTree.append_column("I", getCols().thumbnail);
+ deviceTree.append_column("Bar", getCols().description);
- tree.set_enable_tree_lines();
- tree.set_headers_visible(false);
- tree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection));
+ deviceTree.set_enable_tree_lines();
+ deviceTree.set_headers_visible(false);
+ deviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection));
- setupTree( store, tabletIter );
+ setupTree( deviceStore, deviceIter );
Inkscape::DeviceManager::getManager().signalDeviceChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::handleDeviceChange));
Inkscape::DeviceManager::getManager().signalAxesChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceAxes));
Inkscape::DeviceManager::getManager().signalButtonsChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceButtons));
- Glib::RefPtr<Gtk::TreeView> treePtr(&tree);
- Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr));
+ Glib::RefPtr<Gtk::TreeView> treePtr(&deviceTree);
+ Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), deviceIter, treePtr));
- tree.expand_all();
+ deviceTree.expand_all();
show_all_children();
}
@@ -781,12 +844,30 @@ static Glib::ustring getCommon( std::list<Glib::ustring> const &names )
return result;
}
+
+void InputDialogImpl::ConfPanel::onModeChange()
+{
+ Glib::ustring newText = modeCombo.get_active_text();
+
+ Glib::RefPtr<Gtk::TreeSelection> sel = confDeviceTree.get_selection();
+ Gtk::TreeModel::iterator iter = sel->get_selected();
+ if (iter) {
+ Glib::RefPtr<InputDevice const> dev = (*iter)[getCols().device];
+ if (dev && (getStringToMode().find(newText) != getStringToMode().end())) {
+ Gdk::InputMode mode = getStringToMode()[newText];
+ Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode );
+ }
+ }
+
+}
+
+
void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet )
{
std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices();
if ( !devList.empty() ) {
- Gtk::TreeModel::Row row = *(store->append());
- row[getCols().description] = _("Hardware");
+ //Gtk::TreeModel::Row row = *(store->append());
+ //row[getCols().description] = _("Hardware");
// Let's make some tablets!!!
std::list<TabletTmp> tablets;
@@ -811,7 +892,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
// Phase 2 - build a UI for the present devices
for ( std::list<TabletTmp>::iterator it = tablets.begin(); it != tablets.end(); ++it ) {
- tablet = store->append(row.children());
+ tablet = store->prepend(/*row.children()*/);
Gtk::TreeModel::Row childrow = *tablet;
if ( it->name.empty() ) {
// Check to see if we can derive one
@@ -874,13 +955,14 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it = devList.begin(); it != devList.end(); ++it ) {
Glib::RefPtr<InputDevice const> dev = *it;
if ( dev && (consumed.find( dev->getId() ) == consumed.end()) ) {
- Gtk::TreeModel::Row deviceRow = *(store->append(row.children()));
+ Gtk::TreeModel::Row deviceRow = *(store->prepend(/*row.children()*/));
deviceRow[getCols().description] = dev->getName();
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
deviceRow[getCols().thumbnail] = getPix(PIX_CORE);
}
}
+
} else {
g_warning("No devices found");
}
@@ -889,84 +971,158 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
InputDialogImpl::ConfPanel::ConfPanel() :
Gtk::VBox(),
- store(Gtk::TreeStore::create(getCols())),
- tabletIter(),
- tree(store),
- treeScroller(),
+ confDeviceStore(Gtk::TreeStore::create(getCols())),
+ confDeviceIter(),
+ confDeviceTree(confDeviceStore),
+ confDeviceScroller(),
watcher(*this),
useExt(_("_Use pressure-sensitive tablet (requires restart)"), true),
- save(_("_Save"), true)
+ save(_("_Save"), true),
+ detailsBox(false, 4),
+ titleFrame(false, 4),
+ titleLabel(""),
+ axisFrame(_("Axes")),
+ keysFrame(_("Keys")),
+ modeLabel(_("Mode")),
+ modeBox(false, 4)
+
{
- pack_start(treeScroller);
- treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- treeScroller.add(tree);
- class Foo : public Gtk::TreeModel::ColumnRecord {
+ confDeviceScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ confDeviceScroller.set_shadow_type(Gtk::SHADOW_IN);
+ confDeviceScroller.add(confDeviceTree);
+ confDeviceScroller.set_size_request(120, 0);
+
+ /* class Foo : public Gtk::TreeModel::ColumnRecord {
public :
Gtk::TreeModelColumn<Glib::ustring> one;
Foo() {add(one);}
};
static Foo foo;
- Glib::RefPtr<Gtk::ListStore> poppers = Gtk::ListStore::create(foo);
- poppers->reference();
-
- Gtk::TreeModel::Row row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_DISABLED];
- row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_SCREEN];
- row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_WINDOW];
//Add the TreeView's view columns:
{
Gtk::CellRendererToggle *rendr = new Gtk::CellRendererToggle();
Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("xx", *rendr);
if (col) {
- tree.append_column(*col);
+ confDeviceTree.append_column(*col);
col->set_cell_data_func(*rendr, sigc::ptr_fun(setCellStateToggle));
- rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), store));
+ rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), confDeviceStore));
}
- }
+ }*/
- int expPos = tree.append_column("", getCols().expander);
+ //int expPos = confDeviceTree.append_column("", getCols().expander);
- tree.append_column("I", getCols().thumbnail);
- tree.append_column("Bar", getCols().description);
+ confDeviceTree.append_column("I", getCols().thumbnail);
+ confDeviceTree.append_column("Bar", getCols().description);
- {
- Gtk::CellRendererCombo *rendr = new Gtk::CellRendererCombo();
- rendr->property_model().set_value(poppers);
- rendr->property_text_column().set_value(0);
- rendr->property_has_entry() = false;
+ //confDeviceTree.get_column(0)->set_fixed_width(100);
+ //confDeviceTree.get_column(1)->set_expand();
+
+/* {
Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("X", *rendr);
if (col) {
- tree.append_column(*col);
+ confDeviceTree.append_column(*col);
col->set_cell_data_func(*rendr, sigc::ptr_fun(setModeCellString));
- rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), store));
+ rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), confDeviceStore));
rendr->property_editable() = true;
}
- }
+ }*/
+
+ //confDeviceTree.set_enable_tree_lines();
+ confDeviceTree.property_enable_tree_lines() = false;
+ confDeviceTree.property_enable_grid_lines() = false;
+ confDeviceTree.set_headers_visible(false);
+ //confDeviceTree.set_expander_column( *confDeviceTree.get_column(expPos - 1) );
- tree.set_enable_tree_lines();
- tree.set_headers_visible(false);
- tree.set_expander_column( *tree.get_column(expPos - 1) );
+ confDeviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onTreeSelect));
- setupTree( store, tabletIter );
+ setupTree( confDeviceStore, confDeviceIter );
- Glib::RefPtr<Gtk::TreeView> treePtr(&tree);
- Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr));
+ Glib::RefPtr<Gtk::TreeView> treePtr(&confDeviceTree);
+ Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), confDeviceIter, treePtr));
- tree.expand_all();
+ confDeviceTree.expand_all();
useExt.set_active(Preferences::get()->getBool("/options/useextinput/value"));
useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled));
- pack_start(useExt, Gtk::PACK_SHRINK);
+ Gtk::HButtonBox *buttonBox = manage (new Gtk::HButtonBox);
+ buttonBox->set_layout (Gtk::BUTTONBOX_END);
+ //Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0);
+ buttonBox->add(save);
save.signal_clicked().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::saveSettings));
- Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0);
- align->add(save);
- pack_start(*Gtk::manage(align), Gtk::PACK_SHRINK);
+
+ titleFrame.pack_start(titleLabel, true, true);
+ //titleFrame.set_shadow_type(Gtk::SHADOW_IN);
+
+ modeCombo.append(getModeToString()[Gdk::MODE_DISABLED]);
+ modeCombo.append(getModeToString()[Gdk::MODE_SCREEN]);
+ modeCombo.append(getModeToString()[Gdk::MODE_WINDOW]);
+ modeCombo.set_tooltip_text(_("A device can be 'Disabled', its co-ordinates mapped to the whole 'Screen', or to a single (usually focused) 'Window'"));
+ modeCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onModeChange));
+
+ modeBox.pack_start(modeLabel, false, false);
+ modeBox.pack_start(modeCombo, true, true);
+
+ axisVBox.add(axisScroll);
+ axisFrame.add(axisVBox);
+
+ keysFrame.add(keysScroll);
+
+ /**
+ * Scrolled Window
+ */
+ keysScroll.add(keysTree);
+ keysScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ keysScroll.set_shadow_type(Gtk::SHADOW_IN);
+ keysScroll.set_size_request(120, 80);
+
+ keysStore = Gtk::ListStore::create(keysColumns);
+
+ _kb_shortcut_renderer.property_editable() = true;
+
+ keysTree.set_model(keysStore);
+ keysTree.set_headers_visible(false);
+ keysTree.append_column("Name", keysColumns.name);
+ keysTree.append_column("Value", keysColumns.value);
+
+ //keysTree.append_column("Value", _kb_shortcut_renderer);
+ //keysTree.get_column(1)->add_attribute(_kb_shortcut_renderer.property_text(), keysColumns.value);
+ //_kb_shortcut_renderer.signal_accel_edited().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeEdited) );
+ //_kb_shortcut_renderer.signal_accel_cleared().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeCleared) );
+
+ axisStore = Gtk::ListStore::create(axisColumns);
+
+ axisTree.set_model(axisStore);
+ axisTree.set_headers_visible(false);
+ axisTree.append_column("Name", axisColumns.name);
+ axisTree.append_column("Value", axisColumns.value);
+
+ /**
+ * Scrolled Window
+ */
+ axisScroll.add(axisTree);
+ axisScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ axisScroll.set_shadow_type(Gtk::SHADOW_IN);
+ axisScroll.set_size_request(0, 150);
+
+ pane.pack1(confDeviceScroller);
+ pane.pack2(detailsBox);
+
+ detailsBox.pack_start(titleFrame, false, false, 6);
+ detailsBox.pack_start(modeBox, false, false, 6);
+ detailsBox.pack_start(axisFrame, false, false);
+ detailsBox.pack_start(keysFrame, false, false);
+
+ pack_start(pane, true, true);
+ pack_start(useExt, Gtk::PACK_SHRINK);
+ pack_start(*buttonBox, false, false);
+
+ // Select the first device
+ confDeviceTree.get_selection()->select(confDeviceStore->get_iter("0"));
+
}
InputDialogImpl::ConfPanel::~ConfPanel()
@@ -999,6 +1155,8 @@ void InputDialogImpl::ConfPanel::commitCellModeChange(Glib::ustring const &path,
Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode );
}
}
+
+
}
void InputDialogImpl::ConfPanel::setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter)
@@ -1033,6 +1191,25 @@ void InputDialogImpl::ConfPanel::commitCellStateChange(Glib::ustring const &path
}
}
+void InputDialogImpl::ConfPanel::onTreeSelect()
+{
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = confDeviceTree.get_selection();
+ Gtk::TreeModel::iterator iter = treeSel->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ Glib::ustring val = row[getCols().description];
+ Glib::RefPtr<InputDevice const> dev = row[getCols().device];
+ Gdk::InputMode mode = (*iter)[getCols().mode];
+ modeCombo.set_active(getModeId(mode));
+
+ titleLabel.set_markup("<b>" + row[getCols().description] + "</b>");
+
+ if (dev) {
+ setKeys(dev->getNumKeys());
+ setAxis(dev->getNumAxes());
+ }
+ }
+}
void InputDialogImpl::ConfPanel::saveSettings()
{
Inkscape::DeviceManager::getManager().saveConfig();
@@ -1074,8 +1251,8 @@ void InputDialogImpl::handleDeviceChange(Glib::RefPtr<InputDevice const> device)
{
// g_message("OUCH!!!! for %p hits %s", &device, device->getId().c_str());
std::vector<Glib::RefPtr<Gtk::TreeStore> > stores;
- stores.push_back(store);
- stores.push_back(cfgPanel.store);
+ stores.push_back(deviceStore);
+ stores.push_back(cfgPanel.confDeviceStore);
for (std::vector<Glib::RefPtr<Gtk::TreeStore> >::iterator it = stores.begin(); it != stores.end(); ++it) {
Gtk::TreeModel::iterator deviceIter;
@@ -1158,11 +1335,11 @@ bool InputDialogImpl::findDeviceByLink(const Gtk::TreeModel::iterator& iter,
void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device, Gtk::TreeIter tabletIter, Glib::RefPtr<Gtk::TreeView> tree)
{
- Glib::RefPtr<Gtk::TreeStore> store = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(tree->get_model());
+ Glib::RefPtr<Gtk::TreeStore> deviceStore = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(tree->get_model());
// g_message("Links!!!! for %p hits [%s] with link of [%s]", &device, device->getId().c_str(), device->getLink().c_str());
Gtk::TreeModel::iterator deviceIter;
- store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
+ deviceStore->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
sigc::ptr_fun(&InputDialogImpl::findDevice),
device->getId(),
&deviceIter) );
@@ -1180,16 +1357,16 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Glib::ustring descr = (*deviceIter)[getCols().description];
Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail];
- Gtk::TreeModel::Row deviceRow = *store->append(tabletIter->children());
+ Gtk::TreeModel::Row deviceRow = *deviceStore->append(tabletIter->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
Gtk::TreeModel::iterator oldParent = deviceIter->parent();
- store->erase(deviceIter);
+ deviceStore->erase(deviceIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
}
} else {
@@ -1197,7 +1374,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
if ( deviceIter->parent() == tabletIter ) {
// Simple case. Not already linked
- Gtk::TreeIter newGroup = store->append(tabletIter->children());
+ Gtk::TreeIter newGroup = deviceStore->append(tabletIter->children());
(*newGroup)[getCols().description] = _("Pen");
(*newGroup)[getCols().thumbnail] = getPix(PIX_PEN);
@@ -1205,7 +1382,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Glib::ustring descr = (*deviceIter)[getCols().description];
Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail];
- Gtk::TreeModel::Row deviceRow = *store->append(newGroup->children());
+ Gtk::TreeModel::Row deviceRow = *deviceStore->append(newGroup->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
@@ -1213,7 +1390,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Gtk::TreeModel::iterator linkIter;
- store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
+ deviceStore->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
sigc::ptr_fun(&InputDialogImpl::findDeviceByLink),
device->getId(),
&linkIter) );
@@ -1222,22 +1399,22 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
descr = (*linkIter)[getCols().description];
thumb = (*linkIter)[getCols().thumbnail];
- deviceRow = *store->append(newGroup->children());
+ deviceRow = *deviceStore->append(newGroup->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
Gtk::TreeModel::iterator oldParent = linkIter->parent();
- store->erase(linkIter);
+ deviceStore->erase(linkIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
}
Gtk::TreeModel::iterator oldParent = deviceIter->parent();
- store->erase(deviceIter);
+ deviceStore->erase(deviceIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
tree->expand_row(Gtk::TreePath(newGroup), true);
}
@@ -1246,7 +1423,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
}
void InputDialogImpl::linkComboChanged() {
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
@@ -1272,34 +1449,26 @@ void InputDialogImpl::linkComboChanged() {
void InputDialogImpl::resyncToSelection() {
bool clear = true;
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
Glib::ustring val = row[getCols().description];
Glib::RefPtr<InputDevice const> dev = row[getCols().device];
+
if ( dev ) {
- devDetails.set_sensitive(true);
+ axisTable.set_sensitive(true);
linkConnection.block();
-#if WITH_GTKMM_2_24
linkCombo.remove_all();
linkCombo.append(_("None"));
-#else
- linkCombo.clear_items();
- linkCombo.append_text(_("None"));
-#endif
linkCombo.set_active(0);
if ( dev->getSource() != Gdk::SOURCE_MOUSE ) {
Glib::ustring linked = dev->getLink();
std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices();
for ( std::list<Glib::RefPtr<InputDevice const> >::const_iterator it = devList.begin(); it != devList.end(); ++it ) {
if ( ((*it)->getSource() != Gdk::SOURCE_MOUSE) && ((*it) != dev) ) {
-#if WITH_GTKMM_2_24
linkCombo.append((*it)->getName().c_str());
-#else
- linkCombo.append_text((*it)->getName().c_str());
-#endif
if ( (linked.length() > 0) && (linked == (*it)->getId()) ) {
linkCombo.set_active_text((*it)->getName().c_str());
}
@@ -1313,39 +1482,70 @@ void InputDialogImpl::resyncToSelection() {
clear = false;
devName.set_label(row[getCols().description]);
- detailFrame.set_label(row[getCols().description]);
+ axisFrame.set_label(row[getCols().description]);
setupValueAndCombo( dev->getNumAxes(), dev->getNumAxes(), devAxesCount, axesCombo);
setupValueAndCombo( dev->getNumKeys(), dev->getNumKeys(), devKeyCount, buttonCombo);
+
+
}
}
- devDetails.set_sensitive(!clear);
+ axisTable.set_sensitive(!clear);
if (clear) {
- detailFrame.set_label("");
+ axisFrame.set_label("");
devName.set_label("");
devAxesCount.set_label("");
devKeyCount.set_label("");
}
}
+void InputDialogImpl::ConfPanel::setAxis(gint count)
+{
+ /*
+ * TODO - Make each axis editable
+ */
+ axisStore->clear();
+
+ static Glib::ustring axesLabels[6] = {_("X"), _("Y"), _("Pressure"), _("X tilt"), _("Y tilt"), _("Wheel")};
+
+ for ( gint barNum = 0; barNum < static_cast<gint>(G_N_ELEMENTS(axesLabels)); barNum++ ) {
+
+ Gtk::TreeModel::Row row = *(axisStore->append());
+ row[axisColumns.name] = axesLabels[barNum];
+ if (barNum < count) {
+ row[axisColumns.value] = Glib::ustring::format(barNum+1);
+ } else {
+ row[axisColumns.value] = _("None");
+ }
+ }
+
+}
+void InputDialogImpl::ConfPanel::setKeys(gint count)
+{
+ /*
+ * TODO - Make each key assignable
+ */
+
+ keysStore->clear();
+
+ for (gint i = 0; i < count; i++) {
+ Gtk::TreeModel::Row row = *(keysStore->append());
+ row[keysColumns.name] = Glib::ustring::format(i+1);
+ row[keysColumns.value] = _("Disabled");
+ }
+
+
+}
void InputDialogImpl::setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo )
{
gchar *tmp = g_strdup_printf("%d", reported);
label.set_label(tmp);
g_free(tmp);
-#if WITH_GTKMM_2_24
combo.remove_all();
-#else
- combo.clear_items();
-#endif
for ( gint i = 1; i <= reported; ++i ) {
tmp = g_strdup_printf("%d", i);
-#if WITH_GTKMM_2_24
combo.append(tmp);
-#else
- combo.append_text(tmp);
-#endif
g_free(tmp);
}
@@ -1371,9 +1571,9 @@ void InputDialogImpl::updateTestButtons( Glib::ustring const& key, gint hotButto
void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
{
- static gdouble epsilon = 0.0001;
+ //static gdouble epsilon = 0.0001;
{
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
@@ -1385,7 +1585,6 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
}
}
-
for ( gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(testAxes)); i++ ) {
if ( axesMap[key].find(i) != axesMap[key].end() ) {
switch ( axesMap[key][i].first ) {
@@ -1400,7 +1599,6 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
testAxes[i].set(getPix(PIX_AXIS_OFF));
axesValues[i].set_sensitive(true);
if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) {
-
// FIXME: Device axis ranges are inaccessible in GTK+ 3 and
// are deprecated in GTK+ 2. Progress-bar ranges are disabled
// until we find an alternative solution
diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp
index 465192aee..6a1bc829e 100644
--- a/src/ui/dialog/layer-properties.cpp
+++ b/src/ui/dialog/layer-properties.cpp
@@ -28,7 +28,10 @@
#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"
namespace Inkscape {
namespace UI {
@@ -39,19 +42,36 @@ LayerPropertiesDialog::LayerPropertiesDialog()
{
Gtk::Box *mainVBox = get_vbox();
+#if WITH_GTKMM_3_0
+ _layout_table.set_row_spacing(4);
+ _layout_table.set_column_spacing(4);
+#else
_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);
+
+ _layer_name_entry.set_halign(Gtk::ALIGN_FILL);
+ _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);
- mainVBox->pack_start(_layout_table, false, false, 4);
+#endif
+
+ mainVBox->pack_start(_layout_table, true, true, 4);
// Buttons
_close_button.set_use_stock(true);
@@ -82,6 +102,7 @@ LayerPropertiesDialog::LayerPropertiesDialog()
}
LayerPropertiesDialog::~LayerPropertiesDialog() {
+
_setDesktop(NULL);
_setLayer(NULL);
}
@@ -145,7 +166,9 @@ 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();
@@ -159,15 +182,162 @@ LayerPropertiesDialog::_setup_position_controls() {
row->set_value(_dropdown_columns.position, LPOS_CHILD);
row->set_value(_dropdown_columns.name, Glib::ustring(_("As sublayer of current")));
- _layout_table.attach(_layer_position_combo,
- 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
_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();
+ _layout_table.attach(_layer_position_combo, 1, 1, 1, 1);
+
+ _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();
+}
+
+void
+LayerPropertiesDialog::_setup_layers_controls() {
+
+ ModelColumns *zoop = new ModelColumns();
+ _model = zoop;
+ _store = Gtk::TreeStore::create( *zoop );
+ _tree.set_model( _store );
+ _tree.set_headers_visible(false);
+
+ Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler(
+ INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) );
+ int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1;
+ Gtk::TreeViewColumn* col = _tree.get_column(visibleColNum);
+ if ( col ) {
+ col->add_attribute( eyeRenderer->property_active(), _model->_colVisible );
+ }
+
+ Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler(
+ INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-unlocked")) );
+ int lockedColNum = _tree.append_column("lock", *renderer) - 1;
+ col = _tree.get_column(lockedColNum);
+ if ( col ) {
+ col->add_attribute( renderer->property_active(), _model->_colLocked );
+ }
+
+ Gtk::CellRendererText *_text_renderer = manage(new Gtk::CellRendererText());
+ int nameColNum = _tree.append_column("Name", *_text_renderer) - 1;
+ Gtk::TreeView::Column *_name_column = _tree.get_column(nameColNum);
+ _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel);
+
+ _tree.set_expander_column( *_tree.get_column(nameColNum) );
+ _tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayerPropertiesDialog::_handleKeyEvent), false );
+ _tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayerPropertiesDialog::_handleButtonEvent) );
+
+ _scroller.add( _tree );
+ _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
+ _scroller.set_shadow_type(Gtk::SHADOW_IN);
+ _scroller.set_size_request(220, 180);
+
+ SPDocument* document = _desktop->doc();
+ SPRoot* root = document->getRoot();
+ if ( root ) {
+ SPObject* target = _desktop->currentLayer();
+ _store->clear();
+ _addLayer( document, SP_OBJECT(root), 0, target, 0 );
+ }
+
+ _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();
}
+void LayerPropertiesDialog::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level )
+{
+ int _maxNestDepth = 20;
+ if ( _desktop && _desktop->layer_manager && layer && (level < _maxNestDepth) ) {
+ unsigned int counter = _desktop->layer_manager->childCount(layer);
+ for ( unsigned int i = 0; i < counter; i++ ) {
+ SPObject *child = _desktop->layer_manager->nthChildOf(layer, i);
+ if ( child ) {
+#if DUMP_LAYERS
+ g_message(" %3d layer:%p {%s} [%s]", level, child, child->id, child->label() );
+#endif // DUMP_LAYERS
+
+ Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
+ Gtk::TreeModel::Row row = *iter;
+ row[_model->_colObject] = child;
+ row[_model->_colLabel] = child->label() ? child->label() : child->getId();
+ row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false;
+ row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false;
+
+ if ( target && child == target ) {
+ _tree.expand_to_path( _store->get_path(iter) );
+
+ Glib::RefPtr<Gtk::TreeSelection> select = _tree.get_selection();
+ select->select(iter);
+
+ //_checkTreeSelection();
+ }
+
+ _addLayer( doc, child, &row, target, level + 1 );
+ }
+ }
+ }
+}
+
+SPObject* LayerPropertiesDialog::_selectedLayer()
+{
+ SPObject* obj = 0;
+
+ Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
+ if ( iter ) {
+ Gtk::TreeModel::Row row = *iter;
+ obj = row[_model->_colObject];
+ }
+
+ return obj;
+}
+
+bool LayerPropertiesDialog::_handleKeyEvent(GdkEventKey *event)
+{
+
+ switch (get_group0_keyval(event)) {
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter: {
+ _strategy->perform(*this);
+ _close();
+ return true;
+ }
+ break;
+ }
+ return false;
+}
+
+void LayerPropertiesDialog::_handleButtonEvent(GdkEventButton* event)
+{
+ if ( (event->type == GDK_2BUTTON_PRESS) && (event->button == 1) ) {
+ _strategy->perform(*this);
+ _close();
+ }
+}
+
/** Formats the label for a given layer row
*/
void LayerPropertiesDialog::_prepareLabelRenderer(
@@ -202,8 +372,11 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) {
void LayerPropertiesDialog::Create::setup(LayerPropertiesDialog &dialog) {
dialog.set_title(_("Add Layer"));
- //TODO: find an unused layer number, forming name from _("Layer ") + "%d"
- dialog._layer_name_entry.set_text(_("Layer"));
+
+ // Set the initial name to the "next available" layer name
+ LayerManager *mgr = dialog._desktop->layer_manager;
+ Glib::ustring newName = mgr->getNextLayerName(NULL, dialog._desktop->currentLayer()->label());
+ dialog._layer_name_entry.set_text(newName.c_str());
dialog._apply_button.set_label(_("_Add"));
dialog._setup_position_controls();
}
@@ -231,6 +404,20 @@ void LayerPropertiesDialog::Create::perform(LayerPropertiesDialog &dialog) {
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("New layer created."));
}
+void LayerPropertiesDialog::Move::setup(LayerPropertiesDialog &dialog) {
+ dialog.set_title(_("Move to Layer"));
+ //TODO: find an unused layer number, forming name from _("Layer ") + "%d"
+ dialog._layer_name_entry.set_text(_("Layer"));
+ dialog._apply_button.set_label(_("_Move"));
+ dialog._setup_layers_controls();
+}
+
+void LayerPropertiesDialog::Move::perform(LayerPropertiesDialog &dialog) {
+
+ SPObject *moveto = dialog._selectedLayer();
+ sp_selection_to_layer(dialog._desktop, moveto, false);
+}
+
void LayerPropertiesDialog::_setDesktop(SPDesktop *desktop) {
if (desktop) {
Inkscape::GC::anchor (desktop);
diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h
index c7d7de130..9de303f89 100644
--- a/src/ui/dialog/layer-properties.h
+++ b/src/ui/dialog/layer-properties.h
@@ -12,14 +12,28 @@
#ifndef INKSCAPE_DIALOG_LAYER_PROPERTIES_H
#define INKSCAPE_DIALOG_LAYER_PROPERTIES_H
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#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>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/scrolledwindow.h>
#include "layer-fns.h"
+#include "ui/widget/layer-selector.h"
class SPDesktop;
@@ -40,6 +54,9 @@ class LayerPropertiesDialog : public Gtk::Dialog {
static void showCreate(SPDesktop *desktop, SPObject *layer) {
_showDialog(Create::instance(), desktop, layer);
}
+ static void showMove(SPDesktop *desktop, SPObject *layer) {
+ _showDialog(Move::instance(), desktop, layer);
+ }
protected:
struct Strategy {
@@ -57,9 +74,15 @@ protected:
void setup(LayerPropertiesDialog &dialog);
void perform(LayerPropertiesDialog &dialog);
};
+ struct Move : public Strategy {
+ static Move &instance() { static Move instance; return instance; }
+ void setup(LayerPropertiesDialog &dialog);
+ void perform(LayerPropertiesDialog &dialog);
+ };
friend class Rename;
friend class Create;
+ friend class Move;
Strategy *_strategy;
SPDesktop *_desktop;
@@ -79,9 +102,40 @@ 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;
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+
+ ModelColumns()
+ {
+ add(_colObject);
+ add(_colVisible);
+ add(_colLocked);
+ add(_colLabel);
+ }
+ virtual ~ModelColumns() {}
+
+ Gtk::TreeModelColumn<SPObject*> _colObject;
+ Gtk::TreeModelColumn<Glib::ustring> _colLabel;
+ Gtk::TreeModelColumn<bool> _colVisible;
+ Gtk::TreeModelColumn<bool> _colLocked;
+ };
+
+ Gtk::TreeView _tree;
+ ModelColumns* _model;
+ Glib::RefPtr<Gtk::TreeStore> _store;
+ Gtk::ScrolledWindow _scroller;
+
+
PositionDropdownColumns _dropdown_columns;
Gtk::CellRendererText _label_renderer;
Glib::RefPtr<Gtk::ListStore> _dropdown_list;
@@ -104,8 +158,14 @@ protected:
void _close();
void _setup_position_controls();
+ void _setup_layers_controls();
void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
+ void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
+ SPObject* _selectedLayer();
+ bool _handleKeyEvent(GdkEventKey *event);
+ void _handleButtonEvent(GdkEventButton* event);
+
private:
LayerPropertiesDialog(LayerPropertiesDialog const &); // no copy
LayerPropertiesDialog &operator=(LayerPropertiesDialog const &); // no assign
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index 70cf7075c..4f7b8f27c 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -69,6 +69,9 @@ enum {
BUTTON_SOLO,
BUTTON_SHOW_ALL,
BUTTON_HIDE_ALL,
+ BUTTON_LOCK_OTHERS,
+ BUTTON_LOCK_ALL,
+ BUTTON_UNLOCK_ALL,
DRAGNDROP
};
@@ -263,6 +266,21 @@ bool LayersPanel::_executeAction()
_fireAction( SP_VERB_LAYER_HIDE_ALL );
}
break;
+ case BUTTON_LOCK_OTHERS:
+ {
+ _fireAction( SP_VERB_LAYER_LOCK_OTHERS );
+ }
+ break;
+ case BUTTON_LOCK_ALL:
+ {
+ _fireAction( SP_VERB_LAYER_LOCK_ALL );
+ }
+ break;
+ case BUTTON_UNLOCK_ALL:
+ {
+ _fireAction( SP_VERB_LAYER_UNLOCK_ALL );
+ }
+ break;
case DRAGNDROP:
{
_doTreeMove( );
@@ -540,30 +558,76 @@ bool LayersPanel::_handleKeyEvent(GdkEventKey *event)
}
return false;
}
-void LayersPanel::_handleButtonEvent(GdkEventButton* event)
+
+bool LayersPanel::_handleButtonEvent(GdkEventButton* event)
{
static unsigned doubleclick = 0;
- // TODO - fix to a better is-popup function
if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) {
+ // TODO - fix to a better is-popup function
+ Gtk::TreeModel::Path path;
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ if ( _tree.get_path_at_pos( x, y, path ) ) {
+ _checkTreeSelection();
+ _popupMenu.popup(event->button, event->time);
+ }
+ }
- {
- Gtk::TreeModel::Path path;
- Gtk::TreeViewColumn* col = 0;
- int x = static_cast<int>(event->x);
- int y = static_cast<int>(event->y);
- int x2 = 0;
- int y2 = 0;
- if ( _tree.get_path_at_pos( x, y,
- path, col,
- x2, y2 ) ) {
- _checkTreeSelection();
- _popupMenu.popup(event->button, event->time);
+ if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1)
+ && (event->state & GDK_MOD1_MASK)) {
+ // Alt left click on the visible/lock columns - eat this event to keep row selection
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn* col = 0;
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ int x2 = 0;
+ int y2 = 0;
+ if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) ) {
+ if (col == _tree.get_column(COL_VISIBLE-1) ||
+ col == _tree.get_column(COL_LOCKED-1)) {
+ return true;
}
}
+ }
+ // TODO - ImageToggler doesn't seem to handle Shift/Alt clicks - so we deal with them here.
+ if ( (event->type == GDK_BUTTON_RELEASE) && (event->button == 1)
+ && (event->state & (GDK_SHIFT_MASK | GDK_MOD1_MASK))) {
+
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn* col = 0;
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
+ int x2 = 0;
+ int y2 = 0;
+ if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) ) {
+ if (event->state & GDK_SHIFT_MASK) {
+ // Shift left click on the visible/lock columns toggles "solo" mode
+ if (col == _tree.get_column(COL_VISIBLE - 1)) {
+ _takeAction(BUTTON_SOLO);
+ } else if (col == _tree.get_column(COL_LOCKED - 1)) {
+ _takeAction(BUTTON_LOCK_OTHERS);
+ }
+ } else if (event->state & GDK_MOD1_MASK) {
+ // Alt+left click on the visible/lock columns toggles "solo" mode and preserves selection
+ Gtk::TreeModel::iterator iter = _store->get_iter(path);
+ if (_store->iter_is_valid(iter)) {
+ Gtk::TreeModel::Row row = *iter;
+ SPObject *obj = row[_model->_colObject];
+ if (col == _tree.get_column(COL_VISIBLE - 1)) {
+ _desktop->toggleLayerSolo( obj );
+ DocumentUndo::maybeDone(_desktop->doc(), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo"));
+ } else if (col == _tree.get_column(COL_LOCKED - 1)) {
+ _desktop->toggleLockOtherLayers( obj );
+ DocumentUndo::maybeDone(_desktop->doc(), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers"));
+ }
+ }
+ }
+ }
}
+
if ( (event->type == GDK_2BUTTON_PRESS) && (event->button == 1) ) {
doubleclick = 1;
}
@@ -584,6 +648,7 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* event)
}
}
+ return false;
}
/*
@@ -678,7 +743,7 @@ void LayersPanel::_renameLayer(Gtk::TreeModel::Row row, const Glib::ustring& nam
if ( !name.empty() && (!oldLabel || name != oldLabel) ) {
_desktop->layer_manager->renameLayer( obj, name.c_str(), FALSE );
DocumentUndo::done( _desktop->doc() , SP_VERB_NONE,
- _("Renamed layer"));
+ _("Rename layer"));
}
}
@@ -780,8 +845,8 @@ LayersPanel::LayersPanel() :
_text_renderer->signal_edited().connect( sigc::mem_fun(*this, &LayersPanel::_handleEdited) );
_text_renderer->signal_editing_canceled().connect( sigc::mem_fun(*this, &LayersPanel::_handleEditingCancelled) );
- _tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
- _tree.signal_button_release_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
+ _tree.signal_button_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false );
+ _tree.signal_button_release_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false );
_tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleKeyEvent), false );
_scroller.add( _tree );
@@ -810,43 +875,34 @@ LayersPanel::LayersPanel() :
SPDesktop* targetDesktop = getDesktop();
-#if !WITH_GTKMM_3_0
- // TODO: This has been removed from Gtkmm 3.0. Check that everything still
- // looks OK!
- _buttonsRow.set_child_min_width( 16 );
-#endif
-
- _buttonsRow.set_layout (Gtk::BUTTONBOX_END);
-
Gtk::Button* btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, C_("Layers", "New") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
- _buttonsRow.add( *btn );
- _buttonsRow.set_child_secondary( *btn , true);
+ _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
- _watchingNonTop.push_back( btn );
- _buttonsRow.add( *btn );
-
- btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
- _watchingNonTop.push_back( btn );
- _buttonsRow.add( *btn );
-
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
+ _watchingNonBottom.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, C_("Layers", "Dn") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
_watchingNonBottom.push_back( btn );
- _buttonsRow.add( *btn );
-
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
btn = manage( new Gtk::Button() );
- _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
- btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
- _watchingNonBottom.push_back( btn );
- _buttonsRow.add( *btn );
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
+ _watchingNonTop.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
+
+ btn = manage( new Gtk::Button() );
+ _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") );
+ btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
+ _watchingNonTop.push_back( btn );
+ _buttonsPrimary.pack_end(*btn, Gtk::PACK_SHRINK);
// btn = manage( new Gtk::Button("Dup") );
// btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) );
@@ -856,9 +912,10 @@ LayersPanel::LayersPanel() :
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_DELETE, GTK_STOCK_REMOVE, _("X") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) );
_watching.push_back( btn );
- _buttonsRow.add( *btn );
- _buttonsRow.set_child_secondary( *btn , true);
-
+ _buttonsSecondary.pack_start(*btn, Gtk::PACK_SHRINK);
+
+ _buttonsRow.pack_start(_buttonsSecondary, Gtk::PACK_EXPAND_WIDGET);
+ _buttonsRow.pack_end(_buttonsPrimary, Gtk::PACK_EXPAND_WIDGET);
@@ -876,6 +933,12 @@ LayersPanel::LayersPanel() :
_popupMenu.append(*manage(new Gtk::SeparatorMenuItem()));
+ _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_OTHERS, 0, "Lock Others", (int)BUTTON_LOCK_OTHERS ) );
+ _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_ALL, 0, "Lock All", (int)BUTTON_LOCK_ALL ) );
+ _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_UNLOCK_ALL, 0, "Unlock All", (int)BUTTON_UNLOCK_ALL ) );
+
+ _popupMenu.append(*manage(new Gtk::SeparatorMenuItem()));
+
_watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up", (int)BUTTON_UP ) );
_watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Down", (int)BUTTON_DOWN ) );
diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h
index 12e5f7986..e9fd9ebc6 100644
--- a/src/ui/dialog/layers.h
+++ b/src/ui/dialog/layers.h
@@ -13,7 +13,6 @@
#define SEEN_LAYERS_PANEL_H
#include <gtkmm/box.h>
-#include <gtkmm/buttonbox.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/scrolledwindow.h>
@@ -65,7 +64,7 @@ private:
void _preToggle( GdkEvent const *event );
void _toggled( Glib::ustring const& str, int targetCol );
- void _handleButtonEvent(GdkEventButton *event);
+ bool _handleButtonEvent(GdkEventButton *event);
bool _handleKeyEvent(GdkEventKey *event);
bool _handleDragDrop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
void _handleEdited(const Glib::ustring& path, const Glib::ustring& new_text);
@@ -122,9 +121,13 @@ private:
Gtk::CellRendererText *_text_renderer;
Gtk::TreeView::Column *_name_column;
#if WITH_GTKMM_3_0
- Gtk::ButtonBox _buttonsRow;
+ Gtk::Box _buttonsRow;
+ Gtk::Box _buttonsPrimary;
+ Gtk::Box _buttonsSecondary;
#else
- Gtk::HButtonBox _buttonsRow;
+ Gtk::HBox _buttonsRow;
+ Gtk::HBox _buttonsPrimary;
+ Gtk::HBox _buttonsSecondary;
#endif
Gtk::ScrolledWindow _scroller;
Gtk::Menu _popupMenu;
diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp
index c22aace37..e899dbcfc 100644
--- a/src/ui/dialog/livepatheffect-add.cpp
+++ b/src/ui/dialog/livepatheffect-add.cpp
@@ -48,6 +48,7 @@ LivePathEffectAdd::LivePathEffectAdd() :
effectlist_treeview.set_model(effectlist_store);
effectlist_treeview.set_headers_visible(false);
effectlist_treeview.append_column("Name", _columns.name);
+ //effectlist_treeview.set_activates_default(true);
/**
* Initialize Effect list
@@ -68,7 +69,7 @@ LivePathEffectAdd::LivePathEffectAdd() :
* Buttons
*/
close_button.set_use_stock(true);
- close_button.set_can_default();
+ //close_button.set_can_default();
add_button.set_use_underline(true);
add_button.set_can_default();
diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp
index f67c4db21..1ae9730d5 100644
--- a/src/ui/dialog/object-attributes.cpp
+++ b/src/ui/dialog/object-attributes.cpp
@@ -123,7 +123,7 @@ void ObjectAttributes::widget_setup (void)
}
blocked = true;
- SPObject *obj = (SPObject*)item; //to get the selected item
+ SPObject *obj = SP_OBJECT(item); //to get the selected item
GObjectClass *klass = G_OBJECT_GET_CLASS(obj); //to deduce the object's type
GType type = G_TYPE_FROM_CLASS(klass);
const SPAttrDesc *desc;
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 0aeb3816f..12ee2f762 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -54,7 +54,7 @@ ObjectProperties::ObjectProperties (void) :
LabelID(_("_ID:"), 1),
LabelLabel(_("_Label:"), 1),
LabelTitle(_("_Title:"),1),
- LabelDescription(_("_Description"),1),
+ LabelDescription(_("_Description:"),1),
FrameDescription("", FALSE),
HBoxCheck(FALSE, 0),
CheckTable(1, 2, TRUE),
@@ -69,16 +69,15 @@ ObjectProperties::ObjectProperties (void) :
subselChangedConn()
{
//initialize labels for the table at the bottom of the dialog
- int_labels.push_back("onclick");
- int_labels.push_back("onmouseover");
- int_labels.push_back("onmouseout");
- int_labels.push_back("onmousedown");
- int_labels.push_back("onmouseup");
- int_labels.push_back("onmousemove");
- int_labels.push_back("onfocusin");
- int_labels.push_back("onfocusout");
- int_labels.push_back("onfocusout");
- int_labels.push_back("onload");
+ int_labels.push_back("onclick:");
+ int_labels.push_back("onmouseover:");
+ int_labels.push_back("onmouseout:");
+ int_labels.push_back("onmousedown:");
+ int_labels.push_back("onmouseup:");
+ int_labels.push_back("onmousemove:");
+ int_labels.push_back("onfocusin:");
+ int_labels.push_back("onfocusout:");
+ int_labels.push_back("onload:");
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) );
deskTrack.connect(GTK_WIDGET(gobj()));
@@ -101,10 +100,11 @@ void ObjectProperties::MakeWidget(void)
TopTable.set_border_width(4);
TopTable.set_row_spacings(4);
- TopTable.set_col_spacings(4);
- contents->pack_start (TopTable, true, true, 0);
+ TopTable.set_col_spacings(0);
+ contents->pack_start (TopTable, false, false, 0);
/* Create the label for the object id */
+ LabelID.set_label (LabelID.get_label() + " ");
LabelID.set_alignment (1, 0.5);
TopTable.attach (LabelID, 0, 1, 0, 1,
Gtk::SHRINK | Gtk::FILL,
@@ -124,6 +124,7 @@ void ObjectProperties::MakeWidget(void)
EntryID.grab_focus();
/* Create the label for the object label */
+ LabelLabel.set_label (LabelLabel.get_label() + " ");
LabelLabel.set_alignment (1, 0.5);
TopTable.attach (LabelLabel, 0, 1, 1, 2,
Gtk::SHRINK | Gtk::FILL,
@@ -141,6 +142,7 @@ void ObjectProperties::MakeWidget(void)
EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed));
/* Create the label for the object title */
+ LabelTitle.set_label (LabelTitle.get_label() + " ");
LabelTitle.set_alignment (1, 0.5);
TopTable.attach (LabelTitle, 0, 1, 2, 3,
Gtk::SHRINK | Gtk::FILL,
@@ -149,18 +151,17 @@ void ObjectProperties::MakeWidget(void)
/* Create the entry box for the object title */
EntryTitle.set_sensitive (FALSE);
EntryTitle.set_max_length (256);
- TopTable.attach (EntryTitle, 1, 3, 2, 3,
+ TopTable.attach (EntryTitle, 1, 2, 2, 3,
Gtk::EXPAND | Gtk::FILL,
Gtk::AttachOptions(), 0, 0 );
LabelTitle.set_mnemonic_widget (EntryTitle);
+ // pressing enter in the label field is the same as clicking Set:
+ EntryTitle.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed));
/* Create the frame for the object description */
FrameDescription.set_label_widget (LabelDescription);
- FrameDescription.set_padding (4,0,0,0);
-
- TopTable.attach (FrameDescription, 0, 3, 3, 4,
- Gtk::EXPAND | Gtk::FILL,
- Gtk::EXPAND | Gtk::FILL, 0, 0 );
+ FrameDescription.set_padding (0,0,0,0);
+ contents->pack_start (FrameDescription, true, true, 0);
/* Create the text view box for the object description */
FrameTextDescription.set_border_width(4);
@@ -175,8 +176,8 @@ void ObjectProperties::MakeWidget(void)
/* Check boxes */
contents->pack_start (HBoxCheck, FALSE, FALSE, 0);
- CheckTable.set_border_width(0);
- HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 10);
+ CheckTable.set_border_width(4);
+ HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 0);
/* Hide */
CBHide.set_tooltip_text (_("Check to make the object invisible"));
@@ -195,7 +196,9 @@ void ObjectProperties::MakeWidget(void)
/* Button for setting the object's id, label, title and description. */
- HBoxCheck.pack_start (BSet, TRUE, TRUE, 10);
+ CheckTable.attach (BSet, 2, 3, 0, 1,
+ Gtk::EXPAND | Gtk::FILL,
+ Gtk::AttachOptions(), 0, 0 );
BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed));
/* Create the frame for interactivity options */
@@ -332,7 +335,6 @@ void ObjectProperties::label_changed(void)
/* Retrieve the label widget for the object's label */
Glib::ustring label = EntryLabel.get_text();
- g_assert(!label.empty());
/* Give feedback on success of setting the drawing object's label
* using the widget's label text
diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp
index bb06e3e79..c7bff185c 100644
--- a/src/ui/dialog/ocaldialogs.cpp
+++ b/src/ui/dialog/ocaldialogs.cpp
@@ -963,11 +963,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node)
{
if (!strcmp((const char*)cur_node->name, "title"))
{
-#if WITH_GTKMM_2_24
row_num = append("");
-#else
- row_num = append_text("");
-#endif
xmlChar *xml_title = xmlNodeGetContent(cur_node);
char* title = (char*) xml_title;
@@ -1116,8 +1112,14 @@ void ImportDialog::on_xml_file_read(const Glib::RefPtr<Gio::AsyncResult>& result
xmlDoc *doc = NULL;
xmlNode *root_element = NULL;
- doc = xmlReadMemory(data, (int) length, xml_uri.c_str(), NULL,
- XML_PARSE_RECOVER + XML_PARSE_NOWARNING + XML_PARSE_NOERROR);
+ int parse_options = XML_PARSE_RECOVER + XML_PARSE_NOWARNING + XML_PARSE_NOERROR; // do not use XML_PARSE_NOENT ! see bug lp:1025185
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool allowNetAccess = prefs->getBool("/options/externalresources/xml/allow_net_access", false);
+ if (!allowNetAccess) {
+ parse_options |= XML_PARSE_NONET;
+ }
+
+ doc = xmlReadMemory(data, (int) length, xml_uri.c_str(), NULL, parse_options);
if (doc == NULL) {
// If nothing is returned, no results could be found
diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h
index 0dc61abb3..1cdfa15bb 100644
--- a/src/ui/dialog/ocaldialogs.h
+++ b/src/ui/dialog/ocaldialogs.h
@@ -64,7 +64,7 @@ public:
FileDialogBase(const Glib::ustring &title, Gtk::Window& /*parent*/) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{
set_title(title);
- sp_transientize((GtkWidget*) gobj());
+ sp_transientize(GTK_WIDGET(gobj()));
// Allow shrinking of window so labels wrap correctly
set_resizable(true);
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index e940a3f55..2ab8cf121 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -138,7 +138,7 @@ static void draw_page(
#endif
bool ret = ctx->setSurfaceTarget (surface, true, &ctm);
if (ret) {
- ret = renderer.setupDocument (ctx, junk->_doc, TRUE, NULL);
+ ret = renderer.setupDocument (ctx, junk->_doc, TRUE, 0., NULL);
if (ret) {
renderer.renderItem(ctx, junk->_base);
ret = ctx->finish();
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 0da28061e..9cc18c02c 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -109,10 +109,6 @@ SpellCheck::SpellCheck (void) :
tree_view.append_column(_("Suggestions:"), tree_columns.suggestions);
{
-// Backward compatibility fix: The GtkComboBoxText API was introduced with
-// GTK+ 2.24. This check should eventually be dropped when we bump our
-// GTK dependency.
-#if GTK_CHECK_VERSION(2, 24, 0)
dictionary_combo = gtk_combo_box_text_new();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dictionary_combo), _lang.c_str());
if (_lang2 != "") {
@@ -121,16 +117,6 @@ SpellCheck::SpellCheck (void) :
if (_lang3 != "") {
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dictionary_combo), _lang3.c_str());
}
-#else
- dictionary_combo = gtk_combo_box_new_text();
- gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang.c_str());
- if (_lang2 != "") {
- gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang2.c_str());
- }
- if (_lang3 != "") {
- gtk_combo_box_append_text (GTK_COMBO_BOX (dictionary_combo), _lang3.c_str());
- }
-#endif
gtk_combo_box_set_active (GTK_COMBO_BOX (dictionary_combo), 0);
gtk_widget_show_all (dictionary_combo);
}
@@ -219,8 +205,8 @@ void SpellCheck::setTargetDesktop(SPDesktop *desktop)
void SpellCheck::clearRects()
{
for (GSList *it = _rects; it; it = it->next) {
- sp_canvas_item_hide((SPCanvasItem*) it->data);
- sp_canvas_item_destroy((SPCanvasItem*) it->data);
+ sp_canvas_item_hide(SP_CANVAS_ITEM(it->data));
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(it->data));
}
g_slist_free(_rects);
_rects = NULL;
@@ -330,8 +316,8 @@ SpellCheck::nextText()
_text = getText(_root);
if (_text) {
- _modified_connection = ((SPObject*) _text)->connectModified(sigc::mem_fun(*this, &SpellCheck::onObjModified));
- _release_connection = ((SPObject*) _text)->connectRelease(sigc::mem_fun(*this, &SpellCheck::onObjReleased));
+ _modified_connection = (SP_OBJECT(_text))->connectModified(sigc::mem_fun(*this, &SpellCheck::onObjModified));
+ _release_connection = (SP_OBJECT(_text))->connectRelease(sigc::mem_fun(*this, &SpellCheck::onObjReleased));
_layout = te_get_layout (_text);
_begin_w = _layout->begin();
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 16bb8222a..be69635e8 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -163,23 +163,14 @@ GlyphComboBox::GlyphComboBox(){
void GlyphComboBox::update(SPFont* spfont){
if (!spfont) return
-//TODO: figure out why do we need to append_text("") before clearing items properly...
+//TODO: figure out why do we need to append("") before clearing items properly...
-#if WITH_GTKMM_2_24
this->append(""); //Gtk is refusing to clear the combobox when I comment out this line
this->remove_all();
-#else
- this->append_text(""); //Gtk is refusing to clear the combobox when I comment out this line
- this->clear_items();
-#endif
for(SPObject* node = spfont->children; node; node=node->next){
if (SP_IS_GLYPH(node)){
-#if WITH_GTKMM_2_24
this->append((static_cast<SPGlyph*>(node))->unicode);
-#else
- this->append_text((static_cast<SPGlyph*>(node))->unicode);
-#endif
}
}
}
@@ -278,7 +269,7 @@ void SvgFontsDialog::update_fonts()
_model->clear();
for(const GSList *l = fonts; l; l = l->next) {
Gtk::TreeModel::Row row = *_model->append();
- SPFont* f = (SPFont*)l->data;
+ SPFont* f = SP_FONT(l->data);
row[_columns.spfont] = f;
row[_columns.svgfont] = new SvgFont(f);
const gchar* lbl = f->label();
@@ -318,7 +309,7 @@ void SvgFontsDialog::update_global_settings_tab(){
SPObject* obj;
for (obj=font->children; obj; obj=obj->next){
if (SP_IS_FONTFACE(obj)){
- _familyname_entry->set_text(((SPFontFace*) obj)->font_family);
+ _familyname_entry->set_text((SP_FONTFACE(obj))->font_family);
}
}
}
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 68bafe549..43b88e5c6 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -54,6 +54,8 @@
#include "dialog-manager.h"
#include "selection.h"
#include "verbs.h"
+#include "gradient-chemistry.h"
+#include "helper/action.h"
namespace Inkscape {
namespace UI {
@@ -62,10 +64,10 @@ namespace Dialogs {
#define VBLOCK 16
#define PREVIEW_PIXBUF_WIDTH 128
-void _loadPaletteFile( gchar const *filename );
+void _loadPaletteFile( gchar const *filename, gboolean user=FALSE );
-
-std::vector<SwatchPage*> possible;
+std::list<SwatchPage*> userSwatchPages;
+std::list<SwatchPage*> systemSwatchPages;
static std::map<SPDocument*, SwatchPage*> docPalettes;
static std::vector<DocTrack*> docTrackings;
static std::map<SwatchesPanel*, SPDocument*> docPerPanel;
@@ -142,8 +144,21 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
}
if (!shown) {
- GtkWidget *dialog = sp_gradient_vector_editor_new( gr );
- gtk_widget_show( dialog );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/dialogs/gradienteditor/showlegacy", false)) {
+ // Legacy gradient dialog
+ GtkWidget *dialog = sp_gradient_vector_editor_new( gr );
+ gtk_widget_show( dialog );
+ } else {
+ // Invoke the gradient tool
+ Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT );
+ if ( verb ) {
+ SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP);
+ if ( action ) {
+ sp_action_perform( action, NULL );
+ }
+ }
+ }
}
}
}
@@ -197,20 +212,7 @@ void SwatchesPanelHook::deleteGradient( GtkMenuItem */*menuitem*/, gpointer /*us
if ( bounceTarget ) {
SwatchesPanel* swp = bouncePanel;
SPDesktop* desktop = swp ? swp->getDesktop() : 0;
- SPDocument *doc = desktop ? desktop->doc() : 0;
- if (doc) {
- std::string targetName(bounceTarget->def.descr);
- const GSList *gradients = doc->getResourceList("gradient");
- for (const GSList *item = gradients; item; item = item->next) {
- SPGradient* grad = SP_GRADIENT(item->data);
- if ( targetName == grad->getId() ) {
- grad->setSwatch(false);
- DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT,
- _("Delete"));
- break;
- }
- }
- }
+ sp_gradient_unset_swatch(desktop, bounceTarget->def.descr);
}
}
@@ -237,6 +239,9 @@ static void removeit( GtkWidget *widget, gpointer data )
gtk_container_remove( GTK_CONTAINER(data), widget );
}
+/* extern'ed from colot-item.cpp */
+gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data );
+
gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data )
{
gboolean handled = FALSE;
@@ -371,13 +376,13 @@ static char* trim( char* str ) {
return ret;
}
-void skipWhitespace( char*& str ) {
+static void skipWhitespace( char*& str ) {
while ( *str == ' ' || *str == '\t' ) {
str++;
}
}
-bool parseNum( char*& str, int& val ) {
+static bool parseNum( char*& str, int& val ) {
val = 0;
while ( '0' <= *str && *str <= '9' ) {
val = val * 10 + (*str - '0');
@@ -388,7 +393,7 @@ bool parseNum( char*& str, int& val ) {
}
-void _loadPaletteFile( gchar const *filename )
+void _loadPaletteFile( gchar const *filename, gboolean user/*=FALSE*/ )
{
char block[1024];
FILE *f = Inkscape::IO::fopen_utf8name( filename, "r" );
@@ -490,7 +495,10 @@ void _loadPaletteFile( gchar const *filename )
}
} while ( result && !hasErr );
if ( !hasErr ) {
- possible.push_back(onceMore);
+ if (user)
+ userSwatchPages.push_back(onceMore);
+ else
+ systemSwatchPages.push_back(onceMore);
#if ENABLE_MAGIC_COLORS
ColorItem::_wireMagicColors( onceMore );
#endif // ENABLE_MAGIC_COLORS
@@ -504,9 +512,16 @@ void _loadPaletteFile( gchar const *filename )
}
}
+static bool
+compare_swatch_names(SwatchPage const *a, SwatchPage const *b) {
+
+ return g_utf8_collate(a->_name.c_str(), b->_name.c_str()) < 0;
+}
+
static void loadEmUp()
{
static bool beenHere = false;
+ gboolean userPalete = true;
if ( !beenHere ) {
beenHere = true;
@@ -518,7 +533,6 @@ static void loadEmUp()
// Use this loop to iterate through a list of possible document locations.
while (!sources.empty()) {
gchar *dirname = sources.front();
-
if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS )
&& Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) {
GError *err = 0;
@@ -532,11 +546,13 @@ static void loadEmUp()
while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
gchar* lower = g_ascii_strdown( filename, -1 );
// if ( g_str_has_suffix(lower, ".gpl") ) {
+ if ( !g_str_has_suffix(lower, "~") ) {
gchar* full = g_build_filename(dirname, filename, NULL);
if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) {
- _loadPaletteFile(full);
+ _loadPaletteFile(full, userPalete);
}
g_free(full);
+ }
// }
g_free(lower);
}
@@ -547,15 +563,15 @@ static void loadEmUp()
// toss the dirname
g_free(dirname);
sources.pop_front();
+ userPalete = false;
}
}
-}
-
-
-
-
+ // Sort the list of swatches by name, grouped by user/system
+ userSwatchPages.sort(compare_swatch_names);
+ systemSwatchPages.sort(compare_swatch_names);
+}
@@ -589,7 +605,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
}
loadEmUp();
- if ( !possible.empty() ) {
+ if ( !systemSwatchPages.empty() ) {
SwatchPage* first = 0;
int index = 0;
Glib::ustring targetName;
@@ -600,8 +616,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
if (targetName == "Auto") {
first = docPalettes[0];
} else {
- index++;
- for ( std::vector<SwatchPage*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
+ //index++;
+ std::vector<SwatchPage*> pages = _getSwatchSets();
+ for ( std::vector<SwatchPage*>::iterator iter = pages.begin(); iter != pages.end(); ++iter ) {
if ( (*iter)->_name == targetName ) {
first = *iter;
break;
@@ -632,6 +649,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
hotItem = single;
}
_regItem( single, 3, i );
+
i++;
}
}
@@ -1024,6 +1042,7 @@ void SwatchesPanel::handleDefsModified(SPDocument *document)
}
}
+
std::vector<SwatchPage*> SwatchesPanel::_getSwatchSets() const
{
std::vector<SwatchPage*> tmp;
@@ -1031,7 +1050,8 @@ std::vector<SwatchPage*> SwatchesPanel::_getSwatchSets() const
tmp.push_back(docPalettes[_currentDocument]);
}
- tmp.insert(tmp.end(), possible.begin(), possible.end());
+ tmp.insert(tmp.end(), userSwatchPages.begin(), userSwatchPages.end());
+ tmp.insert(tmp.end(), systemSwatchPages.begin(), systemSwatchPages.end());
return tmp;
}
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
new file mode 100644
index 000000000..9d4ab5d8a
--- /dev/null
+++ b/src/ui/dialog/symbols.cpp
@@ -0,0 +1,610 @@
+/**
+ * @file
+ * Symbols dialog.
+ */
+/* Authors:
+ * Copyright (C) 2012 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <iostream>
+#include <algorithm>
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/buttonbox.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.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 "path-prefix.h"
+#include "io/sys.h"
+
+#include "ui/cache/svg_preview_cache.h"
+#include "ui/clipboard.h"
+
+#include "symbols.h"
+
+#include "desktop.h"
+#include "desktop-handles.h"
+#include "document.h"
+#include "inkscape.h"
+#include "sp-root.h"
+#include "sp-use.h"
+#include "sp-symbol.h"
+
+#include "verbs.h"
+#include "xml/repr.h"
+
+namespace Inkscape {
+namespace UI {
+
+static Cache::SvgPreview svg_preview_cache;
+
+namespace Dialog {
+
+ // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html
+class SymbolColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+
+ Gtk::TreeModelColumn<Glib::ustring> symbol_id;
+ Gtk::TreeModelColumn<Glib::ustring> symbol_title;
+ Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > symbol_image;
+
+ SymbolColumns() {
+ add(symbol_id);
+ add(symbol_title);
+ add(symbol_image);
+ }
+};
+
+SymbolColumns* SymbolsDialog::getColumns()
+{
+ SymbolColumns* columns = new SymbolColumns();
+ return columns;
+}
+
+/**
+ * Constructor
+ */
+SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
+ UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS),
+ store(Gtk::ListStore::create(*getColumns())),
+ iconView(0),
+ previewScale(0),
+ previewSize(0),
+ currentDesktop(0),
+ deskTrack(),
+ currentDocument(0),
+ previewDocument(0),
+ instanceConns()
+{
+
+ /******************** Table *************************/
+ // Replace by Grid for GTK 3.0
+ Gtk::Table *table = new Gtk::Table(2, 4, false);
+ // panel is a cloked Gtk::VBox
+ _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET);
+ guint row = 0;
+
+ /******************** Symbol Sets *************************/
+ Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: "));
+ table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK);
+
+ symbolSet = new Gtk::ComboBoxText(); // Fill in later
+ symbolSet->append(_("Current Document"));
+ symbolSet->set_active_text(_("Current Document"));
+ table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK);
+
+ sigc::connection connSet =
+ symbolSet->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild));
+ instanceConns.push_back(connSet);
+
+ ++row;
+
+ /********************* Icon View **************************/
+ SymbolColumns* columns = getColumns();
+
+ iconView = new Gtk::IconView(static_cast<Glib::RefPtr<Gtk::TreeModel> >(store));
+ //iconView->set_text_column( columns->symbol_id );
+ iconView->set_tooltip_column( 1 );
+ iconView->set_pixbuf_column( columns->symbol_image );
+
+ std::vector< Gtk::TargetEntry > targets;
+ targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste"));
+
+ iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY);
+ iconView->signal_drag_data_get().connect(sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet));
+
+ sigc::connection connIconChanged;
+ connIconChanged =
+ iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::iconChanged));
+ instanceConns.push_back(connIconChanged);
+
+ Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow();
+ scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
+ scroller->add(*Gtk::manage(iconView));
+ table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL);
+
+ ++row;
+
+ /******************** Preview Scale ***********************/
+ Gtk::Label* labelScale = new Gtk::Label(_("Preview scale: "));
+ table->attach(*Gtk::manage(labelScale),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK);
+
+ previewScale = new Gtk::ComboBoxText();
+ const gchar *scales[] =
+ {_("Fit"), _("Fit to width"), _("Fit to height"), "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL};
+ for( int i = 0; scales[i]; ++i ) {
+ previewScale->append(scales[i]);
+ }
+ previewScale->set_active_text(scales[0]);
+ table->attach(*Gtk::manage(previewScale),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK);
+
+ sigc::connection connScale =
+ previewScale->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild));
+ instanceConns.push_back(connScale);
+
+ ++row;
+
+ /******************** Preview Size ************************/
+ Gtk::Label* labelSize = new Gtk::Label(_("Preview size: "));
+ table->attach(*Gtk::manage(labelSize),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK);
+
+ previewSize = new Gtk::ComboBoxText();
+ const gchar *sizes[] = {"16", "24", "32", "48", "64", NULL};
+ for( int i = 0; sizes[i]; ++i ) {
+ previewSize->append(sizes[i]);
+ }
+ previewSize->set_active_text(sizes[2]);
+ table->attach(*Gtk::manage(previewSize),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK);
+
+ sigc::connection connSize =
+ previewSize->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild));
+ instanceConns.push_back(connSize);
+
+ ++row;
+
+ /**********************************************************/
+ currentDesktop = inkscape_active_desktop();
+ currentDocument = sp_desktop_document(currentDesktop);
+
+ previewDocument = symbols_preview_doc(); /* Template to render symbols in */
+ previewDocument->ensureUpToDate(); /* Necessary? */
+
+ key = SPItem::display_key_new(1);
+ renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY ));
+
+ get_symbols();
+ draw_symbols( currentDocument ); /* Defaults to current document */
+
+ desktopChangeConn =
+ deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) );
+ instanceConns.push_back( desktopChangeConn );
+ deskTrack.connect(GTK_WIDGET(gobj()));
+}
+
+SymbolsDialog::~SymbolsDialog()
+{
+ for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) {
+ it->disconnect();
+ }
+ instanceConns.clear();
+ deskTrack.disconnect();
+}
+
+SymbolsDialog& SymbolsDialog::getInstance()
+{
+ return *new SymbolsDialog();
+}
+
+void SymbolsDialog::rebuild() {
+
+ store->clear();
+ Glib::ustring symbolSetString = symbolSet->get_active_text();
+
+ SPDocument* symbolDocument = symbolSets[symbolSetString];
+ if( !symbolDocument ) {
+ // Symbol must be from Current Document (this method of
+ // checking should be language independent).
+ symbolDocument = currentDocument;
+ }
+ draw_symbols( symbolDocument );
+}
+
+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
+
+ if( iconArray.empty() ) {
+ //std::cout << " iconArray empty: huh? " << std::endl;
+ } else {
+ Gtk::TreeModel::Path const & path = *iconArray.begin();
+ Gtk::ListStore::iterator row = store->get_iter(path);
+ Glib::ustring symbol_id = (*row)[getColumns()->symbol_id];
+
+ GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE );
+ gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() );
+ }
+
+}
+
+void SymbolsDialog::iconChanged() {
+#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
+
+ if( iconArray.empty() ) {
+ //std::cout << " iconArray empty: huh? " << std::endl;
+ } else {
+ Gtk::TreeModel::Path const & path = *iconArray.begin();
+ Gtk::ListStore::iterator row = store->get_iter(path);
+ Glib::ustring symbol_id = (*row)[getColumns()->symbol_id];
+
+ /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */
+ Glib::ustring symbolSetString = symbolSet->get_active_text();
+
+ SPDocument* symbolDocument = symbolSets[symbolSetString];
+ if( !symbolDocument ) {
+ // Symbol must be from Current Document (this method of
+ // checking should be language independent).
+ symbolDocument = currentDocument;
+ }
+
+ SPObject* symbol = symbolDocument->getObjectById(symbol_id);
+ if( symbol ) {
+
+ // Find style for use in <use>
+ // First look for default style stored in <symbol>
+ gchar const* style = symbol->getAttribute("inkscape:symbol-style");
+ if( !style ) {
+ // If no default style in <symbol>, look in documents.
+ if( symbolDocument == currentDocument ) {
+ style = style_from_use( symbol_id.c_str(), currentDocument );
+ } else {
+ style = symbolDocument->getReprRoot()->attribute("style");
+ }
+ }
+
+ ClipboardManager *cm = ClipboardManager::get();
+ cm->copySymbol(symbol->getRepr(), style);
+ }
+ }
+}
+
+/* Hunts preference directories for symbol files */
+void SymbolsDialog::get_symbols() {
+
+ std::list<Glib::ustring> directories;
+
+ if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
+ Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
+ directories.push_back( INKSCAPE_SYMBOLSDIR );
+ }
+ if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
+ Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
+ directories.push_back( profile_path("symbols") );
+ }
+
+ std::list<Glib::ustring>::iterator it;
+ for( it = directories.begin(); it != directories.end(); ++it ) {
+
+ GError *err = 0;
+ GDir *dir = g_dir_open( (*it).c_str(), 0, &err );
+ if( dir ) {
+
+ gchar *filename = 0;
+ while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) {
+
+ gchar *fullname = g_build_filename((*it).c_str(), filename, NULL);
+
+ if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) {
+
+ SPDocument* symbol_doc = SPDocument::createNewDoc( fullname, FALSE );
+ if( symbol_doc ) {
+ symbolSets[Glib::ustring(filename)]= symbol_doc;
+ symbolSet->append(filename);
+ }
+ }
+ g_free( fullname );
+ }
+ g_dir_close( dir );
+ }
+ }
+}
+
+GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
+{
+
+ // Stop multiple counting of same symbol
+ if( SP_IS_USE(r) ) {
+ return l;
+ }
+
+ if( SP_IS_SYMBOL(r) ) {
+ l = g_slist_prepend (l, r);
+ }
+
+ for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
+ l = symbols_in_doc_recursive( child, l );
+ }
+
+ return l;
+}
+
+GSList* SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) {
+
+ GSList *l = NULL;
+ l = symbols_in_doc_recursive (symbolDocument->getRoot(), l );
+ return l;
+}
+
+GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l)
+{
+
+ if( SP_IS_USE(r) ) {
+ l = g_slist_prepend (l, r);
+ }
+
+ for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
+ l = use_in_doc_recursive( child, l );
+ }
+
+ return l;
+}
+
+GSList* SymbolsDialog::use_in_doc( SPDocument* useDocument ) {
+
+ GSList *l = NULL;
+ l = use_in_doc_recursive (useDocument->getRoot(), l );
+ return l;
+}
+
+// Returns style from first <use> element found that references id.
+// This is a last ditch effort to find a style.
+gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* document) {
+
+ gchar const* style = 0;
+ GSList* l = use_in_doc( document );
+ for( ; l != NULL; l = l->next ) {
+ SPObject* use = SP_OBJECT(l->data);
+ if( SP_IS_USE( use ) ) {
+ gchar const *href = use->getRepr()->attribute("xlink:href");
+ if( href ) {
+ Glib::ustring href2(href);
+ Glib::ustring id2(id);
+ id2 = "#" + id2;
+ if( !href2.compare(id2) ) {
+ style = use->getRepr()->attribute("style");
+ break;
+ }
+ }
+ }
+ }
+ return style;
+}
+
+void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) {
+
+
+ SymbolColumns* columns = getColumns();
+
+ GSList* l = symbols_in_doc( symbolDocument );
+ for( ; l != NULL; l = l->next ) {
+
+ SPObject* symbol = SP_OBJECT(l->data);
+ if (!SP_IS_SYMBOL(symbol)) {
+ //std::cout << " Error: not symbol" << std::endl;
+ continue;
+ }
+
+ gchar const *id = symbol->getRepr()->attribute("id");
+ gchar const *title = symbol->title(); // From title element
+ if( !title ) {
+ title = id;
+ }
+
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbolDocument, &renderDrawing, key );
+ if( pixbuf ) {
+
+ Gtk::ListStore::iterator row = store->append();
+ (*row)[columns->symbol_id] = Glib::ustring( id );
+ (*row)[columns->symbol_title] = Glib::ustring( title );
+ (*row)[columns->symbol_image] = pixbuf;
+ }
+ }
+
+ delete columns;
+}
+
+/*
+ * Returns image of symbol.
+ *
+ * Symbols normally are not visible. They must be referenced by a
+ * <use> element. A temporary document is created with a dummy
+ * <symbol> element and a <use> element that references the symbol
+ * element. Each real symbol is swapped in for the dummy symbol and
+ * the temporary document is rendered.
+ */
+Glib::RefPtr<Gdk::Pixbuf>
+SymbolsDialog::create_symbol_image(gchar const *symbol_id,
+ SPDocument *source,
+ Inkscape::Drawing* drawing,
+ unsigned /*visionkey*/)
+{
+ // Retrieve the symbol named 'symbol_id' from the source SVG document
+ SPObject const* symbol = source->getObjectById(symbol_id);
+ if (symbol == NULL) {
+ //std::cout << " Failed to find symbol: " << symbol_id << std::endl;
+ //return 0;
+ }
+
+ // Create a copy repr of the symbol with id="the_symbol"
+ Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc();
+ Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc);
+ repr->setAttribute("id", "the_symbol");
+
+ // Replace old "the_symbol" in previewDocument by new.
+ Inkscape::XML::Node *root = previewDocument->getReprRoot();
+ SPObject *symbol_old = previewDocument->getObjectById("the_symbol");
+ if (symbol_old) {
+ symbol_old->deleteObject(false);
+ }
+
+ // First look for default style stored in <symbol>
+ gchar const* style = repr->attribute("inkscape:symbol-style");
+ if( !style ) {
+ // If no default style in <symbol>, look in documents.
+ if( source == currentDocument ) {
+ style = style_from_use( symbol_id, source );
+ } else {
+ style = source->getReprRoot()->attribute("style");
+ }
+ }
+ // Last ditch effort to provide some default styling
+ if( !style ) style = "fill:#bbbbbb;stroke:#808080";
+
+ // This is for display in Symbols dialog only
+ if( style ) {
+ repr->setAttribute( "style", style );
+ }
+
+ // BUG: Symbols don't work if defined outside of <defs>. Causes Inkscape
+ // crash when trying to read in such a file.
+ root->appendChild(repr);
+ //defsrepr->appendChild(repr);
+ Inkscape::GC::release(repr);
+
+ // Uncomment this to get the previewDocument documents saved (useful for debugging)
+ // FILE *fp = fopen (g_strconcat(symbol_id, ".svg", NULL), "w");
+ // sp_repr_save_stream(previewDocument->getReprDoc(), fp);
+ // fclose (fp);
+
+ // Make sure previewDocument is up-to-date.
+ previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ previewDocument->ensureUpToDate();
+
+ // Make sure we have symbol in previewDocument
+ SPObject *object_temp = previewDocument->getObjectById( "the_use" );
+ previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ previewDocument->ensureUpToDate();
+
+ // if( object_temp == NULL || !SP_IS_ITEM(object_temp) ) {
+ // //std::cout << " previewDocument broken?" << std::endl;
+ // //return 0;
+ // }
+
+ SPItem *item = SP_ITEM(object_temp);
+
+ Glib::ustring previewSizeString = previewSize->get_active_text();
+ unsigned psize = atol( previewSizeString.c_str() );
+
+ Glib::ustring previewScaleString = previewScale->get_active_text();
+ int previewScaleRow = previewScale->get_active_row_number();
+
+ /* Update to renderable state */
+ Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize);
+ //std::cout << " Key: " << key << std::endl;
+ // FIX ME
+ //Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::RefPtr<Gdk::Pixbuf>(0);
+
+ // Find object's bbox in document.
+ // Note symbols can have own viewport... ignore for now.
+ //Geom::OptRect dbox = item->geometricBounds();
+ Geom::OptRect dbox = item->documentVisualBounds();
+ if (!dbox) {
+ //std::cout << " No dbox" << std::endl;
+ return pixbuf;
+ }
+
+ if (!pixbuf) {
+
+ /* Scale symbols to fit */
+ double scale = 1.0;
+ double width = dbox->width();
+ double height = dbox->height();
+ if( width == 0.0 ) {
+ width = 1.0;
+ }
+ if( height == 0.0 ) {
+ height = 1.0;
+ }
+
+ switch (previewScaleRow) {
+ case 0:
+ /* Fit */
+ scale = psize/std::max(width,height);
+ break;
+ case 1:
+ /* Fit width */
+ scale = psize/width;
+ break;
+ case 2:
+ /* Fit height */
+ scale = psize/height;
+ break;
+ default:
+ scale = atof( previewScaleString.c_str() );
+ }
+
+ pixbuf = Glib::wrap(render_pixbuf(*drawing, scale, *dbox, psize));
+ svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj());
+ }
+
+ return pixbuf;
+}
+
+/*
+ * Return empty doc to render symbols in.
+ * Symbols are by default not rendered so a <use> element is
+ * provided.
+ */
+SPDocument* SymbolsDialog::symbols_preview_doc()
+{
+ // BUG: <symbol> must be inside <defs>
+ gchar const *buffer =
+"<svg xmlns=\"http://www.w3.org/2000/svg\""
+" 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\">"
+" <symbol id=\"the_symbol\"/>"
+" </defs>"
+" <use id=\"the_use\" xlink:href=\"#the_symbol\"/>"
+"</svg>";
+
+ return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE );
+}
+
+void SymbolsDialog::setTargetDesktop(SPDesktop *desktop)
+{
+ if (this->currentDesktop != desktop) {
+ this->currentDesktop = desktop;
+ if( !symbolSets[symbolSet->get_active_text()] ) {
+ // Symbol set is from Current document, update
+ rebuild();
+ }
+ }
+}
+
+} //namespace Dialogs
+} //namespace UI
+} //namespace Inkscape
diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h
new file mode 100644
index 000000000..5486ff546
--- /dev/null
+++ b/src/ui/dialog/symbols.h
@@ -0,0 +1,115 @@
+/** @file
+ * @brief Symbols dialog
+ */
+/* Authors:
+ * Tavmjong Bah
+ *
+ * Copyright (C) 2012 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H
+#define INKSCAPE_UI_DIALOG_SYMBOLS_H
+
+#include "ui/widget/panel.h"
+#include "ui/widget/button.h"
+
+#include "ui/dialog/desktop-tracker.h"
+
+#include "display/drawing.h"
+
+#include <glib.h>
+#include <gtkmm/treemodel.h>
+
+#include <vector>
+
+class SPObject;
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+class SymbolColumns; // For Gtk::ListStore
+
+/**
+ * A dialog that displays selectable symbols.
+ */
+class SymbolsDialog : public UI::Widget::Panel {
+
+public:
+ SymbolsDialog( gchar const* prefsPath = "/dialogs/symbols" );
+ virtual ~SymbolsDialog();
+
+ static SymbolsDialog& getInstance();
+
+protected:
+
+
+private:
+ SymbolsDialog(SymbolsDialog const &); // no copy
+ SymbolsDialog &operator=(SymbolsDialog const &); // no assign
+
+ static SymbolColumns *getColumns();
+
+ void rebuild();
+ void iconChanged();
+ void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);
+
+ void get_symbols();
+ void draw_symbols( SPDocument* symbol_document );
+ SPDocument* symbols_preview_doc();
+
+ GSList* symbols_in_doc_recursive(SPObject *r, GSList *l);
+ GSList* symbols_in_doc( SPDocument* document );
+ GSList* use_in_doc_recursive(SPObject *r, GSList *l);
+ GSList* use_in_doc( SPDocument* document );
+ gchar const* style_from_use( gchar const* id, SPDocument* document);
+
+ Glib::RefPtr<Gdk::Pixbuf>
+ create_symbol_image(gchar const *symbol_name,
+ SPDocument *source, Inkscape::Drawing* drawing,
+ unsigned /*visionkey*/);
+
+ /* Keep track of all symbol template documents */
+ std::map<Glib::ustring, SPDocument*> symbolSets;
+
+
+ Glib::RefPtr<Gtk::ListStore> store;
+ Gtk::ComboBoxText* symbolSet;
+ Gtk::IconView* iconView;
+ Gtk::ComboBoxText* previewScale;
+ Gtk::ComboBoxText* previewSize;
+
+ void setTargetDesktop(SPDesktop *desktop);
+ SPDesktop* currentDesktop;
+ DesktopTracker deskTrack;
+ SPDocument* currentDocument;
+ SPDocument* previewDocument; /* Document to render single symbol */
+
+ /* For rendering the template drawing */
+ unsigned key;
+ Inkscape::Drawing renderDrawing;
+
+ std::vector<sigc::connection> instanceConns;
+ sigc::connection desktopChangeConn;
+
+};
+
+} //namespace Dialogs
+} //namespace UI
+} //namespace Inkscape
+
+
+#endif // INKSCAPE_UI_DIALOG_SYMBOLS_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/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 033571bb4..6696db083 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -106,30 +106,12 @@ TextEdit::TextEdit()
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);
-/*
-This would introduce dependency on gtk version 2.24 which is currently not available in
-Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011)
-This conditional and its #else block can be deleted in the future.
-*/
-#if GTK_CHECK_VERSION(2, 24,0)
spacing_combo = gtk_combo_box_text_new_with_entry ();
-#else
- spacing_combo = gtk_combo_box_entry_new_text ();
-#endif
gtk_widget_set_size_request (spacing_combo, 90, -1);
const gchar *spacings[] = {"50%", "80%", "90%", "100%", "110%", "120%", "130%", "140%", "150%", "200%", "300%", NULL};
for (int i = 0; spacings[i]; i++) {
-/*
-This would introduce dependency on gtk version 2.24 which is currently not available in
-Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011)
-This conditional and its #else block can be deleted in the future.
-*/
-#if GTK_CHECK_VERSION(2, 24,0)
gtk_combo_box_text_append_text((GtkComboBoxText *) spacing_combo, spacings[i]);
-#else
- gtk_combo_box_append_text((GtkComboBox *) spacing_combo, spacings[i]);
-#endif
}
gtk_widget_set_tooltip_text (px, _("Spacing between lines (percent of font size)"));
@@ -505,16 +487,7 @@ SPCSSAttr *TextEdit::getTextStyle ()
// Note that CSS 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
-/*
-This would introduce dependency on gtk version 2.24 which is currently not available in
-Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011)
-This conditional and its #else block can be deleted in the future.
-*/
-#if GTK_CHECK_VERSION(2, 24,0)
const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo);
-#else
- const gchar *sstr = gtk_entry_get_text ((GtkEntry *) (gtk_bin_get_child (GTK_BIN (spacing_combo))));
-#endif
sp_repr_css_set_property (css, "line-height", sstr);
return css;
diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp
index 5031a60b6..1ce78a278 100644
--- a/src/ui/dialog/tile.cpp
+++ b/src/ui/dialog/tile.cpp
@@ -42,7 +42,7 @@
* 0 *elem1 == *elem2
* >0 *elem1 goes after *elem2
*/
-int sp_compare_x_position(SPItem *first, SPItem *second)
+static int sp_compare_x_position(SPItem *first, SPItem *second)
{
using Geom::X;
using Geom::Y;
@@ -84,7 +84,7 @@ int sp_compare_x_position(SPItem *first, SPItem *second)
/*
* Sort items by their y co-ordinates.
*/
-int
+static int
sp_compare_y_position(SPItem *first, SPItem *second)
{
Geom::OptRect a = first->documentVisualBounds();
diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp
index a6495c205..1ad827a56 100644
--- a/src/ui/dialog/tracedialog.cpp
+++ b/src/ui/dialog/tracedialog.cpp
@@ -26,6 +26,8 @@
#include <glibmm/i18n.h>
#include "desktop.h"
+#include "desktop-tracker.h"
+#include "selection.h"
#include "trace/potrace/inkscape-potrace.h"
#include "inkscape.h"
@@ -83,6 +85,13 @@ class TraceDialogImpl : public TraceDialog
void abort();
void previewCallback();
+ void previewLiveCallback();
+ void onSettingsChange();
+ void onSelectionModified( guint flags );
+ void onSetDefaults();
+
+ void setDesktop(SPDesktop *desktop);
+ void setTargetDesktop(SPDesktop *desktop);
//############ General items
@@ -90,6 +99,7 @@ class TraceDialogImpl : public TraceDialog
Gtk::Button *mainOkButton;
Gtk::Button *mainCancelButton;
+ Gtk::Button *mainResetButton;
//######## Left pannel
@@ -194,11 +204,40 @@ class TraceDialogImpl : public TraceDialog
UI::Widget::Frame previewFrame;
Gtk::VBox previewVBox;
Gtk::Button previewButton;
+ Gtk::CheckButton previewLiveButton;
+ gboolean previewLive;
Gtk::Image previewImage;
+ SPDesktop *desktop;
+ DesktopTracker deskTrack;
+ sigc::connection desktopChangeConn;
+ sigc::connection selectChangedConn;
+ sigc::connection selectModifiedConn;
+
};
+void TraceDialogImpl::setDesktop(SPDesktop *desktop)
+{
+ Panel::setDesktop(desktop);
+ deskTrack.setBase(desktop);
+}
+void TraceDialogImpl::setTargetDesktop(SPDesktop *desktop)
+{
+ if (this->desktop != desktop) {
+ if (this->desktop) {
+ selectChangedConn.disconnect();
+ selectModifiedConn.disconnect();
+ }
+ this->desktop = desktop;
+ if (desktop && desktop->selection) {
+ selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange)));
+ selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &TraceDialogImpl::onSelectionModified)));
+
+ }
+ onSettingsChange();
+ }
+}
//#########################################################################
//## E V E N T S
@@ -294,8 +333,9 @@ void TraceDialogImpl::potraceProcess(bool do_i_trace)
{
int width = preview->get_width();
int height = preview->get_height();
- double scaleFX = 200.0 / (double)width;
- double scaleFY = 200.0 / (double)height;
+ const Gtk::Allocation& vboxAlloc = previewImage.get_allocation();
+ double scaleFX = vboxAlloc.get_width() / (double)width;
+ double scaleFY = vboxAlloc.get_height() / (double)height;
double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX;
int newWidth = (int) (((double)width) * scaleFactor);
int newHeight = (int) (((double)height) * scaleFactor);
@@ -351,6 +391,58 @@ void TraceDialogImpl::abort()
//#########################################################################
/**
+ * Callback for when any setting changes
+ */
+void TraceDialogImpl::onSettingsChange()
+{
+ if (previewLive) {
+ previewCallback();
+ }
+}
+
+void TraceDialogImpl::onSelectionModified( guint flags )
+{
+ if (flags & ( SP_OBJECT_MODIFIED_FLAG |
+ SP_OBJECT_PARENT_MODIFIED_FLAG |
+ SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
+ onSettingsChange();
+ }
+}
+
+/**
+ * Callback for when users resets defaults
+ */
+void TraceDialogImpl::onSetDefaults()
+{
+
+ // temporarily disable live update
+ gboolean wasLive = previewLive;
+ previewLive = false;
+
+ modeBrightnessRadioButton.set_active(true);
+ modeBrightnessSpinner.set_value(0.45);
+ modeCannyHiSpinner.set_value(0.65);
+ modeMultiScanNrColorSpinner.set_value(8.0);
+ modeMultiScanNrColorSpinner.set_value(8.0);
+ optionsSpecklesSizeSpinner.set_value(2);
+ optionsCornersThresholdSpinner.set_value(1.0);
+ optionsOptimToleranceSpinner.set_value(0.2);
+
+ modeInvertButton.set_active(false);
+ modeMultiScanSmoothButton.set_active(true);
+ modeMultiScanStackButton.set_active(true);
+ modeMultiScanBackgroundButton.set_active(false);
+ optionsSpecklesButton.set_active(true);
+ optionsCornersButton.set_active(true);
+ optionsOptimButton.set_active(true);
+ sioxButton.set_active(false);
+
+ previewLive = wasLive;
+ onSettingsChange();
+
+}
+
+/**
* Callback from the Preview button. Can be called from elsewhere.
*/
void TraceDialogImpl::previewCallback()
@@ -359,24 +451,31 @@ void TraceDialogImpl::previewCallback()
}
/**
+ * Callback from the Preview Live button.
+ */
+void TraceDialogImpl::previewLiveCallback()
+{
+ previewLive = previewLiveButton.get_active();
+ previewButton.set_sensitive(!previewLive);
+ onSettingsChange();
+}
+
+/**
* Default response from the dialog. Let's intercept it
*/
void TraceDialogImpl::responseCallback(int response_id)
{
- if (response_id == GTK_RESPONSE_OK)
- {
- // for now, we assume potrace, as it's the only one we have
- potraceProcess(true);
- }
- else if (response_id == GTK_RESPONSE_CANCEL)
- {
+ if (response_id == GTK_RESPONSE_OK) {
+ // for now, we assume potrace, as it's the only one we have
+ potraceProcess(true);
+ } else if (response_id == GTK_RESPONSE_CANCEL) {
abort();
- }
- else
- {
+ } else if (response_id == GTK_RESPONSE_HELP) {
+ onSetDefaults();
+ } else {
hide();
return;
- }
+ }
}
@@ -417,6 +516,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeBrightnessSpinner.set_value(0.45);
modeBrightnessBox.pack_end(modeBrightnessSpinner, false, false, MARGIN);
modeBrightnessSpinner.set_tooltip_text(_("Brightness cutoff for black/white"));
+ modeBrightnessSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeBrightnessSpinnerLabel.set_label(_("_Threshold:"));
modeBrightnessSpinnerLabel.set_use_underline(true);
@@ -435,6 +535,8 @@ TraceDialogImpl::TraceDialogImpl() :
modeCannyRadioButton.set_use_underline(true);
modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN);
modeCannyRadioButton.set_tooltip_text(_("Trace with optimal edge detection by J. Canny's algorithm"));
+ modeCannyRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
+
/*
modeCannyBox.pack_start(modeCannySeparator);
modeCannyLoSpinnerLabel.set_label(_("Low"));
@@ -451,6 +553,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeCannyHiSpinner.set_value(0.65);
modeCannyBox.pack_end(modeCannyHiSpinner, false, false, MARGIN);
modeCannyHiSpinner.set_tooltip_text(_("Brightness cutoff for adjacent pixels (determines edge thickness)"));
+ modeCannyHiSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeCannyHiSpinnerLabel.set_label(_("T_hreshold:"));
modeCannyHiSpinnerLabel.set_use_underline(true);
@@ -469,6 +572,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeQuantRadioButton.set_use_underline(true);
modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN);
modeQuantRadioButton.set_tooltip_text(_("Trace along the boundaries of reduced colors"));
+ modeQuantRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeQuantNrColorSpinner.set_digits(0);
modeQuantNrColorSpinner.set_increments(1.0, 0);
@@ -476,6 +580,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeQuantNrColorSpinner.set_value(8.0);
modeQuantBox.pack_end(modeQuantNrColorSpinner, false, false, MARGIN);
modeQuantNrColorSpinner.set_tooltip_text(_("The number of reduced colors"));
+ modeQuantNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeQuantNrColorLabel.set_label(_("_Colors:"));
modeQuantNrColorLabel.set_mnemonic_widget(modeQuantNrColorSpinner);
@@ -491,6 +596,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN);
modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN);
modeInvertButton.set_tooltip_text(_("Invert black and white regions"));
+ modeInvertButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeBrightnessFrame.add(modeBrightnessVBox);
modePageBox.pack_start(modeBrightnessFrame, false, false, 0);
@@ -504,6 +610,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanBrightnessRadioButton.set_use_underline(true);
modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN);
modeMultiScanBrightnessRadioButton.set_tooltip_text(_("Trace the given number of brightness levels"));
+ modeMultiScanBrightnessRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanNrColorSpinner.set_digits(0);
modeMultiScanNrColorSpinner.set_increments(1.0, 0);
@@ -515,6 +622,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanNrColorLabel.set_mnemonic_widget(modeMultiScanNrColorSpinner);
modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN);
modeMultiScanNrColorSpinner.set_tooltip_text(_("The desired number of scans"));
+ modeMultiScanNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN);
@@ -523,6 +631,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanColorRadioButton.set_use_underline(true);
modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN);
modeMultiScanColorRadioButton.set_tooltip_text(_("Trace the given number of reduced colors"));
+ modeMultiScanColorRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN);
@@ -531,6 +640,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanMonoRadioButton.set_use_underline(true);
modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN);
modeMultiScanMonoRadioButton.set_tooltip_text(_("Same as Colors, but the result is converted to grayscale"));
+ modeMultiScanMonoRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN);
@@ -540,6 +650,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanSmoothButton.set_active(true);
modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN);
modeMultiScanSmoothButton.set_tooltip_text(_("Apply Gaussian blur to the bitmap before tracing"));
+ modeMultiScanSmoothButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
// TRANSLATORS: "Stack" is a verb here
modeMultiScanStackButton.set_label(_("Stac_k scans"));
@@ -547,6 +658,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanStackButton.set_active(true);
modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN);
modeMultiScanStackButton.set_tooltip_text(_("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)"));
+ modeMultiScanStackButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanBackgroundButton.set_label(_("Remo_ve background"));
@@ -555,6 +667,7 @@ TraceDialogImpl::TraceDialogImpl() :
modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN);
// TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan
modeMultiScanBackgroundButton.set_tooltip_text(_("Remove bottom (background) layer when done"));
+ modeMultiScanBackgroundButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
modeMultiScanVBox.pack_start(modeMultiScanHBox4, false, false, MARGIN);
@@ -577,12 +690,14 @@ TraceDialogImpl::TraceDialogImpl() :
optionsSpecklesButton.set_use_underline(true);
optionsSpecklesButton.set_tooltip_text(_("Ignore small spots (speckles) in the bitmap"));
optionsSpecklesButton.set_active(true);
+ optionsSpecklesButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsSpecklesBox.pack_start(optionsSpecklesButton, false, false, MARGIN);
optionsSpecklesSizeSpinner.set_digits(0);
optionsSpecklesSizeSpinner.set_increments(1, 0);
optionsSpecklesSizeSpinner.set_range(0, 1000);
optionsSpecklesSizeSpinner.set_value(2);
optionsSpecklesSizeSpinner.set_tooltip_text(_("Speckles of up to this many pixels will be suppressed"));
+ optionsSpecklesSizeSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN);
optionsSpecklesSizeLabel.set_label(_("S_ize:"));
optionsSpecklesSizeLabel.set_use_underline(true);
@@ -593,6 +708,7 @@ TraceDialogImpl::TraceDialogImpl() :
optionsCornersButton.set_use_underline(true);
optionsCornersButton.set_tooltip_text(_("Smooth out sharp corners of the trace"));
optionsCornersButton.set_active(true);
+ optionsCornersButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsCornersBox.pack_start(optionsCornersButton, false, false, MARGIN);
optionsCornersThresholdSpinner.set_digits(2);
optionsCornersThresholdSpinner.set_increments(0.01, 0);
@@ -600,6 +716,7 @@ TraceDialogImpl::TraceDialogImpl() :
optionsCornersThresholdSpinner.set_value(1.0);
optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN);
optionsCornersThresholdSpinner.set_tooltip_text(_("Increase this to smooth corners more"));
+ optionsCornersThresholdSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsCornersThresholdLabel.set_label(_("_Threshold:"));
optionsCornersThresholdLabel.set_use_underline(true);
optionsCornersThresholdLabel.set_mnemonic_widget(optionsCornersThresholdSpinner);
@@ -609,6 +726,7 @@ TraceDialogImpl::TraceDialogImpl() :
optionsOptimButton.set_use_underline(true);
optionsOptimButton.set_active(true);
optionsOptimButton.set_tooltip_text(_("Try to optimize paths by joining adjacent Bezier curve segments"));
+ optionsOptimButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsOptimBox.pack_start(optionsOptimButton, false, false, MARGIN);
optionsOptimToleranceSpinner.set_digits(2);
optionsOptimToleranceSpinner.set_increments(0.05, 0);
@@ -616,6 +734,7 @@ TraceDialogImpl::TraceDialogImpl() :
optionsOptimToleranceSpinner.set_value(0.2);
optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN);
optionsOptimToleranceSpinner.set_tooltip_text(_("Increase this to reduce the number of nodes in the trace by more aggressive optimization"));
+ optionsOptimToleranceSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) );
optionsOptimToleranceLabel.set_label(_("To_lerance:"));
optionsOptimToleranceLabel.set_use_underline(true);
optionsOptimToleranceLabel.set_mnemonic_widget(optionsOptimToleranceSpinner);
@@ -645,7 +764,7 @@ TraceDialogImpl::TraceDialogImpl() :
//#### end left panel
- mainHBox.pack_start(leftVBox);
+ mainHBox.pack_start(leftVBox, false, false, 0);
//#### begin right panel
@@ -658,12 +777,20 @@ TraceDialogImpl::TraceDialogImpl() :
rightVBox.pack_start(sioxBox, false, false, 0);
//## preview
+ Gtk::HBox *previewButtonHBox = manage(new Gtk::HBox(false, MARGIN ));
+ previewLiveButton.set_label(_("Live Preview"));
+ previewLiveButton.set_use_underline(true);
+ previewLiveCallback();
+ previewLiveButton.signal_clicked().connect(
+ sigc::mem_fun(*this, &TraceDialogImpl::previewLiveCallback) );
previewButton.set_label(_("_Update"));
previewButton.set_use_underline(true);
previewButton.signal_clicked().connect(
sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) );
- previewVBox.pack_end(previewButton, false, false, 0);
+ previewButtonHBox->pack_start(previewLiveButton, false, false, 0);
+ previewButtonHBox->pack_end(previewButton, true, true, 0);
+ previewVBox.pack_end(*previewButtonHBox, false, false, 0);
// I guess it's correct to call the "intermediate bitmap" a preview of the trace
previewButton.set_tooltip_text(_("Preview the intermediate bitmap with the current settings, without actual tracing"));
previewImage.set_size_request(200,200);
@@ -677,11 +804,13 @@ TraceDialogImpl::TraceDialogImpl() :
//#### end right panel
- mainHBox.pack_start(rightVBox);
+ mainHBox.pack_start(rightVBox, true, true, 0);
//#### Global stuff
contents->pack_start(mainHBox);
+ mainResetButton = addResponseButton(_("Reset"), GTK_RESPONSE_HELP, true);
+ mainResetButton ->set_tooltip_text(_("Reset all settings to defaults"));
//## The OK button
mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
@@ -694,6 +823,9 @@ TraceDialogImpl::TraceDialogImpl() :
show_all_children();
+ desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &TraceDialogImpl::setTargetDesktop) );
+ deskTrack.connect(GTK_WIDGET(gobj()));
+
//## Connect the signal
signalResponse().connect(
sigc::mem_fun(*this, &TraceDialogImpl::responseCallback));
@@ -714,6 +846,9 @@ TraceDialog &TraceDialog::getInstance()
*/
TraceDialogImpl::~TraceDialogImpl()
{
+ selectChangedConn.disconnect();
+ selectModifiedConn.disconnect();
+ desktopChangeConn.disconnect();
}
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 1c9d6689b..329450b52 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -42,16 +42,16 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
-void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, Transformation *daad)
+static void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection *selection, Transformation *daad)
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
}
-void on_selection_modified( Inkscape::Application */*inkscape*/,
- Inkscape::Selection *selection,
- guint /*flags*/,
- Transformation *daad )
+static void on_selection_modified( Inkscape::Application */*inkscape*/,
+ Inkscape::Selection *selection,
+ guint /*flags*/,
+ Transformation *daad )
{
int page = daad->getCurrentPage();
daad->updateSelection((Inkscape::UI::Dialog::Transformation::PageType)page, selection);
diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp
index 73b76054e..b96c9158a 100644
--- a/src/ui/dialog/undo-history.cpp
+++ b/src/ui/dialog/undo-history.cpp
@@ -167,7 +167,7 @@ UndoHistory::UndoHistory()
{
if ( !_document || !_event_log || !_columns ) return;
- set_size_request(300, 95);
+ set_size_request(-1, 95);
_getContents()->pack_start(_scrolled_window);
_scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -180,31 +180,35 @@ UndoHistory::UndoHistory()
_event_list_view.set_headers_visible(false);
CellRendererSPIcon* icon_renderer = Gtk::manage(new CellRendererSPIcon());
- icon_renderer->property_xpad() = 8;
- icon_renderer->property_width() = 36;
+ icon_renderer->property_xpad() = 2;
+ icon_renderer->property_width() = 24;
int cols_count = _event_list_view.append_column("Icon", *icon_renderer);
Gtk::TreeView::Column* icon_column = _event_list_view.get_column(cols_count-1);
icon_column->add_attribute(icon_renderer->property_event_type(), _columns->type);
+ CellRendererInt* children_renderer = Gtk::manage(new CellRendererInt(greater_than_1));
+ children_renderer->property_weight() = 600; // =Pango::WEIGHT_SEMIBOLD (not defined in old versions of pangomm)
+ children_renderer->property_xalign() = 1.0;
+ children_renderer->property_xpad() = 2;
+ children_renderer->property_width() = 24;
+
+ cols_count = _event_list_view.append_column("Children", *children_renderer);
+ Gtk::TreeView::Column* children_column = _event_list_view.get_column(cols_count-1);
+ children_column->add_attribute(children_renderer->property_number(), _columns->child_count);
+
Gtk::CellRendererText* description_renderer = Gtk::manage(new Gtk::CellRendererText());
+ description_renderer->property_ellipsize() = Pango::ELLIPSIZE_END;
cols_count = _event_list_view.append_column("Description", *description_renderer);
Gtk::TreeView::Column* description_column = _event_list_view.get_column(cols_count-1);
description_column->add_attribute(description_renderer->property_text(), _columns->description);
description_column->set_resizable();
+ description_column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
+ description_column->set_min_width (150);
_event_list_view.set_expander_column( *_event_list_view.get_column(cols_count-1) );
- CellRendererInt* children_renderer = Gtk::manage(new CellRendererInt(greater_than_1));
- children_renderer->property_weight() = 600; // =Pango::WEIGHT_SEMIBOLD (not defined in old versions of pangomm)
- children_renderer->property_xalign() = 1.0;
- children_renderer->property_xpad() = 20;
-
- cols_count = _event_list_view.append_column("Children", *children_renderer);
- Gtk::TreeView::Column* children_column = _event_list_view.get_column(cols_count-1);
- children_column->add_attribute(children_renderer->property_number(), _columns->child_count);
-
_scrolled_window.add(_event_list_view);
// connect EventLog callbacks
diff --git a/src/ui/previewable.h b/src/ui/previewable.h
index 9a086a9a2..377e109fb 100644
--- a/src/ui/previewable.h
+++ b/src/ui/previewable.h
@@ -35,12 +35,13 @@ typedef enum {
VIEW_TYPE_GRID
} ViewType;
+
class Previewable
{
public:
// TODO need to add some nice parameters
virtual ~Previewable() {}
- virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio ) = 0;
+ virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio, guint border) = 0;
};
diff --git a/src/ui/previewfillable.h b/src/ui/previewfillable.h
index d5f609a0b..044357503 100644
--- a/src/ui/previewfillable.h
+++ b/src/ui/previewfillable.h
@@ -28,11 +28,12 @@ public:
virtual void addPreview( Previewable* preview ) = 0;
virtual void freezeUpdates() = 0;
virtual void thawUpdates() = 0;
- virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio) = 0;
+ virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio, ::BorderStyle border ) = 0;
virtual void setOrientation(SPAnchorType how) = 0;
virtual ::PreviewSize getPreviewSize() const = 0;
virtual ViewType getPreviewType() const = 0;
virtual guint getPreviewRatio() const = 0;
+ virtual ::BorderStyle getPreviewBorder() const = 0;
virtual void setWrap( bool b ) = 0;
virtual bool getWrap() const = 0;
};
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index e1c2c718a..0b280ccb9 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -12,10 +12,12 @@
#include "previewholder.h"
+#include "preferences.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
#include <gtkmm/scrollbar.h>
+#include <gtkmm/adjustment.h>
#define COLUMNS_FOR_SMALL 16
#define COLUMNS_FOR_LARGE 8
@@ -38,7 +40,8 @@ PreviewHolder::PreviewHolder() :
_baseSize(PREVIEW_SIZE_SMALL),
_ratio(100),
_view(VIEW_TYPE_LIST),
- _wrap(false)
+ _wrap(false),
+ _border(BORDER_NONE)
{
_scroller = manage(new Gtk::ScrolledWindow());
_insides = manage(new Gtk::Table( 1, 2 ));
@@ -54,9 +57,30 @@ PreviewHolder::PreviewHolder() :
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
+
+ if (!adj) {
+ return FALSE;
+ }
+
+ int move = (event->direction == GDK_SCROLL_DOWN) ? adj->get_page_size() : -adj->get_page_size();
+ double value = std::min(adj->get_upper() - move, adj->get_value() + move );
+
+ adj->set_value(value);
+
+ return FALSE;
+}
void PreviewHolder::clear()
{
@@ -77,13 +101,13 @@ void PreviewHolder::addPreview( Previewable* preview )
int i = items.size() - 1;
if ( _view == VIEW_TYPE_LIST ) {
- Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio));
- Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio));
+ Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
+ Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
_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 );
} else {
- Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio));
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio, _border));
int width = 1;
int height = 1;
@@ -129,12 +153,13 @@ void PreviewHolder::thawUpdates()
rebuildUI();
}
-void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio )
+void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio, ::BorderStyle border )
{
- if ( size != _baseSize || view != _view || ratio != _ratio ) {
+ if ( size != _baseSize || view != _view || ratio != _ratio || border != _border ) {
_baseSize = size;
_view = view;
_ratio = ratio;
+ _border = border;
// Kludge to restore scrollbars
if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER );
@@ -304,12 +329,15 @@ void PreviewHolder::rebuildUI()
if ( _view == VIEW_TYPE_LIST ) {
_insides = manage(new Gtk::Table( 1, 2 ));
_insides->set_col_spacings( 8 );
+ if (_border == BORDER_WIDE) {
+ _insides->set_row_spacings( 1 );
+ }
for ( unsigned int i = 0; i < items.size(); i++ ) {
- Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio));
+ Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio, _border));
//label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
- Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio));
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border));
_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 );
@@ -322,11 +350,18 @@ void PreviewHolder::rebuildUI()
int height = 1;
for ( unsigned int i = 0; i < items.size(); i++ ) {
- Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio));
+
+ // If this is the last row, flag so the previews can draw a bottom
+ ::BorderStyle border = ((row == height -1) && (_border == BORDER_SOLID)) ? BORDER_SOLID_LAST_ROW : _border;
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, border));
if ( !_insides ) {
calcGridSize( thing, items.size(), width, height );
_insides = manage(new Gtk::Table( height, width ));
+ if (_border == BORDER_WIDE) {
+ _insides->set_col_spacings( 1 );
+ _insides->set_row_spacings( 1 );
+ }
}
_insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h
index b7073024e..4c591bfaf 100644
--- a/src/ui/previewholder.h
+++ b/src/ui/previewholder.h
@@ -33,18 +33,20 @@ public:
virtual void addPreview( Previewable* preview );
virtual void freezeUpdates();
virtual void thawUpdates();
- virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio );
+ virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio, ::BorderStyle border );
virtual void setOrientation(SPAnchorType how);
virtual int getColumnPref() const { return _prefCols; }
virtual void setColumnPref( int cols );
virtual ::PreviewSize getPreviewSize() const { return _baseSize; }
virtual ViewType getPreviewType() const { return _view; }
virtual guint getPreviewRatio() const { return _ratio; }
+ virtual ::BorderStyle getPreviewBorder() const { return _border; }
virtual void setWrap( bool b );
virtual bool getWrap() const { return _wrap; }
protected:
virtual void on_size_allocate( Gtk::Allocation& allocation );
+ virtual bool on_scroll_event(GdkEventScroll*);
// virtual void on_size_request( Gtk::Requisition* requisition );
@@ -62,6 +64,7 @@ private:
guint _ratio;
ViewType _view;
bool _wrap;
+ ::BorderStyle _border;
};
} //namespace UI
diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp
index b532c8b65..7b6502ec3 100644
--- a/src/ui/tool/node-tool.cpp
+++ b/src/ui/tool/node-tool.cpp
@@ -197,6 +197,10 @@ void ink_node_tool_dispose(GObject *object)
nt->enableGrDrag(false);
+ if (nt->flash_tempitem) {
+ nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem);
+ }
+
nt->_selection_changed_connection.disconnect();
nt->_selection_modified_connection.disconnect();
nt->_mouseover_changed_connection.disconnect();
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index bda410856..dc6e0fbae 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -293,7 +293,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
Geom::Point parent_pos = _parent->position();
Geom::Point origin = _last_drag_origin();
SnapManager &sm = _desktop->namedview->snap_manager;
- bool snap = sm.someSnapperMightSnap();
+ bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap();
boost::optional<Inkscape::Snapper::SnapConstraint> ctrl_constraint;
// with Alt, preserve length
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
index 8589f16b0..bbda64648 100644
--- a/src/ui/widget/Makefile_insert
+++ b/src/ui/widget/Makefile_insert
@@ -19,6 +19,8 @@ ink_common_sources += \
ui/widget/entry.h \
ui/widget/filter-effect-chooser.h \
ui/widget/filter-effect-chooser.cpp \
+ ui/widget/gimpspinscale.c \
+ ui/widget/gimpspinscale.h \
ui/widget/frame.cpp \
ui/widget/frame.h \
ui/widget/imageicon.cpp \
@@ -62,6 +64,8 @@ ink_common_sources += \
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 \
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index e5c542a7c..31fb3096c 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -55,7 +55,7 @@ void ColorPicker::setupDialog(const Glib::ustring &title)
_colorSelectorDialog.hide();
_colorSelectorDialog.set_title (title);
_colorSelectorDialog.set_border_width (4);
- _colorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK);
+ _colorSelector = SP_COLOR_SELECTOR(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK));
_colorSelectorDialog.get_vbox()->pack_start (
*Glib::wrap(&_colorSelector->vbox), true, true, 0);
diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp
index a7dabef1c..a38a93fb1 100644
--- a/src/ui/widget/dock.cpp
+++ b/src/ui/widget/dock.cpp
@@ -81,9 +81,15 @@ Dock::Dock(Gtk::Orientation orientation)
static_cast<GdlSwitcherStyle>(prefs->getIntLimited("/options/dock/switcherstyle",
GDL_SWITCHER_STYLE_BOTH, 0, 4));
- g_object_set (GDL_DOCK_OBJECT(_gdl_dock)->master,
- "switcher-style", gdl_switcher_style,
- NULL);
+ GdlDockMaster* master = NULL;
+
+ g_object_get(GDL_DOCK_OBJECT(_gdl_dock),
+ "master", &master,
+ NULL);
+
+ g_object_set(master,
+ "switcher-style", gdl_switcher_style,
+ NULL);
GdlDockBarStyle gdl_dock_bar_style =
static_cast<GdlDockBarStyle>(prefs->getIntLimited("/options/dock/dockbarstyle",
diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp
index 8d6bcf60f..65706a9dc 100644
--- a/src/ui/widget/filter-effect-chooser.cpp
+++ b/src/ui/widget/filter-effect-chooser.cpp
@@ -22,12 +22,9 @@ namespace UI {
namespace Widget {
SimpleFilterModifier::SimpleFilterModifier(int flags)
- : _hb_blur(false, 0),
- _lb_blend(_("Blend mode:")),
- _lb_blur(_("_Blur:")),
- _lb_blur_unit(_("%")),
+ : _lb_blend(_("Blend mode:")),
_blend(BlendModeConverter, SP_ATTR_INVALID, false),
- _blur(0, 0, 100, 1, 0.01, 1)
+ _blur(_("Blur (%)"), 0, 0, 100, 1, 0.01, 1)
{
_flags = flags;
@@ -37,11 +34,7 @@ SimpleFilterModifier::SimpleFilterModifier(int flags)
_hb_blend.pack_start(_blend);
}
if (flags & BLUR) {
- add(_hb_blur);
- _lb_blur.set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER);
- _hb_blur.pack_start(_lb_blur, false, false, 0);
- _hb_blur.pack_start(_blur, true, true, 0);
- _hb_blur.pack_start(_lb_blur_unit, false, false, 3);
+ add(_blur);
}
show_all_children();
@@ -49,8 +42,6 @@ SimpleFilterModifier::SimpleFilterModifier(int flags)
_hb_blend.set_spacing(12);
_lb_blend.set_use_underline();
_lb_blend.set_mnemonic_widget(_blend);
- _lb_blur.set_use_underline();
- _lb_blur.set_mnemonic_widget(_blur.get_scale());
_blend.signal_changed().connect(signal_blend_blur_changed());
_blur.signal_value_changed().connect(signal_blend_blur_changed());
}
diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h
index 6afb6c180..ae3ec07c4 100644
--- a/src/ui/widget/filter-effect-chooser.h
+++ b/src/ui/widget/filter-effect-chooser.h
@@ -18,6 +18,7 @@
#include "combo-enums.h"
#include "filter-enums.h"
#include "spin-slider.h"
+#include "spin-scale.h"
namespace Inkscape {
namespace UI {
@@ -45,17 +46,14 @@ public:
double get_blur_value() const;
void set_blur_value(const double);
void set_blur_sensitive(const bool);
- Gtk::Label *get_blur_label() { return &_lb_blur; };
-
private:
int _flags;
Gtk::HBox _hb_blend;
- Gtk::HBox _hb_blur;
- Gtk::Label _lb_blend, _lb_blur, _lb_blur_unit;
+ Gtk::Label _lb_blend;
ComboBoxEnum<Inkscape::Filters::FilterBlendMode> _blend;
- SpinSlider _blur;
+ SpinScale _blur;
sigc::signal<void> _signal_blend_blur_changed;
};
diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp
index b2968f806..eaa4336bb 100644
--- a/src/ui/widget/frame.cpp
+++ b/src/ui/widget/frame.cpp
@@ -56,9 +56,7 @@ 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)
{
-#if WITH_GTKMM_2_24
_alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right);
-#endif
}
Gtk::Label const *
diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c
new file mode 100644
index 000000000..f9f9a3807
--- /dev/null
+++ b/src/ui/widget/gimpspinscale.c
@@ -0,0 +1,1092 @@
+/* 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_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);
+
+ switch (property_id)
+ {
+ case PROP_LABEL:
+ g_free (private->label);
+ private->label = g_value_dup_string (value);
+ if (private->layout)
+ {
+ g_object_unref (private->layout);
+ private->layout = NULL;
+ }
+ gtk_widget_queue_resize (GTK_WIDGET (object));
+ break;
+
+ case PROP_FOCUS_WIDGET:
+ {
+ /* TODO unhook prior */
+ private->focusWidget = (GtkWidget*)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);
+
+ switch (property_id)
+ {
+ case PROP_LABEL:
+ g_value_set_string (value, private->label);
+ 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;
+ }
+}
+
+static void
+#if WITH_GTKMM_3_0
+gimp_spin_scale_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+#else
+gimp_spin_scale_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+#endif
+{
+ GimpSpinScalePrivate *private = GET_PRIVATE (widget);
+ GtkStyle *style = gtk_widget_get_style (widget);
+ PangoContext *context = gtk_widget_get_pango_context (widget);
+ PangoFontMetrics *metrics;
+
+#if WITH_GTKMM_3_0
+ GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
+ minimum_width,
+ natural_width);
+#else
+ gint height;
+ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+#endif
+
+ metrics = pango_context_get_metrics (context, style->font_desc,
+ pango_context_get_language (context));
+
+#if WITH_GTKMM_3_0
+#else
+ 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;
+ }
+
+#endif
+
+
+ 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));
+
+#if WITH_GTKMM_3_0
+ *minimum_width += char_pixels * 3;
+ *natural_width += char_pixels * 3;
+#else
+ /* ~3 chars for the ellipses */
+ requisition->width += char_pixels * 3;
+#endif
+
+ }
+
+ pango_font_metrics_unref (metrics);
+}
+
+#if WITH_GTKMM_3_0
+static void
+gimp_spin_scale_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkStyle *style = gtk_widget_get_style (widget);
+ 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, style->font_desc,
+ 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);
+}
+#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 WITH_GTKMM_3_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 WITH_GTKMM_3_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 WITH_GTKMM_3_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 WITH_GTKMM_3_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 WITH_GTKMM_3_0
+ (allocation.width - minimum_width + 10));
+#else
+ (allocation.width - requisition.width + 10));
+#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 WITH_GTKMM_3_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 WITH_GTKMM_3_0
+ cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3);
+
+ gtk_style_context_get_color (style, gtk_widget_get_state_flags (widget),
+ &color);
+
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
+ cairo_move_to (cr, layout_offset_x, layout_offset_y-3);
+
+ gdk_cairo_set_source_color (cr,
+ &style->text[gtk_widget_get_state (widget)]);
+#endif
+
+ pango_cairo_show_layout (cr, private->layout);
+ }
+
+#if WITH_GTKMM_3_0
+#else
+ 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);
+#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_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_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)
+{
+ GimpSpinScalePrivate *private;
+
+ g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
+
+ private = GET_PRIVATE (scale);
+
+ return private->gamma;
+}
+
+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;
+}
diff --git a/src/ui/widget/gimpspinscale.h b/src/ui/widget/gimpspinscale.h
new file mode 100644
index 000000000..ad63625ac
--- /dev/null
+++ b/src/ui/widget/gimpspinscale.h
@@ -0,0 +1,76 @@
+/* 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_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/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index c6622627b..fbb9c0e24 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -34,6 +34,7 @@
#include "widgets/icon.h"
#include "widgets/shrink-wrap-button.h"
#include "xml/node-event-vector.h"
+#include "widgets/gradient-vector.h"
namespace Inkscape {
namespace Widgets {
@@ -185,7 +186,10 @@ void LayerSelector::setDesktop(SPDesktop *desktop) {
if (_desktop) {
// _desktop_shutdown_connection.disconnect();
- _layer_changed_connection.disconnect();
+ if (_current_layer_changed_connection)
+ _current_layer_changed_connection.disconnect();
+ if (_layers_changed_connection)
+ _layers_changed_connection.disconnect();
// g_signal_handlers_disconnect_by_func(_desktop, (gpointer)&detach, this);
}
_desktop = desktop;
@@ -195,9 +199,13 @@ void LayerSelector::setDesktop(SPDesktop *desktop) {
// sigc::bind (sigc::ptr_fun (detach), this));
// g_signal_connect_after(_desktop, "shutdown", GCallback(detach), this);
- _layer_changed_connection = _desktop->connectCurrentLayerChanged(
- sigc::mem_fun(*this, &LayerSelector::_selectLayer)
- );
+ LayerManager *mgr = _desktop->layer_manager;
+ if ( mgr ) {
+ _current_layer_changed_connection = mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayerSelector::_selectLayer) );
+ //_layerUpdatedConnection = mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayerSelector::_updateLayer) );
+ _layers_changed_connection = mgr->connectChanged( sigc::mem_fun(*this, &LayerSelector::_layersChanged) );
+ }
+
_selectLayer(_desktop->currentLayer());
}
}
@@ -230,6 +238,17 @@ private:
}
+void LayerSelector::_layersChanged()
+{
+ if (_desktop) {
+ /*
+ * This code fixes #166691 but causes issues #1066543 and #1080378.
+ * Comment out until solution found.
+ */
+ //_selectLayer(_desktop->currentLayer());
+ }
+}
+
/** Selects the given layer in the dropdown selector.
*/
void LayerSelector::_selectLayer(SPObject *layer) {
@@ -300,11 +319,13 @@ void LayerSelector::_setDesktopLayer() {
Gtk::ListStore::iterator selected(_selector.get_active());
SPObject *layer=_selector.get_active()->get_value(_model_columns.object);
if ( _desktop && layer ) {
- _layer_changed_connection.block();
+ _current_layer_changed_connection.block();
+ _layers_changed_connection.block();
_desktop->layer_manager->setCurrentLayer(layer);
- _layer_changed_connection.unblock();
+ _current_layer_changed_connection.unblock();
+ _layers_changed_connection.unblock();
_selectLayer(_desktop->currentLayer());
}
@@ -565,7 +586,7 @@ void LayerSelector::_prepareLabelRenderer(
gchar const *label;
if ( object != root ) {
label = object->label();
- if (!label) {
+ if (!object->label()) {
label = object->defaultLabel();
label_defaulted = true;
}
@@ -573,7 +594,7 @@ void LayerSelector::_prepareLabelRenderer(
label = _("(root)");
}
- gchar *text = g_markup_printf_escaped(format, label);
+ gchar *text = g_markup_printf_escaped(format, gr_ellipsize_text (label, 50).c_str());
_label_renderer.property_markup() = text;
g_free(text);
g_free(format);
@@ -585,6 +606,7 @@ void LayerSelector::_prepareLabelRenderer(
_label_renderer.property_style() = ( label_defaulted ?
Pango::STYLE_ITALIC :
Pango::STYLE_NORMAL );
+
}
void LayerSelector::_lockLayer(bool lock) {
diff --git a/src/ui/widget/layer-selector.h b/src/ui/widget/layer-selector.h
index 6fbdc9857..ff9e4ddfc 100644
--- a/src/ui/widget/layer-selector.h
+++ b/src/ui/widget/layer-selector.h
@@ -68,7 +68,8 @@ private:
Glib::RefPtr<Gtk::ListStore> _layer_model;
// sigc::connection _desktop_shutdown_connection;
- sigc::connection _layer_changed_connection;
+ sigc::connection _layers_changed_connection;
+ sigc::connection _current_layer_changed_connection;
sigc::connection _selection_changed_connection;
sigc::connection _visibility_toggled_connection;
sigc::connection _lock_toggled_connection;
@@ -76,6 +77,8 @@ private:
SPObject *_layer;
void _selectLayer(SPObject *layer);
+ void _layersChanged();
+
void _setDesktopLayer();
void _buildEntry(unsigned depth, SPObject &object);
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp
index 7fff7d87f..8ecd36af2 100644
--- a/src/ui/widget/licensor.cpp
+++ b/src/ui/widget/licensor.cpp
@@ -44,7 +44,7 @@ const struct rdf_license_t _other_license =
class LicenseItem : public Gtk::RadioButton {
public:
- LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr);
+ LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group);
protected:
void on_toggled();
struct rdf_license_t const *_lic;
@@ -52,13 +52,12 @@ protected:
Registry &_wr;
};
-LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr)
+LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group)
: Gtk::RadioButton(_(license->name)), _lic(license), _eep(entity), _wr(wr)
{
- static Gtk::RadioButtonGroup group = get_group();
- static bool first = true;
- if (first) first = false;
- else set_group (group);
+ if (group) {
+ set_group (*group);
+ }
}
/// \pre it is assumed that the license URI entry is a Gtk::Entry
@@ -97,18 +96,19 @@ void Licensor::init (Registry& wr)
LicenseItem *i;
wr.setUpdating (true);
- i = manage (new LicenseItem (&_proprietary_license, _eentry, wr));
+ i = manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL));
+ Gtk::RadioButtonGroup group = i->get_group();
add (*i);
LicenseItem *pd = i;
for (struct rdf_license_t * license = rdf_licenses;
license && license->name;
license++) {
- i = manage (new LicenseItem (license, _eentry, wr));
+ i = manage (new LicenseItem (license, _eentry, wr, &group));
add(*i);
}
// add Other at the end before the URI field for the confused ppl.
- LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr));
+ LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr, &group));
add (*io);
pd->set_active();
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 1cb384501..2789676ea 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -16,6 +16,7 @@
#include <glibmm/i18n.h>
+#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "document.h"
@@ -32,6 +33,7 @@
#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 {
@@ -62,50 +64,34 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co
_blur_tag(Glib::ustring(history_prefix) + ":blur"),
_opacity_tag(Glib::ustring(history_prefix) + ":opacity"),
_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),
+ _opacity_scale(_("Opacity (%)"), 100.0, 0.0, 100.0, 1.0, 1.0, 1),
_fe_cb(flags),
_fe_vbox(false, 0),
- _fe_alignment(1, 1, 1, 1),
_blocked(false)
{
// Filter Effects
pack_start(_fe_vbox, false, false, 2);
- _fe_alignment.set_padding(0, 0, 4, 0);
- _fe_alignment.add(_fe_cb);
- _fe_vbox.pack_start(_fe_alignment, false, false, 0);
+ _fe_vbox.pack_start(_fe_cb, false, false, 0);
_fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged));
// Opacity
pack_start(_opacity_vbox, false, false, 2);
- _opacity_label.set_alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER);
- _opacity_hbox.pack_start(_opacity_label, false, false, 3);
- //_opacity_vbox.pack_start(_opacity_label_box, false, false, 0);
- _opacity_vbox.pack_start(_opacity_hbox, false, false, 0);
- _opacity_hbox.pack_start(_opacity_hscale, true, true, 0);
- _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
- _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
- _opacity_label.set_mnemonic_widget(_opacity_hscale);
-#else
- _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
- _opacity_label.set_mnemonic_widget(_opacity_hscale);
-#endif
+ _opacity_vbox.pack_start(_opacity_scale);
+
+ _opacity_scale.set_appearance("compact");
+
+ _opacity_scale.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ _opacity_scale.set_focuswidget(GTK_WIDGET(desktop->canvas));
/* SizeGroup keeps the blur and opacity labels aligned in Fill & Stroke dlg */
+/*
GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget(labels, (GtkWidget *) _opacity_label.gobj());
gtk_size_group_add_widget(labels, (GtkWidget *) _fe_cb.get_blur_label()->gobj());
+*/
show_all_children();
@@ -223,11 +209,7 @@ ObjectCompositeSettings::_opacityValueChanged()
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
+ os << CLAMP (_opacity_scale.get_adjustment()->get_value() / 100, 0.0, 1.0);
sp_repr_css_set_property (css, "opacity", os.str().c_str());
_subject->setCSS(css);
@@ -263,18 +245,14 @@ ObjectCompositeSettings::_subjectChanged() {
switch (result) {
case QUERY_STYLE_NOTHING:
- _opacity_hbox.set_sensitive(false);
+ _opacity_vbox.set_sensitive(false);
// gtk_widget_set_sensitive (opa, FALSE);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
case QUERY_STYLE_MULTIPLE_SAME:
- _opacity_hbox.set_sensitive(true);
-#if WITH_GTKMM_3_0
- _opacity_adjustment->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
-#else
- _opacity_adjustment.set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
-#endif
+ _opacity_vbox.set_sensitive(true);
+ _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value));
break;
}
diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h
index 32da626d6..d3a208525 100644
--- a/src/ui/widget/object-composite-settings.h
+++ b/src/ui/widget/object-composite-settings.h
@@ -45,22 +45,12 @@ private:
Glib::ustring _opacity_tag;
Gtk::VBox _opacity_vbox;
- 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;
+ Inkscape::UI::Widget::SpinScale _opacity_scale;
StyleSubject *_subject;
SimpleFilterModifier _fe_cb;
Gtk::VBox _fe_vbox;
- Gtk::Alignment _fe_alignment;
bool _blocked;
gulong _desktop_activated;
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 90eb6a3fd..2ab72d6c7 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -245,12 +245,14 @@ PageSizer::PageSizer(Registry & _wr)
_widgetRegistry(&_wr)
{
// set precision of scalar entry boxes
+ _wr.setUpdating (true);
_dimensionWidth.setDigits(5);
_dimensionHeight.setDigits(5);
_marginTop.setDigits(5);
_marginLeft.setDigits(5);
_marginRight.setDigits(5);
_marginBottom.setDigits(5);
+ _wr.setUpdating (false);
//# Set up the Paper Size combo box
_paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
@@ -315,11 +317,13 @@ PageSizer::PageSizer(Registry & _wr)
// Setting default custom unit to document unit
SPDesktop *dt = SP_ACTIVE_DESKTOP;
SPNamedView *nv = sp_desktop_namedview(dt);
+ _wr.setUpdating (true);
if (nv->units) {
_dimensionUnits.setUnit(nv->units);
} else if (nv->doc_units) {
_dimensionUnits.setUnit(nv->doc_units);
}
+ _wr.setUpdating (false);
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index a1ae6a36d..dcf5956bf 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -42,7 +42,8 @@ static const int PANEL_SETTING_SIZE = 0;
static const int PANEL_SETTING_MODE = 1;
static const int PANEL_SETTING_SHAPE = 2;
static const int PANEL_SETTING_WRAP = 3;
-static const int PANEL_SETTING_NEXTFREE = 4;
+static const int PANEL_SETTING_BORDER = 4;
+static const int PANEL_SETTING_NEXTFREE = 5;
void Panel::prep() {
@@ -93,7 +94,7 @@ void Panel::_init()
Glib::ustring tmp("<");
_anchor = SP_ANCHOR_CENTER;
- guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0;
bool panel_wrap = 0;
if (!_prefs_path.empty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -101,6 +102,7 @@ void Panel::_init()
panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 100, 0, 500 );
+ panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 );
}
_menu = new Gtk::Menu();
@@ -198,6 +200,42 @@ void Panel::_init()
}
{
+ Glib::ustring widthItemLabel(C_("Swatches", "Border"));
+
+ //TRANSLATORS: Indicates border of colour swatches
+ const gchar *widthLabels[] = {
+ NC_("Swatches border", "None"),
+ NC_("Swatches border", "Solid"),
+ NC_("Swatches border", "Wide"),
+ };
+
+ Gtk::MenuItem *item = manage( new Gtk::MenuItem(widthItemLabel));
+ Gtk::Menu *type_menu = manage(new Gtk::Menu());
+ item->set_submenu(*type_menu);
+ _menu->append(*item);
+
+ Gtk::RadioMenuItem::Group widthGroup;
+
+ guint values[] = {0, 1, 2};
+ guint hot_index = 0;
+ for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) {
+ // Assume all values are in increasing order
+ if ( values[i] <= panel_border ) {
+ hot_index = i;
+ }
+ }
+ for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) {
+ Glib::ustring _label(g_dpgettext2(NULL, "Swatches border", widthLabels[i]));
+ Gtk::RadioMenuItem *_item = manage(new Gtk::RadioMenuItem(widthGroup, _label));
+ type_menu->append(*_item);
+ if ( i <= hot_index ) {
+ _item->set_active(true);
+ }
+ _item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_BORDER, values[i]));
+ }
+ }
+
+ {
//TRANSLATORS: "Wrap" indicates how colour swatches are displayed
Glib::ustring wrap_label(C_("Swatches","Wrap"));
Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrap_label));
@@ -259,6 +297,7 @@ void Panel::_init()
_bounceCall(PANEL_SETTING_MODE, panel_mode);
_bounceCall(PANEL_SETTING_SHAPE, panel_ratio);
_bounceCall(PANEL_SETTING_WRAP, panel_wrap);
+ _bounceCall(PANEL_SETTING_BORDER, panel_border);
}
void Panel::setLabel(Glib::ustring const &label)
@@ -323,7 +362,7 @@ void Panel::present()
void Panel::restorePanelPrefs()
{
- guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0;
bool panel_wrap = 0;
if (!_prefs_path.empty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -331,11 +370,13 @@ void Panel::restorePanelPrefs()
panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 000, 0, 500 );
+ panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 );
}
_bounceCall(PANEL_SETTING_SIZE, panel_size);
_bounceCall(PANEL_SETTING_MODE, panel_mode);
_bounceCall(PANEL_SETTING_SHAPE, panel_ratio);
_bounceCall(PANEL_SETTING_WRAP, panel_wrap);
+ _bounceCall(PANEL_SETTING_BORDER, panel_border);
}
sigc::signal<void, int> &Panel::signalResponse()
@@ -360,30 +401,32 @@ void Panel::_bounceCall(int i, int j)
if (_fillable) {
ViewType curr_type = _fillable->getPreviewType();
guint curr_ratio = _fillable->getPreviewRatio();
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
+
switch (j) {
case 0:
{
- _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio, curr_border);
}
break;
case 1:
{
- _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio, curr_border);
}
break;
case 2:
{
- _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio, curr_border);
}
break;
case 3:
{
- _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio, curr_border);
}
break;
case 4:
{
- _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio, curr_border);
}
break;
default:
@@ -399,15 +442,16 @@ void Panel::_bounceCall(int i, int j)
if (_fillable) {
::PreviewSize curr_size = _fillable->getPreviewSize();
guint curr_ratio = _fillable->getPreviewRatio();
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
switch (j) {
case 0:
{
- _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio);
+ _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio, curr_border);
}
break;
case 1:
{
- _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio);
+ _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio, curr_border);
}
break;
default:
@@ -423,7 +467,40 @@ void Panel::_bounceCall(int i, int j)
if ( _fillable ) {
ViewType curr_type = _fillable->getPreviewType();
::PreviewSize curr_size = _fillable->getPreviewSize();
- _fillable->setStyle(curr_size, curr_type, j);
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
+
+ _fillable->setStyle(curr_size, curr_type, j, curr_border);
+ }
+ break;
+ case PANEL_SETTING_BORDER:
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/panel_border", j);
+ }
+ if ( _fillable ) {
+ ::PreviewSize curr_size = _fillable->getPreviewSize();
+ ViewType curr_type = _fillable->getPreviewType();
+ guint curr_ratio = _fillable->getPreviewRatio();
+
+ switch (j) {
+ case 0:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_NONE);
+ }
+ break;
+ case 1:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_SOLID);
+ }
+ break;
+ case 2:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_WIDE);
+ }
+ break;
+ default:
+ break;
+ }
}
break;
case PANEL_SETTING_WRAP:
@@ -483,6 +560,7 @@ void Panel::_regItem(Gtk::MenuItem* item, int group, int id)
_menu->append(*item);
item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), group + PANEL_SETTING_NEXTFREE, id));
item->show();
+
}
void Panel::_handleAction(int /*set_id*/, int /*item_id*/)
@@ -495,21 +573,21 @@ void Panel::_apply()
g_warning("Apply button clicked for panel [Panel::_apply()]");
}
-Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id)
+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);
+ _addResponseButton(button, response_id, pack_start);
return button;
}
-Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id)
+Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id, bool pack_start)
{
Gtk::Button *button = new Gtk::Button(stock_id);
- _addResponseButton(button, response_id);
+ _addResponseButton(button, response_id, pack_start);
return button;
}
-void Panel::_addResponseButton(Gtk::Button *button, int response_id)
+void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_start)
{
// Create a button box for the response buttons if it's the first button to be added
if (!_action_area) {
@@ -520,6 +598,10 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id)
_action_area->pack_end(*button);
+ if (pack_start) {
+ _action_area->set_child_secondary( *button , true);
+ }
+
if (response_id != 0) {
// Re-emit clicked signals as response signals
button->signal_clicked().connect(sigc::bind(_signal_response.make_slot(), response_id));
diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h
index 2d92d65c9..b4cc04809 100644
--- a/src/ui/widget/panel.h
+++ b/src/ui/widget/panel.h
@@ -96,8 +96,8 @@ 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);
- Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id);
+ 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);
@@ -119,7 +119,7 @@ protected:
virtual void _handleResponse(int response_id);
/* Helper methods */
- void _addResponseButton(Gtk::Button *button, int response_id);
+ void _addResponseButton(Gtk::Button *button, int response_id, bool pack_start=false);
Inkscape::Selection *_getSelection();
/**
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 07145f5f3..e7e317d11 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -378,12 +378,7 @@ ZoomCorrRuler::redraw() {
Glib::RefPtr<Gdk::Window> window = get_window();
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
-#if WITH_GTKMM_2_24
int w = window->get_width();
-#else
- int w, h;
- window->get_size(w, h);
-#endif
_drawing_width = w - _border * 2;
cr->set_source_rgb(1.0, 1.0, 1.0);
@@ -597,11 +592,7 @@ void PrefCombo::init(Glib::ustring const &prefs_path,
for (int i = 0 ; i < num_items; ++i)
{
-#if WITH_GTKMM_2_24
this->append(labels[i]);
-#else
- this->append_text(labels[i]);
-#endif
_values.push_back(values[i]);
if (value == values[i])
row = i;
@@ -623,11 +614,7 @@ void PrefCombo::init(Glib::ustring const &prefs_path,
for (int i = 0 ; i < num_items; ++i)
{
-#if WITH_GTKMM_2_24
this->append(labels[i]);
-#else
- this->append_text(labels[i]);
-#endif
_ustr_values.push_back(values[i]);
if (value == values[i])
row = i;
@@ -640,7 +627,7 @@ void PrefCombo::on_changed()
if (this->get_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if(_values.size() > 0)
+ if(!_values.empty())
{
prefs->setInt(_prefs_path, _values[this->get_active_row_number()]);
}
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp
index 7be666843..1d91515e5 100644
--- a/src/ui/widget/rotateable.cpp
+++ b/src/ui/widget/rotateable.cpp
@@ -24,12 +24,15 @@ Rotateable::Rotateable():
{
dragging = false;
working = false;
+ scrolling = false;
modifier = 0;
current_axis = axis;
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));
+ signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll));
+
}
bool Rotateable::on_click(GdkEventButton *event) {
@@ -124,6 +127,34 @@ bool Rotateable::on_release(GdkEventButton *event) {
return false;
}
+bool Rotateable::on_scroll(GdkEventScroll* event)
+{
+ double change = 0.0;
+
+ if (event->direction == GDK_SCROLL_UP) {
+ change = 1.0;
+ } else if (event->direction == GDK_SCROLL_DOWN) {
+ change = -1.0;
+ } else {
+ return FALSE;
+ }
+
+ drag_started_x = event->x;
+ drag_started_y = event->y;
+ modifier = get_single_modifier(modifier, event->state);
+ dragging = false;
+ working = false;
+ scrolling = true;
+ current_axis = axis;
+
+ do_scroll(change, modifier);
+
+ dragging = false;
+ working = false;
+ scrolling = false;
+
+ return TRUE;
+}
Rotateable::~Rotateable() {
}
diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h
index 15e0bf71c..52fb5306c 100644
--- a/src/ui/widget/rotateable.h
+++ b/src/ui/widget/rotateable.h
@@ -31,10 +31,12 @@ public:
bool on_click(GdkEventButton *event);
bool on_motion(GdkEventMotion *event);
bool on_release(GdkEventButton *event);
+ bool on_scroll(GdkEventScroll* event);
double axis;
double current_axis;
double maxdecl;
+ bool scrolling;
private:
double drag_started_x;
@@ -47,6 +49,7 @@ private:
virtual void do_motion (double /*by*/, guint /*state*/) {}
virtual void do_release (double /*by*/, guint /*state*/) {}
+ virtual void do_scroll (double /*by*/, guint /*state*/) {}
};
} // namespace Widget
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index a37f36eea..41d7c8be2 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -23,6 +23,7 @@
#include "desktop-handles.h"
#include "style.h"
#include "desktop-style.h"
+#include "sp-namedview.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
#include "sp-pattern.h"
@@ -38,7 +39,6 @@
#include "sp-gradient.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
-#include "helper/units.h"
#include "event-context.h"
#include "message-context.h"
#include "verbs.h"
@@ -47,7 +47,9 @@
#include "pixmaps/cursor-adj-h.xpm"
#include "pixmaps/cursor-adj-s.xpm"
#include "pixmaps/cursor-adj-l.xpm"
+#include "pixmaps/cursor-adj-a.xpm"
#include "sp-cursor.h"
+#include "gradient-chemistry.h"
static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 };
static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
@@ -143,10 +145,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_opacity_blocked (false),
- _popup_px(_sw_group),
- _popup_pt(_sw_group),
- _popup_mm(_sw_group),
-
+ _unit_mis(NULL),
_sw_unit(NULL)
{
_drop[0] = _drop[1] = 0;
@@ -297,34 +296,39 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
}
{
- _popup_px.add(*(new Gtk::Label(_("px"), 0.0, 0.5)));
- _popup_px.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_px));
- _popup_sw.attach(_popup_px, 0,1, 0,1);
-
- _popup_pt.add(*(new Gtk::Label(_("pt"), 0.0, 0.5)));
- _popup_pt.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_pt));
- _popup_sw.attach(_popup_pt, 0,1, 1,2);
-
- _popup_mm.add(*(new Gtk::Label(_("mm"), 0.0, 0.5)));
- _popup_mm.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_mm));
- _popup_sw.attach(_popup_mm, 0,1, 2,3);
+ int row = 0;
+
+ // List of units should match with Fill/Stroke dialog stroke style width list
+ for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) {
+ SPUnit const *u = static_cast<SPUnit*>(l->data);
+ Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group));
+ mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5)));
+ _unit_mis = g_slist_append(_unit_mis, mi);
+ mi->signal_activate().connect(sigc::bind<SPUnitId>(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id));
+ _popup_sw.attach(*mi, 0,1, row, row+1);
+ row++;
+ }
- _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, 3,4);
+ _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1);
+ row++;
for (guint i = 0; i < G_N_ELEMENTS(_sw_presets_str); ++i) {
Gtk::MenuItem *mi = Gtk::manage(new Gtk::MenuItem());
mi->add(*(new Gtk::Label(_sw_presets_str[i], 0.0, 0.5)));
mi->signal_activate().connect(sigc::bind<int>(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i));
- _popup_sw.attach(*mi, 0,1, 4+i, 5+i);
+ _popup_sw.attach(*mi, 0,1, row, row+1);
+ row++;
}
- guint i = G_N_ELEMENTS(_sw_presets_str) + 5;
-
- _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, i,i+1);
+ _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1);
+ row++;
_popup_sw_remove.add(*(new Gtk::Label(_("Remove"), 0.0, 0.5)));
_popup_sw_remove.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_remove));
- _popup_sw.attach(_popup_sw_remove, 0,1, i+1,i+2);
+ _popup_sw.attach(_popup_sw_remove, 0,1, row, row+1);
+ row++;
+
+ sp_set_font_size_smaller (GTK_WIDGET(_popup_sw.gobj()));
_popup_sw.show_all();
}
@@ -335,6 +339,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
_stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
+
_opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
_opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
// Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
@@ -446,7 +451,17 @@ SelectedStyle::setDesktop(SPDesktop *desktop)
this )
));
- //_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units;
+ _sw_unit = const_cast<SPUnit*>(sp_desktop_namedview(desktop)->doc_units);
+
+ // Set the doc default unit active in the units list
+ gint length = g_slist_length(_unit_mis);
+ for (int i = 0; i < length; i++) {
+ Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i);
+ if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) {
+ mi->set_active();
+ break;
+ }
+ }
}
void SelectedStyle::dragDataReceived( GtkWidget */*widget*/,
@@ -598,6 +613,12 @@ void SelectedStyle::on_fill_invert() {
SPCSSAttr *css = sp_repr_css_attr_new ();
guint32 color = _thisselected[SS_FILL];
gchar c[64];
+ if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) {
+ sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_FILL);
+ return;
+
+ }
+
if (_mode[SS_FILL] != SS_COLOR) return;
sp_svg_write_color (c, sizeof(c),
SP_RGBA32_U_COMPOSE(
@@ -618,6 +639,10 @@ void SelectedStyle::on_stroke_invert() {
SPCSSAttr *css = sp_repr_css_attr_new ();
guint32 color = _thisselected[SS_STROKE];
gchar c[64];
+ if (_mode[SS_STROKE] == SS_LGRADIENT || _mode[SS_STROKE] == SS_RGRADIENT) {
+ sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_STROKE);
+ return;
+ }
if (_mode[SS_STROKE] != SS_COLOR) return;
sp_svg_write_color (c, sizeof(c),
SP_RGBA32_U_COMPOSE(
@@ -876,16 +901,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event)
return false;
}
-void SelectedStyle::on_popup_px() {
- _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PX));
- update();
-}
-void SelectedStyle::on_popup_pt() {
- _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PT));
- update();
-}
-void SelectedStyle::on_popup_mm() {
- _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_MM));
+void SelectedStyle::on_popup_units(SPUnitId id) {
+ _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id));
update();
}
@@ -971,13 +988,13 @@ SelectedStyle::update()
if (SP_IS_LINEARGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_l[i], vector);
+ sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_l[i]), vector);
place->add(_gradient_box_l[i]);
place->set_tooltip_text(__lgradient[i]);
_mode[i] = SS_LGRADIENT;
} else if (SP_IS_RADIALGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_r[i], vector);
+ sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_r[i]), vector);
place->add(_gradient_box_r[i]);
place->set_tooltip_text(__rgradient[i]);
_mode[i] = SS_RGRADIENT;
@@ -993,7 +1010,7 @@ SelectedStyle::update()
guint32 color = paint->value.color.toRGBA32(
SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
_lastselected[i] = _thisselected[i];
- _thisselected[i] = color | 0xff; // only color, opacity === 1
+ _thisselected[i] = color; // include opacity
((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
_color_preview[i]->show_all();
place->add(*_color_preview[i]);
@@ -1196,39 +1213,43 @@ RotateableSwatch::~RotateableSwatch() {
}
double
-RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier)
+RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifier)
{
- sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
-
+ sp_color_rgb_to_hsl_floatv (hsla, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
+ hsla[3] = SP_RGBA32_A_F(cc);
double diff = 0;
if (modifier == 2) { // saturation
- double old = hsl[1];
+ double old = hsla[1];
if (by > 0) {
- hsl[1] += by * (1 - hsl[1]);
+ hsla[1] += by * (1 - hsla[1]);
} else {
- hsl[1] += by * (hsl[1]);
+ hsla[1] += by * (hsla[1]);
}
- diff = hsl[1] - old;
+ diff = hsla[1] - old;
} else if (modifier == 1) { // lightness
- double old = hsl[2];
+ double old = hsla[2];
if (by > 0) {
- hsl[2] += by * (1 - hsl[2]);
+ hsla[2] += by * (1 - hsla[2]);
} else {
- hsl[2] += by * (hsl[2]);
+ hsla[2] += by * (hsla[2]);
}
- diff = hsl[2] - old;
+ diff = hsla[2] - old;
+ } else if (modifier == 3) { // alpha
+ double old = hsla[3];
+ hsla[3] += by/2;
+ diff = hsla[3] - old;
} else { // hue
- double old = hsl[0];
- hsl[0] += by/2;
- while (hsl[0] < 0)
- hsl[0] += 1;
- while (hsl[0] > 1)
- hsl[0] -= 1;
- diff = hsl[0] - old;
+ double old = hsla[0];
+ hsla[0] += by/2;
+ while (hsla[0] < 0)
+ hsla[0] += 1;
+ while (hsla[0] > 1)
+ hsla[0] -= 1;
+ diff = hsla[0] - old;
}
float rgb[3];
- sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
+ sp_color_hsl_to_rgb_floatv (rgb, hsla[0], hsla[1], hsla[2]);
gchar c[64];
sp_svg_write_color (c, sizeof(c),
@@ -1241,10 +1262,14 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
);
SPCSSAttr *css = sp_repr_css_attr_new ();
- if (fillstroke == SS_FILL)
- sp_repr_css_set_property (css, "fill", c);
- else
- sp_repr_css_set_property (css, "stroke", c);
+
+ if (modifier == 3) { // alpha
+ Inkscape::CSSOStringStream osalpha;
+ osalpha << hsla[3];
+ sp_repr_css_set_property(css, (fillstroke == SS_FILL) ? "fill-opacity" : "stroke-opacity", osalpha.str().c_str());
+ } else {
+ sp_repr_css_set_property (css, (fillstroke == SS_FILL) ? "fill" : "stroke", c);
+ }
sp_desktop_set_style (parent->getDesktop(), css);
sp_repr_css_attr_unref (css);
return diff;
@@ -1255,7 +1280,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- if (!cr_set && modifier != 3) {
+ if (!scrolling && !cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
GdkPixbuf *pixbuf = NULL;
@@ -1263,6 +1288,8 @@ RotateableSwatch::do_motion(double by, guint modifier) {
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_s_xpm);
} else if (modifier == 1) { // lightness
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_l_xpm);
+ } else if (modifier == 3) { // alpha
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_a_xpm);
} else { // hue
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_h_xpm);
}
@@ -1290,43 +1317,51 @@ RotateableSwatch::do_motion(double by, guint modifier) {
cc = startcolor;
}
- float hsl[3];
+ float hsla[4];
double diff = 0;
- if (modifier != 3) {
- diff = color_adjust(hsl, by, cc, modifier);
- }
- if (modifier == 3) { // Alt, do nothing
+ diff = color_adjust(hsla, by, cc, modifier);
+
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha")));
+ double ch = hsla[3];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>alpha</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation")));
- double ch = hsl[1];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[1];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 1) { // lightness
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness")));
- double ch = hsl[2];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[2];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else { // hue
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue")));
- double ch = hsl[0];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
+ double ch = hsla[0];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
}
}
+
+void
+RotateableSwatch::do_scroll(double by, guint modifier) {
+ do_motion(by/30.0, modifier);
+ do_release(by/30.0, modifier);
+}
+
void
RotateableSwatch::do_release(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- float hsl[3];
- if (modifier != 3) {
- color_adjust(hsl, by, startcolor, modifier);
- }
+ float hsla[4];
+ color_adjust(hsla, by, startcolor, modifier);
if (cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
@@ -1342,7 +1377,9 @@ RotateableSwatch::do_release(double by, guint modifier) {
cr_set = false;
}
- if (modifier == 3) { // Alt, do nothing
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, ("Adjust alpha"));
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
@@ -1452,6 +1489,11 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
parent->getDesktop()->event_context->_message_context->clear();
}
+void
+RotateableStrokeWidth::do_scroll(double by, guint modifier) {
+ do_motion(by/10.0, modifier);
+ startvalue_set = false;
+}
Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
{
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index 542983b53..fac4f22e6 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -27,6 +27,7 @@
#include <sigc++/sigc++.h>
#include "rotateable.h"
+#include "helper/units.h"
class SPDesktop;
class SPUnit;
@@ -60,8 +61,10 @@ public:
~RotateableSwatch();
double color_adjust (float *hsl, double by, guint32 cc, guint state);
+
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
guint fillstroke;
@@ -86,6 +89,7 @@ public:
double value_adjust(double current, double by, guint modifier, bool final);
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
SelectedStyle *parent;
@@ -250,12 +254,8 @@ protected:
Gtk::Menu _popup_sw;
Gtk::RadioButtonGroup _sw_group;
- Gtk::RadioMenuItem _popup_px;
- void on_popup_px();
- Gtk::RadioMenuItem _popup_pt;
- void on_popup_pt();
- Gtk::RadioMenuItem _popup_mm;
- void on_popup_mm();
+ GSList *_unit_mis;
+ void on_popup_units(SPUnitId id);
void on_popup_preset(int i);
Gtk::MenuItem _popup_sw_remove;
diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp
new file mode 100644
index 000000000..00c575568
--- /dev/null
+++ b/src/ui/widget/spin-scale.cpp
@@ -0,0 +1,248 @@
+/*
+ * Author:
+ *
+ * Copyright (C) 2012 Author
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#include <glib.h>
+#include <glibmm/i18n.h>
+#include <glibmm/stringutils.h>
+#include <gtkmm/adjustment.h>
+
+#include "spin-scale.h"
+#include "ui/widget/gimpspinscale.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+SpinScale::SpinScale(const char* label, 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);
+ _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());
+
+ pack_start(*Gtk::manage(Glib::wrap(_spinscale)));
+
+ if (tip_text){
+ gtk_widget_set_tooltip_text( _spinscale, tip_text );
+ }
+
+ show_all_children();
+}
+
+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)
+ : AttrWidget(a, 0.0),
+ _adjustment(adj)
+
+{
+
+ _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits);
+
+ signal_value_changed().connect(signal_attr_changed().make_slot());
+
+ pack_start(*Gtk::manage(Glib::wrap(_spinscale)));
+
+ if (tip_text){
+ gtk_widget_set_tooltip_text( _spinscale, tip_text );
+ }
+
+ show_all_children();
+}
+
+Glib::ustring SpinScale::get_as_attribute() const
+{
+ const double val = _adjustment->get_value();
+
+ //if(_spin.get_digits() == 0)
+ // return Glib::Ascii::dtostr((int)val);
+ //else
+ return Glib::Ascii::dtostr(val);
+}
+
+void SpinScale::set_from_attribute(SPObject* o)
+{
+ const gchar* val = attribute_value(o);
+ if(val)
+ _adjustment->set_value(Glib::Ascii::strtod(val));
+ else
+ _adjustment->set_value(get_default()->as_double());
+}
+
+Glib::SignalProxy0<void> SpinScale::signal_value_changed()
+{
+ return _adjustment->signal_value_changed();
+}
+
+double SpinScale::get_value() const
+{
+ return _adjustment->get_value();
+}
+
+void SpinScale::set_value(const double val)
+{
+ _adjustment->set_value(val);
+}
+
+void SpinScale::set_focuswidget(GtkWidget *widget)
+{
+ gimp_spin_scale_set_focuswidget(_spinscale, widget);
+}
+
+
+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
+{
+ return _adjustment;
+}
+#if WITH_GTKMM_3_0
+Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment()
+#else
+Gtk::Adjustment *SpinScale::get_adjustment()
+#endif
+{
+ return _adjustment;
+}
+
+
+DualSpinScale::DualSpinScale(const char* label1, const char* label2, double value, double lower, double upper, double step_inc,
+ double climb_rate, int digits, const SPAttributeEnum a, char* tip_text1, char* tip_text2)
+ : AttrWidget(a),
+ _s1(label1, value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text1),
+ _s2(label2, value, lower, upper, step_inc, climb_rate, digits, SP_ATTR_INVALID, tip_text2),
+ //TRANSLATORS: "Link" means to _link_ two sliders together
+ _link(C_("Sliders", "Link"))
+{
+ signal_value_changed().connect(signal_attr_changed().make_slot());
+
+ _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, &DualSpinScale::update_linked));
+
+ _link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinScale::link_toggled));
+
+ Gtk::VBox* vb = Gtk::manage(new Gtk::VBox);
+ vb->add(_s1);
+ vb->add(_s2);
+ pack_start(*vb);
+ pack_start(_link, false, false);
+ _link.set_active(true);
+
+ show_all();
+}
+
+Glib::ustring DualSpinScale::get_as_attribute() const
+{
+ if(_link.get_active())
+ return _s1.get_as_attribute();
+ else
+ return _s1.get_as_attribute() + " " + _s2.get_as_attribute();
+}
+
+void DualSpinScale::set_from_attribute(SPObject* o)
+{
+ const gchar* val = attribute_value(o);
+ if(val) {
+ // Split val into parts
+ gchar** toks = g_strsplit(val, " ", 2);
+
+ if(toks) {
+ double v1 = 0.0, v2 = 0.0;
+ if(toks[0])
+ v1 = v2 = Glib::Ascii::strtod(toks[0]);
+ if(toks[1])
+ v2 = Glib::Ascii::strtod(toks[1]);
+
+ _link.set_active(toks[1] == 0);
+
+ _s1.get_adjustment()->set_value(v1);
+ _s2.get_adjustment()->set_value(v2);
+
+ g_strfreev(toks);
+ }
+ }
+}
+
+sigc::signal<void>& DualSpinScale::signal_value_changed()
+{
+ return _signal_value_changed;
+}
+
+const SpinScale& DualSpinScale::get_SpinScale1() const
+{
+ return _s1;
+}
+
+SpinScale& DualSpinScale::get_SpinScale1()
+{
+ return _s1;
+}
+
+const SpinScale& DualSpinScale::get_SpinScale2() const
+{
+ return _s2;
+}
+
+SpinScale& DualSpinScale::get_SpinScale2()
+{
+ return _s2;
+}
+
+/*void DualSpinScale::remove_scale()
+{
+ _s1.remove_scale();
+ _s2.remove_scale();
+}*/
+
+void DualSpinScale::link_toggled()
+{
+ _s2.set_sensitive(!_link.get_active());
+ update_linked();
+}
+
+void DualSpinScale::update_linked()
+{
+ if(_link.get_active())
+ _s2.set_value(_s1.get_value());
+}
+
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h
new file mode 100644
index 000000000..a8403307f
--- /dev/null
+++ b/src/ui/widget/spin-scale.h
@@ -0,0 +1,117 @@
+/*
+ * Author:
+ *
+ * Copyright (C) 2012 Author
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_SPIN_SCALE_H
+#define INKSCAPE_UI_WIDGET_SPIN_SCALE_H
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/scale.h>
+#include <gtkmm/togglebutton.h>
+#include "spinbutton.h"
+#include "attr-widget.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * Wrap the gimpspinscale class
+ * A combo widget with label, scale slider, spinbutton and adjustment
+ */
+class SpinScale : public Gtk::HBox, public AttrWidget
+{
+
+public:
+ SpinScale(const char* label, double value, double lower, double upper, double step_inc, double climb_rate,
+ 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);
+
+ virtual Glib::ustring get_as_attribute() const;
+ virtual void set_from_attribute(SPObject*);
+
+ // Shortcuts to _adjustment
+ Glib::SignalProxy0<void> signal_value_changed();
+ double get_value() const;
+ 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;
+};
+
+
+/**
+ * Contains two SpinScales for controlling number-opt-number attributes.
+ *
+ * @see SpinScale
+ */
+class DualSpinScale : public Gtk::HBox, public AttrWidget
+{
+public:
+ DualSpinScale(const char* label1, const char* label2, double value, double lower, double upper, double step_inc,
+ double climb_rate, int digits, const SPAttributeEnum, char* tip_text1, char* tip_text2);
+
+ virtual Glib::ustring get_as_attribute() const;
+ virtual void set_from_attribute(SPObject*);
+
+ sigc::signal<void>& signal_value_changed();
+
+ const SpinScale& get_SpinScale1() const;
+ SpinScale& get_SpinScale1();
+
+ const SpinScale& get_SpinScale2() const;
+ SpinScale& get_SpinScale2();
+
+ //void remove_scale();
+private:
+ void link_toggled();
+ void update_linked();
+ sigc::signal<void> _signal_value_changed;
+ SpinScale _s1, _s2;
+ Gtk::ToggleButton _link;
+};
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_SPIN_SCALE_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp
index 97ae18e20..323b1209c 100644
--- a/src/ui/widget/spin-slider.cpp
+++ b/src/ui/widget/spin-slider.cpp
@@ -186,7 +186,7 @@ void DualSpinSlider::set_from_attribute(SPObject* o)
gchar** toks = g_strsplit(val, " ", 2);
if(toks) {
- double v1, v2;
+ double v1 = 0.0, v2 = 0.0;
if(toks[0])
v1 = v2 = Glib::Ascii::strtod(toks[0]);
if(toks[1])
diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp
index 857ae7019..60d5f6ecc 100644
--- a/src/ui/widget/style-swatch.cpp
+++ b/src/ui/widget/style-swatch.cpp
@@ -340,15 +340,12 @@ void StyleSwatch::setStyle(SPStyle *query)
if (op != 1) {
{
gchar *str;
- if (op == 0)
- str = g_strdup_printf(_("O:%.3g"), op);
- else
- str = g_strdup_printf(_("O:.%d"), (int) (op*10));
+ str = g_strdup_printf(_("O: %2.0f"), (op*100.0));
_opacity_value.set_markup (str);
g_free (str);
}
{
- gchar *str = g_strdup_printf(_("Opacity: %.3g"), op);
+ gchar *str = g_strdup_printf(_("Opacity: %2.1f %%"), (op*100.0));
_opacity_place.set_tooltip_text(str);
g_free (str);
}
diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp
index 86e8c9e58..18b7bcab9 100644
--- a/src/ui/widget/unit-menu.cpp
+++ b/src/ui/widget/unit-menu.cpp
@@ -34,11 +34,7 @@ bool UnitMenu::setUnitType(UnitType unit_type)
UnitTable::UnitMap::iterator iter = m.begin();
while(iter != m.end()) {
Glib::ustring text = (*iter).first;
-#if WITH_GTKMM_2_24
append(text);
-#else
- append_text(text);
-#endif
++iter;
}
_type = unit_type;
@@ -49,11 +45,7 @@ bool UnitMenu::setUnitType(UnitType unit_type)
bool UnitMenu::resetUnitType(UnitType unit_type)
{
-#if WITH_GTKMM_2_24
- remove_all();
-#else
- clear_items();
-#endif
+ remove_all();
return setUnitType(unit_type);
}
@@ -61,11 +53,7 @@ bool UnitMenu::resetUnitType(UnitType unit_type)
void UnitMenu::addUnit(Unit const& u)
{
_unit_table.addUnit(u, false);
-#if WITH_GTKMM_2_24
append(u.abbr);
-#else
- append_text(u.abbr);
-#endif
}
Unit UnitMenu::getUnit() const
diff --git a/src/unclump.cpp b/src/unclump.cpp
index 43bcf5005..1427e8eab 100644
--- a/src/unclump.cpp
+++ b/src/unclump.cpp
@@ -15,6 +15,7 @@
#include <map>
#include <2geom/transforms.h>
#include "sp-item.h"
+#include "unclump.h"
// Taking bbox of an item is an expensive operation, and we need to do it many times, so here we
@@ -27,7 +28,7 @@ std::map<const gchar *, Geom::Point> wh_cache;
/**
Center of bbox of item
*/
-Geom::Point
+static Geom::Point
unclump_center (SPItem *item)
{
std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(item->getId());
@@ -46,7 +47,7 @@ unclump_center (SPItem *item)
}
}
-Geom::Point
+static Geom::Point
unclump_wh (SPItem *item)
{
Geom::Point wh;
@@ -71,7 +72,7 @@ Distance between "edges" of item1 and item2. An item is considered to be an elli
so its radius (distance from center to edge) depends on the w/h and the angle towards the other item.
May be negative if the edge of item1 is between the center and the edge of item2.
*/
-double
+static double
unclump_dist (SPItem *item1, SPItem *item2)
{
Geom::Point c1 = unclump_center (item1);
@@ -166,7 +167,7 @@ unclump_dist (SPItem *item1, SPItem *item2)
/**
Average unclump_dist from item to others
*/
-double unclump_average (SPItem *item, GSList *others)
+static double unclump_average (SPItem *item, GSList *others)
{
int n = 0;
double sum = 0;
@@ -190,7 +191,7 @@ double unclump_average (SPItem *item, GSList *others)
/**
Closest to item among others
*/
-SPItem *unclump_closest (SPItem *item, GSList *others)
+static SPItem *unclump_closest (SPItem *item, GSList *others)
{
double min = HUGE_VAL;
SPItem *closest = NULL;
@@ -214,7 +215,7 @@ SPItem *unclump_closest (SPItem *item, GSList *others)
/**
Most distant from item among others
*/
-SPItem *unclump_farest (SPItem *item, GSList *others)
+static SPItem *unclump_farest (SPItem *item, GSList *others)
{
double max = -HUGE_VAL;
SPItem *farest = NULL;
@@ -240,7 +241,7 @@ Removes from the \a rest list those items that are "behind" \a closest as seen f
i.e. those on the other side of the line through \a closest perpendicular to the direction from \a
item to \a closest. Returns a newly created list which must be freed.
*/
-GSList *
+static GSList *
unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest)
{
Geom::Point it = unclump_center (item);
@@ -282,7 +283,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest)
/**
Moves \a what away from \a from by \a dist
*/
-void
+static void
unclump_push (SPItem *from, SPItem *what, double dist)
{
Geom::Point it = unclump_center (what);
@@ -305,7 +306,7 @@ unclump_push (SPItem *from, SPItem *what, double dist)
/**
Moves \a what towards \a to by \a dist
*/
-void
+static void
unclump_pull (SPItem *to, SPItem *what, double dist)
{
Geom::Point it = unclump_center (what);
diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp
index 37e9d6cc1..3e1bab6bc 100644
--- a/src/util/expression-evaluator.cpp
+++ b/src/util/expression-evaluator.cpp
@@ -75,7 +75,7 @@ typedef struct
/** Unit Resolver...
*/
-bool unitresolverproc (const gchar* identifier, GimpEevlQuantity *result, Unit* unit)
+static bool unitresolverproc (const gchar* identifier, GimpEevlQuantity *result, Unit* unit)
{
static UnitTable unit_table;
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index f342f2c69..3adcfbb40 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -204,7 +204,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, g
dragger->dragging_started = true;
}
-void
+static void
vp_knot_grabbed_handler (SPKnot */*knot*/, unsigned int /*state*/, gpointer data)
{
VPDragger *dragger = (VPDragger *) data;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index d02472383..bbadb1a25 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -78,6 +78,7 @@
#include "ui/dialog/layers.h"
#include "ui/dialog/object-properties.h"
#include "ui/dialog/swatches.h"
+#include "ui/dialog/symbols.h"
#include "ui/dialog/spellcheck.h"
#include "ui/icon-names.h"
#include "ui/tool/node-tool.h"
@@ -132,7 +133,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("File"))
{ }
}; // FileVerb class
@@ -151,7 +152,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Edit"))
{ }
}; // EditVerb class
@@ -170,7 +171,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Selection"))
{ }
}; // SelectionVerb class
@@ -189,7 +190,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Layer"))
{ }
}; // LayerVerb class
@@ -208,7 +209,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Object"))
{ }
}; // ObjectVerb class
@@ -227,7 +228,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Context"))
{ }
}; // ContextVerb class
@@ -246,7 +247,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("View"))
{ }
}; // ZoomVerb class
@@ -266,7 +267,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Dialog"))
{ }
}; // DialogVerb class
@@ -285,7 +286,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Help"))
{ }
}; // HelpVerb class
@@ -304,7 +305,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Help"))
{ }
}; // TutorialVerb class
@@ -323,7 +324,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Text"))
{ }
}; //TextVerb : public Verb
@@ -340,7 +341,7 @@ Verb::VerbIDTable Verb::_verb_ids;
* each call it is incremented. The list of allocated verbs is kept
* in the \c _verbs hashtable which is indexed by the \c code.
*/
-Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) :
+Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image, gchar const *group) :
_actions(0),
_id(id),
_name(name),
@@ -349,6 +350,7 @@ Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *im
_shortcut(0),
_image(image),
_code(0),
+ _group(group),
_default_sensitive(false)
{
static int count = SP_VERB_LAST;
@@ -957,6 +959,12 @@ void EditVerb::perform(SPAction *action, void *data)
case SP_VERB_EDIT_UNTILE:
sp_selection_untile(dt);
break;
+ case SP_VERB_EDIT_SYMBOL:
+ sp_selection_symbol(dt);
+ break;
+ case SP_VERB_EDIT_UNSYMBOL:
+ sp_selection_unsymbol(dt);
+ break;
case SP_VERB_EDIT_CLEAR_ALL:
sp_edit_clear_all(dt);
break;
@@ -1190,6 +1198,10 @@ void LayerVerb::perform(SPAction *action, void *data)
sp_selection_to_prev_layer(dt);
break;
}
+ case SP_VERB_LAYER_MOVE_TO: {
+ Inkscape::UI::Dialogs::LayerPropertiesDialog::showMove(dt, dt->currentLayer());
+ break;
+ }
case SP_VERB_LAYER_TO_TOP:
case SP_VERB_LAYER_TO_BOTTOM:
case SP_VERB_LAYER_RAISE:
@@ -1338,17 +1350,34 @@ void LayerVerb::perform(SPAction *action, void *data)
break;
}
case SP_VERB_LAYER_SHOW_ALL: {
- dt->toggleAllLayers( false );
+ dt->toggleHideAllLayers( false );
DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:showall", SP_VERB_LAYER_SHOW_ALL, _("Show all layers"));
break;
}
-
case SP_VERB_LAYER_HIDE_ALL: {
- dt->toggleAllLayers( true );
+ dt->toggleHideAllLayers( true );
DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:hideall", SP_VERB_LAYER_HIDE_ALL, _("Hide all layers"));
break;
}
-
+ case SP_VERB_LAYER_LOCK_ALL: {
+ dt->toggleLockAllLayers( true );
+ DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockall", SP_VERB_LAYER_LOCK_ALL, _("Lock all layers"));
+ break;
+ }
+ case SP_VERB_LAYER_LOCK_OTHERS: {
+ if ( dt->currentLayer() == dt->currentRoot() ) {
+ dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer."));
+ } else {
+ dt->toggleLockOtherLayers( dt->currentLayer() );
+ DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers"));
+ }
+ break;
+ }
+ case SP_VERB_LAYER_UNLOCK_ALL: {
+ dt->toggleLockAllLayers( false );
+ DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:unlockall", SP_VERB_LAYER_UNLOCK_ALL, _("Unlock all layers"));
+ break;
+ }
case SP_VERB_LAYER_TOGGLE_LOCK:
case SP_VERB_LAYER_TOGGLE_HIDE: {
if ( dt->currentLayer() == dt->currentRoot() ) {
@@ -1771,6 +1800,24 @@ void ZoomVerb::perform(SPAction *action, void *data)
case SP_VERB_TOGGLE_SCROLLBARS:
dt->toggleScrollbars();
break;
+ case SP_VERB_TOGGLE_COMMANDS_TOOLBAR:
+ dt->toggleToolbar("commands");
+ break;
+ case SP_VERB_TOGGLE_SNAP_TOOLBAR:
+ dt->toggleToolbar("snaptoolbox");
+ break;
+ case SP_VERB_TOGGLE_TOOL_TOOLBAR:
+ dt->toggleToolbar("toppanel");
+ break;
+ case SP_VERB_TOGGLE_TOOLBOX:
+ dt->toggleToolbar("toolbox");
+ break;
+ case SP_VERB_TOGGLE_PALETTE:
+ dt->toggleToolbar("panels");
+ break;
+ case SP_VERB_TOGGLE_STATUSBAR:
+ dt->toggleToolbar("statusbar");
+ break;
case SP_VERB_TOGGLE_GUIDES:
sp_namedview_toggle_guides(doc, repr);
break;
@@ -1829,6 +1876,7 @@ void ZoomVerb::perform(SPAction *action, void *data)
inkscape_dialogs_unhide();
dt->_dlg_mgr->showDialog("IconPreviewPanel");
break;
+
default:
break;
}
@@ -1872,6 +1920,9 @@ void DialogVerb::perform(SPAction *action, void *data)
case SP_VERB_DIALOG_SWATCHES:
dt->_dlg_mgr->showDialog("Swatches");
break;
+ case SP_VERB_DIALOG_SYMBOLS:
+ dt->_dlg_mgr->showDialog("Symbols");
+ break;
case SP_VERB_DIALOG_TRANSFORM:
dt->_dlg_mgr->showDialog("Transformation");
break;
@@ -1952,6 +2003,7 @@ void DialogVerb::perform(SPAction *action, void *data)
case SP_VERB_DIALOG_PRINT_COLORS_PREVIEW:
dt->_dlg_mgr->showDialog("PrintColorsPreviewDialog");
break;
+
default:
break;
}
@@ -2054,7 +2106,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Extensions"))
{
set_default_sensitive(false);
}
@@ -2119,7 +2171,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("View"))
{
set_default_sensitive(false);
}
@@ -2185,7 +2237,7 @@ public:
gchar const *name,
gchar const *tip,
gchar const *image) :
- Verb(code, id, name, tip, image)
+ Verb(code, id, name, tip, image, _("Layer"))
{
set_default_sensitive(true);
}
@@ -2244,8 +2296,8 @@ void LockAndHideVerb::perform(SPAction *action, void *data)
// these must be in the same order as the SP_VERB_* enum in "verbs.h"
Verb *Verb::_base_verbs[] = {
// Header
- new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL),
- new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL),
+ new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL, NULL),
+ new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL, NULL),
// File
new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"),
@@ -2335,6 +2387,10 @@ Verb *Verb::_base_verbs[] = {
N_("Convert selection to a rectangle with tiled pattern fill"), NULL),
new EditVerb(SP_VERB_EDIT_UNTILE, "ObjectsFromPattern", N_("Pattern to _Objects"),
N_("Extract objects from a tiled pattern fill"), NULL),
+ new EditVerb(SP_VERB_EDIT_SYMBOL, "ObjectsToSymbol", N_("Group to Symbol"),
+ N_("Convert group to a symbol"), NULL),
+ new EditVerb(SP_VERB_EDIT_UNSYMBOL, "ObjectsFromSymbol", N_("Symbol to Group"),
+ N_("Extract group from a symbol"), NULL),
new EditVerb(SP_VERB_EDIT_CLEAR_ALL, "EditClearAll", N_("Clea_r All"),
N_("Delete all objects from document"), NULL),
new EditVerb(SP_VERB_EDIT_SELECT_ALL, "EditSelectAll", N_("Select Al_l"),
@@ -2465,6 +2521,8 @@ Verb *Verb::_base_verbs[] = {
N_("Move selection to the layer above the current"), INKSCAPE_ICON("selection-move-to-layer-above")),
new LayerVerb(SP_VERB_LAYER_MOVE_TO_PREV, "LayerMoveToPrev", N_("Move Selection to Layer Bel_ow"),
N_("Move selection to the layer below the current"), INKSCAPE_ICON("selection-move-to-layer-below")),
+ new LayerVerb(SP_VERB_LAYER_MOVE_TO, "LayerMoveTo", N_("Move Selection to Layer..."),
+ N_("Move selection to layer"), INKSCAPE_ICON("layer-rename")),
new LayerVerb(SP_VERB_LAYER_TO_TOP, "LayerToTop", N_("Layer to _Top"),
N_("Raise the current layer to the top"), INKSCAPE_ICON("layer-top")),
new LayerVerb(SP_VERB_LAYER_TO_BOTTOM, "LayerToBottom", N_("Layer to _Bottom"),
@@ -2483,6 +2541,12 @@ Verb *Verb::_base_verbs[] = {
N_("Show all the layers"), NULL),
new LayerVerb(SP_VERB_LAYER_HIDE_ALL, "LayerHideAll", N_("_Hide all layers"),
N_("Hide all the layers"), NULL),
+ new LayerVerb(SP_VERB_LAYER_LOCK_ALL, "LayerLockAll", N_("_Lock all layers"),
+ N_("Lock all the layers"), NULL),
+ new LayerVerb(SP_VERB_LAYER_LOCK_OTHERS, "LayerLockOthers", N_("Lock/Unlock _other layers"),
+ N_("Lock all the other layers"), NULL),
+ new LayerVerb(SP_VERB_LAYER_UNLOCK_ALL, "LayerUnlockAll", N_("_Unlock all layers"),
+ N_("Unlock all the layers"), NULL),
new LayerVerb(SP_VERB_LAYER_TOGGLE_LOCK, "LayerToggleLock", N_("_Lock/Unlock Current Layer"),
N_("Toggle lock on current layer"), NULL),
new LayerVerb(SP_VERB_LAYER_TOGGLE_HIDE, "LayerToggleHide", N_("_Show/hide Current Layer"),
@@ -2626,6 +2690,12 @@ Verb *Verb::_base_verbs[] = {
new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), INKSCAPE_ICON("show-grid")),
new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), INKSCAPE_ICON("show-guides")),
new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Enable snapping"), INKSCAPE_ICON("snap")),
+ new ZoomVerb(SP_VERB_TOGGLE_COMMANDS_TOOLBAR, "ToggleCommandsToolbar", N_("_Commands Bar"), N_("Show or hide the Commands bar (under the menu)"), NULL),
+ new ZoomVerb(SP_VERB_TOGGLE_SNAP_TOOLBAR, "ToggleSnapToolbar", N_("Sn_ap Controls Bar"), N_("Show or hide the snapping controls"), NULL),
+ new ZoomVerb(SP_VERB_TOGGLE_TOOL_TOOLBAR, "ToggleToolToolbar", N_("T_ool Controls Bar"), N_("Show or hide the Tool Controls bar"), NULL),
+ new ZoomVerb(SP_VERB_TOGGLE_TOOLBOX, "ToggleToolbox", N_("_Toolbox"), N_("Show or hide the main toolbox (on the left)"), NULL),
+ new ZoomVerb(SP_VERB_TOGGLE_PALETTE, "TogglePalette", N_("_Palette"), N_("Show or hide the color palette"), NULL),
+ new ZoomVerb(SP_VERB_TOGGLE_STATUSBAR, "ToggleStatusbar", N_("_Statusbar"), N_("Show or hide the statusbar (at the bottom of the window)"), NULL),
new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
INKSCAPE_ICON("zoom-next")),
new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
@@ -2639,7 +2709,7 @@ Verb *Verb::_base_verbs[] = {
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"),
INKSCAPE_ICON("view-fullscreen")),
- new ZoomVerb(SP_VERB_FULLSCREENFOCUS, "FullScreenFocus", N_("Fullscreen & Focus Mode"), Glib::ustring::format(N_("Stretch this document window to full screen"), N_(" and "), N_("Remove excess toolbars to focus on drawing")).c_str(),
+ new ZoomVerb(SP_VERB_FULLSCREENFOCUS, "FullScreenFocus", N_("Fullscreen & Focus Mode"), N_("Stretch this document window to full screen"),
INKSCAPE_ICON("view-fullscreen")),
#endif // HAVE_GTK_WINDOW_FULLSCREEN
new ZoomVerb(SP_VERB_FOCUSTOGGLE, "FocusToggle", N_("Toggle _Focus Mode"), N_("Remove excess toolbars to focus on drawing"),
@@ -2694,6 +2764,8 @@ Verb *Verb::_base_verbs[] = {
// TRANSLATORS: "Swatches" means: color samples
new DialogVerb(SP_VERB_DIALOG_SWATCHES, "DialogSwatches", N_("S_watches..."),
N_("Select colors from a swatches palette"), GTK_STOCK_SELECT_COLOR),
+ new DialogVerb(SP_VERB_DIALOG_SYMBOLS, "DialogSymbols", N_("S_ymbols..."),
+ N_("Select symbol from a symbols palette"), GTK_STOCK_SELECT_COLOR),
new DialogVerb(SP_VERB_DIALOG_TRANSFORM, "DialogTransform", N_("Transfor_m..."),
N_("Precisely control objects' transformations"), INKSCAPE_ICON("dialog-transform")),
new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."),
@@ -2744,7 +2816,6 @@ Verb *Verb::_base_verbs[] = {
N_("Select which color separations to render in Print Colors Preview rendermode"), NULL),
new DialogVerb(SP_VERB_DIALOG_EXPORT, "DialogExport", N_("_Export PNG Image..."),
N_("Export this document or a selection as a PNG image"), INKSCAPE_ICON("document-export")),
-
// Help
new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"),
N_("Information on Inkscape extensions"), NULL),
@@ -2828,9 +2899,27 @@ Verb *Verb::_base_verbs[] = {
// Footer
- new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL)
+ new Verb(SP_VERB_LAST, " '\"invalid id", NULL, NULL, NULL, NULL)
};
+std::vector<Inkscape::Verb *>
+Verb::getList (void) {
+
+ std::vector<Verb *> verbs;
+ // Go through the dynamic verb table
+ for (VerbTable::iterator iter = _verbs.begin(); iter != _verbs.end(); ++iter) {
+ Verb * verb = iter->second;
+ if (verb->get_code() == SP_VERB_INVALID ||
+ verb->get_code() == SP_VERB_NONE ||
+ verb->get_code() == SP_VERB_LAST) {
+ continue;
+ }
+
+ verbs.push_back(verb);
+ }
+
+ return verbs;
+};
void
Verb::list (void) {
diff --git a/src/verbs.h b/src/verbs.h
index 2f0ae85c1..c4a7b67e0 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -84,6 +84,8 @@ enum {
SP_VERB_EDIT_SELECTION_2_GUIDES,
SP_VERB_EDIT_TILE,
SP_VERB_EDIT_UNTILE,
+ SP_VERB_EDIT_SYMBOL,
+ SP_VERB_EDIT_UNSYMBOL,
SP_VERB_EDIT_CLEAR_ALL,
SP_VERB_EDIT_SELECT_ALL,
SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS,
@@ -139,6 +141,7 @@ enum {
SP_VERB_LAYER_PREV,
SP_VERB_LAYER_MOVE_TO_NEXT,
SP_VERB_LAYER_MOVE_TO_PREV,
+ SP_VERB_LAYER_MOVE_TO,
SP_VERB_LAYER_TO_TOP,
SP_VERB_LAYER_TO_BOTTOM,
SP_VERB_LAYER_RAISE,
@@ -148,6 +151,9 @@ enum {
SP_VERB_LAYER_SOLO,
SP_VERB_LAYER_SHOW_ALL,
SP_VERB_LAYER_HIDE_ALL,
+ SP_VERB_LAYER_LOCK_ALL,
+ SP_VERB_LAYER_LOCK_OTHERS,
+ SP_VERB_LAYER_UNLOCK_ALL,
SP_VERB_LAYER_TOGGLE_LOCK,
SP_VERB_LAYER_TOGGLE_HIDE,
/* Object */
@@ -221,6 +227,12 @@ enum {
SP_VERB_TOGGLE_GRID,
SP_VERB_TOGGLE_GUIDES,
SP_VERB_TOGGLE_SNAPPING,
+ SP_VERB_TOGGLE_COMMANDS_TOOLBAR,
+ SP_VERB_TOGGLE_SNAP_TOOLBAR,
+ SP_VERB_TOGGLE_TOOL_TOOLBAR,
+ SP_VERB_TOGGLE_TOOLBOX,
+ SP_VERB_TOGGLE_PALETTE,
+ SP_VERB_TOGGLE_STATUSBAR,
SP_VERB_ZOOM_NEXT,
SP_VERB_ZOOM_PREV,
SP_VERB_ZOOM_1_1,
@@ -254,6 +266,7 @@ enum {
SP_VERB_DIALOG_FILL_STROKE,
SP_VERB_DIALOG_GLYPHS,
SP_VERB_DIALOG_SWATCHES,
+ SP_VERB_DIALOG_SYMBOLS,
SP_VERB_DIALOG_TRANSFORM,
SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
SP_VERB_DIALOG_SPRAY_OPTION,
@@ -327,6 +340,7 @@ enum {
SP_VERB_ALIGN_VERTICAL_BOTTOM,
SP_VERB_ALIGN_VERTICAL_TOP_TO_ANCHOR,
SP_VERB_ALIGN_VERTICAL_HORIZONTAL_CENTER,
+
/* Footer */
SP_VERB_LAST
};
@@ -334,6 +348,7 @@ enum {
gchar *sp_action_get_title (const SPAction *action);
#include <map>
+#include <vector>
namespace Inkscape {
@@ -404,6 +419,9 @@ private:
*/
unsigned int _code;
+ /** Name of the group the verb belongs to. */
+ gchar const * _group;
+
/**
* Whether this verb is set to default to sensitive or
* insensitive when new actions are created.
@@ -438,17 +456,24 @@ public:
gchar const * get_name (void) { return _name; }
/** Accessor to get the internal variable. */
+ gchar const * get_short_tip (void) { return _tip; };
+
+ /** Accessor to get the internal variable. */
gchar const * get_tip (void) ;
/** Accessor to get the internal variable. */
gchar const * get_image (void) { return _image; }
+ /** Get the verbs group */
+ gchar const * get_group (void) { return _group; }
+
/** Set the name after initialization. */
gchar const * set_name (gchar const * name) { _name = name; return _name; }
/** Set the tooltip after initialization. */
gchar const * set_tip (gchar const * tip) { _tip = tip; return _tip; }
+
protected:
SPAction *make_action_helper (Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL);
virtual SPAction *make_action (Inkscape::UI::View::View *view);
@@ -480,7 +505,8 @@ public:
gchar const * id,
gchar const * name,
gchar const * tip,
- gchar const * image) :
+ gchar const * image,
+ gchar const * group) :
_actions(0),
_id(id),
_name(name),
@@ -489,12 +515,13 @@ public:
_shortcut(0),
_image(image),
_code(code),
+ _group(group),
_default_sensitive(true)
{
_verbs.insert(VerbTable::value_type(_code, this));
_verb_ids.insert(VerbIDTable::value_type(_id, this));
}
- Verb (gchar const * id, gchar const * name, gchar const * tip, gchar const * image);
+ Verb (gchar const * id, gchar const * name, gchar const * tip, gchar const * image, gchar const * group);
virtual ~Verb (void);
SPAction * get_action(Inkscape::UI::View::View * view);
@@ -546,6 +573,8 @@ protected:
public:
static void list (void);
+ static std::vector<Inkscape::Verb *>getList (void);
+
}; /* Verb class */
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 38180bd69..19410ee1d 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -36,7 +36,6 @@ set(widgets_SRC
select-toolbar.cpp
shrink-wrap-button.cpp
sp-attribute-widget.cpp
- sp-color-gtkselector.cpp
sp-color-icc-selector.cpp
sp-color-notebook.cpp
sp-color-scales.cpp
@@ -94,7 +93,6 @@ set(widgets_SRC
select-toolbar.h
shrink-wrap-button.h
sp-attribute-widget.h
- sp-color-gtkselector.h
sp-color-icc-selector.h
sp-color-notebook.h
sp-color-scales.h
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index 7d6b413bd..46f0bd645 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -66,8 +66,6 @@ ink_common_sources += \
widgets/spiral-toolbar.h \
widgets/sp-attribute-widget.cpp \
widgets/sp-attribute-widget.h \
- widgets/sp-color-gtkselector.cpp \
- widgets/sp-color-gtkselector.h \
widgets/sp-color-icc-selector.cpp \
widgets/sp-color-icc-selector.h \
widgets/sp-color-notebook.cpp \
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index 84434c88b..e96e4c097 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -92,7 +92,7 @@ static void sp_arctb_sensitivize( GObject *tbl, double v1, double v2 )
static void
sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name, gchar const *other_name)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -128,8 +128,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
}
sp_genericellipse_normalize(ge);
- ((SPObject *)arc)->updateRepr();
- ((SPObject *)arc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ (SP_OBJECT(arc))->updateRepr();
+ (SP_OBJECT(arc))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
modmade = true;
}
@@ -163,7 +163,7 @@ static void sp_arctb_end_value_changed(GtkAdjustment *adj, GObject *tbl)
static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
@@ -419,7 +419,7 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec
sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), (GObject *)holder))
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), G_OBJECT(holder)))
);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index 2192ebfdc..cb4951660 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -227,7 +227,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj
static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis axis)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
SPDocument *document = sp_desktop_document(desktop);
// quit if run by the attr_changed or selection changed listener
@@ -431,7 +431,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
}
sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), (GObject *)holder))
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), G_OBJECT(holder)))
);
g_signal_connect(holder, "destroy", G_CALLBACK(delete_connection), connection);
g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder);
diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp
index 45356601b..1ac083276 100644
--- a/src/widgets/button.cpp
+++ b/src/widgets/button.cpp
@@ -218,9 +218,7 @@ sp_button_perform_action (SPButton *button, gpointer /*data*/)
GtkWidget *
sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action )
{
- SPButton *button;
-
- button = (SPButton *)g_object_new (SP_TYPE_BUTTON, NULL);
+ SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL));
button->type = type;
button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION );
diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp
index a0ae136e8..287deb815 100644
--- a/src/widgets/calligraphy-toolbar.cpp
+++ b/src/widgets/calligraphy-toolbar.cpp
@@ -74,6 +74,16 @@ using Inkscape::UI::PrefPusher;
//########################
//## Calligraphy ##
//########################
+
+std::vector<Glib::ustring> get_presets_list() {
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+
+ return presets;
+}
+
void update_presets_list(GObject *tbl)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -88,7 +98,7 @@ void update_presets_list(GObject *tbl)
return;
}
- std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ std::vector<Glib::ustring> presets = get_presets_list();
int ege_index = 1;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) {
@@ -233,22 +243,24 @@ static void sp_dcc_build_presets_list(GObject *tbl)
// iterate over all presets to populate the list
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ std::vector<Glib::ustring> presets = get_presets_list();
int ii=1;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i) {
GtkTreeIter iter;
Glib::ustring preset_name = prefs->getString(*i + "/name");
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 );
+ if (!preset_name.empty()) {
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 );
+ }
}
- {
+/* {
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter, 0, _("Save..."), 1, ii, -1 );
g_object_set_data(tbl, "save_presets_index", GINT_TO_POINTER(ii));
- }
+ }*/
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
@@ -259,7 +271,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl)
{
using Inkscape::UI::Dialog::CalligraphicProfileRename;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop" ));
if (! desktop) {
return;
}
@@ -268,15 +280,25 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl)
return;
}
- CalligraphicProfileRename::show(desktop);
+ EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
+ //gint preset_index = ege_select_one_action_get_active( sel );
+ Glib::ustring current_profile_name = _("No preset");
+ if (ege_select_one_action_get_active_text( sel )) {
+ current_profile_name = ege_select_one_action_get_active_text( sel );
+ }
+
+ if (current_profile_name == _("No preset")) {
+ current_profile_name = "";
+ }
+ CalligraphicProfileRename::show(desktop, current_profile_name);
if ( !CalligraphicProfileRename::applied()) {
// dialog cancelled
update_presets_list (tbl);
return;
}
- Glib::ustring profile_name = CalligraphicProfileRename::getProfileName();
+ Glib::ustring new_profile_name = CalligraphicProfileRename::getProfileName();
- if (profile_name.empty()) {
+ if (new_profile_name.empty()) {
// empty name entered
update_presets_list (tbl);
return;
@@ -285,7 +307,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl)
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE));
// If there's a preset with the given name, find it and set save_path appropriately
- std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+ std::vector<Glib::ustring> presets = get_presets_list();
int total_presets = presets.size();
int new_index = -1;
Glib::ustring save_path; // profile pref path without a trailing slash
@@ -293,13 +315,21 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl)
int temp_index = 0;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) {
Glib::ustring name = prefs->getString(*i + "/name");
- if (!name.empty() && profile_name == name) {
+ if (!name.empty() && (new_profile_name == name || current_profile_name == name)) {
new_index = temp_index;
save_path = *i;
break;
}
}
+
+ if ( CalligraphicProfileRename::deleted() && new_index != -1) {
+ prefs->remove(save_path);
+ g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
+ sp_dcc_build_presets_list (tbl);
+ return;
+ }
+
if (new_index == -1) {
// no preset with this name, create
new_index = total_presets + 1;
@@ -327,7 +357,7 @@ static void sp_dcc_save_profile(GtkWidget * /*widget*/, GObject *tbl)
g_warning("Bad key when writing preset: %s\n", widget_name);
}
}
- prefs->setString(save_path + "/name", profile_name);
+ prefs->setString(save_path + "/name", new_profile_name);
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
sp_dcc_build_presets_list (tbl);
@@ -338,7 +368,7 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint preset_index = ege_select_one_action_get_active( act );
+ guint preset_index = ege_select_one_action_get_active( act );
// This is necessary because EgeSelectOneAction spams us with GObject "changed" signal calls
// even when the preset is not changed. It would be good to replace it with something more
// modern. Index 0 means "No preset", so we don't do anything.
@@ -346,6 +376,7 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl)
return;
}
+/*
gint save_presets_index = GPOINTER_TO_INT(g_object_get_data(tbl, "save_presets_index"));
if (preset_index == save_presets_index) {
@@ -353,14 +384,19 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl)
sp_dcc_save_profile(NULL, tbl);
return;
}
+*/
if (g_object_get_data(tbl, "presets_blocked")) {
return;
}
// preset_index is one-based so we subtract 1
- std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
- Glib::ustring preset_path = presets.at(preset_index - 1);
+ std::vector<Glib::ustring> presets = get_presets_list();
+
+ Glib::ustring preset_path = "";
+ if (preset_index - 1 < presets.size()) {
+ preset_path = presets.at(preset_index - 1);
+ }
if (!preset_path.empty()) {
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it
@@ -391,9 +427,16 @@ static void sp_ddc_change_profile(EgeSelectOneAction* act, GObject* tbl)
}
}
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(FALSE));
+ } else {
+ ege_select_one_action_set_active(act, 0);
}
}
+static void sp_ddc_edit_profile(GtkAction * /*act*/, GObject* tbl)
+{
+ sp_dcc_save_profile(NULL, tbl);
+}
+
void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -595,6 +638,18 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(sp_ddc_change_profile), holder);
gtk_action_group_add_action(mainActions, GTK_ACTION(act1));
}
+
+ /*calligraphic profile editor */
+ {
+ InkAction* inky = ink_action_new( "ProfileEditAction",
+ _("Add/Edit Profile"),
+ _("Add or edit calligraphic profile"),
+ GTK_STOCK_PROPERTIES,
+ Inkscape::ICON_SIZE_DECORATION );
+ g_object_set( inky, "short_label", _("Edit"), NULL );
+ g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_ddc_edit_profile), (GObject*)holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
+ }
}
}
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 2b00856ec..87deffc71 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -98,7 +98,7 @@ static void sp_connector_path_set_ignore(void)
static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
@@ -123,7 +123,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
bool modmade = false;
GSList *l = (GSList *) selection->itemList();
while (l) {
- SPItem *item = (SPItem *) l->data;
+ SPItem *item = SP_ITEM(l->data);
if (cc_item_is_connector(item)) {
item->setAttribute( "inkscape:connector-type",
@@ -148,7 +148,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
@@ -172,7 +172,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
bool modmade = false;
GSList *l = (GSList *) selection->itemList();
while (l) {
- SPItem *item = (SPItem *) l->data;
+ SPItem *item = SP_ITEM(l->data);
if (cc_item_is_connector(item)) {
item->setAttribute( "inkscape:connector-curvature",
@@ -198,7 +198,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
SPDocument *doc = sp_desktop_document(desktop);
if (!DocumentUndo::getUndoSensitive(doc)) {
@@ -305,7 +305,7 @@ static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context);
if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE) {
@@ -315,7 +315,7 @@ static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)
static void sp_connector_remove_connection_point(GtkWidget *, GObject *tbl)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context);
if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE) {
@@ -461,7 +461,7 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder );
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), (GObject *)holder));
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), holder));
}
// Avoid overlaps toggle button
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 81361f0f9..3791ec73c 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -301,7 +301,7 @@ GType SPDesktopWidget::getType(void)
static void
sp_desktop_widget_class_init (SPDesktopWidgetClass *klass)
{
- dtw_parent_class = (SPViewWidgetClass*)g_type_class_peek_parent (klass);
+ dtw_parent_class = SP_VIEW_WIDGET_CLASS(g_type_class_peek_parent(klass));
GObjectClass *object_class = (GObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
@@ -317,17 +317,11 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass)
*/
void SPDesktopWidget::init( SPDesktopWidget *dtw )
{
- GtkWidget *widget;
- GtkWidget *tbl;
- GtkWidget *canvas_tbl;
-
- GtkWidget *eventbox;
-
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
new (&dtw->modified_connection) sigc::connection();
- widget = GTK_WIDGET (dtw);
+ GtkWidget *widget = GTK_WIDGET (dtw);
dtw->window = 0;
dtw->desktop = NULL;
@@ -365,6 +359,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#else
dtw->hbox = gtk_hbox_new(FALSE, 0);
#endif
+
gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 );
gtk_widget_show(dtw->hbox);
@@ -382,24 +377,42 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 );
- tbl = gtk_table_new (2, 3, FALSE);
- gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 );
-
- canvas_tbl = gtk_table_new (3, 3, FALSE);
-
/* Horizontal ruler */
- eventbox = gtk_event_box_new ();
+ GtkWidget *eventbox = gtk_event_box_new ();
dtw->hruler = sp_ruler_new(GTK_ORIENTATION_HORIZONTAL);
dtw->hruler_box = eventbox;
sp_ruler_set_metric(SP_RULER(dtw->hruler), SP_PT);
gtk_widget_set_tooltip_text (dtw->hruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))));
gtk_container_add (GTK_CONTAINER (eventbox), dtw->hruler);
- gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL),
- gtk_widget_get_style(widget)->xthickness, 0);
+ guint xthickness = gtk_widget_get_style(widget)->xthickness;
+ guint ythickness = gtk_widget_get_style(widget)->ythickness;
g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_hruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_hruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_hruler_event), dtw);
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *tbl = gtk_grid_new();
+ GtkWidget *canvas_tbl = gtk_grid_new();
+
+ gtk_widget_set_margin_left(eventbox, xthickness);
+ gtk_widget_set_margin_right(eventbox, xthickness);
+
+ gtk_widget_set_halign(eventbox, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(eventbox, TRUE);
+ gtk_widget_set_valign(eventbox, GTK_ALIGN_START);
+
+ gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 1, 0, 1, 1);
+#else
+ GtkWidget *tbl = gtk_table_new(2, 3, FALSE);
+ GtkWidget *canvas_tbl = gtk_table_new(3, 3, FALSE);
+
+ gtk_table_attach(GTK_TABLE (canvas_tbl), eventbox, 1, 2, 0, 1,
+ GTK_FILL, GTK_FILL,
+ xthickness, 0);
+#endif
+
+ gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 );
+
/* Vertical ruler */
eventbox = gtk_event_box_new ();
dtw->vruler = sp_ruler_new(GTK_ORIENTATION_VERTICAL);
@@ -407,28 +420,45 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
sp_ruler_set_metric (SP_RULER (dtw->vruler), SP_PT);
gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))));
gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler));
- gtk_table_attach (GTK_TABLE (canvas_tbl), eventbox, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0,
- gtk_widget_get_style(widget)->ythickness);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_top(eventbox, ythickness);
+ gtk_widget_set_margin_bottom(eventbox, ythickness);
+
+ gtk_widget_set_halign(eventbox, GTK_ALIGN_START);
+ gtk_widget_set_valign(eventbox, GTK_ALIGN_FILL);
+ gtk_widget_set_vexpand(eventbox, TRUE);
+
+ gtk_grid_attach(GTK_GRID(canvas_tbl), eventbox, 0, 1, 1, 1);
+#else
+ gtk_table_attach(GTK_TABLE (canvas_tbl), eventbox, 0, 1, 1, 2,
+ GTK_FILL, GTK_FILL,
+ 0, ythickness);
+#endif
+
g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_vruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_vruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "motion_notify_event", G_CALLBACK (sp_dt_vruler_event), dtw);
- /* Horizontal scrollbar */
+ // Horizontal scrollbar
dtw->hadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
-#if GTK_CHECK_VERSION(3,0,0)
- dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj));
-#else
- dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj));
-#endif
- gtk_table_attach (GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_SHRINK), 0, 0);
- /* Vertical scrollbar and the sticky zoom button */
#if GTK_CHECK_VERSION(3,0,0)
+ dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj));
+ gtk_widget_set_halign(dtw->hscrollbar, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(dtw->hscrollbar, TRUE);
+ gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1);
dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous(GTK_BOX(dtw->vscrollbar_box), FALSE);
#else
+ dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj));
+ gtk_table_attach(GTK_TABLE (canvas_tbl), dtw->hscrollbar, 1, 2, 2, 3,
+ GTK_FILL, GTK_SHRINK,
+ 0, 0);
dtw->vscrollbar_box = gtk_vbox_new (FALSE, 0);
#endif
+
+ // Sticky zoom button
dtw->sticky_zoom = sp_button_new_from_data ( Inkscape::ICON_SIZE_DECORATION,
SP_BUTTON_TYPE_TOGGLE,
NULL,
@@ -437,15 +467,27 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dtw->sticky_zoom), prefs->getBool("/options/stickyzoom/value"));
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->sticky_zoom, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (dtw->sticky_zoom), "toggled", G_CALLBACK (sp_dtw_sticky_zoom_toggled), dtw);
+
+ // Vertical scrollbar
dtw->vadj = (GtkAdjustment *) gtk_adjustment_new (0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0);
+
#if GTK_CHECK_VERSION(3,0,0)
dtw->vscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(dtw->vadj));
#else
dtw->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (dtw->vadj));
#endif
+
gtk_box_pack_start (GTK_BOX (dtw->vscrollbar_box), dtw->vscrollbar, TRUE, TRUE, 0);
- gtk_table_attach (GTK_TABLE (canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_FILL), 0, 0);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_valign(dtw->vscrollbar, GTK_ALIGN_FILL);
+ gtk_widget_set_vexpand(dtw->vscrollbar, TRUE);
+ gtk_grid_attach(GTK_GRID(canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2);
+#else
+ gtk_table_attach(GTK_TABLE(canvas_tbl), dtw->vscrollbar_box, 2, 3, 0, 2,
+ GTK_SHRINK, GTK_FILL,
+ 0, 0);
+#endif
gchar const* tip = "";
Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE );
@@ -476,7 +518,16 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
#else
cms_adjust_set_sensitive(dtw, FALSE);
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
- gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, (GtkAttachOptions)(GTK_SHRINK), (GtkAttachOptions)(GTK_SHRINK), 0, 0);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_grid_attach( GTK_GRID(canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1);
+#else
+ gtk_table_attach( GTK_TABLE(canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3,
+ (GtkAttachOptions)(GTK_SHRINK),
+ (GtkAttachOptions)(GTK_SHRINK),
+ 0, 0);
+#endif
+
{
if (!watcher) {
watcher = new CMSPrefWatcher();
@@ -500,17 +551,24 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas)));
style->bg[GTK_STATE_NORMAL] = style->white;
gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style);
-#endif
-
+
// 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)
if ( prefs->getBool("/options/useextinput/value", true) )
gtk_widget_set_extension_events(GTK_WIDGET (dtw->canvas) , GDK_EXTENSION_EVENTS_ALL); //set extension events for tablets, unless disabled in preferences
#endif
g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(GTK_WIDGET(dtw->canvas), GTK_ALIGN_FILL);
+ gtk_widget_set_valign(GTK_WIDGET(dtw->canvas), GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE);
+ gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE);
+ gtk_grid_attach(GTK_GRID(canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), 0, 0);
+#endif
/* Dock */
bool create_dock =
@@ -530,12 +588,28 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
paned_class->cycle_handle_focus = NULL;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(GTK_WIDGET(paned->gobj()), TRUE);
+ gtk_widget_set_vexpand(GTK_WIDGET(paned->gobj()), TRUE);
+ gtk_widget_set_halign(GTK_WIDGET(paned->gobj()), GTK_ALIGN_FILL);
+ gtk_widget_set_valign(GTK_WIDGET(paned->gobj()), GTK_ALIGN_FILL);
+ gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (paned->gobj()), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+#endif
} else {
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(GTK_WIDGET(canvas_tbl), TRUE);
+ gtk_widget_set_vexpand(GTK_WIDGET(canvas_tbl), TRUE);
+ gtk_widget_set_halign(GTK_WIDGET(canvas_tbl), GTK_ALIGN_FILL);
+ gtk_widget_set_valign(GTK_WIDGET(canvas_tbl), GTK_ALIGN_FILL);
+ gtk_grid_attach(GTK_GRID(tbl), GTK_WIDGET (canvas_tbl), 1, 1, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (tbl), GTK_WIDGET (canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+#endif
}
dtw->selected_style = new Inkscape::UI::Widget::SelectedStyle(true);
@@ -573,35 +647,66 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
// cursor coordinates
- dtw->coord_status = gtk_table_new (5, 2, FALSE);
+#if GTK_CHECK_VERSION(3,0,0)
+ dtw->coord_status = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(dtw->coord_status), 0);
+ gtk_grid_set_column_spacing(GTK_GRID(dtw->coord_status), 2);
+ GtkWidget* sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status),
+ GTK_WIDGET(sep),
+ 0, 0, 1, 2);
+#else
+ dtw->coord_status = gtk_table_new(5, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(dtw->coord_status), 0);
gtk_table_set_col_spacings(GTK_TABLE(dtw->coord_status), 2);
gtk_table_attach(GTK_TABLE(dtw->coord_status),
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_separator_new(GTK_ORIENTATION_VERTICAL),
-#else
gtk_vseparator_new(),
+ 0, 1, 0, 2,
+ GTK_FILL, GTK_FILL, 0, 0);
#endif
- 0,1, 0,2, GTK_FILL, GTK_FILL, 0, 0);
+
eventbox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (eventbox), dtw->coord_status);
gtk_widget_set_tooltip_text (eventbox, _("Cursor coordinates"));
GtkWidget *label_x = gtk_label_new(_("X:"));
gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_grid_attach(GTK_GRID(dtw->coord_status),
+ label_x, 1, 0, 1, 1);
+#else
gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0);
+#endif
+
GtkWidget *label_y = gtk_label_new(_("Y:"));
gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1);
+#else
gtk_table_attach(GTK_TABLE(dtw->coord_status), label_y, 1,2, 1,2, GTK_FILL, GTK_FILL, 0, 0);
+#endif
+
dtw->coord_status_x = gtk_label_new(NULL);
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" );
gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5);
dtw->coord_status_y = gtk_label_new(NULL);
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" );
gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5);
+ GtkWidget* label_z = gtk_label_new(_("Z:"));
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2);
+#else
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), gtk_label_new(_("Z:")), 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0);
+#endif
+
sp_set_font_size_smaller (dtw->coord_status);
gtk_box_pack_end (GTK_BOX (statusbar_tail), eventbox, FALSE, FALSE, 1);
@@ -680,6 +785,7 @@ static void sp_desktop_widget_dispose(GObject *object)
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw);
+ dtw->layer_selector->setDesktop(NULL);
dtw->layer_selector->unreference();
inkscape_remove_desktop (dtw->desktop); // clears selection too
dtw->modified_connection.disconnect();
@@ -711,12 +817,15 @@ SPDesktopWidget::updateTitle(gchar const* uri)
gchar const *fname = uri;
GString *name = g_string_new ("");
- gchar const *grayscalename = "(grayscale) ";
- gchar const *grayscalenamecomma = ", grayscale";
- gchar const *printcolorsname = "(print colors preview) ";
- gchar const *printcolorsnamecomma = ", print colors preview";
- gchar const *colormodename = "";
- gchar const *colormodenamecomma = "";
+ gchar const *grayscalename = N_("grayscale");
+ gchar const *grayscalenamecomma = N_(", grayscale");
+ gchar const *printcolorsname = N_("print colors preview");
+ gchar const *printcolorsnamecomma = N_(", print colors preview");
+ gchar const *outlinename = N_("outline");
+ gchar const *nofiltersname = N_("no filters");
+ gchar const *colormodename = NULL;
+ gchar const *colormodenamecomma = NULL;
+ gchar const *rendermodename = NULL;
gchar const *modifiedname = "";
SPDocument *doc = this->desktop->doc();
if (doc->isModifiedSinceSave()) {
@@ -730,22 +839,40 @@ SPDesktopWidget::updateTitle(gchar const* uri)
colormodename = printcolorsname;
colormodenamecomma = printcolorsnamecomma;
}
+ if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) {
+ rendermodename = outlinename;
+ } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) {
+ rendermodename = nofiltersname;
+ }
+
if (this->desktop->number > 1) {
- if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) {
- g_string_printf (name, _("%s%s: %d (outline%s) - Inkscape"), modifiedname, fname, this->desktop->number, colormodenamecomma);
- } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) {
- g_string_printf (name, _("%s%s: %d (no filters%s) - Inkscape"), modifiedname, fname, this->desktop->number, colormodenamecomma);
+ if (rendermodename) {
+ if (colormodenamecomma) {
+ g_string_printf (name, _("%s%s: %d (%s%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename), _(colormodenamecomma));
+ } else {
+ g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename));
+ }
} else {
- g_string_printf (name, _("%s%s: %d %s- Inkscape"), modifiedname, fname, this->desktop->number, colormodename);
+ if (colormodename) {
+ g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(colormodename));
+ } else {
+ g_string_printf (name, _("%s%s: %d - Inkscape"), modifiedname, fname, this->desktop->number);
+ }
}
} else {
- if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) {
- g_string_printf (name, _("%s%s (outline%s) - Inkscape"), modifiedname, fname, colormodenamecomma);
- } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) {
- g_string_printf (name, _("%s%s (no filters%s) - Inkscape"), modifiedname, fname, colormodenamecomma);
+ if (rendermodename) {
+ if (colormodenamecomma) {
+ g_string_printf (name, _("%s%s (%s%s) - Inkscape"), modifiedname, fname, _(rendermodename), _(colormodenamecomma));
+ } else {
+ g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(rendermodename));
+ }
} else {
- g_string_printf (name, _("%s%s %s- Inkscape"), modifiedname, fname, colormodename);
+ if (colormodename) {
+ g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(colormodename));
+ } else {
+ g_string_printf (name, _("%s%s - Inkscape"), modifiedname, fname);
+ }
}
}
window->set_title (name->str);
diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp
index 595c289f2..535a5d101 100644
--- a/src/widgets/eek-preview.cpp
+++ b/src/widgets/eek-preview.cpp
@@ -42,6 +42,7 @@ using std::min;
#include <gtk/gtk.h>
#include "eek-preview.h"
+#include "preferences.h"
#define PRIME_BUTTON_MAGIC_NUMBER 1
@@ -224,13 +225,32 @@ static gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* /*
static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr)
{
- GtkStyle* style = gtk_widget_get_style(widget);
- GtkAllocation allocation;
- gtk_widget_get_allocation (widget, &allocation);
- EekPreview* preview = EEK_PREVIEW(widget);
- GdkColor fg = {0, preview->_r, preview->_g, preview->_b};
- gint insetX = 0;
- gint insetY = 0;
+ GtkStyle* style = gtk_widget_get_style(widget);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ EekPreview* preview = EEK_PREVIEW(widget);
+
+ GdkColor fg = { 0,
+ static_cast<guint16>(preview->_r),
+ static_cast<guint16>(preview->_g),
+ static_cast<guint16>(preview->_b)};
+
+ gint insetTop = 0, insetBottom = 0;
+ gint insetLeft = 0, insetRight = 0;
+
+ if (preview->_border == BORDER_SOLID) {
+ insetTop = 1;
+ insetLeft = 1;
+ }
+ if (preview->_border == BORDER_SOLID_LAST_ROW) {
+ insetTop = insetBottom = 1;
+ insetLeft = 1;
+ }
+ if (preview->_border == BORDER_WIDE) {
+ insetTop = insetBottom = 1;
+ insetLeft = insetRight = 1;
+ }
+
#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context(widget);
@@ -247,60 +267,64 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr)
#else
GdkWindow* window = gtk_widget_get_window(widget);
- gtk_paint_flat_box( style,
- window,
- (GtkStateType)gtk_widget_get_state(widget),
- GTK_SHADOW_NONE,
- NULL,
- widget,
- NULL,
- 0, 0,
- allocation.width, allocation.height);
+ gtk_paint_flat_box( style,
+ window,
+ (GtkStateType)gtk_widget_get_state(widget),
+ GTK_SHADOW_NONE,
+ NULL,
+ widget,
+ NULL,
+ 0, 0,
+ allocation.width, allocation.height);
gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE );
#endif
- GdkRectangle rect = {insetX,
- insetY,
- allocation.width - (insetX * 2),
- allocation.height - (insetY * 2)};
+ // Border
+ if (preview->_border != BORDER_NONE) {
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill(cr);
+ }
- gdk_cairo_set_source_color(cr, &fg);
- gdk_cairo_rectangle(cr, &rect);
- cairo_paint(cr);
+ cairo_set_source_rgb(cr, preview->_r/65535.0, preview->_g/65535.0, preview->_b/65535.0 );
+ cairo_rectangle(cr, insetLeft, insetTop, allocation.width - (insetLeft + insetRight), allocation.height - (insetTop + insetBottom));
+ cairo_fill(cr);
- if ( preview->_previewPixbuf ) {
- GtkDrawingArea *da = &(preview->drawing);
+ if ( preview->_previewPixbuf ) {
+ GtkDrawingArea *da = &(preview->drawing);
GdkWindow *da_window = gtk_widget_get_window(GTK_WIDGET(da));
cairo_t *cr = gdk_cairo_create(da_window);
-#if GTK_CHECK_VERSION(2,24,0)
gint w = gdk_window_get_width(da_window);
gint h = gdk_window_get_height(da_window);
-#else
- gint w = 0;
- gint h = 0;
- gdk_drawable_get_size(da_window, &w, &h);
-#endif
-
+
if ((w != preview->_scaledW) || (h != preview->_scaledH)) {
- if (preview->_scaled) {
- g_object_unref(preview->_scaled);
- }
- preview->_scaled = gdk_pixbuf_scale_simple(preview->_previewPixbuf, w, h, GDK_INTERP_BILINEAR);
- preview->_scaledW = w;
- preview->_scaledH = h;
+ if (preview->_scaled) {
+ g_object_unref(preview->_scaled);
}
+ preview->_scaled = gdk_pixbuf_scale_simple(preview->_previewPixbuf, w - (insetLeft + insetRight), h - (insetTop + insetBottom), GDK_INTERP_BILINEAR);
+ preview->_scaledW = w - (insetLeft + insetRight);
+ preview->_scaledH = h - (insetTop + insetBottom);
+ }
+
+ GdkPixbuf *pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf;
+
+ // Border
+ if (preview->_border != BORDER_NONE) {
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill(cr);
+ }
- GdkPixbuf *pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf;
- gdk_cairo_set_source_pixbuf(cr, pix, 0, 0);
+ gdk_cairo_set_source_pixbuf(cr, pix, insetLeft, insetTop);
cairo_paint(cr);
cairo_destroy(cr);
- }
+ }
if ( preview->_linked ) {
/* Draw arrow */
- GdkRectangle possible = {insetX, insetY, (allocation.width - (insetX * 2)), (allocation.height - (insetY * 2)) };
+ GdkRectangle possible = {insetLeft, insetTop, (allocation.width - (insetLeft + insetRight)), (allocation.height - (insetTop + insetBottom)) };
GdkRectangle area = {possible.x, possible.y, possible.width / 2, possible.height / 2 };
/* Make it square */
@@ -370,7 +394,7 @@ static gboolean eek_preview_draw(GtkWidget* widget, cairo_t* cr)
}
if ( preview->_linked & PREVIEW_LINK_OTHER ) {
- GdkRectangle otherArea = {insetX, area.y, area.width, area.height};
+ GdkRectangle otherArea = {insetLeft, area.y, area.width, area.height};
if ( otherArea.height < possible.height ) {
otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
}
@@ -524,7 +548,8 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton*
gtk_widget_grab_focus(widget);
}
- if ( event->button == PRIME_BUTTON_MAGIC_NUMBER ) {
+ if ( event->button == PRIME_BUTTON_MAGIC_NUMBER ||
+ event->button == 2 ) {
preview->_hot = TRUE;
if ( preview->_within ) {
gtk_widget_set_state( widget, GTK_STATE_ACTIVE );
@@ -541,8 +566,10 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton
EekPreview* preview = EEK_PREVIEW(widget);
preview->_hot = FALSE;
gtk_widget_set_state( widget, GTK_STATE_NORMAL );
- if ( preview->_within && event->button == PRIME_BUTTON_MAGIC_NUMBER ) {
- gboolean isAlt = (event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK;
+ if ( preview->_within &&
+ (event->button == PRIME_BUTTON_MAGIC_NUMBER || event->button == 2)) {
+ gboolean isAlt = ( ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) ||
+ (event->button == 2));
if ( isAlt ) {
g_signal_emit( widget, eek_preview_signals[ALTCLICKED_SIGNAL], 0, 2 );
@@ -554,7 +581,7 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton
return FALSE;
}
-gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event)
+static gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event)
{
(void)widget;
(void)event;
@@ -562,7 +589,7 @@ gboolean eek_preview_key_press_event( GtkWidget* widget, GdkEventKey* event)
return FALSE;
}
-gboolean eek_preview_key_release_event( GtkWidget* widget, GdkEventKey* event)
+static gboolean eek_preview_key_release_event( GtkWidget* widget, GdkEventKey* event)
{
(void)widget;
(void)event;
@@ -752,7 +779,7 @@ void eek_preview_set_focus_on_click( EekPreview* preview, gboolean focus_on_clic
}
}
-void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio )
+void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio, guint border )
{
preview->_prevstyle = prevstyle;
preview->_view = view;
@@ -766,7 +793,7 @@ void eek_preview_set_details( EekPreview* preview, PreviewStyle prevstyle, ViewT
ratio = PREVIEW_MAX_RATIO;
}
preview->_ratio = ratio;
-
+ preview->_border = border;
gtk_widget_queue_draw(GTK_WIDGET(preview));
}
@@ -802,7 +829,7 @@ static void eek_preview_init( EekPreview *preview )
preview->_view = VIEW_TYPE_LIST;
preview->_size = PREVIEW_SIZE_SMALL;
preview->_ratio = 100;
-
+ preview->_border = BORDER_NONE;
preview->_previewPixbuf = 0;
preview->_scaled = 0;
diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h
index 7275ab9b4..42e89a161 100644
--- a/src/widgets/eek-preview.h
+++ b/src/widgets/eek-preview.h
@@ -90,6 +90,14 @@ typedef enum {
PREVIEW_LINK_ALL = 31
} LinkType;
+
+typedef enum {
+ BORDER_NONE = 0,
+ BORDER_SOLID,
+ BORDER_WIDE,
+ BORDER_SOLID_LAST_ROW,
+} BorderStyle;
+
typedef struct _EekPreview EekPreview;
typedef struct _EekPreviewClass EekPreviewClass;
@@ -113,6 +121,7 @@ struct _EekPreview
PreviewSize _size;
guint _ratio;
guint _linked;
+ guint _border;
GdkPixbuf* _previewPixbuf;
GdkPixbuf* _scaled;
};
@@ -128,7 +137,7 @@ struct _EekPreviewClass
GType eek_preview_get_type(void) G_GNUC_CONST;
GtkWidget* eek_preview_new(void);
-void eek_preview_set_details( EekPreview* splat, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio );
+void eek_preview_set_details( EekPreview* splat, PreviewStyle prevstyle, ViewType view, PreviewSize size, guint ratio, guint);
void eek_preview_set_color( EekPreview* splat, int r, int g, int b );
void eek_preview_set_pixbuf( EekPreview* splat, GdkPixbuf* pixbuf );
diff --git a/src/widgets/erasor-toolbar.cpp b/src/widgets/erasor-toolbar.cpp
index 740af6821..14f87c943 100644
--- a/src/widgets/erasor-toolbar.cpp
+++ b/src/widgets/erasor-toolbar.cpp
@@ -82,7 +82,7 @@ static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
bool eraserMode = ege_select_one_action_get_active( act ) != 0;
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -94,9 +94,11 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ /*
if ( eraserMode != 0 ) {
} else {
}
+ */
// TODO finish implementation
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 0244621bf..dde511612 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -129,11 +129,11 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c)
object_class->dispose = sp_font_selector_dispose;
}
-void sp_font_selector_set_size_tooltip(SPFontSelector *fsel)
+static void sp_font_selector_set_size_tooltip(SPFontSelector *fsel)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
- Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")");
+ Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
gtk_widget_set_tooltip_text (fsel->size, _(tooltip.c_str()));
}
@@ -218,16 +218,7 @@ static void sp_font_selector_init(SPFontSelector *fsel)
gtk_widget_show(hb);
gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0);
-/*
-This would introduce dependency on gtk version 2.24 which is currently not available in
-Trisquel GNU/Linux 4.5.1 (released on May 25th, 2011)
-This conditional and its #else block can be deleted in the future.
-*/
-#if GTK_CHECK_VERSION(2, 24,0)
fsel->size = gtk_combo_box_text_new_with_entry ();
-#else
- fsel->size = gtk_combo_box_entry_new_text ();
-#endif
sp_font_selector_set_size_tooltip(fsel);
gtk_widget_set_size_request(fsel->size, 90, -1);
@@ -346,11 +337,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel )
{
double size = sizes[n] / ratios[unit];
-#if GTK_CHECK_VERSION(2, 24,0)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), Glib::ustring::format(size).c_str());
-#else
- gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), size);
-#endif
}
}
@@ -358,11 +345,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel )
static void sp_font_selector_size_changed( GtkComboBox */*cbox*/, SPFontSelector *fsel )
{
char *text = NULL;
-#if GTK_CHECK_VERSION(2, 24,0)
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (fsel->size));
-#else
- text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
-#endif
gfloat old_size = fsel->fontsize;
gchar *endptr;
@@ -448,7 +431,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel)
GtkWidget *sp_font_selector_new()
{
- SPFontSelector *fsel = (SPFontSelector*) g_object_new(SP_TYPE_FONT_SELECTOR, NULL);
+ SPFontSelector *fsel = SP_FONT_SELECTOR(g_object_new(SP_TYPE_FONT_SELECTOR, NULL));
return (GtkWidget *) fsel;
}
diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp
index 3c84e606b..359a41167 100644
--- a/src/widgets/gradient-image.cpp
+++ b/src/widgets/gradient-image.cpp
@@ -127,7 +127,7 @@ static void sp_gradient_image_destroy(GtkObject *object)
static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisition *requisition)
{
- requisition->width = 64;
+ requisition->width = 54;
requisition->height = 12;
}
@@ -192,9 +192,7 @@ static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct)
GtkWidget *
sp_gradient_image_new (SPGradient *gradient)
{
- SPGradientImage *image;
-
- image = (SPGradientImage*)g_object_new (SP_TYPE_GRADIENT_IMAGE, NULL);
+ SPGradientImage *image = SP_GRADIENT_IMAGE(g_object_new(SP_TYPE_GRADIENT_IMAGE, NULL));
sp_gradient_image_set_gradient (image, gradient);
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 3eba2da23..89a891284 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -19,6 +19,7 @@
#include <gtk/gtk.h>
#include "document.h"
+#include "../document-undo.h"
#include "../document-private.h"
#include "../gradient-chemistry.h"
#include "inkscape.h"
@@ -52,6 +53,8 @@ static void sp_gradient_selector_dispose(GObject *object);
static void sp_gradient_selector_vector_set (SPGradientVectorSelector *gvs, SPGradient *gr, SPGradientSelector *sel);
static void sp_gradient_selector_edit_vector_clicked (GtkWidget *w, SPGradientSelector *sel);
static void sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel);
+static void sp_gradient_selector_delete_vector_clicked (GtkWidget *w, SPGradientSelector *sel);
+
static GtkVBoxClass *parent_class;
static guint signals[LAST_SIGNAL] = {0};
@@ -124,6 +127,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
sel->safelyInit = true;
sel->blocked = false;
new (&sel->nonsolid) std::vector<GtkWidget*>();
+ new (&sel->swatch_widgets) std::vector<GtkWidget*>();
sel->mode = SPGradientSelector::MODE_LINEAR;
@@ -143,17 +147,17 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
sel->icon_renderer = Gtk::manage(new Gtk::CellRendererPixbuf());
sel->text_renderer = Gtk::manage(new Gtk::CellRendererText());
- sel->treeview->append_column("Gradient", *sel->icon_renderer);
+ sel->treeview->append_column(_("Gradient"), *sel->icon_renderer);
Gtk::TreeView::Column* icon_column = sel->treeview->get_column(0);
icon_column->add_attribute(sel->icon_renderer->property_pixbuf(), sel->columns->pixbuf);
icon_column->set_sort_column(sel->columns->color);
icon_column->set_clickable(true);
- sel->treeview->append_column("Name", *sel->text_renderer);
+ sel->treeview->append_column(_("Name"), *sel->text_renderer);
Gtk::TreeView::Column* name_column = sel->treeview->get_column(1);
sel->text_renderer->property_editable() = true;
name_column->add_attribute(sel->text_renderer->property_text(), sel->columns->name);
- name_column->set_min_width(200);
+ name_column->set_min_width(180);
name_column->set_clickable(true);
name_column->set_resizable(true);
@@ -169,7 +173,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
count_column->signal_clicked().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeCountColClick) );
gvs->tree_select_connection = sel->treeview->get_selection()->signal_changed().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeSelection) );
- sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onTreeEdited) );
+ sel->text_renderer->signal_edited().connect( sigc::mem_fun(*sel, &SPGradientSelector::onGradientRename) );
sel->scrolled_window = Gtk::manage(new Gtk::ScrolledWindow());
sel->scrolled_window->add(*sel->treeview);
@@ -188,7 +192,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
#else
GtkWidget *hb = gtk_hbox_new( FALSE, 2 );
#endif
- sel->nonsolid.push_back(hb);
+ //sel->nonsolid.push_back(hb);
gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
sel->add = gtk_button_new ();
@@ -212,6 +216,16 @@ static void sp_gradient_selector_init(SPGradientSelector *sel)
gtk_button_set_relief(GTK_BUTTON(sel->edit), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text( sel->edit, _("Edit gradient"));
+ sel->del = gtk_button_new ();
+ gtk_button_set_image((GtkButton*)sel->del , gtk_image_new_from_stock ( GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR ) );
+
+ sel->swatch_widgets.push_back(sel->del);
+ gtk_box_pack_start (GTK_BOX (hb), sel->del, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (sel->del), "clicked", G_CALLBACK (sp_gradient_selector_delete_vector_clicked), sel);
+ gtk_widget_set_sensitive (sel->del, FALSE);
+ gtk_button_set_relief(GTK_BUTTON(sel->del), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text( sel->del, _("Delete swatch"));
+
gtk_widget_show_all(hb);
@@ -225,6 +239,7 @@ static void sp_gradient_selector_dispose(GObject *object)
sel->safelyInit = false;
using std::vector;
sel->nonsolid.~vector<GtkWidget*>();
+ sel->swatch_widgets.~vector<GtkWidget*>();
}
if (sel->icon_renderer) {
@@ -248,12 +263,9 @@ void SPGradientSelector::setSpread(SPGradientSpread spread)
}
-GtkWidget *
-sp_gradient_selector_new (void)
+GtkWidget *sp_gradient_selector_new()
{
- SPGradientSelector *sel;
-
- sel = (SPGradientSelector*)g_object_new (SP_TYPE_GRADIENT_SELECTOR, NULL);
+ SPGradientSelector *sel = SP_GRADIENT_SELECTOR(g_object_new (SP_TYPE_GRADIENT_SELECTOR, NULL));
return (GtkWidget *) sel;
}
@@ -267,9 +279,28 @@ void SPGradientSelector::setMode(SelectorMode mode)
{
gtk_widget_hide(*it);
}
+ for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ {
+ gtk_widget_show_all(*it);
+ }
+
+ Gtk::TreeView::Column* icon_column = treeview->get_column(0);
+ icon_column->set_title(_("Swatch"));
SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors);
vs->setSwatched();
+ } else {
+ for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ {
+ gtk_widget_show_all(*it);
+ }
+ for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ {
+ gtk_widget_hide(*it);
+ }
+ Gtk::TreeView::Column* icon_column = treeview->get_column(0);
+ icon_column->set_title(_("Gradient"));
+
}
}
}
@@ -289,7 +320,7 @@ SPGradientSpread SPGradientSelector::getSpread()
return gradientSpread;
}
-void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text)
+void SPGradientSelector::onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text)
{
Gtk::TreePath path(path_string);
Gtk::TreeModel::iterator iter = store->get_iter(path);
@@ -300,10 +331,12 @@ void SPGradientSelector::onTreeEdited( const Glib::ustring& path_string, const G
if ( row ) {
SPObject* obj = row[columns->data];
if ( obj ) {
+ row[columns->name] = gr_prepare_label(obj);
if (!new_text.empty() && new_text != row[columns->name]) {
rename_id(obj, new_text );
+ Inkscape::DocumentUndo::done(obj->document, SP_VERB_CONTEXT_GRADIENT,
+ _("Rename gradient"));
}
- row[columns->name] = gr_prepare_label(obj);
}
}
}
@@ -336,6 +369,14 @@ void SPGradientSelector::onTreeSelection()
return;
}
+ if (!treeview->has_focus()) {
+ /* Workaround for GTK bug on Windows/OS X
+ * When the treeview initially doesn't have focus and is clicked
+ * sometimes get_selection()->signal_changed() has the wrong selection
+ */
+ treeview->grab_focus();
+ }
+
const Glib::RefPtr<Gtk::TreeSelection> sel = treeview->get_selection();
if (!sel) {
return;
@@ -350,7 +391,7 @@ void SPGradientSelector::onTreeSelection()
}
if (obj) {
- sp_gradient_selector_vector_set (NULL, (SPGradient*)obj, this);
+ sp_gradient_selector_vector_set (NULL, SP_GRADIENT(obj), this);
}
}
@@ -363,7 +404,10 @@ bool SPGradientSelector::_checkForSelected(const Gtk::TreePath &path, const Gtk:
{
treeview->scroll_to_row(path, 0.5);
Glib::RefPtr<Gtk::TreeSelection> select = treeview->get_selection();
+ bool wasBlocked = blocked;
+ blocked = true;
select->select(iter);
+ blocked = wasBlocked;
found = true;
}
@@ -401,6 +445,17 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
gtk_widget_show_all(*it);
}
}
+ } else if (mode != MODE_SWATCH) {
+
+ for (std::vector<GtkWidget*>::iterator it = swatch_widgets.begin(); it != swatch_widgets.end(); ++it)
+ {
+ gtk_widget_hide(*it);
+ }
+ for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ {
+ gtk_widget_show_all(*it);
+ }
+
}
if (edit) {
@@ -409,6 +464,9 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
if (add) {
gtk_widget_set_sensitive(add, TRUE);
}
+ if (del) {
+ gtk_widget_set_sensitive(del, TRUE);
+ }
} else {
if (edit) {
gtk_widget_set_sensitive(edit, FALSE);
@@ -416,6 +474,9 @@ void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
if (add) {
gtk_widget_set_sensitive(add, (doc != NULL));
}
+ if (del) {
+ gtk_widget_set_sensitive(del, FALSE);
+ }
}
}
@@ -440,6 +501,29 @@ sp_gradient_selector_vector_set (SPGradientVectorSelector *gvs, SPGradient *gr,
}
}
+
+static void
+sp_gradient_selector_delete_vector_clicked (GtkWidget */*w*/, SPGradientSelector *sel)
+{
+ const Glib::RefPtr<Gtk::TreeSelection> selection = sel->treeview->get_selection();
+ if (!selection) {
+ return;
+ }
+
+ SPGradient *obj = NULL;
+ /* Single selection */
+ Gtk::TreeModel::iterator iter = selection->get_selected();
+ if ( iter ) {
+ Gtk::TreeModel::Row row = *iter;
+ obj = row[sel->columns->data];
+ }
+
+ if (obj) {
+ sp_gradient_unset_swatch(SP_ACTIVE_DESKTOP, obj->getId());
+ }
+
+}
+
static void
sp_gradient_selector_edit_vector_clicked (GtkWidget */*w*/, SPGradientSelector *sel)
{
@@ -494,7 +578,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
Glib::ustring old_id = gr->getId();
- gr = (SPGradient *) doc->getObjectByRepr(repr);
+ gr = SP_GRADIENT(doc->getObjectByRepr(repr));
// Rename the new gradients id to be similar to the cloned gradients
rename_id(gr, old_id);
diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h
index f7cc3cc14..ea83ff819 100644
--- a/src/widgets/gradient-selector.h
+++ b/src/widgets/gradient-selector.h
@@ -61,7 +61,7 @@ struct SPGradientSelector {
/* Tree */
bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPGradient *vector);
void onTreeSelection();
- void onTreeEdited( const Glib::ustring& path_string, const Glib::ustring& new_text);
+ void onGradientRename( const Glib::ustring& path_string, const Glib::ustring& new_text);
void onTreeNameColClick();
void onTreeColorColClick();
void onTreeCountColClick();
@@ -97,6 +97,7 @@ struct SPGradientSelector {
/* Editing buttons */
GtkWidget *edit;
GtkWidget *add;
+ GtkWidget *del;
GtkWidget *merge;
/* Position widget */
@@ -106,6 +107,7 @@ struct SPGradientSelector {
bool blocked;
std::vector<GtkWidget*> nonsolid;
+ std::vector<GtkWidget*> swatch_widgets;
void setMode(SelectorMode mode);
void setUnits(SPGradientUnits units);
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index ae85ed515..ea125a380 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -55,6 +55,7 @@
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "gradient-context.h"
+#include "gradient-toolbar.h"
#include "toolbox.h"
@@ -122,7 +123,7 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient
if (drag && drag->selected) {
GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data);
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
- GrDraggable *draggable = (GrDraggable *) i->data;
+ GrDraggable *draggable = static_cast<GrDraggable*>(i->data);
gr_apply_gradient_to_item(draggable->item, gr, initialType, initialMode, draggable->fill_or_stroke);
}
return;
@@ -633,27 +634,7 @@ static void gr_linked_changed(GtkToggleAction *act, gpointer /*data*/)
static void gr_reverse(GtkWidget * /*button*/, gpointer data)
{
SPDesktop *desktop = static_cast<SPDesktop *>(data);
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPEventContext *ev = sp_desktop_event_context(desktop);
-
- if (!ev) {
- return;
- }
-
- GrDrag *drag = ev->get_drag();
-
- // First try selected dragger
- if (drag && drag->selected) {
- drag->selected_reverse_vector();
- } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients)
- for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
- sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL);
- sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE);
- }
- }
- // we did an undoable action
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT,
- _("Invert gradient"));
+ sp_gradient_reverse_selected_gradients(desktop);
}
/*
@@ -694,10 +675,10 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEv
// for all selected draggers
for (GList *i = drag->selected; i != NULL; i = i->next) {
- GrDragger *dragger = (GrDragger *) i->data;
+ GrDragger *dragger = static_cast<GrDragger*>(i->data);
// for all draggables of dragger
for (GSList const* j = dragger->draggables; j != NULL; j = j->next) {
- GrDraggable *draggable = (GrDraggable *) j->data;
+ GrDraggable *draggable = static_cast<GrDraggable*>(j->data);
if (draggable->point_type != POINT_RG_FOCUS) {
n++;
@@ -938,7 +919,7 @@ static void gr_new_fillstroke_changed( EgeSelectOneAction *act, GObject * /*tbl*
/*
* User selected a gradient from the combobox
*/
-void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
+static void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
{
if (blocked) {
return;
@@ -967,7 +948,7 @@ void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
}
-void gr_spread_change(EgeSelectOneAction *act, GtkWidget *widget)
+static void gr_spread_change(EgeSelectOneAction *act, GtkWidget *widget)
{
if (blocked) {
return;
@@ -1128,7 +1109,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
- EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), ("Choose a gradient"), NULL, GTK_TREE_MODEL(store) );
+ EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), (_("Choose a gradient")), NULL, GTK_TREE_MODEL(store) );
g_object_set( act1, "short_label", _("Select:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
gtk_action_set_sensitive( GTK_ACTION(act1), FALSE );
@@ -1144,13 +1125,13 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, _("none"), 1, SP_GRADIENT_SPREAD_PAD, -1 );
+ gtk_list_store_set( model, &iter, 0, _("None"), 1, SP_GRADIENT_SPREAD_PAD, -1 );
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, _("reflected"), 1, SP_GRADIENT_SPREAD_REFLECT, -1 );
+ gtk_list_store_set( model, &iter, 0, _("Reflected"), 1, SP_GRADIENT_SPREAD_REFLECT, -1 );
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, _("direct"), 1, SP_GRADIENT_SPREAD_REPEAT, -1 );
+ gtk_list_store_set( model, &iter, 0, _("Direct"), 1, SP_GRADIENT_SPREAD_REPEAT, -1 );
EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectRepeatAction", _("Repeat"),
(// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute
@@ -1176,7 +1157,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientEditStopsAction", _("Stops"), _("Select a stop for the current gradient"), NULL, GTK_TREE_MODEL(store) );
- g_object_set( act1, "short_label", _("Edit:"), NULL );
+ g_object_set( act1, "short_label", _("Stops:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
gtk_action_set_sensitive( GTK_ACTION(act1), FALSE );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(gr_stop_combo_changed), holder );
@@ -1251,7 +1232,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
_("Link gradients"),
_("Link gradients to change all related gradients"),
INKSCAPE_ICON("object-unlocked"),
- secondarySize );
+ Inkscape::ICON_SIZE_DECORATION );
g_object_set( itact, "short_label", "Lock", NULL );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(gr_linked_changed), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 88fe15dca..51013a2cd 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -377,7 +377,7 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr)
return ((int)(hsl[0]*100 * 10000)) + ((int)(hsl[1]*100 * 100)) + ((int)(hsl[2]*100 * 1));
}
-GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude)
+static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude)
{
for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index c02f4bceb..d3b7e2dbb 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -40,15 +40,6 @@
#include "icon.h"
-// Bring in work-around for Glib versions missing GStatBuf
-#if !GLIB_CHECK_VERSION(2,25,0)
-#if defined (_MSC_VER) && !defined(_WIN64)
-typedef struct _stat32 GStatBuf;
-#else //defined (_MSC_VER) && !defined(_WIN64)
-typedef struct stat GStatBuf;
-#endif //defined (_MSC_VER) && !defined(_WIN64)
-#endif //!GLIB_CHECK_VERSION(2,25,0)
-
struct IconImpl {
static void classInit(SPIconClass *klass);
static void init(SPIcon *icon);
@@ -881,7 +872,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name )
if ( !widget ) {
//g_message("Creating an SPIcon instance for %s:%d", name, (int)lsize);
- SPIcon *icon = (SPIcon *)g_object_new(SP_TYPE_ICON, NULL);
+ SPIcon *icon = SP_ICON(g_object_new(SP_TYPE_ICON, NULL));
icon->lsize = lsize;
icon->name = g_strdup(name);
icon->psize = getPhysSize(lsize);
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index 673b1588b..3126175b3 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -83,7 +83,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
{
using namespace Inkscape::LivePathEffect;
- SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop");
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
SPEventContext *ec = desktop->event_context;
if (!SP_IS_LPETOOL_CONTEXT(ec)) {
return;
@@ -199,7 +199,7 @@ static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/lpetool/unitid", unit->unit_id);
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) {
SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
lpetool_delete_measuring_items(lc);
@@ -399,7 +399,7 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
{
GtkAction* act = tracker->createAction( "LPEToolUnitsAction", _("Units"), ("") );
gtk_action_group_add_action( mainActions, act );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), (GObject*)holder );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), holder );
g_object_set_data(holder, "lpetool_units_action", act);
gtk_action_set_sensitive(act, prefs->getBool("/tools/lpetool/show_measuring_info", true));
}
@@ -421,12 +421,12 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
sigc::connection *c_selection_modified =
new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), holder)));
pool->add_connection ("selection-modified", c_selection_modified);
sigc::connection *c_selection_changed =
new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder)));
pool->add_connection ("selection-changed", c_selection_changed);
}
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 2153aba51..f556c0c7b 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -72,7 +72,7 @@ using Inkscape::UI::PrefPusher;
static void
sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -122,7 +122,7 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G
// units menu
{
GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), (GObject*)holder );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), holder );
gtk_action_group_add_action( mainActions, act );
}
} // end of sp_measure_toolbox_prep()
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index 7dca63ba2..79cdf8117 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -266,7 +266,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::Dim2 d)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
@@ -632,17 +632,17 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
sigc::connection *c_selection_changed =
new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder)));
pool->add_connection ("selection-changed", c_selection_changed);
sigc::connection *c_selection_modified =
new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder)));
pool->add_connection ("selection-modified", c_selection_modified);
sigc::connection *c_subselection_changed =
new sigc::connection (desktop->connectToolSubselectionChanged
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder)));
pool->add_connection ("tool-subselection-changed", c_subselection_changed);
Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool);
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 6450abf52..5a6e774f5 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -359,7 +359,7 @@ sp_paint_selector_fillrule_toggled(GtkToggleButton *tb, SPPaintSelector *psel)
}
}
-void
+static void
sp_paint_selector_show_fillrule(SPPaintSelector *psel, bool is_fill)
{
if (psel->fillrulebox) {
@@ -791,7 +791,7 @@ static void sp_psel_pattern_change(GtkWidget * /*widget*/, SPPaintSelector *psel
* Returns a list of patterns in the defs of the given source document as a GSList object
* Returns NULL if there are no patterns in the document.
*/
-GSList *
+static GSList *
ink_pattern_list_get (SPDocument *source)
{
if (source == NULL)
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index 73ab4883c..d0e71d2b0 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -91,7 +91,7 @@ using Inkscape::UI::PrefPusher;
/* This is used in generic functions below to share large portions of code between pen and pencil tool */
static Glib::ustring const freehand_tool_name(GObject *dataKludge)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data(dataKludge, "desktop");
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(dataKludge, "desktop"));
return ( tools_isactive(desktop, TOOLS_FREEHAND_PEN)
? "/tools/freehand/pen"
: "/tools/freehand/pencil" );
@@ -104,7 +104,7 @@ static void freehand_mode_changed(EgeSelectOneAction* act, GObject* tbl)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt(freehand_tool_name(tbl) + "/freehand-mode", mode);
- SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop");
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
// in pen tool we have more options than in pencil tool; if one of them was chosen, we do any
// preparatory work here
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 8e74ff113..65eebf94b 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -89,7 +89,7 @@ static void sp_rtb_sensitivize( GObject *tbl )
static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
void (*setter)(SPRect *, gdouble))
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
@@ -395,7 +395,7 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
sp_rtb_sensitivize( holder );
sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), (GObject *)holder))
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder))
);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index 72c839b19..5104d5a9d 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -690,7 +690,14 @@ static void sp_ruler_real_draw_pos(SPRuler *ruler,
y = ROUND ((priv->position - priv->lower) * increment) + (ythickness - bs_height) / 2 - 1;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *sc = gtk_widget_get_style_context(widget);
+ GdkRGBA color;
+ gtk_style_context_get_color(sc, gtk_widget_get_state_flags(widget), &color);
+ gdk_cairo_set_source_rgba(cr, &color);
+#else
gdk_cairo_set_source_color(cr, &style->fg[gtk_widget_get_state(widget)]);
+#endif
cairo_move_to (cr, x, y);
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 61b04121a..3ccfa9cf9 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -52,6 +52,7 @@
#include "ink-action.h"
#include <2geom/rect.h>
#include "ui/icon-names.h"
+#include "select-toolbar.h"
using Inkscape::UnitTracker;
using Inkscape::DocumentUndo;
diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp
index fc844f5ec..941a0466c 100644
--- a/src/widgets/shrink-wrap-button.cpp
+++ b/src/widgets/shrink-wrap-button.cpp
@@ -16,6 +16,8 @@
#include <gtkmm/button.h>
#include <gtk/gtk.h>
+#include "shrink-wrap-button.h"
+
namespace Inkscape {
namespace Widgets {
diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp
deleted file mode 100644
index 2e00aca71..000000000
--- a/src/widgets/sp-color-gtkselector.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include <glibmm/i18n.h>
-#include "sp-color-gtkselector.h"
-
-
-static void sp_color_gtkselector_class_init (SPColorGtkselectorClass *klass);
-static void sp_color_gtkselector_init (SPColorGtkselector *csel);
-static void sp_color_gtkselector_dispose(GObject *object);
-
-static void sp_color_gtkselector_show_all (GtkWidget *widget);
-static void sp_color_gtkselector_hide(GtkWidget *widget);
-
-
-static SPColorSelectorClass *parent_class;
-
-#define XPAD 4
-#define YPAD 1
-
-GType
-sp_color_gtkselector_get_type (void)
-{
- static GType type = 0;
- if (!type) {
- static const GTypeInfo info = {
- sizeof (SPColorGtkselectorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) sp_color_gtkselector_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (SPColorGtkselector),
- 0, /* n_preallocs */
- (GInstanceInitFunc) sp_color_gtkselector_init,
- NULL,
- };
-
- type = g_type_register_static (SP_TYPE_COLOR_SELECTOR,
- "SPColorGtkselector",
- &info,
- static_cast< GTypeFlags > (0) );
- }
- return type;
-}
-
-static void
-sp_color_gtkselector_class_init (SPColorGtkselectorClass *klass)
-{
- static const gchar* nameset[] = {N_("System"), 0};
- GObjectClass *object_class = (GObjectClass *) klass;
- GtkWidgetClass *widget_class;
- SPColorSelectorClass *selector_class;
-
- widget_class = (GtkWidgetClass *) klass;
- selector_class = SP_COLOR_SELECTOR_CLASS (klass);
-
- parent_class = SP_COLOR_SELECTOR_CLASS (g_type_class_peek_parent (klass));
-
- selector_class->name = nameset;
- selector_class->submode_count = 1;
-
- object_class->dispose = sp_color_gtkselector_dispose;
-
- widget_class->show_all = sp_color_gtkselector_show_all;
- widget_class->hide = sp_color_gtkselector_hide;
-}
-
-void sp_color_gtkselector_init (SPColorGtkselector *csel)
-{
- SP_COLOR_SELECTOR(csel)->base = new ColorGtkselector( SP_COLOR_SELECTOR(csel) );
-
- if ( SP_COLOR_SELECTOR(csel)->base )
- {
- SP_COLOR_SELECTOR(csel)->base->init();
- }
-}
-
-void ColorGtkselector::init()
-{
- GtkWidget *gtksel = gtk_color_selection_new();
- gtk_widget_show (gtksel);
- _gtkThing = GTK_COLOR_SELECTION (gtksel);
- gtk_box_pack_start (GTK_BOX (_csel), gtksel, TRUE, TRUE, 0);
-
- _sigId = g_signal_connect(gtksel, "color-changed", G_CALLBACK( _gtkChanged ), _csel);
-}
-
-static void sp_color_gtkselector_dispose(GObject *object)
-{
- if (((GObjectClass *) (parent_class))->dispose)
- (* ((GObjectClass *) (parent_class))->dispose) (object);
-}
-
-static void
-sp_color_gtkselector_show_all (GtkWidget *widget)
-{
- gtk_widget_show (widget);
-}
-
-static void sp_color_gtkselector_hide(GtkWidget *widget)
-{
- gtk_widget_hide(widget);
-}
-
-GtkWidget *
-sp_color_gtkselector_new( GType )
-{
- SPColorGtkselector *csel;
-
- csel = (SPColorGtkselector*)g_object_new (SP_TYPE_COLOR_GTKSELECTOR, NULL);
-
- return GTK_WIDGET (csel);
-}
-
-ColorGtkselector::ColorGtkselector( SPColorSelector* csel )
- : ColorSelector( csel ),
- _gtkThing(0)
-{
-}
-
-ColorGtkselector::~ColorGtkselector()
-{
-}
-
-void ColorGtkselector::_colorChanged()
-{
- GdkColor gcolor;
-
- gcolor.pixel = 0;
- gcolor.red = static_cast< guint16 >(_color.v.c[0] * 65535);
- gcolor.green = static_cast< guint16 >(_color.v.c[1] * 65535);
- gcolor.blue = static_cast< guint16 >(_color.v.c[2] * 65535);
-
-// g_message( "***** _colorChanged %04x %04x %04x", gcolor.red, gcolor.green, gcolor.blue );
- g_signal_handler_block( _gtkThing, _sigId );
- gtk_color_selection_set_current_alpha( _gtkThing, static_cast<guint16>(65535 * _alpha) );
- gtk_color_selection_set_current_color( _gtkThing, &gcolor );
- g_signal_handler_unblock(_gtkThing, _sigId );
-}
-
-void ColorGtkselector::_gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel )
-{
- GdkColor color;
- gtk_color_selection_get_current_color (colorselection, &color);
-
- guint16 alpha = gtk_color_selection_get_current_alpha (colorselection);
-
- SPColor ourColor( (color.red / 65535.0), (color.green / 65535.0), (color.blue / 65535.0) );
-
-// g_message( "***** _gtkChanged %04x %04x %04x", color.red, color.green, color.blue );
-
- ColorGtkselector* gtkInst = static_cast<ColorGtkselector *>(SP_COLOR_SELECTOR(gtksel)->base);
- gtkInst->_updateInternals( ourColor, static_cast< gfloat > (alpha) / 65535.0, gtk_color_selection_is_adjusting(colorselection) );
-}
diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h
deleted file mode 100644
index 3142406c1..000000000
--- a/src/widgets/sp-color-gtkselector.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef SEEN_SP_COLOR_GTKSELECTOR_H
-#define SEEN_SP_COLOR_GTKSELECTOR_H
-
-#include <gtk/gtk.h>
-#include "../color.h"
-#include "sp-color-selector.h"
-
-#include <glib.h>
-
-
-
-struct SPColorGtkselector;
-
-
-
-class ColorGtkselector: public ColorSelector
-{
-public:
- ColorGtkselector( SPColorSelector* csel );
- virtual ~ColorGtkselector();
-
- virtual void init();
-
-protected:
- static void _gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel );
-
- virtual void _colorChanged();
-
- GtkColorSelection* _gtkThing;
- gulong _sigId;
-};
-
-
-
-#define SP_TYPE_COLOR_GTKSELECTOR (sp_color_gtkselector_get_type ())
-#define SP_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselector))
-#define SP_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_GTKSELECTOR, SPColorGtkselectorClass))
-#define SP_IS_COLOR_GTKSELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_GTKSELECTOR))
-#define SP_IS_COLOR_GTKSELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_GTKSELECTOR))
-
-struct SPColorGtkselector {
- SPColorSelector base;
-};
-
-struct SPColorGtkselectorClass {
- SPColorSelectorClass parent_class;
-};
-
-GType sp_color_gtkselector_get_type (void);
-
-GtkWidget *sp_color_gtkselector_new( GType selector_type );
-
-
-
-#endif // SEEN_SP_COLOR_GTKSELECTOR_H
diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp
index d04f17a30..80974c2e4 100644
--- a/src/widgets/sp-color-icc-selector.cpp
+++ b/src/widgets/sp-color-icc-selector.cpp
@@ -272,13 +272,17 @@ void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const
void ColorICCSelector::init()
{
- GtkWidget *t;
gint row = 0;
_updating = FALSE;
_dragging = FALSE;
- t = gtk_table_new (5, 3, FALSE);
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *t = gtk_grid_new();
+#else
+ GtkWidget *t = gtk_table_new(5, 3, FALSE);
+#endif
+
gtk_widget_show (t);
gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4);
@@ -299,7 +303,16 @@ void ColorICCSelector::init()
gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") );
//gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 );
gtk_widget_show( _fixupBtn );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_fixupBtn, XPAD);
+ gtk_widget_set_margin_right(_fixupBtn, XPAD);
+ gtk_widget_set_margin_top(_fixupBtn, YPAD);
+ gtk_widget_set_margin_bottom(_fixupBtn, YPAD);
+ gtk_grid_attach(GTK_GRID(t), _fixupBtn, 0, row, 1, 1);
+#else
gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );
+#endif
// Combobox and store with 2 columns : label (0) and full name (1)
GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -315,7 +328,16 @@ void ColorICCSelector::init()
gtk_widget_show( _profileSel );
gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_profileSel, XPAD);
+ gtk_widget_set_margin_right(_profileSel, XPAD);
+ gtk_widget_set_margin_top(_profileSel, YPAD);
+ gtk_widget_set_margin_bottom(_profileSel, YPAD);
+ gtk_grid_attach(GTK_GRID(t), _profileSel, 1, row, 1, 1);
+#else
gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );
+#endif
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
_profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this );
@@ -342,7 +364,16 @@ void ColorICCSelector::init()
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 );
gtk_widget_show( _fooLabel[i] );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_fooLabel[i], XPAD);
+ gtk_widget_set_margin_right(_fooLabel[i], XPAD);
+ gtk_widget_set_margin_top(_fooLabel[i], YPAD);
+ gtk_widget_set_margin_bottom(_fooLabel[i], YPAD);
+ gtk_grid_attach(GTK_GRID(t), _fooLabel[i], 0, row, 1, 1);
+#else
gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );
+#endif
/* Adjustment */
gdouble step = static_cast<gdouble>(_fooScales[i]) / 100.0;
@@ -358,7 +389,17 @@ void ColorICCSelector::init()
gtk_widget_set_tooltip_text( _fooSlider[i], "." );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
gtk_widget_show( _fooSlider[i] );
- gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_fooSlider[i], XPAD);
+ gtk_widget_set_margin_right(_fooSlider[i], XPAD);
+ gtk_widget_set_margin_top(_fooSlider[i], YPAD);
+ gtk_widget_set_margin_bottom(_fooSlider[i], YPAD);
+ gtk_widget_set_hexpand(_fooSlider[i], TRUE);
+ gtk_grid_attach(GTK_GRID(t), _fooSlider[i], 1, row, 1, 1);
+#else
+ gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD );
+#endif
_fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits );
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -369,7 +410,18 @@ void ColorICCSelector::init()
sp_dialog_defocus_on_enter( _fooBtn[i] );
gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] );
gtk_widget_show( _fooBtn[i] );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_fooBtn[i], XPAD);
+ gtk_widget_set_margin_right(_fooBtn[i], XPAD);
+ gtk_widget_set_margin_top(_fooBtn[i], YPAD);
+ gtk_widget_set_margin_bottom(_fooBtn[i], YPAD);
+ gtk_widget_set_halign(_fooBtn[i], GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(_fooBtn[i], GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(t), _fooBtn[i], 2, row, 1, 1);
+#else
gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD );
+#endif
_fooMap[i] = g_new( guchar, 4 * 1024 );
memset( _fooMap[i], 0x0ff, 1024 * 4 );
@@ -389,7 +441,16 @@ void ColorICCSelector::init()
_label = gtk_label_new_with_mnemonic (_("_A:"));
gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5);
gtk_widget_show (_label);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_label, XPAD);
+ gtk_widget_set_margin_right(_label, XPAD);
+ gtk_widget_set_margin_top(_label, YPAD);
+ gtk_widget_set_margin_bottom(_label, YPAD);
+ gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
+#endif
/* Adjustment */
_adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
@@ -398,7 +459,17 @@ void ColorICCSelector::init()
_slider = sp_color_slider_new (_adj);
gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)"));
gtk_widget_show (_slider);
- gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_slider, XPAD);
+ gtk_widget_set_margin_right(_slider, XPAD);
+ gtk_widget_set_margin_top(_slider, YPAD);
+ gtk_widget_set_margin_bottom(_slider, YPAD);
+ gtk_widget_set_hexpand(_slider, TRUE);
+ gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1);
+#else
+ gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD);
+#endif
sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ),
SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ),
@@ -412,7 +483,18 @@ void ColorICCSelector::init()
sp_dialog_defocus_on_enter (_sbtn);
gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn);
gtk_widget_show (_sbtn);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_sbtn, XPAD);
+ gtk_widget_set_margin_right(_sbtn, XPAD);
+ gtk_widget_set_margin_top(_sbtn, YPAD);
+ gtk_widget_set_margin_bottom(_sbtn, YPAD);
+ gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
+#endif
/* Signals */
g_signal_connect (G_OBJECT (_adj), "value_changed",
@@ -510,9 +592,9 @@ void ColorICCSelector::_switchToProfile( gchar const* name )
if ( trans ) {
guint32 val = _color.toRGBA32(0);
guchar pre[4] = {
- SP_RGBA32_R_U(val),
- SP_RGBA32_G_U(val),
- SP_RGBA32_B_U(val),
+ static_cast<guchar>(SP_RGBA32_R_U(val)),
+ static_cast<guchar>(SP_RGBA32_G_U(val)),
+ static_cast<guchar>(SP_RGBA32_B_U(val)),
255};
#ifdef DEBUG_LCMS
g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]);
diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp
index bafc75b18..fa586ce5f 100644
--- a/src/widgets/sp-color-notebook.cpp
+++ b/src/widgets/sp-color-notebook.cpp
@@ -107,7 +107,7 @@ sp_color_notebook_switch_page(GtkNotebook *notebook,
{
if ( colorbook )
{
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
nb->switchPage( notebook, page, page_num );
// remember the page we switched to
@@ -144,7 +144,7 @@ static gint sp_color_notebook_menu_handler( GtkWidget *widget, GdkEvent *event )
if (event->type == GDK_BUTTON_PRESS)
{
SPColorSelector* csel = SP_COLOR_SELECTOR(widget);
- ((ColorNotebook*)(csel->base))->menuHandler( event );
+ (dynamic_cast<ColorNotebook*>(csel->base))->menuHandler( event );
/* Tell calling code that we have handled this event; the buck
* stops here. */
@@ -173,11 +173,11 @@ static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer
{
if ( active )
{
- ((ColorNotebook*)(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode);
+ (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->addPage(entry->type, entry->submode);
}
else
{
- ((ColorNotebook*)(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode);
+ (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(entry->backPointer)->base))->removePage(entry->type, entry->submode);
}
}
}
@@ -195,7 +195,6 @@ sp_color_notebook_init (SPColorNotebook *colorbook)
void ColorNotebook::init()
{
- GtkWidget* table = 0;
guint row = 0;
guint i = 0;
guint j = 0;
@@ -279,22 +278,49 @@ void ColorNotebook::init()
}
}
- table = gtk_table_new (2, 3, FALSE);
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget* table = gtk_grid_new();
+#else
+ GtkWidget* table = gtk_table_new(2, 3, FALSE);
+#endif
+
gtk_widget_show (table);
gtk_box_pack_start (GTK_BOX (_csel), table, TRUE, TRUE, 0);
sp_set_font_size_smaller (_buttonbox);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_buttonbox, XPAD);
+ gtk_widget_set_margin_right(_buttonbox, XPAD);
+ gtk_widget_set_margin_top(_buttonbox, YPAD);
+ gtk_widget_set_margin_bottom(_buttonbox, YPAD);
+ gtk_widget_set_hexpand(_buttonbox, TRUE);
+ gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), _buttonbox, 0, row, 2, 1);
+#else
gtk_table_attach (GTK_TABLE (table), _buttonbox, 0, 2, row, row + 1,
static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL),
- static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL),
+ static_cast<GtkAttachOptions>(0),
XPAD, YPAD);
+#endif
+
row++;
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_book, XPAD*2);
+ gtk_widget_set_margin_right(_book, XPAD*2);
+ gtk_widget_set_margin_top(_book, YPAD);
+ gtk_widget_set_margin_bottom(_book, YPAD);
+ gtk_widget_set_hexpand(_book, TRUE);
+ gtk_widget_set_vexpand(_book, TRUE);
+ gtk_grid_attach(GTK_GRID(table), _book, 0, row, 2, 1);
+#else
gtk_table_attach (GTK_TABLE (table), _book, 0, 2, row, row + 1,
static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL),
static_cast<GtkAttachOptions>(GTK_EXPAND|GTK_FILL),
XPAD*2, YPAD);
+#endif
// restore the last active page
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -349,7 +375,6 @@ void ColorNotebook::init()
#if GTK_CHECK_VERSION(3,0,0)
GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(rgbabox), FALSE);
#else
GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0);
#endif
@@ -376,7 +401,6 @@ void ColorNotebook::init()
gtk_widget_set_tooltip_text (_box_toomuchink, _("Too much ink!"));
gtk_widget_set_sensitive (_box_toomuchink, false);
gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2);
-
#endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -411,7 +435,15 @@ void ColorNotebook::init()
gtk_widget_hide(GTK_WIDGET(_box_toomuchink));
#endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(rgbabox, XPAD);
+ gtk_widget_set_margin_right(rgbabox, XPAD);
+ gtk_widget_set_margin_top(rgbabox, YPAD);
+ gtk_widget_set_margin_bottom(rgbabox, YPAD);
+ gtk_grid_attach(GTK_GRID(table), rgbabox, 0, row, 2, 1);
+#else
gtk_table_attach (GTK_TABLE (table), rgbabox, 0, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD);
+#endif
#ifdef SPCS_PREVIEW
_p = sp_color_preview_new (0xffffffff);
@@ -467,14 +499,11 @@ static void sp_color_notebook_hide(GtkWidget *widget)
gtk_widget_hide(widget);
}
-GtkWidget *
-sp_color_notebook_new (void)
+GtkWidget *sp_color_notebook_new()
{
- SPColorNotebook *colorbook;
-
- colorbook = (SPColorNotebook*)g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL);
+ SPColorNotebook *colorbook = SP_COLOR_NOTEBOOK(g_object_new (SP_TYPE_COLOR_NOTEBOOK, NULL));
- return GTK_WIDGET (colorbook);
+ return GTK_WIDGET(colorbook);
}
ColorNotebook::ColorNotebook( SPColorSelector* csel )
@@ -520,7 +549,7 @@ void ColorNotebook::_picker_clicked(GtkWidget *widget, SPColorNotebook *colorboo
void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colorbook)
{
- ((ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base))->_rgbaEntryChanged( entry );
+ (dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base))->_rgbaEntryChanged( entry );
}
void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry)
@@ -630,7 +659,7 @@ void ColorNotebook::_setCurrentPage(int i)
void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook)
{
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget))) {
return;
@@ -645,14 +674,14 @@ void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorboo
void ColorNotebook::_entryGrabbed (SPColorSelector *, SPColorNotebook *colorbook)
{
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
nb->_grabbed();
}
void ColorNotebook::_entryDragged (SPColorSelector *csel, SPColorNotebook *colorbook)
{
gboolean oldState;
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
oldState = nb->_dragging;
@@ -664,14 +693,14 @@ void ColorNotebook::_entryDragged (SPColorSelector *csel, SPColorNotebook *color
void ColorNotebook::_entryReleased (SPColorSelector *, SPColorNotebook *colorbook)
{
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
nb->_released();
}
void ColorNotebook::_entryChanged (SPColorSelector *csel, SPColorNotebook *colorbook)
{
gboolean oldState;
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
oldState = nb->_dragging;
@@ -688,7 +717,7 @@ void ColorNotebook::_entryModified (SPColorSelector *csel, SPColorNotebook *colo
g_return_if_fail (csel != NULL);
g_return_if_fail (SP_IS_COLOR_SELECTOR (csel));
- ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
+ ColorNotebook* nb = dynamic_cast<ColorNotebook*>(SP_COLOR_SELECTOR(colorbook)->base);
SPColor color;
gfloat alpha = 1.0;
diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp
index 1af5a1068..95c6d341d 100644
--- a/src/widgets/sp-color-scales.cpp
+++ b/src/widgets/sp-color-scales.cpp
@@ -133,13 +133,16 @@ void sp_color_scales_init (SPColorScales *cs)
void ColorScales::init()
{
- GtkWidget *t;
gint i;
_updating = FALSE;
_dragging = FALSE;
- t = gtk_table_new (5, 3, FALSE);
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *t = gtk_grid_new();
+#else
+ GtkWidget *t = gtk_table_new (5, 3, FALSE);
+#endif
gtk_widget_show (t);
gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4);
@@ -149,20 +152,51 @@ void ColorScales::init()
_l[i] = gtk_label_new("");
gtk_misc_set_alignment (GTK_MISC (_l[i]), 1.0, 0.5);
gtk_widget_show (_l[i]);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_l[i], XPAD);
+ gtk_widget_set_margin_right(_l[i], XPAD);
+ 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] = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0);
/* Slider */
_s[i] = sp_color_slider_new (_a[i]);
gtk_widget_show (_s[i]);
- gtk_table_attach (GTK_TABLE (t), _s[i], 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_s[i], XPAD);
+ gtk_widget_set_margin_right(_s[i], XPAD);
+ gtk_widget_set_margin_top(_s[i], YPAD);
+ gtk_widget_set_margin_bottom(_s[i], YPAD);
+ gtk_widget_set_hexpand(_s[i], TRUE);
+ gtk_grid_attach(GTK_GRID(t), _s[i], 1, i, 1, 1);
+#else
+ gtk_table_attach (GTK_TABLE (t), _s[i], 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);
sp_dialog_defocus_on_enter (_b[i]);
gtk_label_set_mnemonic_widget (GTK_LABEL(_l[i]), _b[i]);
gtk_widget_show (_b[i]);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_b[i], XPAD);
+ gtk_widget_set_margin_right(_b[i], XPAD);
+ gtk_widget_set_margin_top(_b[i], YPAD);
+ gtk_widget_set_margin_bottom(_b[i], YPAD);
+ 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));
@@ -198,12 +232,9 @@ static void sp_color_scales_hide(GtkWidget *widget)
gtk_widget_hide(widget);
}
-GtkWidget *
-sp_color_scales_new (void)
+GtkWidget *sp_color_scales_new()
{
- SPColorScales *csel;
-
- csel = (SPColorScales*)g_object_new (SP_TYPE_COLOR_SCALES, NULL);
+ SPColorScales *csel = SP_COLOR_SCALES(g_object_new (SP_TYPE_COLOR_SCALES, NULL));
return GTK_WIDGET (csel);
}
diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp
index d58d495bb..3ba748f2b 100644
--- a/src/widgets/sp-color-slider.cpp
+++ b/src/widgets/sp-color-slider.cpp
@@ -373,12 +373,9 @@ sp_color_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event)
return FALSE;
}
-GtkWidget *
-sp_color_slider_new (GtkAdjustment *adjustment)
+GtkWidget *sp_color_slider_new(GtkAdjustment *adjustment)
{
- SPColorSlider *slider;
-
- slider = (SPColorSlider*)g_object_new (SP_TYPE_COLOR_SLIDER, NULL);
+ SPColorSlider *slider = SP_COLOR_SLIDER(g_object_new(SP_TYPE_COLOR_SLIDER, NULL));
sp_color_slider_set_adjustment (slider, adjustment);
@@ -651,13 +648,22 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr)
gint w = ARROW_SIZE;
cairo_set_line_width(cr, 1.0);
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA white = {1,1,1,1};
+ GdkRGBA black = {0,0,0,1};
+#else
GdkColor white, black;
gdk_color_parse("#fff", &white);
gdk_color_parse("#000", &black);
+#endif
while ( w > 0 )
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_cairo_set_source_rgba(cr, &white);
+#else
gdk_cairo_set_source_color(cr, &white);
+#endif
cairo_move_to(cr, x - 0.5, y1 + 0.5);
cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5);
cairo_move_to(cr, x - 0.5, y2 + 0.5);
@@ -667,7 +673,11 @@ static gboolean sp_color_slider_draw(GtkWidget *widget, cairo_t *cr)
x++;
if ( w > 0 )
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gdk_cairo_set_source_rgba(cr, &black);
+#else
gdk_cairo_set_source_color(cr, &black);
+#endif
cairo_move_to(cr, x - 0.5, y1 + 0.5);
cairo_line_to(cr, x + w - 1 + 0.5, y1 + 0.5);
cairo_move_to(cr, x - 0.5, y2 + 0.5);
diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp
index 4cc9f9e4a..a979a168a 100644
--- a/src/widgets/sp-color-wheel-selector.cpp
+++ b/src/widgets/sp-color-wheel-selector.cpp
@@ -109,7 +109,8 @@ static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation )
gint diam = std::min(allocation->width, allocation->height);
// drop a little for resizing
- diam -= 4;
+ // This magic number stops the dialog expanding in width when resizing height
+ diam -= 16;
GtkStyle *style = gtk_widget_get_style( GTK_WIDGET(hsv) );
if ( style ) {
@@ -145,13 +146,17 @@ static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpoint
void ColorWheelSelector::init()
{
- GtkWidget *t;
gint row = 0;
_updating = FALSE;
_dragging = FALSE;
- t = gtk_table_new (5, 3, FALSE);
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *t = gtk_grid_new();
+#else
+ GtkWidget *t = gtk_table_new (5, 3, FALSE);
+#endif
+
gtk_widget_show (t);
gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 0);
@@ -161,7 +166,16 @@ void ColorWheelSelector::init()
_wheel = gtk_hsv_new();
gtk_hsv_set_metrics( GTK_HSV(_wheel), 48, 8 );
gtk_widget_show( _wheel );
- gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), XPAD, YPAD);
+
+#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(t), _wheel, 0, row, 3, 1);
+#else
+ gtk_table_attach(GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
+#endif
row++;
@@ -169,7 +183,18 @@ void ColorWheelSelector::init()
_label = gtk_label_new_with_mnemonic (_("_A:"));
gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5);
gtk_widget_show (_label);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_label, XPAD);
+ gtk_widget_set_margin_right(_label, XPAD);
+ gtk_widget_set_margin_top(_label, YPAD);
+ gtk_widget_set_margin_bottom(_label, YPAD);
+ gtk_widget_set_halign(_label, GTK_ALIGN_FILL);
+ gtk_widget_set_valign(_label, GTK_ALIGN_FILL);
+ gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
+#endif
/* Adjustment */
_adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0);
@@ -178,7 +203,19 @@ void ColorWheelSelector::init()
_slider = sp_color_slider_new (_adj);
gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)"));
gtk_widget_show (_slider);
- gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_slider, XPAD);
+ gtk_widget_set_margin_right(_slider, XPAD);
+ gtk_widget_set_margin_top(_slider, YPAD);
+ gtk_widget_set_margin_bottom(_slider, YPAD);
+ gtk_widget_set_hexpand(_slider, TRUE);
+ gtk_widget_set_halign(_slider, GTK_ALIGN_FILL);
+ gtk_widget_set_valign(_slider, GTK_ALIGN_FILL);
+ gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1);
+#else
+ gtk_table_attach(GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD);
+#endif
sp_color_slider_set_colors (SP_COLOR_SLIDER (_slider),
SP_RGBA32_F_COMPOSE (1.0, 1.0, 1.0, 0.0),
@@ -192,7 +229,18 @@ void ColorWheelSelector::init()
sp_dialog_defocus_on_enter (_sbtn);
gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn);
gtk_widget_show (_sbtn);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(_sbtn, XPAD);
+ gtk_widget_set_margin_right(_sbtn, XPAD);
+ gtk_widget_set_margin_top(_sbtn, YPAD);
+ gtk_widget_set_margin_bottom(_sbtn, YPAD);
+ gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);
+#endif
/* Signals */
g_signal_connect (G_OBJECT (_adj), "value_changed",
@@ -233,12 +281,9 @@ static void sp_color_wheel_selector_hide(GtkWidget *widget)
gtk_widget_hide(widget);
}
-GtkWidget *
-sp_color_wheel_selector_new (void)
+GtkWidget *sp_color_wheel_selector_new()
{
- SPColorWheelSelector *csel;
-
- csel = (SPColorWheelSelector*)g_object_new (SP_TYPE_COLOR_WHEEL_SELECTOR, NULL);
+ SPColorWheelSelector *csel = SP_COLOR_WHEEL_SELECTOR(g_object_new (SP_TYPE_COLOR_WHEEL_SELECTOR, NULL));
return GTK_WIDGET (csel);
}
diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp
index 8e7c94572..1fd120d17 100644
--- a/src/widgets/sp-xmlview-attr-list.cpp
+++ b/src/widgets/sp-xmlview-attr-list.cpp
@@ -41,12 +41,9 @@ static Inkscape::XML::NodeEventVector repr_events = {
NULL /* order_changed */
};
-GtkWidget *
-sp_xmlview_attr_list_new (Inkscape::XML::Node * repr)
+GtkWidget *sp_xmlview_attr_list_new (Inkscape::XML::Node * repr)
{
- SPXMLViewAttrList * attr_list;
-
- attr_list = (SPXMLViewAttrList*)g_object_new (SP_TYPE_XMLVIEW_ATTR_LIST, NULL);
+ SPXMLViewAttrList * attr_list = SP_XMLVIEW_ATTR_LIST(g_object_new(SP_TYPE_XMLVIEW_ATTR_LIST, NULL));
attr_list->store = gtk_list_store_new (ATTR_N_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING );
gtk_tree_view_set_model (GTK_TREE_VIEW(attr_list), GTK_TREE_MODEL(attr_list->store));
diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp
index bf740baa0..d31e031c2 100644
--- a/src/widgets/sp-xmlview-content.cpp
+++ b/src/widgets/sp-xmlview-content.cpp
@@ -46,14 +46,10 @@ static Inkscape::XML::NodeEventVector repr_events = {
NULL /* order_changed */
};
-GtkWidget *
-sp_xmlview_content_new (Inkscape::XML::Node * repr)
+GtkWidget *sp_xmlview_content_new(Inkscape::XML::Node * repr)
{
- GtkTextBuffer *tb;
- SPXMLViewContent *text;
-
- tb = gtk_text_buffer_new (NULL);
- text = (SPXMLViewContent*)g_object_new (SP_TYPE_XMLVIEW_CONTENT, NULL);
+ GtkTextBuffer *tb = gtk_text_buffer_new(NULL);
+ SPXMLViewContent *text = SP_XMLVIEW_CONTENT(g_object_new(SP_TYPE_XMLVIEW_CONTENT, NULL));
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text), tb);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text), GTK_WRAP_CHAR);
diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp
index 11e6717c1..258cea0b4 100644
--- a/src/widgets/sp-xmlview-tree.cpp
+++ b/src/widgets/sp-xmlview-tree.cpp
@@ -95,16 +95,13 @@ static const Inkscape::XML::NodeEventVector pi_repr_events = {
static GtkTreeViewClass * parent_class = NULL;
-GtkWidget *
-sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/)
+GtkWidget *sp_xmlview_tree_new(Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/)
{
- SPXMLViewTree * tree;
-
- tree = (SPXMLViewTree*)g_object_new (SP_TYPE_XMLVIEW_TREE, NULL);
+ SPXMLViewTree *tree = SP_XMLVIEW_TREE(g_object_new (SP_TYPE_XMLVIEW_TREE, NULL));
- tree->store = gtk_tree_store_new (STORE_N_COLS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);
+ tree->store = gtk_tree_store_new (STORE_N_COLS, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);
- // Detach the model from the view until all the data is loaded
+ // Detach the model from the view until all the data is loaded
g_object_ref(tree->store);
gtk_tree_view_set_model(GTK_TREE_VIEW(tree), NULL);
@@ -125,7 +122,7 @@ sp_xmlview_tree_new (Inkscape::XML::Node * repr, void * /*factory*/, void * /*da
g_signal_connect(GTK_TREE_VIEW(tree), "drag_data_received", G_CALLBACK(on_drag_data_received), tree);
g_signal_connect(GTK_TREE_VIEW(tree), "drag-motion", G_CALLBACK(do_drag_motion), tree);
- return (GtkWidget *) tree;
+ return (GtkWidget *) tree;
}
GType
@@ -264,93 +261,80 @@ NodeData *node_data_new(SPXMLViewTree * tree, GtkTreeIter * /*node*/, GtkTreeRow
return data;
}
-void
-node_data_free (gpointer ptr) {
- NodeData * data;
- data = (NodeData *) ptr;
- sp_repr_remove_listener_by_data (data->repr, data);
- g_assert (data->repr != NULL);
- Inkscape::GC::release(data->repr);
- g_free (data);
+void node_data_free(gpointer ptr)
+{
+ NodeData *data = static_cast<NodeData *>(ptr);
+ sp_repr_remove_listener_by_data (data->repr, data);
+ g_assert (data->repr != NULL);
+ Inkscape::GC::release(data->repr);
+ g_free (data);
}
-void
-element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr)
+void element_child_added (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * ref, gpointer ptr)
{
- NodeData * data;
- GtkTreeIter before;
+ NodeData *data = static_cast<NodeData *>(ptr);
+ GtkTreeIter before;
- data = (NodeData *) ptr;
+ if (data->tree->blocked) return;
- if (data->tree->blocked) return;
-
- if (!ref_to_sibling (data, ref, &before)) {
- return;
- }
+ if (!ref_to_sibling (data, ref, &before)) {
+ return;
+ }
GtkTreeIter data_iter;
tree_ref_to_iter(data->tree, &data_iter, data->rowref);
- add_node (data->tree, &data_iter, &before, child);
+ add_node (data->tree, &data_iter, &before, child);
}
-void
-element_attr_changed (Inkscape::XML::Node * repr, const gchar * key, const gchar * /*old_value*/, const gchar * new_value, bool /*is_interactive*/, gpointer ptr)
+void element_attr_changed(Inkscape::XML::Node * repr, const gchar * key, const gchar * /*old_value*/, const gchar * new_value, bool /*is_interactive*/, gpointer ptr)
{
- NodeData * data;
- gchar *label;
- const gchar *layer;
-
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData *>(ptr);
+ gchar *label;
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- if (0 != strcmp (key, "id") && 0 != strcmp (key, "inkscape:label"))
- return;
+ if (0 != strcmp (key, "id") && 0 != strcmp (key, "inkscape:label"))
+ return;
- new_value = repr->attribute("id");
- layer = repr->attribute("inkscape:label");
+ new_value = repr->attribute("id");
+ const gchar *layer = repr->attribute("inkscape:label");
- if (new_value && layer) {
- label = g_strdup_printf ("<%s id=\"%s\" inkscape:label=\"%s\">", repr->name(), new_value, layer);
- } else if (new_value) {
- label = g_strdup_printf ("<%s id=\"%s\">", repr->name(), new_value);
- } else {
- label = g_strdup_printf ("<%s>", repr->name());
- }
+ if (new_value && layer) {
+ label = g_strdup_printf ("<%s id=\"%s\" inkscape:label=\"%s\">", repr->name(), new_value, layer);
+ } else if (new_value) {
+ label = g_strdup_printf ("<%s id=\"%s\">", repr->name(), new_value);
+ } else {
+ label = g_strdup_printf ("<%s>", repr->name());
+ }
- GtkTreeIter iter;
- if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
- gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
- }
- g_free (label);
+ GtkTreeIter iter;
+ if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
+ gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
+ }
+ g_free (label);
}
-void
-element_child_removed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr)
+void element_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*ref*/, gpointer ptr)
{
- NodeData * data;
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData *>(ptr);
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- GtkTreeIter iter;
- if (repr_to_child (data, child, &iter)) {
+ GtkTreeIter iter;
+ if (repr_to_child (data, child, &iter)) {
gtk_tree_store_remove (GTK_TREE_STORE(data->tree->store), &iter);
}
-
}
-void
-element_order_changed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr)
+void element_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * child, Inkscape::XML::Node * /*oldref*/, Inkscape::XML::Node * newref, gpointer ptr)
{
- NodeData * data;
- GtkTreeIter before, node;
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData *>(ptr);
+ GtkTreeIter before, node;
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- ref_to_sibling (data, newref, &before);
- repr_to_child (data, child, &node);
+ ref_to_sibling (data, newref, &before);
+ repr_to_child (data, child, &node);
if (gtk_tree_store_iter_is_valid(data->tree->store, &before)) {
gtk_tree_store_move_before (data->tree->store, &node, &before);
@@ -360,59 +344,47 @@ element_order_changed (Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node * chi
}
}
-void
-text_content_changed (Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer ptr)
+void text_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar * new_content, gpointer ptr)
{
- NodeData *data;
- gchar *label;
-
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData *>(ptr);
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- label = g_strdup_printf ("\"%s\"", new_content);
+ gchar *label = g_strdup_printf ("\"%s\"", new_content);
GtkTreeIter iter;
if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
}
- g_free (label);
+ g_free (label);
}
-void
-comment_content_changed (Inkscape::XML::Node */*repr*/, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
+void comment_content_changed(Inkscape::XML::Node * /*repr*/, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
{
- NodeData *data;
- gchar *label;
-
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData*>(ptr);
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- label = g_strdup_printf ("<!--%s-->", new_content);
+ gchar *label = g_strdup_printf ("<!--%s-->", new_content);
GtkTreeIter iter;
if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
}
- g_free (label);
+ g_free (label);
}
-void
-pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
+void pi_content_changed(Inkscape::XML::Node *repr, const gchar * /*old_content*/, const gchar *new_content, gpointer ptr)
{
- NodeData *data;
- gchar *label;
-
- data = (NodeData *) ptr;
+ NodeData *data = static_cast<NodeData *>(ptr);
- if (data->tree->blocked) return;
+ if (data->tree->blocked) return;
- label = g_strdup_printf ("<?%s %s?>", repr->name(), new_content);
+ gchar *label = g_strdup_printf ("<?%s %s?>", repr->name(), new_content);
GtkTreeIter iter;
if (tree_ref_to_iter(data->tree, &iter, data->rowref)) {
gtk_tree_store_set (GTK_TREE_STORE(data->tree->store), &iter, STORE_TEXT_COL, label, -1);
}
- g_free (label);
+ g_free (label);
}
/*
@@ -454,7 +426,7 @@ void on_drag_data_received(GtkWidget * /*wgt*/, GdkDragContext * /*context*/, in
*/
void on_row_changed(GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
{
- SPXMLViewTree *tree = (SPXMLViewTree *)user_data;
+ SPXMLViewTree *tree = SP_XMLVIEW_TREE(user_data);
if (!tree->dndactive) {
return;
@@ -634,7 +606,7 @@ gboolean do_drag_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint
if (path) {
action = GDK_ACTION_MOVE;
- SPXMLViewTree *tree = (SPXMLViewTree *)user_data;
+ SPXMLViewTree *tree = SP_XMLVIEW_TREE(user_data);
GtkTreeIter iter;
gtk_tree_model_get_iter(GTK_TREE_MODEL(tree->store), &iter, path);
if (sp_xmlview_tree_node_get_repr (GTK_TREE_MODEL(tree->store), &iter)->type() != Inkscape::XML::ELEMENT_NODE) {
@@ -762,3 +734,14 @@ gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *ke
return !match;
}
+
+/*
+ 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/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h
index e588e78a7..50fcb3bc8 100644
--- a/src/widgets/sp-xmlview-tree.h
+++ b/src/widgets/sp-xmlview-tree.h
@@ -53,3 +53,14 @@ gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Nod
#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp
index 290b0bb75..1d44b9190 100644
--- a/src/widgets/spinbutton-events.cpp
+++ b/src/widgets/spinbutton-events.cpp
@@ -20,6 +20,7 @@
#include "sp-widget.h"
#include "widget-sizes.h"
+#include "spinbutton-events.h"
gboolean
spinbutton_focus_in (GtkWidget *w, GdkEventKey */*event*/, gpointer /*data*/)
@@ -63,29 +64,27 @@ spinbutton_defocus (GtkWidget *container)
}
}
-gboolean
-spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data)
+gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer data)
{
- SPWidget *spw = (SPWidget *) data;
gdouble v;
gdouble step;
gdouble page;
switch (get_group0_keyval (event)) {
case GDK_KEY_Escape: // defocus
- spinbutton_undo (w);
- spinbutton_defocus(GTK_WIDGET(spw));
+ spinbutton_undo(w);
+ spinbutton_defocus(w);
return TRUE; // I consumed the event
break;
case GDK_KEY_Return: // defocus
case GDK_KEY_KP_Enter:
- spinbutton_defocus (GTK_WIDGET(spw));
+ spinbutton_defocus(w);
return TRUE; // I consumed the event
break;
case GDK_KEY_Tab:
case GDK_KEY_ISO_Left_Tab:
// set the flag meaning "do not leave toolbar when changing value"
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
return FALSE; // I didn't consume the event
break;
@@ -94,45 +93,45 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data)
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
- v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w));
- gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page);
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
+ v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w));
+ gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page);
v += step;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v);
return TRUE; // I consumed the event
break;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
- v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w));
- gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page);
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
+ v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w));
+ gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page);
v -= step;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v);
return TRUE; // I consumed the event
break;
case GDK_KEY_Page_Up:
case GDK_KEY_KP_Page_Up:
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
- v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w));
- gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page);
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
+ v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w));
+ gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page);
v += page;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v);
return TRUE; // I consumed the event
break;
case GDK_KEY_Page_Down:
case GDK_KEY_KP_Page_Down:
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
- v = gtk_spin_button_get_value(GTK_SPIN_BUTTON (w));
- gtk_spin_button_get_increments(GTK_SPIN_BUTTON (w), &step, &page);
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
+ v = gtk_spin_button_get_value(GTK_SPIN_BUTTON(w));
+ gtk_spin_button_get_increments(GTK_SPIN_BUTTON(w), &step, &page);
v -= page;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), v);
return TRUE; // I consumed the event
break;
case GDK_KEY_z:
case GDK_KEY_Z:
- g_object_set_data (G_OBJECT (spw), "stay", GINT_TO_POINTER(TRUE));
+ g_object_set_data(G_OBJECT(w), "stay", GINT_TO_POINTER(TRUE));
if (event->state & GDK_CONTROL_MASK) {
- spinbutton_undo (w);
+ spinbutton_undo(w);
return TRUE; // I consumed the event
}
break;
@@ -142,3 +141,14 @@ spinbutton_keypress (GtkWidget *w, GdkEventKey *event, gpointer data)
}
return FALSE; // I didn't consume the event
}
+
+/*
+ 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/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp
index 34996d24e..c51c8b6cf 100644
--- a/src/widgets/spiral-toolbar.cpp
+++ b/src/widgets/spiral-toolbar.cpp
@@ -78,7 +78,7 @@ using Inkscape::UI::PrefPusher;
static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name)
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -314,7 +314,7 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), (GObject *)holder))
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), holder))
);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index e7db45581..ce8ce388d 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -19,11 +19,17 @@
#include <gtkmm/box.h>
#include <gtkmm/label.h>
+
+#if GTK_CHECK_VERSION(3,0,0)
+#include <gtkmm/grid.h>
+#else
#include <gtkmm/table.h>
+#endif
#include "selection.h"
#include "helper/unit-menu.h"
+#include "spw-utilities.h"
#include <gtk/gtk.h>
@@ -31,8 +37,11 @@
* Creates a label widget with the given text, at the given col, row
* position in the table.
*/
-Gtk::Label *
-spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target)
+#if GTK_CHECK_VERSION(3,0,0)
+Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int row, Gtk::Widget* target)
+#else
+Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Widget* target)
+#endif
{
Gtk::Label *label_widget = new Gtk::Label();
g_assert(label_widget != NULL);
@@ -47,7 +56,18 @@ spw_label(Gtk::Table *table, const gchar *label_text, int col, int row, Gtk::Wid
}
label_widget->set_alignment(1.0, 0.5);
label_widget->show();
+
+#if GTK_CHECK_VERSION(3,0,0)
+ label_widget->set_hexpand();
+ label_widget->set_halign(Gtk::ALIGN_FILL);
+ label_widget->set_valign(Gtk::ALIGN_CENTER);
+ label_widget->set_margin_left(4);
+ label_widget->set_margin_right(4);
+ table->attach(*label_widget, col, row, 1, 1);
+#else
table->attach(*label_widget, col, col+1, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 4, 0);
+#endif
+
return label_widget;
}
@@ -60,8 +80,19 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
g_assert(label_widget != NULL);
gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5);
gtk_widget_show (label_widget);
- gtk_table_attach (GTK_TABLE (table), label_widget, col, col+1, row, row+1,
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(label_widget, 4);
+ gtk_widget_set_margin_right(label_widget, 4);
+ gtk_widget_set_hexpand(label_widget, TRUE);
+ gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL);
+ gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1);
+#else
+ gtk_table_attach(GTK_TABLE (table), label_widget, col, col+1, row, row+1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0);
+#endif
+
return label_widget;
}
@@ -69,14 +100,26 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
* Creates a horizontal layout manager with 4-pixel spacing between children
* and space for 'width' columns.
*/
-Gtk::HBox *
-spw_hbox(Gtk::Table * table, int width, int col, int row)
+#if GTK_CHECK_VERSION(3,0,0)
+Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row)
+#else
+Gtk::HBox * spw_hbox(Gtk::Table * table, int width, int col, int row)
+#endif
{
/* Create a new hbox with a 4-pixel spacing between children */
Gtk::HBox *hb = new Gtk::HBox(false, 4);
g_assert(hb != NULL);
hb->show();
+
+#if GTK_CHECK_VERSION(3,0,0)
+ hb->set_hexpand();
+ hb->set_halign(Gtk::ALIGN_FILL);
+ hb->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*hb, col, row, width, 1);
+#else
table->attach(*hb, col, col+width, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
return hb;
}
@@ -116,16 +159,33 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table,
g_assert(dialog != NULL);
g_assert(table != NULL);
- GtkWidget *l = gtk_label_new (label);
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
- gtk_widget_show (l);
+ GtkWidget *l = gtk_label_new (label);
+ gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+ gtk_widget_show (l);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(l, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(l, TRUE);
+ gtk_widget_set_valign(l, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (table), l, 0, 1, row, row+1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
+#endif
b = gtk_check_button_new ();
gtk_widget_show (b);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(b, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(b, TRUE);
+ gtk_widget_set_valign(b, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (table), b, 1, 2, row, row+1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
+#endif
+
g_object_set_data (G_OBJECT (b), "key", key);
g_object_set_data (G_OBJECT (dialog), key, b);
g_signal_connect (G_OBJECT (b), "toggled", cb, dialog);
@@ -152,8 +212,17 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table,
spw_label_old(table, label_text, 0, row);
gtk_widget_show (selector);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(selector, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(selector, TRUE);
+ gtk_widget_set_valign(selector, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (table), selector, 1, 2, row, row+1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
+#endif
+
g_object_set_data (G_OBJECT (dialog), key, selector);
return selector;
}
@@ -188,13 +257,22 @@ spw_unit_selector(GtkWidget * dialog, GtkWidget * table,
GtkWidget * sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 4);
g_assert(sb != NULL);
gtk_widget_show (sb);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(sb, GTK_ALIGN_FILL);
+ gtk_widget_set_hexpand(sb, TRUE);
+ gtk_widget_set_valign(sb, GTK_ALIGN_CENTER);
+ gtk_grid_attach(GTK_GRID(table), sb, 1, row, 1, 1);
+#else
gtk_table_attach (GTK_TABLE (table), sb, 1, 2, row, row+1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
+#endif
+
g_signal_connect (G_OBJECT (a), "value_changed", cb, dialog);
return sb;
}
-void
+static void
sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
guint size = GPOINTER_TO_UINT (font);
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index 263abbcaf..fb8c04ebf 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -20,18 +20,26 @@
namespace Gtk {
class Label;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ class Grid;
+#else
class Table;
+#endif
+
class HBox;
class Widget;
}
-Gtk::Label *
-spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
-GtkWidget *
-spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row);
+#if GTK_CHECK_VERSION(3,0,0)
+Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
+Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row);
+#else
+Gtk::Label * spw_label(Gtk::Table *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
+Gtk::HBox * spw_hbox(Gtk::Table *table, int width, int col, int row);
+#endif
-Gtk::HBox *
-spw_hbox(Gtk::Table *table, int width, int col, int row);
+GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row);
GtkWidget *
spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *table,
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 61d8e1000..d783e3336 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -74,7 +74,7 @@ using Inkscape::UI::PrefPusher;
static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKludge )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
// do not remember prefs if this call is initiated by an undo change, because undoing object
@@ -120,7 +120,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKludge )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
if (!IS_NAN(gtk_adjustment_get_value(adj))) {
@@ -173,7 +173,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *dataKludge )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
bool flat = ege_select_one_action_get_active( act ) == 0;
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
@@ -218,7 +218,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludge )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -257,7 +257,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKludge )
{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( dataKludge, "desktop" ));
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -584,7 +584,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
}
sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), (GObject *)holder))
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder))
);
g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index 206f166f9..62fa47603 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -57,8 +57,8 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) :
set_model(marker_store);
pack_start(image_renderer, false);
pack_end(label_renderer, true);
- label_renderer.set_padding(5, 0);
- image_renderer.set_padding(5, 0);
+ label_renderer.set_padding(2, 0);
+ image_renderer.set_padding(2, 0);
set_cell_data_func(label_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareLabelRenderer));
set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer));
gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL);
@@ -562,6 +562,7 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname,
void MarkerComboBox::prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ) {
Glib::ustring name=(*row)[marker_columns.label];
label_renderer.property_markup() = name.c_str();
+ label_renderer.property_scale() = 0.8;
}
void MarkerComboBox::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) {
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 5f686881f..7912b654a 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -122,10 +122,17 @@ StrokeStyle::StrokeStyle() :
f->show();
add(*f);
+#if WITH_GTKMM_3_0
+ table = new Gtk::Grid();
+ table->set_border_width(4);
+ table->set_row_spacing(4);
+#else
table = new Gtk::Table(3, 6, false);
- table->show();
table->set_border_width(4);
table->set_row_spacings(4);
+#endif
+
+ table->show();
f->add(*table);
gint i = 0;
@@ -282,7 +289,16 @@ StrokeStyle::StrokeStyle() :
dashSelector = manage(new SPDashSelector);
dashSelector->show();
+
+#if WITH_GTKMM_3_0
+ dashSelector->set_hexpand();
+ dashSelector->set_halign(Gtk::ALIGN_FILL);
+ dashSelector->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*dashSelector, 1, i, 3, 1);
+#else
table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
i++;
@@ -298,7 +314,16 @@ StrokeStyle::StrokeStyle() :
sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START));
startMarkerCombo->show();
+
+#if WITH_GTKMM_3_0
+ startMarkerCombo->set_hexpand();
+ startMarkerCombo->set_halign(Gtk::ALIGN_FILL);
+ startMarkerCombo->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*startMarkerCombo, 1, i, 3, 1);
+#else
table->attach(*startMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
i++;
midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID));
@@ -308,7 +333,16 @@ StrokeStyle::StrokeStyle() :
sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID));
midMarkerCombo->show();
+
+#if WITH_GTKMM_3_0
+ midMarkerCombo->set_hexpand();
+ midMarkerCombo->set_halign(Gtk::ALIGN_FILL);
+ midMarkerCombo->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*midMarkerCombo, 1, i, 3, 1);
+#else
table->attach(*midMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
i++;
endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END));
@@ -318,7 +352,16 @@ StrokeStyle::StrokeStyle() :
sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END));
endMarkerCombo->show();
+
+#if WITH_GTKMM_3_0
+ endMarkerCombo->set_hexpand();
+ endMarkerCombo->set_halign(Gtk::ALIGN_FILL);
+ endMarkerCombo->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*endMarkerCombo, 1, i, 3, 1);
+#else
table->attach(*endMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
i++;
setDesktop(desktop);
@@ -434,14 +477,13 @@ StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, SPMa
item->requestModified(SP_OBJECT_MODIFIED_FLAG);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers"));
}
sp_repr_css_attr_unref(css);
css = 0;
- DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
- _("Set markers"));
-
spw->update = false;
};
@@ -601,7 +643,6 @@ StrokeStyle::forkMarker(SPObject *marker, int loc, SPItem *item)
sp_repr_css_set_property(css_item, marker_id, g_strconcat("url(#", mark_repr->attribute("id"), ")", NULL));
sp_repr_css_change_recursive(item->getRepr(), css_item, "style");
- Inkscape::GC::release(mark_repr);
sp_repr_css_attr_unref(css_item);
css_item = 0;
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index d437f7e12..5f05b97d1 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -15,9 +15,19 @@
#ifndef SEEN_DIALOGS_STROKE_STYLE_H
#define SEEN_DIALOGS_STROKE_STYLE_H
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "widgets/dash-selector.h"
#include <gtkmm/radiobutton.h>
+
+#if WITH_GTKMM_3_0
+#include <gtkmm/grid.h>
+#else
#include <gtkmm/table.h>
+#endif
+
#include <glibmm/i18n.h>
#include "desktop.h"
@@ -139,11 +149,12 @@ private:
MarkerComboBox *startMarkerCombo;
MarkerComboBox *midMarkerCombo;
MarkerComboBox *endMarkerCombo;
- Gtk::Table *table;
#if WITH_GTKMM_3_0
+ Gtk::Grid *table;
Glib::RefPtr<Gtk::Adjustment> *widthAdj;
Glib::RefPtr<Gtk::Adjustment> *miterLimitAdj;
#else
+ Gtk::Table *table;
Gtk::Adjustment *widthAdj;
Gtk::Adjustment *miterLimitAdj;
#endif
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 60ede002f..9e0977d51 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -665,7 +665,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
// move the x of all texts to preserve the same bbox
Inkscape::Selection *selection = sp_desktop_selection(desktop);
for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
- if (SP_IS_TEXT((SPItem *) items->data)) {
+ if (SP_IS_TEXT(SP_ITEM(items->data))) {
SPItem *item = SP_ITEM(items->data);
unsigned writing_mode = item->style->writing_mode.value;
@@ -1087,7 +1087,7 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject *
/*
* Set the default list of font sizes, scaled to the users preferred unit
*/
-void sp_text_set_sizes(GtkListStore* model_size, int unit)
+static void sp_text_set_sizes(GtkListStore* model_size, int unit)
{
gtk_list_store_clear(model_size);
@@ -1156,7 +1156,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
items = items->next) {
// const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
// std::cout << " " << id << std::endl;
- if( SP_IS_FLOWTEXT(( SPItem *) items->data )) {
+ if( SP_IS_FLOWTEXT(SP_ITEM(items->data))) {
isFlow = true;
// std::cout << " Found flowed text" << std::endl;
break;
@@ -1233,7 +1233,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontSizeAction)), unit);
ink_comboboxentry_action_set_active_text( fontSizeAction, os.str().c_str() );
- Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")");
+ Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
ink_comboboxentry_action_set_tooltip ( fontSizeAction, tooltip.c_str());
// Font styles
@@ -1434,7 +1434,7 @@ static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, g
sp_text_toolbox_selection_changed (selection, tbl);
}
-void
+static void
sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl)
{
sp_text_toolbox_selection_changed (NULL, tbl);
@@ -1492,7 +1492,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
sp_text_set_sizes(model_size, unit);
- Glib::ustring tooltip = Glib::ustring::format("Font size (", sp_style_get_css_unit_string(unit), ")");
+ Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontSizeAction",
_("Font Size"),
@@ -1849,17 +1849,17 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
sigc::connection *c_selection_changed =
new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_changed), holder)));
pool->add_connection ("selection-changed", c_selection_changed);
sigc::connection *c_selection_modified =
new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_selection_modified), holder)));
pool->add_connection ("selection-modified", c_selection_modified);
sigc::connection *c_subselection_changed =
new sigc::connection (desktop->connectToolSubselectionChanged
- (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), (GObject*)holder)));
+ (sigc::bind (sigc::ptr_fun (sp_text_toolbox_subselection_changed), holder)));
pool->add_connection ("tool-subselection-changed", c_subselection_changed);
Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool);
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 49eb82de7..a5e929c7d 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -407,6 +407,7 @@ static gchar const * ui_descr =
" <toolbar name='CalligraphyToolbar'>"
" <separator />"
" <toolitem action='SetProfileAction'/>"
+ " <toolitem action='ProfileEditAction'/>"
" <separator />"
" <toolitem action='CalligraphyWidthAction' />"
" <toolitem action='PressureAction' />"
@@ -1423,8 +1424,13 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
GtkWidget* kludge = dataHolders[aux_toolboxes[i].type_name];
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget* holder = gtk_grid_new();
+ gtk_grid_attach( GTK_GRID(holder), kludge, 2, 0, 1, 1);
+#else
GtkWidget* holder = gtk_table_new( 1, 3, FALSE );
gtk_table_attach( GTK_TABLE(holder), kludge, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+#endif
gchar* tmp = g_strdup_printf( "/ui/%s", aux_toolboxes[i].ui_name );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, tmp );
@@ -1438,7 +1444,12 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_hexpand(toolBar, TRUE);
+ gtk_grid_attach( GTK_GRID(holder), toolBar, 0, 0, 1, 1);
+#else
gtk_table_attach( GTK_TABLE(holder), toolBar, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0 );
+#endif
if ( aux_toolboxes[i].swatch_verb_id != SP_VERB_INVALID ) {
Inkscape::UI::Widget::StyleSwatch *swatch = new Inkscape::UI::Widget::StyleSwatch( NULL, _(aux_toolboxes[i].swatch_tip) );
@@ -1446,7 +1457,16 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
swatch->setClickVerb( aux_toolboxes[i].swatch_verb_id );
swatch->setWatchedTool( aux_toolboxes[i].swatch_tool, true );
GtkWidget *swatch_ = GTK_WIDGET( swatch->gobj() );
- gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, 0 );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_margin_left(swatch_, AUX_BETWEEN_BUTTON_GROUPS);
+ gtk_widget_set_margin_right(swatch_, AUX_BETWEEN_BUTTON_GROUPS);
+ gtk_widget_set_margin_top(swatch_, AUX_SPACING);
+ gtk_widget_set_margin_bottom(swatch_, AUX_SPACING);
+ gtk_grid_attach( GTK_GRID(holder), swatch_, 1, 0, 1, 1);
+#else
+ gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, AUX_SPACING );
+#endif
}
gtk_widget_show_all( holder );
diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h
index 644740637..fe89d4574 100644
--- a/src/widgets/widget-sizes.h
+++ b/src/widgets/widget-sizes.h
@@ -29,9 +29,9 @@
#define STATUS_ZOOM_WIDTH 57
-#define SELECTED_STYLE_SB_WIDTH 38
-#define SELECTED_STYLE_WIDTH 180
-#define STYLE_SWATCH_WIDTH 100
+#define SELECTED_STYLE_SB_WIDTH 48
+#define SELECTED_STYLE_WIDTH 190
+#define STYLE_SWATCH_WIDTH 135
#define STATUS_LAYER_FONT_SIZE 7700
diff --git a/src/xml/Makefile_insert b/src/xml/Makefile_insert
index b10f2448b..da55d7f7e 100644
--- a/src/xml/Makefile_insert
+++ b/src/xml/Makefile_insert
@@ -40,8 +40,7 @@ ink_common_sources += \
xml/subtree.cpp \
xml/subtree.h \
xml/text-node.h \
- xml/invalid-operation-exception.h \
- xml/xml-forward.h
+ xml/invalid-operation-exception.h
# ######################
# ### CxxTest stuff ####
diff --git a/src/xml/node-fns.cpp b/src/xml/node-fns.cpp
index 20e9fbc38..eb3870978 100644
--- a/src/xml/node-fns.cpp
+++ b/src/xml/node-fns.cpp
@@ -9,6 +9,7 @@
#include "xml/node-iterators.h"
#include "util/find-if-before.h"
+#include "node-fns.h"
namespace Inkscape {
namespace XML {
diff --git a/src/xml/quote.cpp b/src/xml/quote.cpp
index 51f9ffb97..030a6c764 100644
--- a/src/xml/quote.cpp
+++ b/src/xml/quote.cpp
@@ -13,6 +13,7 @@
#include <cstring>
#include <glib.h>
+#include "quote.h"
/** \return strlen(xml_quote_strdup(\a val)) (without doing the malloc).
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index 7fba4d7c6..4c339ad5a 100644
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
@@ -312,7 +312,7 @@ void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
/*
* If the new value is different from the old value, this will sometimes send a signal via
* CompositeNodeObserver::notiftyAttributeChanged() which results in calling
- * SPObject::sp_object_repr_attr_changed and thus updates the object's SPStyle. This update
+ * SPObject::repr_attr_changed and thus updates the object's SPStyle. This update
* results in another call to repr->setAttribute().
*/
repr->setAttribute(attr, value.c_str());
@@ -351,7 +351,8 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
guchar *const str_value_unsigned = cr_term_to_string(decl->value);
gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned);
gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in ""
- gchar *units = NULL;
+ Glib::ustring value_unquoted2 = value_unquoted ? value_unquoted : Glib::ustring();
+ Glib::ustring units;
/*
* Problem with parsing of units em and ex, like font-size "1.2em" and "3.4ex"
@@ -360,18 +361,22 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
*
* HACK for now is to strip off em and ex units and add them back at the end
*/
- int l = strlen(value_unquoted);
- if (!strncmp(&value_unquoted[l-2], "em", 2) ||
- !strncmp(&value_unquoted[l-2], "ex", 2)) {
- units = g_strndup(&value_unquoted[l-2], 2);
- value_unquoted = g_strndup(value_unquoted, l-2);
+ int le = value_unquoted2.length();
+ if (le > 2) {
+ units = value_unquoted2.substr(le-2, 2);
+ if ((units == "em") || (units == "ex")) {
+ value_unquoted2 = value_unquoted2.substr(0, le-2);
+ }
+ else {
+ units.clear();
+ }
}
// libcroco uses %.17f for formatting... leading to trailing zeros or small rounding errors.
// CSSOStringStream is used here to write valid CSS (as in sp_style_write_string). This has
// the additional benefit of respecting the numerical precission set in the SVG Output
// preferences. We assume any numerical part comes first (if not, the whole string is copied).
- std::stringstream ss( value_unquoted );
+ std::stringstream ss( value_unquoted2 );
double number = 0;
std::string characters;
std::string temp;
@@ -385,10 +390,9 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
Inkscape::CSSOStringStream os;
if( number_valid ) os << number;
os << characters;
- if (units) {
+ if (!units.empty()) {
os << units;
//g_message("sp_repr_css_merge_from_decl looks like em or ex units %s --> %s", str_value, os.str().c_str());
- g_free(units);
}
((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false);
g_free(value_unquoted);
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 29a5b4a78..1258617c7 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -297,12 +297,18 @@ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns)
XmlSource src;
if ( (src.setFile(filename) == 0) ) {
+ int parse_options = XML_PARSE_HUGE; // do not use XML_PARSE_NOENT ! see bug lp:1025185
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool allowNetAccess = prefs->getBool("/options/externalresources/xml/allow_net_access", false);
+ if (!allowNetAccess) {
+ parse_options |= XML_PARSE_NONET;
+ }
doc = xmlReadIO( XmlSource::readCb,
XmlSource::closeCb,
&src,
localFilename,
src.getEncoding(),
- XML_PARSE_NOENT | XML_PARSE_HUGE);
+ parse_options);
}
}
diff --git a/src/xml/repr-sorting.cpp b/src/xml/repr-sorting.cpp
index fd485925b..09a39acb2 100644
--- a/src/xml/repr-sorting.cpp
+++ b/src/xml/repr-sorting.cpp
@@ -2,6 +2,7 @@
#include "util/longest-common-suffix.h"
#include "xml/repr.h"
#include "xml/node-iterators.h"
+#include "repr-sorting.h"
static bool same_repr(Inkscape::XML::Node const &a, Inkscape::XML::Node const &b)
{
diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp
index 5b8ab12ae..7e9f9c484 100644
--- a/src/xml/repr-util.cpp
+++ b/src/xml/repr-util.cpp
@@ -75,7 +75,7 @@ static char *sp_xml_ns_auto_prefix(char const *uri);
/**
* Locale-independent double to string conversion
*/
-unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf)
+static unsigned int sp_xml_dtoa(gchar *buf, double val, unsigned int tprec, unsigned int fprec, unsigned int padf)
{
double dival, fval, epsilon;
int idigits, ival, i;
diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp
index 55bd28afe..4965f81c8 100644
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
@@ -346,7 +346,7 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_
// tree (and thus has no parent), default values will not be tested.
if( !strcmp( name, "style" ) && (flags >= SP_ATTR_CLEAN_STYLE_WARN) ) {
g_free( cleaned_value );
- cleaned_value = const_cast<char*>(sp_attribute_clean_style( this, value, flags ).c_str());
+ cleaned_value = g_strdup( sp_attribute_clean_style( this, value, flags ).c_str() );
// if( g_strcmp0( value, cleaned_value ) ) {
// g_warning( "SimpleNode::setAttribute: %s", id.c_str() );
// g_warning( " original: %s", value);
diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp
index 68f58614d..9311901d3 100644
--- a/src/zoom-context.cpp
+++ b/src/zoom-context.cpp
@@ -64,9 +64,9 @@ GType sp_zoom_context_get_type(void)
static void sp_zoom_context_class_init(SPZoomContextClass *klass)
{
- SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
+ SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass);
- parent_class = (SPEventContextClass*) g_type_class_peek_parent(klass);
+ parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass));
event_context_class->setup = sp_zoom_context_setup;
event_context_class->finish = sp_zoom_context_finish;
@@ -107,8 +107,8 @@ static void sp_zoom_context_setup(SPEventContext *ec)
ec->enableGrDrag();
}
- if (((SPEventContextClass *) parent_class)->setup) {
- ((SPEventContextClass *) parent_class)->setup(ec);
+ if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) {
+ (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec);
}
}
@@ -116,8 +116,8 @@ static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *
{
gint ret = FALSE;
- if (((SPEventContextClass *) parent_class)->item_handler) {
- ret = ((SPEventContextClass *) parent_class)->item_handler (event_context, item, event);
+ if ((SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler) {
+ ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->item_handler (event_context, item, event);
}
return ret;
@@ -264,8 +264,8 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
}
if (!ret) {
- if (((SPEventContextClass *) parent_class)->root_handler) {
- ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
+ if ((SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler) {
+ ret = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler(event_context, event);
}
}